@voxket-ai/voxket-live 1.0.73 → 1.0.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +21 -307
- package/dist/index.js +11912 -39674
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,321 +1,35 @@
|
|
|
1
|
-
"use strict";var jw=Object.defineProperty;var Lw=(t,e,n)=>e in t?jw(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var at=(t,e,n)=>Lw(t,typeof e!="symbol"?e+"":e,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const R=require("react"),bu=require("react-dom"),Wa=require("class-variance-authority"),xu=require("clsx");function R0(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const g=R0(R),qa=R0(bu);function Vw(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var So={exports:{}},vs={};/**
|
|
2
|
-
|
|
3
|
-
* react-jsx-runtime.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var vh;function Fw(){if(vh)return vs;vh=1;var t=R,e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(a,c,l){var d,u={},f=null,p=null;l!==void 0&&(f=""+l),c.key!==void 0&&(f=""+c.key),c.ref!==void 0&&(p=c.ref);for(d in c)i.call(c,d)&&!s.hasOwnProperty(d)&&(u[d]=c[d]);if(a&&a.defaultProps)for(d in c=a.defaultProps,c)u[d]===void 0&&(u[d]=c[d]);return{$$typeof:e,type:a,key:f,ref:p,props:u,_owner:r.current}}return vs.Fragment=n,vs.jsx=o,vs.jsxs=o,vs}var ys={};/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.development.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var yh;function Uw(){return yh||(yh=1,process.env.NODE_ENV!=="production"&&function(){var t=R,e=Symbol.for("react.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),a=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),v=Symbol.iterator,h="@@iterator";function y(M){if(M===null||typeof M!="object")return null;var ne=v&&M[v]||M[h];return typeof ne=="function"?ne:null}var b=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(M){{for(var ne=arguments.length,le=new Array(ne>1?ne-1:0),pe=1;pe<ne;pe++)le[pe-1]=arguments[pe];C("error",M,le)}}function C(M,ne,le){{var pe=b.ReactDebugCurrentFrame,Ie=pe.getStackAddendum();Ie!==""&&(ne+="%s",le=le.concat([Ie]));var Le=le.map(function(ke){return String(ke)});Le.unshift("Warning: "+ne),Function.prototype.apply.call(console[M],console,Le)}}var S=!1,x=!1,T=!1,E=!1,P=!1,_;_=Symbol.for("react.module.reference");function k(M){return!!(typeof M=="string"||typeof M=="function"||M===i||M===s||P||M===r||M===l||M===d||E||M===p||S||x||T||typeof M=="object"&&M!==null&&(M.$$typeof===f||M.$$typeof===u||M.$$typeof===o||M.$$typeof===a||M.$$typeof===c||M.$$typeof===_||M.getModuleId!==void 0))}function I(M,ne,le){var pe=M.displayName;if(pe)return pe;var Ie=ne.displayName||ne.name||"";return Ie!==""?le+"("+Ie+")":le}function N(M){return M.displayName||"Context"}function K(M){if(M==null)return null;if(typeof M.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof M=="function")return M.displayName||M.name||null;if(typeof M=="string")return M;switch(M){case i:return"Fragment";case n:return"Portal";case s:return"Profiler";case r:return"StrictMode";case l:return"Suspense";case d:return"SuspenseList"}if(typeof M=="object")switch(M.$$typeof){case a:var ne=M;return N(ne)+".Consumer";case o:var le=M;return N(le._context)+".Provider";case c:return I(M,M.render,"ForwardRef");case u:var pe=M.displayName||null;return pe!==null?pe:K(M.type)||"Memo";case f:{var Ie=M,Le=Ie._payload,ke=Ie._init;try{return K(ke(Le))}catch{return null}}}return null}var J=Object.assign,se=0,ie,X,O,oe,L,F,te;function j(){}j.__reactDisabledLog=!0;function q(){{if(se===0){ie=console.log,X=console.info,O=console.warn,oe=console.error,L=console.group,F=console.groupCollapsed,te=console.groupEnd;var M={configurable:!0,enumerable:!0,value:j,writable:!0};Object.defineProperties(console,{info:M,log:M,warn:M,error:M,group:M,groupCollapsed:M,groupEnd:M})}se++}}function ee(){{if(se--,se===0){var M={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:J({},M,{value:ie}),info:J({},M,{value:X}),warn:J({},M,{value:O}),error:J({},M,{value:oe}),group:J({},M,{value:L}),groupCollapsed:J({},M,{value:F}),groupEnd:J({},M,{value:te})})}se<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var G=b.ReactCurrentDispatcher,D;function $(M,ne,le){{if(D===void 0)try{throw Error()}catch(Ie){var pe=Ie.stack.trim().match(/\n( *(at )?)/);D=pe&&pe[1]||""}return`
|
|
18
|
-
`+D+M}}var Q=!1,W;{var ce=typeof WeakMap=="function"?WeakMap:Map;W=new ce}function z(M,ne){if(!M||Q)return"";{var le=W.get(M);if(le!==void 0)return le}var pe;Q=!0;var Ie=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Le;Le=G.current,G.current=null,q();try{if(ne){var ke=function(){throw Error()};if(Object.defineProperty(ke.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ke,[])}catch(It){pe=It}Reflect.construct(M,[],ke)}else{try{ke.call()}catch(It){pe=It}M.call(ke.prototype)}}else{try{throw Error()}catch(It){pe=It}M()}}catch(It){if(It&&pe&&typeof It.stack=="string"){for(var Se=It.stack.split(`
|
|
19
|
-
`),Pt=pe.stack.split(`
|
|
20
|
-
`),tt=Se.length-1,ot=Pt.length-1;tt>=1&&ot>=0&&Se[tt]!==Pt[ot];)ot--;for(;tt>=1&&ot>=0;tt--,ot--)if(Se[tt]!==Pt[ot]){if(tt!==1||ot!==1)do if(tt--,ot--,ot<0||Se[tt]!==Pt[ot]){var qt=`
|
|
21
|
-
`+Se[tt].replace(" at new "," at ");return M.displayName&&qt.includes("<anonymous>")&&(qt=qt.replace("<anonymous>",M.displayName)),typeof M=="function"&&W.set(M,qt),qt}while(tt>=1&&ot>=0);break}}}finally{Q=!1,G.current=Le,ee(),Error.prepareStackTrace=Ie}var cr=M?M.displayName||M.name:"",Oi=cr?$(cr):"";return typeof M=="function"&&W.set(M,Oi),Oi}function me(M,ne,le){return z(M,!1)}function Ee(M){var ne=M.prototype;return!!(ne&&ne.isReactComponent)}function qe(M,ne,le){if(M==null)return"";if(typeof M=="function")return z(M,Ee(M));if(typeof M=="string")return $(M);switch(M){case l:return $("Suspense");case d:return $("SuspenseList")}if(typeof M=="object")switch(M.$$typeof){case c:return me(M.render);case u:return qe(M.type,ne,le);case f:{var pe=M,Ie=pe._payload,Le=pe._init;try{return qe(Le(Ie),ne,le)}catch{}}}return""}var Ct=Object.prototype.hasOwnProperty,gn={},vn=b.ReactDebugCurrentFrame;function Et(M){if(M){var ne=M._owner,le=qe(M.type,M._source,ne?ne.type:null);vn.setExtraStackFrame(le)}else vn.setExtraStackFrame(null)}function Ec(M,ne,le,pe,Ie){{var Le=Function.call.bind(Ct);for(var ke in M)if(Le(M,ke)){var Se=void 0;try{if(typeof M[ke]!="function"){var Pt=Error((pe||"React class")+": "+le+" type `"+ke+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof M[ke]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Pt.name="Invariant Violation",Pt}Se=M[ke](ne,ke,pe,le,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(tt){Se=tt}Se&&!(Se instanceof Error)&&(Et(Ie),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",pe||"React class",le,ke,typeof Se),Et(null)),Se instanceof Error&&!(Se.message in gn)&&(gn[Se.message]=!0,Et(Ie),w("Failed %s type: %s",le,Se.message),Et(null))}}}var Pc=Array.isArray;function _i(M){return Pc(M)}function ms(M){{var ne=typeof Symbol=="function"&&Symbol.toStringTag,le=ne&&M[Symbol.toStringTag]||M.constructor.name||"Object";return le}}function ps(M){try{return or(M),!1}catch{return!0}}function or(M){return""+M}function Ni(M){if(ps(M))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ms(M)),or(M)}var gs=b.ReactCurrentOwner,ve={key:!0,ref:!0,__self:!0,__source:!0},tn,At;function $e(M){if(Ct.call(M,"ref")){var ne=Object.getOwnPropertyDescriptor(M,"ref").get;if(ne&&ne.isReactWarning)return!1}return M.ref!==void 0}function Rc(M){if(Ct.call(M,"key")){var ne=Object.getOwnPropertyDescriptor(M,"key").get;if(ne&&ne.isReactWarning)return!1}return M.key!==void 0}function Sw(M,ne){typeof M.ref=="string"&&gs.current}function ww(M,ne){{var le=function(){tn||(tn=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",ne))};le.isReactWarning=!0,Object.defineProperty(M,"key",{get:le,configurable:!0})}}function Cw(M,ne){{var le=function(){At||(At=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",ne))};le.isReactWarning=!0,Object.defineProperty(M,"ref",{get:le,configurable:!0})}}var kw=function(M,ne,le,pe,Ie,Le,ke){var Se={$$typeof:e,type:M,key:ne,ref:le,props:ke,_owner:Le};return Se._store={},Object.defineProperty(Se._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Se,"_self",{configurable:!1,enumerable:!1,writable:!1,value:pe}),Object.defineProperty(Se,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ie}),Object.freeze&&(Object.freeze(Se.props),Object.freeze(Se)),Se};function Tw(M,ne,le,pe,Ie){{var Le,ke={},Se=null,Pt=null;le!==void 0&&(Ni(le),Se=""+le),Rc(ne)&&(Ni(ne.key),Se=""+ne.key),$e(ne)&&(Pt=ne.ref,Sw(ne,Ie));for(Le in ne)Ct.call(ne,Le)&&!ve.hasOwnProperty(Le)&&(ke[Le]=ne[Le]);if(M&&M.defaultProps){var tt=M.defaultProps;for(Le in tt)ke[Le]===void 0&&(ke[Le]=tt[Le])}if(Se||Pt){var ot=typeof M=="function"?M.displayName||M.name||"Unknown":M;Se&&ww(ke,ot),Pt&&Cw(ke,ot)}return kw(M,Se,Pt,Ie,pe,gs.current,ke)}}var Ac=b.ReactCurrentOwner,dh=b.ReactDebugCurrentFrame;function ar(M){if(M){var ne=M._owner,le=qe(M.type,M._source,ne?ne.type:null);dh.setExtraStackFrame(le)}else dh.setExtraStackFrame(null)}var Ic;Ic=!1;function Mc(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function uh(){{if(Ac.current){var M=K(Ac.current.type);if(M)return`
|
|
22
|
-
|
|
23
|
-
Check the render method of \``+M+"`."}return""}}function Ew(M){return""}var fh={};function Pw(M){{var ne=uh();if(!ne){var le=typeof M=="string"?M:M.displayName||M.name;le&&(ne=`
|
|
24
|
-
|
|
25
|
-
Check the top-level render call using <`+le+">.")}return ne}}function hh(M,ne){{if(!M._store||M._store.validated||M.key!=null)return;M._store.validated=!0;var le=Pw(ne);if(fh[le])return;fh[le]=!0;var pe="";M&&M._owner&&M._owner!==Ac.current&&(pe=" It was passed a child from "+K(M._owner.type)+"."),ar(M),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',le,pe),ar(null)}}function mh(M,ne){{if(typeof M!="object")return;if(_i(M))for(var le=0;le<M.length;le++){var pe=M[le];Mc(pe)&&hh(pe,ne)}else if(Mc(M))M._store&&(M._store.validated=!0);else if(M){var Ie=y(M);if(typeof Ie=="function"&&Ie!==M.entries)for(var Le=Ie.call(M),ke;!(ke=Le.next()).done;)Mc(ke.value)&&hh(ke.value,ne)}}}function Rw(M){{var ne=M.type;if(ne==null||typeof ne=="string")return;var le;if(typeof ne=="function")le=ne.propTypes;else if(typeof ne=="object"&&(ne.$$typeof===c||ne.$$typeof===u))le=ne.propTypes;else return;if(le){var pe=K(ne);Ec(le,M.props,"prop",pe,M)}else if(ne.PropTypes!==void 0&&!Ic){Ic=!0;var Ie=K(ne);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ie||"Unknown")}typeof ne.getDefaultProps=="function"&&!ne.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Aw(M){{for(var ne=Object.keys(M.props),le=0;le<ne.length;le++){var pe=ne[le];if(pe!=="children"&&pe!=="key"){ar(M),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",pe),ar(null);break}}M.ref!==null&&(ar(M),w("Invalid attribute `ref` supplied to `React.Fragment`."),ar(null))}}var ph={};function gh(M,ne,le,pe,Ie,Le){{var ke=k(M);if(!ke){var Se="";(M===void 0||typeof M=="object"&&M!==null&&Object.keys(M).length===0)&&(Se+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Pt=Ew();Pt?Se+=Pt:Se+=uh();var tt;M===null?tt="null":_i(M)?tt="array":M!==void 0&&M.$$typeof===e?(tt="<"+(K(M.type)||"Unknown")+" />",Se=" Did you accidentally export a JSX literal instead of a component?"):tt=typeof M,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",tt,Se)}var ot=Tw(M,ne,le,Ie,Le);if(ot==null)return ot;if(ke){var qt=ne.children;if(qt!==void 0)if(pe)if(_i(qt)){for(var cr=0;cr<qt.length;cr++)mh(qt[cr],M);Object.freeze&&Object.freeze(qt)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else mh(qt,M)}if(Ct.call(ne,"key")){var Oi=K(M),It=Object.keys(ne).filter(function(Dw){return Dw!=="key"}),_c=It.length>0?"{key: someKey, "+It.join(": ..., ")+": ...}":"{key: someKey}";if(!ph[Oi+_c]){var Ow=It.length>0?"{"+It.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
|
|
26
|
-
let props = %s;
|
|
27
|
-
<%s {...props} />
|
|
28
|
-
React keys must be passed directly to JSX without using spread:
|
|
29
|
-
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,_c,Oi,Ow,Oi),ph[Oi+_c]=!0}}return M===i?Aw(ot):Rw(ot),ot}}function Iw(M,ne,le){return gh(M,ne,le,!0)}function Mw(M,ne,le){return gh(M,ne,le,!1)}var _w=Mw,Nw=Iw;ys.Fragment=i,ys.jsx=_w,ys.jsxs=Nw}()),ys}var bh;function Bw(){return bh||(bh=1,process.env.NODE_ENV==="production"?So.exports=Fw():So.exports=Uw()),So.exports}var m=Bw();function $w(t,e){return e.forEach(function(n){n&&typeof n!="string"&&!Array.isArray(n)&&Object.keys(n).forEach(function(i){if(i!=="default"&&!(i in t)){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}})}),Object.freeze(t)}var Hw=Object.defineProperty,zw=(t,e,n)=>e in t?Hw(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,xh=(t,e,n)=>zw(t,typeof e!="symbol"?e+"":e,n);let Nt=class{constructor(){xh(this,"_locking"),xh(this,"_locks"),this._locking=Promise.resolve(),this._locks=0}isLocked(){return this._locks>0}lock(){this._locks+=1;let e;const n=new Promise(r=>e=()=>{this._locks-=1,r()}),i=this._locking.then(()=>e);return this._locking=this._locking.then(()=>n),i}};function Xe(t,e){if(!t)throw new Error(e)}const Ww=34028234663852886e22,qw=-34028234663852886e22,Kw=4294967295,Gw=2147483647,Zw=-2147483648;function qo(t){if(typeof t!="number")throw new Error("invalid int 32: "+typeof t);if(!Number.isInteger(t)||t>Gw||t<Zw)throw new Error("invalid int 32: "+t)}function $l(t){if(typeof t!="number")throw new Error("invalid uint 32: "+typeof t);if(!Number.isInteger(t)||t>Kw||t<0)throw new Error("invalid uint 32: "+t)}function A0(t){if(typeof t!="number")throw new Error("invalid float 32: "+typeof t);if(Number.isFinite(t)&&(t>Ww||t<qw))throw new Error("invalid float 32: "+t)}const I0=Symbol("@bufbuild/protobuf/enum-type");function Yw(t){const e=t[I0];return Xe(e,"missing enum type on enum object"),e}function M0(t,e,n,i){t[I0]=_0(e,n.map(r=>({no:r.no,name:r.name,localName:t[r.no]})))}function _0(t,e,n){const i=Object.create(null),r=Object.create(null),s=[];for(const o of e){const a=N0(o);s.push(a),i[o.name]=a,r[o.no]=a}return{typeName:t,values:s,findName(o){return i[o]},findNumber(o){return r[o]}}}function Jw(t,e,n){const i={};for(const r of e){const s=N0(r);i[s.localName]=s.no,i[s.no]=s.localName}return M0(i,t,e),i}function N0(t){return"localName"in t?t:Object.assign(Object.assign({},t),{localName:t.name})}class Su{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,n){const i=this.getType(),r=i.runtime.bin,s=r.makeReadOptions(n);return r.readMessage(this,s.readerFactory(e),e.byteLength,s),this}fromJson(e,n){const i=this.getType(),r=i.runtime.json,s=r.makeReadOptions(n);return r.readMessage(i,e,s,this),this}fromJsonString(e,n){let i;try{i=JSON.parse(e)}catch(r){throw new Error("cannot decode ".concat(this.getType().typeName," from JSON: ").concat(r instanceof Error?r.message:String(r)))}return this.fromJson(i,n)}toBinary(e){const n=this.getType(),i=n.runtime.bin,r=i.makeWriteOptions(e),s=r.writerFactory();return i.writeMessage(this,s,r),s.finish()}toJson(e){const n=this.getType(),i=n.runtime.json,r=i.makeWriteOptions(e);return i.writeMessage(this,r)}toJsonString(e){var n;const i=this.toJson(e);return JSON.stringify(i,null,(n=e==null?void 0:e.prettySpaces)!==null&&n!==void 0?n:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function Xw(t,e,n,i){var r;const s=(r=i==null?void 0:i.localName)!==null&&r!==void 0?r:e.substring(e.lastIndexOf(".")+1),o={[s]:function(a){t.util.initFields(this),t.util.initPartial(a,this)}}[s];return Object.setPrototypeOf(o.prototype,new Su),Object.assign(o,{runtime:t,typeName:e,fields:t.util.newFieldList(n),fromBinary(a,c){return new o().fromBinary(a,c)},fromJson(a,c){return new o().fromJson(a,c)},fromJsonString(a,c){return new o().fromJsonString(a,c)},equals(a,c){return t.util.equals(o,a,c)}}),o}function Qw(){let t=0,e=0;for(let i=0;i<28;i+=7){let r=this.buf[this.pos++];if(t|=(r&127)<<i,(r&128)==0)return this.assertBounds(),[t,e]}let n=this.buf[this.pos++];if(t|=(n&15)<<28,e=(n&112)>>4,(n&128)==0)return this.assertBounds(),[t,e];for(let i=3;i<=31;i+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<i,(r&128)==0)return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function Nc(t,e,n){for(let s=0;s<28;s=s+7){const o=t>>>s,a=!(!(o>>>7)&&e==0),c=(a?o|128:o)&255;if(n.push(c),!a)return}const i=t>>>28&15|(e&7)<<4,r=e>>3!=0;if(n.push((r?i|128:i)&255),!!r){for(let s=3;s<31;s=s+7){const o=e>>>s,a=!!(o>>>7),c=(a?o|128:o)&255;if(n.push(c),!a)return}n.push(e>>>31&1)}}const Ko=4294967296;function Sh(t){const e=t[0]==="-";e&&(t=t.slice(1));const n=1e6;let i=0,r=0;function s(o,a){const c=Number(t.slice(o,a));r*=n,i=i*n+c,i>=Ko&&(r=r+(i/Ko|0),i=i%Ko)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?D0(i,r):wu(i,r)}function eC(t,e){let n=wu(t,e);const i=n.hi&2147483648;i&&(n=D0(n.lo,n.hi));const r=O0(n.lo,n.hi);return i?"-"+r:r}function O0(t,e){if({lo:t,hi:e}=tC(t,e),e<=2097151)return String(Ko*e+t);const n=t&16777215,i=(t>>>24|e<<8)&16777215,r=e>>16&65535;let s=n+i*6777216+r*6710656,o=i+r*8147497,a=r*2;const c=1e7;return s>=c&&(o+=Math.floor(s/c),s%=c),o>=c&&(a+=Math.floor(o/c),o%=c),a.toString()+wh(o)+wh(s)}function tC(t,e){return{lo:t>>>0,hi:e>>>0}}function wu(t,e){return{lo:t|0,hi:e|0}}function D0(t,e){return e=~e,t?t=~t+1:e+=1,wu(t,e)}const wh=t=>{const e=String(t);return"0000000".slice(e.length)+e};function Ch(t,e){if(t>=0){for(;t>127;)e.push(t&127|128),t=t>>>7;e.push(t)}else{for(let n=0;n<9;n++)e.push(t&127|128),t=t>>7;e.push(1)}}function nC(){let t=this.buf[this.pos++],e=t&127;if((t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<7,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<14,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<21,(t&128)==0)return this.assertBounds(),e;t=this.buf[this.pos++],e|=(t&15)<<28;for(let n=5;(t&128)!==0&&n<10;n++)t=this.buf[this.pos++];if((t&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}function iC(){const t=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"&&(typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){const r=BigInt("-9223372036854775808"),s=BigInt("9223372036854775807"),o=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(c){const l=typeof c=="bigint"?c:BigInt(c);if(l>s||l<r)throw new Error("int64 invalid: ".concat(c));return l},uParse(c){const l=typeof c=="bigint"?c:BigInt(c);if(l>a||l<o)throw new Error("uint64 invalid: ".concat(c));return l},enc(c){return t.setBigInt64(0,this.parse(c),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(c){return t.setBigInt64(0,this.uParse(c),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec(c,l){return t.setInt32(0,c,!0),t.setInt32(4,l,!0),t.getBigInt64(0,!0)},uDec(c,l){return t.setInt32(0,c,!0),t.setInt32(4,l,!0),t.getBigUint64(0,!0)}}}const n=r=>Xe(/^-?[0-9]+$/.test(r),"int64 invalid: ".concat(r)),i=r=>Xe(/^[0-9]+$/.test(r),"uint64 invalid: ".concat(r));return{zero:"0",supported:!1,parse(r){return typeof r!="string"&&(r=r.toString()),n(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),i(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),n(r),Sh(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),i(r),Sh(r)},dec(r,s){return eC(r,s)},uDec(r,s){return O0(r,s)}}}const ze=iC();var Y;(function(t){t[t.DOUBLE=1]="DOUBLE",t[t.FLOAT=2]="FLOAT",t[t.INT64=3]="INT64",t[t.UINT64=4]="UINT64",t[t.INT32=5]="INT32",t[t.FIXED64=6]="FIXED64",t[t.FIXED32=7]="FIXED32",t[t.BOOL=8]="BOOL",t[t.STRING=9]="STRING",t[t.BYTES=12]="BYTES",t[t.UINT32=13]="UINT32",t[t.SFIXED32=15]="SFIXED32",t[t.SFIXED64=16]="SFIXED64",t[t.SINT32=17]="SINT32",t[t.SINT64=18]="SINT64"})(Y||(Y={}));var hi;(function(t){t[t.BIGINT=0]="BIGINT",t[t.STRING=1]="STRING"})(hi||(hi={}));function ni(t,e,n){if(e===n)return!0;if(t==Y.BYTES){if(!(e instanceof Uint8Array)||!(n instanceof Uint8Array)||e.length!==n.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==n[i])return!1;return!0}switch(t){case Y.UINT64:case Y.FIXED64:case Y.INT64:case Y.SFIXED64:case Y.SINT64:return e==n}return!1}function Wr(t,e){switch(t){case Y.BOOL:return!1;case Y.UINT64:case Y.FIXED64:case Y.INT64:case Y.SFIXED64:case Y.SINT64:return e==0?ze.zero:"0";case Y.DOUBLE:case Y.FLOAT:return 0;case Y.BYTES:return new Uint8Array(0);case Y.STRING:return"";default:return 0}}function j0(t,e){switch(t){case Y.BOOL:return e===!1;case Y.STRING:return e==="";case Y.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}var rt;(function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"})(rt||(rt={}));class rC{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let n=new Uint8Array(e),i=0;for(let r=0;r<this.chunks.length;r++)n.set(this.chunks[r],i),i+=this.chunks[r].length;return this.chunks=[],n}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),n=this.stack.pop();if(!n)throw new Error("invalid state, fork stack empty");return this.chunks=n.chunks,this.buf=n.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,n){return this.uint32((e<<3|n)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for($l(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return qo(e),Ch(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let n=this.textEncoder.encode(e);return this.uint32(n.byteLength),this.raw(n)}float(e){A0(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){$l(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){qo(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return qo(e),e=(e<<1^e>>31)>>>0,Ch(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),i=new DataView(n.buffer),r=ze.enc(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),i=new DataView(n.buffer),r=ze.uEnc(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(n)}int64(e){let n=ze.enc(e);return Nc(n.lo,n.hi,this.buf),this}sint64(e){let n=ze.enc(e),i=n.hi>>31,r=n.lo<<1^i,s=(n.hi<<1|n.lo>>>31)^i;return Nc(r,s,this.buf),this}uint64(e){let n=ze.uEnc(e);return Nc(n.lo,n.hi,this.buf),this}}class sC{constructor(e,n){this.varint64=Qw,this.uint32=nC,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=n??new TextDecoder}tag(){let e=this.uint32(),n=e>>>3,i=e&7;if(n<=0||i<0||i>5)throw new Error("illegal tag: field no "+n+" wire type "+i);return[n,i]}skip(e,n){let i=this.pos;switch(e){case rt.Varint:for(;this.buf[this.pos++]&128;);break;case rt.Bit64:this.pos+=4;case rt.Bit32:this.pos+=4;break;case rt.LengthDelimited:let r=this.uint32();this.pos+=r;break;case rt.StartGroup:for(;;){const[s,o]=this.tag();if(o===rt.EndGroup){if(n!==void 0&&s!==n)throw new Error("invalid end group tag");break}this.skip(o,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(i,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return ze.dec(...this.varint64())}uint64(){return ze.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),i=-(e&1);return e=(e>>>1|(n&1)<<31)^i,n=n>>>1^i,ze.dec(e,n)}bool(){let[e,n]=this.varint64();return e!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return ze.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return ze.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(){return this.textDecoder.decode(this.bytes())}}function oC(t,e,n,i){let r;return{typeName:e,extendee:n,get field(){if(!r){const s=typeof i=="function"?i():i;s.name=e.split(".").pop(),s.jsonName="[".concat(e,"]"),r=t.util.newFieldList([s]).list()[0]}return r},runtime:t}}function L0(t){const e=t.field.localName,n=Object.create(null);return n[e]=aC(t),[n,()=>n[e]]}function aC(t){const e=t.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return Wr(e.T,e.L);case"message":const n=e.T,i=new n;return n.fieldWrapper?n.fieldWrapper.unwrapField(i):i;case"map":throw"map fields are not allowed to be extensions"}}function cC(t,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let n=t.length-1;n>=0;--n)if(t[n].no==e.no)return[t[n]];return[]}return t.filter(n=>n.no===e.no)}let $n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Ka=[];for(let t=0;t<$n.length;t++)Ka[$n[t].charCodeAt(0)]=t;Ka[45]=$n.indexOf("+");Ka[95]=$n.indexOf("/");const V0={dec(t){let e=t.length*3/4;t[t.length-2]=="="?e-=2:t[t.length-1]=="="&&(e-=1);let n=new Uint8Array(e),i=0,r=0,s,o=0;for(let a=0;a<t.length;a++){if(s=Ka[t.charCodeAt(a)],s===void 0)switch(t[a]){case"=":r=0;case`
|
|
31
|
-
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(r){case 0:o=s,r=1;break;case 1:n[i++]=o<<2|(s&48)>>4,o=s,r=2;break;case 2:n[i++]=(o&15)<<4|(s&60)>>2,o=s,r=3;break;case 3:n[i++]=(o&3)<<6|s,r=0;break}}if(r==1)throw Error("invalid base64 string.");return n.subarray(0,i)},enc(t){let e="",n=0,i,r=0;for(let s=0;s<t.length;s++)switch(i=t[s],n){case 0:e+=$n[i>>2],r=(i&3)<<4,n=1;break;case 1:e+=$n[r|i>>4],r=(i&15)<<2,n=2;break;case 2:e+=$n[r|i>>6],e+=$n[i&63],n=0;break}return n&&(e+=$n[r],e+="=",n==1&&(e+="=")),e}};function lC(t,e,n){U0(e,t);const i=e.runtime.bin.makeReadOptions(n),r=cC(t.getType().runtime.bin.listUnknownFields(t),e.field),[s,o]=L0(e);for(const a of r)e.runtime.bin.readField(s,i.readerFactory(a.data),e.field,a.wireType,i);return o()}function dC(t,e,n,i){U0(e,t);const r=e.runtime.bin.makeReadOptions(i),s=e.runtime.bin.makeWriteOptions(i);if(F0(t,e)){const l=t.getType().runtime.bin.listUnknownFields(t).filter(d=>d.no!=e.field.no);t.getType().runtime.bin.discardUnknownFields(t);for(const d of l)t.getType().runtime.bin.onUnknownField(t,d.no,d.wireType,d.data)}const o=s.writerFactory();let a=e.field;!a.opt&&!a.repeated&&(a.kind=="enum"||a.kind=="scalar")&&(a=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(a,n,o,s);const c=r.readerFactory(o.finish());for(;c.pos<c.len;){const[l,d]=c.tag(),u=c.skip(d,l);t.getType().runtime.bin.onUnknownField(t,l,d,u)}}function F0(t,e){const n=t.getType();return e.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(t).find(i=>i.no==e.field.no)}function U0(t,e){Xe(t.extendee.typeName==e.getType().typeName,"extension ".concat(t.typeName," can only be applied to message ").concat(t.extendee.typeName))}function B0(t,e){const n=t.localName;if(t.repeated)return e[n].length>0;if(t.oneof)return e[t.oneof.localName].case===n;switch(t.kind){case"enum":case"scalar":return t.opt||t.req?e[n]!==void 0:t.kind=="enum"?e[n]!==t.T.values[0].no:!j0(t.T,e[n]);case"message":return e[n]!==void 0;case"map":return Object.keys(e[n]).length>0}}function kh(t,e){const n=t.localName,i=!t.opt&&!t.req;if(t.repeated)e[n]=[];else if(t.oneof)e[t.oneof.localName]={case:void 0};else switch(t.kind){case"map":e[n]={};break;case"enum":e[n]=i?t.T.values[0].no:void 0;break;case"scalar":e[n]=i?Wr(t.T,t.L):void 0;break;case"message":e[n]=void 0;break}}function Hn(t,e){if(t===null||typeof t!="object"||!Object.getOwnPropertyNames(Su.prototype).every(i=>i in t&&typeof t[i]=="function"))return!1;const n=t.getType();return n===null||typeof n!="function"||!("typeName"in n)||typeof n.typeName!="string"?!1:e===void 0?!0:n.typeName==e.typeName}function $0(t,e){return Hn(e)||!t.fieldWrapper?e:t.fieldWrapper.wrapField(e)}Y.DOUBLE,Y.FLOAT,Y.INT64,Y.UINT64,Y.INT32,Y.UINT32,Y.BOOL,Y.STRING,Y.BYTES;const Th={ignoreUnknownFields:!1},Eh={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function uC(t){return t?Object.assign(Object.assign({},Th),t):Th}function fC(t){return t?Object.assign(Object.assign({},Eh),t):Eh}const xa=Symbol(),Go=Symbol();function hC(){return{makeReadOptions:uC,makeWriteOptions:fC,readMessage(t,e,n,i){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error("cannot decode message ".concat(t.typeName," from JSON: ").concat(xn(e)));i=i??new t;const r=new Map,s=n.typeRegistry;for(const[o,a]of Object.entries(e)){const c=t.fields.findJsonName(o);if(c){if(c.oneof){if(a===null&&c.kind=="scalar")continue;const l=r.get(c.oneof);if(l!==void 0)throw new Error("cannot decode message ".concat(t.typeName,' from JSON: multiple keys for oneof "').concat(c.oneof.name,'" present: "').concat(l,'", "').concat(o,'"'));r.set(c.oneof,o)}Ph(i,a,c,n,t)}else{let l=!1;if(s!=null&&s.findExtension&&o.startsWith("[")&&o.endsWith("]")){const d=s.findExtension(o.substring(1,o.length-1));if(d&&d.extendee.typeName==t.typeName){l=!0;const[u,f]=L0(d);Ph(u,a,d.field,n,d),dC(i,d,f(),n)}}if(!l&&!n.ignoreUnknownFields)throw new Error("cannot decode message ".concat(t.typeName,' from JSON: key "').concat(o,'" is unknown'))}}return i},writeMessage(t,e){const n=t.getType(),i={};let r;try{for(r of n.fields.byNumber()){if(!B0(r,t)){if(r.req)throw"required field not set";if(!e.emitDefaultValues||!pC(r))continue}const o=r.oneof?t[r.oneof.localName].value:t[r.localName],a=Rh(r,o,e);a!==void 0&&(i[e.useProtoFieldName?r.name:r.jsonName]=a)}const s=e.typeRegistry;if(s!=null&&s.findExtensionFor)for(const o of n.runtime.bin.listUnknownFields(t)){const a=s.findExtensionFor(n.typeName,o.no);if(a&&F0(t,a)){const c=lC(t,a,e),l=Rh(a.field,c,e);l!==void 0&&(i[a.field.jsonName]=l)}}}catch(s){const o=r?"cannot encode field ".concat(n.typeName,".").concat(r.name," to JSON"):"cannot encode message ".concat(n.typeName," to JSON"),a=s instanceof Error?s.message:String(s);throw new Error(o+(a.length>0?": ".concat(a):""))}return i},readScalar(t,e,n){return Ds(t,e,n??hi.BIGINT,!0)},writeScalar(t,e,n){if(e!==void 0&&(n||j0(t,e)))return Zo(t,e)},debug:xn}}function xn(t){if(t===null)return"null";switch(typeof t){case"object":return Array.isArray(t)?"array":"object";case"string":return t.length>100?"string":'"'.concat(t.split('"').join('\\"'),'"');default:return String(t)}}function Ph(t,e,n,i,r){let s=n.localName;if(n.repeated){if(Xe(n.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error("cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(xn(e)));const o=t[s];for(const a of e){if(a===null)throw new Error("cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(xn(a)));switch(n.kind){case"message":o.push(n.T.fromJson(a,i));break;case"enum":const c=Oc(n.T,a,i.ignoreUnknownFields,!0);c!==Go&&o.push(c);break;case"scalar":try{o.push(Ds(n.T,a,n.L,!0))}catch(l){let d="cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(xn(a));throw l instanceof Error&&l.message.length>0&&(d+=": ".concat(l.message)),new Error(d)}break}}}else if(n.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error("cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(xn(e)));const o=t[s];for(const[a,c]of Object.entries(e)){if(c===null)throw new Error("cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: map value null"));let l;try{l=mC(n.K,a)}catch(d){let u="cannot decode map key for field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(xn(e));throw d instanceof Error&&d.message.length>0&&(u+=": ".concat(d.message)),new Error(u)}switch(n.V.kind){case"message":o[l]=n.V.T.fromJson(c,i);break;case"enum":const d=Oc(n.V.T,c,i.ignoreUnknownFields,!0);d!==Go&&(o[l]=d);break;case"scalar":try{o[l]=Ds(n.V.T,c,hi.BIGINT,!0)}catch(u){let f="cannot decode map value for field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(xn(e));throw u instanceof Error&&u.message.length>0&&(f+=": ".concat(u.message)),new Error(f)}break}}}else switch(n.oneof&&(t=t[n.oneof.localName]={case:s},s="value"),n.kind){case"message":const o=n.T;if(e===null&&o.typeName!="google.protobuf.Value")return;let a=t[s];Hn(a)?a.fromJson(e,i):(t[s]=a=o.fromJson(e,i),o.fieldWrapper&&!n.oneof&&(t[s]=o.fieldWrapper.unwrapField(a)));break;case"enum":const c=Oc(n.T,e,i.ignoreUnknownFields,!1);switch(c){case xa:kh(n,t);break;case Go:break;default:t[s]=c;break}break;case"scalar":try{const l=Ds(n.T,e,n.L,!1);switch(l){case xa:kh(n,t);break;default:t[s]=l;break}}catch(l){let d="cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(xn(e));throw l instanceof Error&&l.message.length>0&&(d+=": ".concat(l.message)),new Error(d)}break}}function mC(t,e){if(t===Y.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return Ds(t,e,hi.BIGINT,!0).toString()}function Ds(t,e,n,i){if(e===null)return i?Wr(t,n):xa;switch(t){case Y.DOUBLE:case Y.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const r=Number(e);if(Number.isNaN(r)||!Number.isFinite(r))break;return t==Y.FLOAT&&A0(r),r;case Y.INT32:case Y.FIXED32:case Y.SFIXED32:case Y.SINT32:case Y.UINT32:let s;if(typeof e=="number"?s=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(s=Number(e)),s===void 0)break;return t==Y.UINT32||t==Y.FIXED32?$l(s):qo(s),s;case Y.INT64:case Y.SFIXED64:case Y.SINT64:if(typeof e!="number"&&typeof e!="string")break;const o=ze.parse(e);return n?o.toString():o;case Y.FIXED64:case Y.UINT64:if(typeof e!="number"&&typeof e!="string")break;const a=ze.uParse(e);return n?a.toString():a;case Y.BOOL:if(typeof e!="boolean")break;return e;case Y.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case Y.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return V0.dec(e)}throw new Error}function Oc(t,e,n,i){if(e===null)return t.typeName=="google.protobuf.NullValue"?0:i?t.values[0].no:xa;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const r=t.findName(e);if(r!==void 0)return r.no;if(n)return Go;break}throw new Error("cannot decode enum ".concat(t.typeName," from JSON: ").concat(xn(e)))}function pC(t){return t.repeated||t.kind=="map"?!0:!(t.oneof||t.kind=="message"||t.opt||t.req)}function Rh(t,e,n){if(t.kind=="map"){Xe(typeof e=="object"&&e!=null);const i={},r=Object.entries(e);switch(t.V.kind){case"scalar":for(const[o,a]of r)i[o.toString()]=Zo(t.V.T,a);break;case"message":for(const[o,a]of r)i[o.toString()]=a.toJson(n);break;case"enum":const s=t.V.T;for(const[o,a]of r)i[o.toString()]=Dc(s,a,n.enumAsInteger);break}return n.emitDefaultValues||r.length>0?i:void 0}if(t.repeated){Xe(Array.isArray(e));const i=[];switch(t.kind){case"scalar":for(let r=0;r<e.length;r++)i.push(Zo(t.T,e[r]));break;case"enum":for(let r=0;r<e.length;r++)i.push(Dc(t.T,e[r],n.enumAsInteger));break;case"message":for(let r=0;r<e.length;r++)i.push(e[r].toJson(n));break}return n.emitDefaultValues||i.length>0?i:void 0}switch(t.kind){case"scalar":return Zo(t.T,e);case"enum":return Dc(t.T,e,n.enumAsInteger);case"message":return $0(t.T,e).toJson(n)}}function Dc(t,e,n){var i;if(Xe(typeof e=="number"),t.typeName=="google.protobuf.NullValue")return null;if(n)return e;const r=t.findNumber(e);return(i=r==null?void 0:r.name)!==null&&i!==void 0?i:e}function Zo(t,e){switch(t){case Y.INT32:case Y.SFIXED32:case Y.SINT32:case Y.FIXED32:case Y.UINT32:return Xe(typeof e=="number"),e;case Y.FLOAT:case Y.DOUBLE:return Xe(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case Y.STRING:return Xe(typeof e=="string"),e;case Y.BOOL:return Xe(typeof e=="boolean"),e;case Y.UINT64:case Y.FIXED64:case Y.INT64:case Y.SFIXED64:case Y.SINT64:return Xe(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case Y.BYTES:return Xe(e instanceof Uint8Array),V0.enc(e)}}const lr=Symbol("@bufbuild/protobuf/unknown-fields"),Ah={readUnknownFields:!0,readerFactory:t=>new sC(t)},Ih={writeUnknownFields:!0,writerFactory:()=>new rC};function gC(t){return t?Object.assign(Object.assign({},Ah),t):Ah}function vC(t){return t?Object.assign(Object.assign({},Ih),t):Ih}function yC(){return{makeReadOptions:gC,makeWriteOptions:vC,listUnknownFields(t){var e;return(e=t[lr])!==null&&e!==void 0?e:[]},discardUnknownFields(t){delete t[lr]},writeUnknownFields(t,e){const i=t[lr];if(i)for(const r of i)e.tag(r.no,r.wireType).raw(r.data)},onUnknownField(t,e,n,i){const r=t;Array.isArray(r[lr])||(r[lr]=[]),r[lr].push({no:e,wireType:n,data:i})},readMessage(t,e,n,i,r){const s=t.getType(),o=r?e.len:e.pos+n;let a,c;for(;e.pos<o&&([a,c]=e.tag(),!(r===!0&&c==rt.EndGroup));){const l=s.fields.find(a);if(!l){const d=e.skip(c,a);i.readUnknownFields&&this.onUnknownField(t,a,c,d);continue}Mh(t,e,l,c,i)}if(r&&(c!=rt.EndGroup||a!==n))throw new Error("invalid end group tag")},readField:Mh,writeMessage(t,e,n){const i=t.getType();for(const r of i.fields.byNumber()){if(!B0(r,t)){if(r.req)throw new Error("cannot encode field ".concat(i.typeName,".").concat(r.name," to binary: required field not set"));continue}const s=r.oneof?t[r.oneof.localName].value:t[r.localName];_h(r,s,e,n)}return n.writeUnknownFields&&this.writeUnknownFields(t,e),e},writeField(t,e,n,i){e!==void 0&&_h(t,e,n,i)}}}function Mh(t,e,n,i,r){let{repeated:s,localName:o}=n;switch(n.oneof&&(t=t[n.oneof.localName],t.case!=o&&delete t.value,t.case=o,o="value"),n.kind){case"scalar":case"enum":const a=n.kind=="enum"?Y.INT32:n.T;let c=Sa;if(n.kind=="scalar"&&n.L>0&&(c=xC),s){let f=t[o];if(i==rt.LengthDelimited&&a!=Y.STRING&&a!=Y.BYTES){let v=e.uint32()+e.pos;for(;e.pos<v;)f.push(c(e,a))}else f.push(c(e,a))}else t[o]=c(e,a);break;case"message":const l=n.T;s?t[o].push(Yo(e,new l,r,n)):Hn(t[o])?Yo(e,t[o],r,n):(t[o]=Yo(e,new l,r,n),l.fieldWrapper&&!n.oneof&&!n.repeated&&(t[o]=l.fieldWrapper.unwrapField(t[o])));break;case"map":let[d,u]=bC(n,e,r);t[o][d]=u;break}}function Yo(t,e,n,i){const r=e.getType().runtime.bin,s=i==null?void 0:i.delimited;return r.readMessage(e,t,s?i.no:t.uint32(),n,s),e}function bC(t,e,n){const i=e.uint32(),r=e.pos+i;let s,o;for(;e.pos<r;){const[a]=e.tag();switch(a){case 1:s=Sa(e,t.K);break;case 2:switch(t.V.kind){case"scalar":o=Sa(e,t.V.T);break;case"enum":o=e.int32();break;case"message":o=Yo(e,new t.V.T,n,void 0);break}break}}if(s===void 0&&(s=Wr(t.K,hi.BIGINT)),typeof s!="string"&&typeof s!="number"&&(s=s.toString()),o===void 0)switch(t.V.kind){case"scalar":o=Wr(t.V.T,hi.BIGINT);break;case"enum":o=t.V.T.values[0].no;break;case"message":o=new t.V.T;break}return[s,o]}function xC(t,e){const n=Sa(t,e);return typeof n=="bigint"?n.toString():n}function Sa(t,e){switch(e){case Y.STRING:return t.string();case Y.BOOL:return t.bool();case Y.DOUBLE:return t.double();case Y.FLOAT:return t.float();case Y.INT32:return t.int32();case Y.INT64:return t.int64();case Y.UINT64:return t.uint64();case Y.FIXED64:return t.fixed64();case Y.BYTES:return t.bytes();case Y.FIXED32:return t.fixed32();case Y.SFIXED32:return t.sfixed32();case Y.SFIXED64:return t.sfixed64();case Y.SINT64:return t.sint64();case Y.UINT32:return t.uint32();case Y.SINT32:return t.sint32()}}function _h(t,e,n,i){Xe(e!==void 0);const r=t.repeated;switch(t.kind){case"scalar":case"enum":let s=t.kind=="enum"?Y.INT32:t.T;if(r)if(Xe(Array.isArray(e)),t.packed)wC(n,s,t.no,e);else for(const o of e)js(n,s,t.no,o);else js(n,s,t.no,e);break;case"message":if(r){Xe(Array.isArray(e));for(const o of e)Nh(n,i,t,o)}else Nh(n,i,t,e);break;case"map":Xe(typeof e=="object"&&e!=null);for(const[o,a]of Object.entries(e))SC(n,i,t,o,a);break}}function SC(t,e,n,i,r){t.tag(n.no,rt.LengthDelimited),t.fork();let s=i;switch(n.K){case Y.INT32:case Y.FIXED32:case Y.UINT32:case Y.SFIXED32:case Y.SINT32:s=Number.parseInt(i);break;case Y.BOOL:Xe(i=="true"||i=="false"),s=i=="true";break}switch(js(t,n.K,1,s),n.V.kind){case"scalar":js(t,n.V.T,2,r);break;case"enum":js(t,Y.INT32,2,r);break;case"message":Xe(r!==void 0),t.tag(2,rt.LengthDelimited).bytes(r.toBinary(e));break}t.join()}function Nh(t,e,n,i){const r=$0(n.T,i);n.delimited?t.tag(n.no,rt.StartGroup).raw(r.toBinary(e)).tag(n.no,rt.EndGroup):t.tag(n.no,rt.LengthDelimited).bytes(r.toBinary(e))}function js(t,e,n,i){Xe(i!==void 0);let[r,s]=H0(e);t.tag(n,r)[s](i)}function wC(t,e,n,i){if(!i.length)return;t.tag(n,rt.LengthDelimited).fork();let[,r]=H0(e);for(let s=0;s<i.length;s++)t[r](i[s]);t.join()}function H0(t){let e=rt.Varint;switch(t){case Y.BYTES:case Y.STRING:e=rt.LengthDelimited;break;case Y.DOUBLE:case Y.FIXED64:case Y.SFIXED64:e=rt.Bit64;break;case Y.FIXED32:case Y.SFIXED32:case Y.FLOAT:e=rt.Bit32;break}const n=Y[t].toLowerCase();return[e,n]}function CC(){return{setEnumType:M0,initPartial(t,e){if(t===void 0)return;const n=e.getType();for(const i of n.fields.byMember()){const r=i.localName,s=e,o=t;if(o[r]!=null)switch(i.kind){case"oneof":const a=o[r].case;if(a===void 0)continue;const c=i.findField(a);let l=o[r].value;c&&c.kind=="message"&&!Hn(l,c.T)?l=new c.T(l):c&&c.kind==="scalar"&&c.T===Y.BYTES&&(l=bs(l)),s[r]={case:a,value:l};break;case"scalar":case"enum":let d=o[r];i.T===Y.BYTES&&(d=i.repeated?d.map(bs):bs(d)),s[r]=d;break;case"map":switch(i.V.kind){case"scalar":case"enum":if(i.V.T===Y.BYTES)for(const[p,v]of Object.entries(o[r]))s[r][p]=bs(v);else Object.assign(s[r],o[r]);break;case"message":const f=i.V.T;for(const p of Object.keys(o[r])){let v=o[r][p];f.fieldWrapper||(v=new f(v)),s[r][p]=v}break}break;case"message":const u=i.T;if(i.repeated)s[r]=o[r].map(f=>Hn(f,u)?f:new u(f));else{const f=o[r];u.fieldWrapper?u.typeName==="google.protobuf.BytesValue"?s[r]=bs(f):s[r]=f:s[r]=Hn(f,u)?f:new u(f)}break}}},equals(t,e,n){return e===n?!0:!e||!n?!1:t.fields.byMember().every(i=>{const r=e[i.localName],s=n[i.localName];if(i.repeated){if(r.length!==s.length)return!1;switch(i.kind){case"message":return r.every((o,a)=>i.T.equals(o,s[a]));case"scalar":return r.every((o,a)=>ni(i.T,o,s[a]));case"enum":return r.every((o,a)=>ni(Y.INT32,o,s[a]))}throw new Error("repeated cannot contain ".concat(i.kind))}switch(i.kind){case"message":let o=r,a=s;return i.T.fieldWrapper&&(o!==void 0&&!Hn(o)&&(o=i.T.fieldWrapper.wrapField(o)),a!==void 0&&!Hn(a)&&(a=i.T.fieldWrapper.wrapField(a))),i.T.equals(o,a);case"enum":return ni(Y.INT32,r,s);case"scalar":return ni(i.T,r,s);case"oneof":if(r.case!==s.case)return!1;const c=i.findField(r.case);if(c===void 0)return!0;switch(c.kind){case"message":return c.T.equals(r.value,s.value);case"enum":return ni(Y.INT32,r.value,s.value);case"scalar":return ni(c.T,r.value,s.value)}throw new Error("oneof cannot contain ".concat(c.kind));case"map":const l=Object.keys(r).concat(Object.keys(s));switch(i.V.kind){case"message":const d=i.V.T;return l.every(f=>d.equals(r[f],s[f]));case"enum":return l.every(f=>ni(Y.INT32,r[f],s[f]));case"scalar":const u=i.V.T;return l.every(f=>ni(u,r[f],s[f]))}break}})},clone(t){const e=t.getType(),n=new e,i=n;for(const r of e.fields.byMember()){const s=t[r.localName];let o;if(r.repeated)o=s.map(wo);else if(r.kind=="map"){o=i[r.localName];for(const[a,c]of Object.entries(s))o[a]=wo(c)}else r.kind=="oneof"?o=r.findField(s.case)?{case:s.case,value:wo(s.value)}:{case:void 0}:o=wo(s);i[r.localName]=o}for(const r of e.runtime.bin.listUnknownFields(t))e.runtime.bin.onUnknownField(i,r.no,r.wireType,r.data);return n}}}function wo(t){if(t===void 0)return t;if(Hn(t))return t.clone();if(t instanceof Uint8Array){const e=new Uint8Array(t.byteLength);return e.set(t),e}return t}function bs(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function kC(t,e,n){return{syntax:t,json:hC(),bin:yC(),util:Object.assign(Object.assign({},CC()),{newFieldList:e,initFields:n}),makeMessageType(i,r,s){return Xw(this,i,r,s)},makeEnum:Jw,makeEnumType:_0,getEnumType:Yw,makeExtension(i,r,s){return oC(this,i,r,s)}}}class TC{constructor(e,n){this._fields=e,this._normalizer=n}findJsonName(e){if(!this.jsonNames){const n={};for(const i of this.list())n[i.jsonName]=n[i.name]=i;this.jsonNames=n}return this.jsonNames[e]}find(e){if(!this.numbers){const n={};for(const i of this.list())n[i.no]=i;this.numbers=n}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,n)=>e.no-n.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let n;for(const i of this.list())i.oneof?i.oneof!==n&&(n=i.oneof,e.push(n)):e.push(i)}return this.members}}function z0(t,e){const n=W0(t);return e?n:MC(IC(n))}function EC(t){return z0(t,!1)}const PC=W0;function W0(t){let e=!1;const n=[];for(let i=0;i<t.length;i++){let r=t.charAt(i);switch(r){case"_":e=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n.push(r),e=!1;break;default:e&&(e=!1,r=r.toUpperCase()),n.push(r);break}}return n.join("")}const RC=new Set(["constructor","toString","toJSON","valueOf"]),AC=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),q0=t=>"".concat(t,"$"),IC=t=>AC.has(t)?q0(t):t,MC=t=>RC.has(t)?q0(t):t;class _C{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=EC(e)}addField(e){Xe(e.oneof===this,"field ".concat(e.name," not one of ").concat(this.name)),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let n=0;n<this.fields.length;n++)this._lookup[this.fields[n].localName]=this.fields[n]}return this._lookup[e]}}function NC(t,e){var n,i,r,s,o,a;const c=[];let l;for(const d of typeof t=="function"?t():t){const u=d;if(u.localName=z0(d.name,d.oneof!==void 0),u.jsonName=(n=d.jsonName)!==null&&n!==void 0?n:PC(d.name),u.repeated=(i=d.repeated)!==null&&i!==void 0?i:!1,d.kind=="scalar"&&(u.L=(r=d.L)!==null&&r!==void 0?r:hi.BIGINT),u.delimited=(s=d.delimited)!==null&&s!==void 0?s:!1,u.req=(o=d.req)!==null&&o!==void 0?o:!1,u.opt=(a=d.opt)!==null&&a!==void 0?a:!1,d.packed===void 0&&(u.packed=d.kind=="enum"||d.kind=="scalar"&&d.T!=Y.BYTES&&d.T!=Y.STRING),d.oneof!==void 0){const f=typeof d.oneof=="string"?d.oneof:d.oneof.name;(!l||l.name!=f)&&(l=new _C(f)),u.oneof=l,l.addField(u)}c.push(u)}return c}const B=kC("proto3",t=>new TC(t,e=>NC(e)),t=>{for(const e of t.getType().fields.byMember()){if(e.opt)continue;const n=e.localName,i=t;if(e.repeated){i[n]=[];continue}switch(e.kind){case"oneof":i[n]={case:void 0};break;case"enum":i[n]=0;break;case"map":i[n]={};break;case"scalar":i[n]=Wr(e.T,e.L);break}}});class _t extends Su{constructor(e){super(),this.seconds=ze.zero,this.nanos=0,B.util.initPartial(e,this)}fromJson(e,n){if(typeof e!="string")throw new Error("cannot decode google.protobuf.Timestamp from JSON: ".concat(B.json.debug(e)));const i=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!i)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const r=Date.parse(i[1]+"-"+i[2]+"-"+i[3]+"T"+i[4]+":"+i[5]+":"+i[6]+(i[8]?i[8]:"Z"));if(Number.isNaN(r))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(r<Date.parse("0001-01-01T00:00:00Z")||r>Date.parse("9999-12-31T23:59:59Z"))throw new Error("cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");return this.seconds=ze.parse(r/1e3),this.nanos=0,i[7]&&(this.nanos=parseInt("1"+i[7]+"0".repeat(9-i[7].length))-1e9),this}toJson(e){const n=Number(this.seconds)*1e3;if(n<Date.parse("0001-01-01T00:00:00Z")||n>Date.parse("9999-12-31T23:59:59Z"))throw new Error("cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let i="Z";if(this.nanos>0){const r=(this.nanos+1e9).toString().substring(1);r.substring(3)==="000000"?i="."+r.substring(0,3)+"Z":r.substring(6)==="000"?i="."+r.substring(0,6)+"Z":i="."+r+"Z"}return new Date(n).toISOString().replace(".000Z",i)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return _t.fromDate(new Date)}static fromDate(e){const n=e.getTime();return new _t({seconds:ze.parse(Math.floor(n/1e3)),nanos:n%1e3*1e6})}static fromBinary(e,n){return new _t().fromBinary(e,n)}static fromJson(e,n){return new _t().fromJson(e,n)}static fromJsonString(e,n){return new _t().fromJsonString(e,n)}static equals(e,n){return B.util.equals(_t,e,n)}}_t.runtime=B;_t.typeName="google.protobuf.Timestamp";_t.fields=B.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);const OC=B.makeMessageType("livekit.MetricsBatch",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:_t},{no:3,name:"str_data",kind:"scalar",T:9,repeated:!0},{no:4,name:"time_series",kind:"message",T:DC,repeated:!0},{no:5,name:"events",kind:"message",T:LC,repeated:!0}]),DC=B.makeMessageType("livekit.TimeSeriesMetric",()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"samples",kind:"message",T:jC,repeated:!0},{no:5,name:"rid",kind:"scalar",T:13}]),jC=B.makeMessageType("livekit.MetricSample",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:_t},{no:3,name:"value",kind:"scalar",T:2}]),LC=B.makeMessageType("livekit.EventMetric",()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"start_timestamp_ms",kind:"scalar",T:3},{no:5,name:"end_timestamp_ms",kind:"scalar",T:3,opt:!0},{no:6,name:"normalized_start_timestamp",kind:"message",T:_t},{no:7,name:"normalized_end_timestamp",kind:"message",T:_t,opt:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"rid",kind:"scalar",T:13}]),K0=B.makeEnum("livekit.BackupCodecPolicy",[{no:0,name:"PREFER_REGRESSION"},{no:1,name:"SIMULCAST"},{no:2,name:"REGRESSION"}]),cn=B.makeEnum("livekit.TrackType",[{no:0,name:"AUDIO"},{no:1,name:"VIDEO"},{no:2,name:"DATA"}]),lt=B.makeEnum("livekit.TrackSource",[{no:0,name:"UNKNOWN"},{no:1,name:"CAMERA"},{no:2,name:"MICROPHONE"},{no:3,name:"SCREEN_SHARE"},{no:4,name:"SCREEN_SHARE_AUDIO"}]),Cu=B.makeEnum("livekit.VideoQuality",[{no:0,name:"LOW"},{no:1,name:"MEDIUM"},{no:2,name:"HIGH"},{no:3,name:"OFF"}]),As=B.makeEnum("livekit.ConnectionQuality",[{no:0,name:"POOR"},{no:1,name:"GOOD"},{no:2,name:"EXCELLENT"},{no:3,name:"LOST"}]),Hs=B.makeEnum("livekit.ClientConfigSetting",[{no:0,name:"UNSET"},{no:1,name:"DISABLED"},{no:2,name:"ENABLED"}]),dn=B.makeEnum("livekit.DisconnectReason",[{no:0,name:"UNKNOWN_REASON"},{no:1,name:"CLIENT_INITIATED"},{no:2,name:"DUPLICATE_IDENTITY"},{no:3,name:"SERVER_SHUTDOWN"},{no:4,name:"PARTICIPANT_REMOVED"},{no:5,name:"ROOM_DELETED"},{no:6,name:"STATE_MISMATCH"},{no:7,name:"JOIN_FAILURE"},{no:8,name:"MIGRATION"},{no:9,name:"SIGNAL_CLOSE"},{no:10,name:"ROOM_CLOSED"},{no:11,name:"USER_UNAVAILABLE"},{no:12,name:"USER_REJECTED"},{no:13,name:"SIP_TRUNK_FAILURE"},{no:14,name:"CONNECTION_TIMEOUT"},{no:15,name:"MEDIA_FAILURE"}]),dr=B.makeEnum("livekit.ReconnectReason",[{no:0,name:"RR_UNKNOWN"},{no:1,name:"RR_SIGNAL_DISCONNECTED"},{no:2,name:"RR_PUBLISHER_FAILED"},{no:3,name:"RR_SUBSCRIBER_FAILED"},{no:4,name:"RR_SWITCH_CANDIDATE"}]),VC=B.makeEnum("livekit.SubscriptionError",[{no:0,name:"SE_UNKNOWN"},{no:1,name:"SE_CODEC_UNSUPPORTED"},{no:2,name:"SE_TRACK_NOTFOUND"}]),pt=B.makeEnum("livekit.AudioTrackFeature",[{no:0,name:"TF_STEREO"},{no:1,name:"TF_NO_DTX"},{no:2,name:"TF_AUTO_GAIN_CONTROL"},{no:3,name:"TF_ECHO_CANCELLATION"},{no:4,name:"TF_NOISE_SUPPRESSION"},{no:5,name:"TF_ENHANCED_NOISE_CANCELLATION"},{no:6,name:"TF_PRECONNECT_BUFFER"}]),Ga=B.makeMessageType("livekit.Room",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"empty_timeout",kind:"scalar",T:13},{no:14,name:"departure_timeout",kind:"scalar",T:13},{no:4,name:"max_participants",kind:"scalar",T:13},{no:5,name:"creation_time",kind:"scalar",T:3},{no:15,name:"creation_time_ms",kind:"scalar",T:3},{no:6,name:"turn_password",kind:"scalar",T:9},{no:7,name:"enabled_codecs",kind:"message",T:wa,repeated:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"num_participants",kind:"scalar",T:13},{no:11,name:"num_publishers",kind:"scalar",T:13},{no:10,name:"active_recording",kind:"scalar",T:8},{no:13,name:"version",kind:"message",T:ov}]),wa=B.makeMessageType("livekit.Codec",()=>[{no:1,name:"mime",kind:"scalar",T:9},{no:2,name:"fmtp_line",kind:"scalar",T:9}]),FC=B.makeMessageType("livekit.ParticipantPermission",()=>[{no:1,name:"can_subscribe",kind:"scalar",T:8},{no:2,name:"can_publish",kind:"scalar",T:8},{no:3,name:"can_publish_data",kind:"scalar",T:8},{no:9,name:"can_publish_sources",kind:"enum",T:B.getEnumType(lt),repeated:!0},{no:7,name:"hidden",kind:"scalar",T:8},{no:8,name:"recorder",kind:"scalar",T:8},{no:10,name:"can_update_metadata",kind:"scalar",T:8},{no:11,name:"agent",kind:"scalar",T:8},{no:12,name:"can_subscribe_metrics",kind:"scalar",T:8}]),Zi=B.makeMessageType("livekit.ParticipantInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"identity",kind:"scalar",T:9},{no:3,name:"state",kind:"enum",T:B.getEnumType(_r)},{no:4,name:"tracks",kind:"message",T:Cr,repeated:!0},{no:5,name:"metadata",kind:"scalar",T:9},{no:6,name:"joined_at",kind:"scalar",T:3},{no:17,name:"joined_at_ms",kind:"scalar",T:3},{no:9,name:"name",kind:"scalar",T:9},{no:10,name:"version",kind:"scalar",T:13},{no:11,name:"permission",kind:"message",T:FC},{no:12,name:"region",kind:"scalar",T:9},{no:13,name:"is_publisher",kind:"scalar",T:8},{no:14,name:"kind",kind:"enum",T:B.getEnumType(Yi)},{no:15,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:16,name:"disconnect_reason",kind:"enum",T:B.getEnumType(dn)},{no:18,name:"kind_details",kind:"enum",T:B.getEnumType(UC),repeated:!0}]),_r=B.makeEnum("livekit.ParticipantInfo.State",[{no:0,name:"JOINING"},{no:1,name:"JOINED"},{no:2,name:"ACTIVE"},{no:3,name:"DISCONNECTED"}]),Yi=B.makeEnum("livekit.ParticipantInfo.Kind",[{no:0,name:"STANDARD"},{no:1,name:"INGRESS"},{no:2,name:"EGRESS"},{no:3,name:"SIP"},{no:4,name:"AGENT"}]),UC=B.makeEnum("livekit.ParticipantInfo.KindDetail",[{no:0,name:"CLOUD_AGENT"},{no:1,name:"FORWARDED"}]),Ft=B.makeEnum("livekit.Encryption.Type",[{no:0,name:"NONE"},{no:1,name:"GCM"},{no:2,name:"CUSTOM"}]),BC=B.makeMessageType("livekit.SimulcastCodecInfo",()=>[{no:1,name:"mime_type",kind:"scalar",T:9},{no:2,name:"mid",kind:"scalar",T:9},{no:3,name:"cid",kind:"scalar",T:9},{no:4,name:"layers",kind:"message",T:Hi,repeated:!0}]),Cr=B.makeMessageType("livekit.TrackInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"type",kind:"enum",T:B.getEnumType(cn)},{no:3,name:"name",kind:"scalar",T:9},{no:4,name:"muted",kind:"scalar",T:8},{no:5,name:"width",kind:"scalar",T:13},{no:6,name:"height",kind:"scalar",T:13},{no:7,name:"simulcast",kind:"scalar",T:8},{no:8,name:"disable_dtx",kind:"scalar",T:8},{no:9,name:"source",kind:"enum",T:B.getEnumType(lt)},{no:10,name:"layers",kind:"message",T:Hi,repeated:!0},{no:11,name:"mime_type",kind:"scalar",T:9},{no:12,name:"mid",kind:"scalar",T:9},{no:13,name:"codecs",kind:"message",T:BC,repeated:!0},{no:14,name:"stereo",kind:"scalar",T:8},{no:15,name:"disable_red",kind:"scalar",T:8},{no:16,name:"encryption",kind:"enum",T:B.getEnumType(Ft)},{no:17,name:"stream",kind:"scalar",T:9},{no:18,name:"version",kind:"message",T:ov},{no:19,name:"audio_features",kind:"enum",T:B.getEnumType(pt),repeated:!0},{no:20,name:"backup_codec_policy",kind:"enum",T:B.getEnumType(K0)}]),Hi=B.makeMessageType("livekit.VideoLayer",()=>[{no:1,name:"quality",kind:"enum",T:B.getEnumType(Cu)},{no:2,name:"width",kind:"scalar",T:13},{no:3,name:"height",kind:"scalar",T:13},{no:4,name:"bitrate",kind:"scalar",T:13},{no:5,name:"ssrc",kind:"scalar",T:13}]),Mt=B.makeMessageType("livekit.DataPacket",()=>[{no:1,name:"kind",kind:"enum",T:B.getEnumType(be)},{no:4,name:"participant_identity",kind:"scalar",T:9},{no:5,name:"destination_identities",kind:"scalar",T:9,repeated:!0},{no:2,name:"user",kind:"message",T:Z0,oneof:"value"},{no:3,name:"speaker",kind:"message",T:$C,oneof:"value"},{no:6,name:"sip_dtmf",kind:"message",T:Y0,oneof:"value"},{no:7,name:"transcription",kind:"message",T:HC,oneof:"value"},{no:8,name:"metrics",kind:"message",T:OC,oneof:"value"},{no:9,name:"chat_message",kind:"message",T:Hl,oneof:"value"},{no:10,name:"rpc_request",kind:"message",T:J0,oneof:"value"},{no:11,name:"rpc_ack",kind:"message",T:X0,oneof:"value"},{no:12,name:"rpc_response",kind:"message",T:Q0,oneof:"value"},{no:13,name:"stream_header",kind:"message",T:Wl,oneof:"value"},{no:14,name:"stream_chunk",kind:"message",T:ql,oneof:"value"},{no:15,name:"stream_trailer",kind:"message",T:Kl,oneof:"value"},{no:16,name:"sequence",kind:"scalar",T:13},{no:17,name:"participant_sid",kind:"scalar",T:9}]),be=B.makeEnum("livekit.DataPacket.Kind",[{no:0,name:"RELIABLE"},{no:1,name:"LOSSY"}]),$C=B.makeMessageType("livekit.ActiveSpeakerUpdate",()=>[{no:1,name:"speakers",kind:"message",T:G0,repeated:!0}]),G0=B.makeMessageType("livekit.SpeakerInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"level",kind:"scalar",T:2},{no:3,name:"active",kind:"scalar",T:8}]),Z0=B.makeMessageType("livekit.UserPacket",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:5,name:"participant_identity",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12},{no:3,name:"destination_sids",kind:"scalar",T:9,repeated:!0},{no:6,name:"destination_identities",kind:"scalar",T:9,repeated:!0},{no:4,name:"topic",kind:"scalar",T:9,opt:!0},{no:8,name:"id",kind:"scalar",T:9,opt:!0},{no:9,name:"start_time",kind:"scalar",T:4,opt:!0},{no:10,name:"end_time",kind:"scalar",T:4,opt:!0},{no:11,name:"nonce",kind:"scalar",T:12}]),Y0=B.makeMessageType("livekit.SipDTMF",()=>[{no:3,name:"code",kind:"scalar",T:13},{no:4,name:"digit",kind:"scalar",T:9}]),HC=B.makeMessageType("livekit.Transcription",()=>[{no:2,name:"transcribed_participant_identity",kind:"scalar",T:9},{no:3,name:"track_id",kind:"scalar",T:9},{no:4,name:"segments",kind:"message",T:zC,repeated:!0}]),zC=B.makeMessageType("livekit.TranscriptionSegment",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"start_time",kind:"scalar",T:4},{no:4,name:"end_time",kind:"scalar",T:4},{no:5,name:"final",kind:"scalar",T:8},{no:6,name:"language",kind:"scalar",T:9}]),Hl=B.makeMessageType("livekit.ChatMessage",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"timestamp",kind:"scalar",T:3},{no:3,name:"edit_timestamp",kind:"scalar",T:3,opt:!0},{no:4,name:"message",kind:"scalar",T:9},{no:5,name:"deleted",kind:"scalar",T:8},{no:6,name:"generated",kind:"scalar",T:8}]),J0=B.makeMessageType("livekit.RpcRequest",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"method",kind:"scalar",T:9},{no:3,name:"payload",kind:"scalar",T:9},{no:4,name:"response_timeout_ms",kind:"scalar",T:13},{no:5,name:"version",kind:"scalar",T:13}]),X0=B.makeMessageType("livekit.RpcAck",()=>[{no:1,name:"request_id",kind:"scalar",T:9}]),Q0=B.makeMessageType("livekit.RpcResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:9,oneof:"value"},{no:3,name:"error",kind:"message",T:ev,oneof:"value"}]),ev=B.makeMessageType("livekit.RpcError",()=>[{no:1,name:"code",kind:"scalar",T:13},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"data",kind:"scalar",T:9}]),tv=B.makeMessageType("livekit.ParticipantTracks",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sids",kind:"scalar",T:9,repeated:!0}]),nv=B.makeMessageType("livekit.ServerInfo",()=>[{no:1,name:"edition",kind:"enum",T:B.getEnumType(iv)},{no:2,name:"version",kind:"scalar",T:9},{no:3,name:"protocol",kind:"scalar",T:5},{no:4,name:"region",kind:"scalar",T:9},{no:5,name:"node_id",kind:"scalar",T:9},{no:6,name:"debug_info",kind:"scalar",T:9},{no:7,name:"agent_protocol",kind:"scalar",T:5}]),iv=B.makeEnum("livekit.ServerInfo.Edition",[{no:0,name:"Standard"},{no:1,name:"Cloud"}]),WC=B.makeMessageType("livekit.ClientInfo",()=>[{no:1,name:"sdk",kind:"enum",T:B.getEnumType(rv)},{no:2,name:"version",kind:"scalar",T:9},{no:3,name:"protocol",kind:"scalar",T:5},{no:4,name:"os",kind:"scalar",T:9},{no:5,name:"os_version",kind:"scalar",T:9},{no:6,name:"device_model",kind:"scalar",T:9},{no:7,name:"browser",kind:"scalar",T:9},{no:8,name:"browser_version",kind:"scalar",T:9},{no:9,name:"address",kind:"scalar",T:9},{no:10,name:"network",kind:"scalar",T:9},{no:11,name:"other_sdks",kind:"scalar",T:9}]),rv=B.makeEnum("livekit.ClientInfo.SDK",[{no:0,name:"UNKNOWN"},{no:1,name:"JS"},{no:2,name:"SWIFT"},{no:3,name:"ANDROID"},{no:4,name:"FLUTTER"},{no:5,name:"GO"},{no:6,name:"UNITY"},{no:7,name:"REACT_NATIVE"},{no:8,name:"RUST"},{no:9,name:"PYTHON"},{no:10,name:"CPP"},{no:11,name:"UNITY_WEB"},{no:12,name:"NODE"},{no:13,name:"UNREAL"}]),sv=B.makeMessageType("livekit.ClientConfiguration",()=>[{no:1,name:"video",kind:"message",T:Oh},{no:2,name:"screen",kind:"message",T:Oh},{no:3,name:"resume_connection",kind:"enum",T:B.getEnumType(Hs)},{no:4,name:"disabled_codecs",kind:"message",T:qC},{no:5,name:"force_relay",kind:"enum",T:B.getEnumType(Hs)}]),Oh=B.makeMessageType("livekit.VideoConfiguration",()=>[{no:1,name:"hardware_encoder",kind:"enum",T:B.getEnumType(Hs)}]),qC=B.makeMessageType("livekit.DisabledCodecs",()=>[{no:1,name:"codecs",kind:"message",T:wa,repeated:!0},{no:2,name:"publish",kind:"message",T:wa,repeated:!0}]),ov=B.makeMessageType("livekit.TimedVersion",()=>[{no:1,name:"unix_micro",kind:"scalar",T:3},{no:2,name:"ticks",kind:"scalar",T:5}]),zl=B.makeEnum("livekit.DataStream.OperationType",[{no:0,name:"CREATE"},{no:1,name:"UPDATE"},{no:2,name:"DELETE"},{no:3,name:"REACTION"}]),av=B.makeMessageType("livekit.DataStream.TextHeader",()=>[{no:1,name:"operation_type",kind:"enum",T:B.getEnumType(zl)},{no:2,name:"version",kind:"scalar",T:5},{no:3,name:"reply_to_stream_id",kind:"scalar",T:9},{no:4,name:"attached_stream_ids",kind:"scalar",T:9,repeated:!0},{no:5,name:"generated",kind:"scalar",T:8}],{localName:"DataStream_TextHeader"}),cv=B.makeMessageType("livekit.DataStream.ByteHeader",()=>[{no:1,name:"name",kind:"scalar",T:9}],{localName:"DataStream_ByteHeader"}),Wl=B.makeMessageType("livekit.DataStream.Header",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"timestamp",kind:"scalar",T:3},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"mime_type",kind:"scalar",T:9},{no:5,name:"total_length",kind:"scalar",T:4,opt:!0},{no:7,name:"encryption_type",kind:"enum",T:B.getEnumType(Ft)},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:9,name:"text_header",kind:"message",T:av,oneof:"content_header"},{no:10,name:"byte_header",kind:"message",T:cv,oneof:"content_header"}],{localName:"DataStream_Header"}),ql=B.makeMessageType("livekit.DataStream.Chunk",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"chunk_index",kind:"scalar",T:4},{no:3,name:"content",kind:"scalar",T:12},{no:4,name:"version",kind:"scalar",T:5},{no:5,name:"iv",kind:"scalar",T:12,opt:!0}],{localName:"DataStream_Chunk"}),Kl=B.makeMessageType("livekit.DataStream.Trailer",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"reason",kind:"scalar",T:9},{no:3,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}],{localName:"DataStream_Trailer"}),ln=B.makeEnum("livekit.SignalTarget",[{no:0,name:"PUBLISHER"},{no:1,name:"SUBSCRIBER"}]),Gl=B.makeEnum("livekit.StreamState",[{no:0,name:"ACTIVE"},{no:1,name:"PAUSED"}]),KC=B.makeEnum("livekit.CandidateProtocol",[{no:0,name:"UDP"},{no:1,name:"TCP"},{no:2,name:"TLS"}]),GC=B.makeMessageType("livekit.SignalRequest",()=>[{no:1,name:"offer",kind:"message",T:Ji,oneof:"message"},{no:2,name:"answer",kind:"message",T:Ji,oneof:"message"},{no:3,name:"trickle",kind:"message",T:ku,oneof:"message"},{no:4,name:"add_track",kind:"message",T:Yl,oneof:"message"},{no:5,name:"mute",kind:"message",T:Tu,oneof:"message"},{no:6,name:"subscription",kind:"message",T:Za,oneof:"message"},{no:7,name:"track_setting",kind:"message",T:lv,oneof:"message"},{no:8,name:"leave",kind:"message",T:Ya,oneof:"message"},{no:10,name:"update_layers",kind:"message",T:uv,oneof:"message"},{no:11,name:"subscription_permission",kind:"message",T:pv,oneof:"message"},{no:12,name:"sync_state",kind:"message",T:gv,oneof:"message"},{no:13,name:"simulate",kind:"message",T:bn,oneof:"message"},{no:14,name:"ping",kind:"scalar",T:3,oneof:"message"},{no:15,name:"update_metadata",kind:"message",T:fv,oneof:"message"},{no:16,name:"ping_req",kind:"message",T:bv,oneof:"message"},{no:17,name:"update_audio_track",kind:"message",T:dv,oneof:"message"},{no:18,name:"update_video_track",kind:"message",T:QC,oneof:"message"}]),Dh=B.makeMessageType("livekit.SignalResponse",()=>[{no:1,name:"join",kind:"message",T:ZC,oneof:"message"},{no:2,name:"answer",kind:"message",T:Ji,oneof:"message"},{no:3,name:"offer",kind:"message",T:Ji,oneof:"message"},{no:4,name:"trickle",kind:"message",T:ku,oneof:"message"},{no:5,name:"update",kind:"message",T:XC,oneof:"message"},{no:6,name:"track_published",kind:"message",T:Eu,oneof:"message"},{no:8,name:"leave",kind:"message",T:Ya,oneof:"message"},{no:9,name:"mute",kind:"message",T:Tu,oneof:"message"},{no:10,name:"speakers_changed",kind:"message",T:ek,oneof:"message"},{no:11,name:"room_update",kind:"message",T:tk,oneof:"message"},{no:12,name:"connection_quality",kind:"message",T:ik,oneof:"message"},{no:13,name:"stream_state_update",kind:"message",T:sk,oneof:"message"},{no:14,name:"subscribed_quality_update",kind:"message",T:ak,oneof:"message"},{no:15,name:"subscription_permission_update",kind:"message",T:ck,oneof:"message"},{no:16,name:"refresh_token",kind:"scalar",T:9,oneof:"message"},{no:17,name:"track_unpublished",kind:"message",T:JC,oneof:"message"},{no:18,name:"pong",kind:"scalar",T:3,oneof:"message"},{no:19,name:"reconnect",kind:"message",T:YC,oneof:"message"},{no:20,name:"pong_resp",kind:"message",T:dk,oneof:"message"},{no:21,name:"subscription_response",kind:"message",T:hk,oneof:"message"},{no:22,name:"request_response",kind:"message",T:mk,oneof:"message"},{no:23,name:"track_subscribed",kind:"message",T:pk,oneof:"message"},{no:24,name:"room_moved",kind:"message",T:lk,oneof:"message"}]),Zl=B.makeMessageType("livekit.SimulcastCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"cid",kind:"scalar",T:9}]),Yl=B.makeMessageType("livekit.AddTrackRequest",()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"type",kind:"enum",T:B.getEnumType(cn)},{no:4,name:"width",kind:"scalar",T:13},{no:5,name:"height",kind:"scalar",T:13},{no:6,name:"muted",kind:"scalar",T:8},{no:7,name:"disable_dtx",kind:"scalar",T:8},{no:8,name:"source",kind:"enum",T:B.getEnumType(lt)},{no:9,name:"layers",kind:"message",T:Hi,repeated:!0},{no:10,name:"simulcast_codecs",kind:"message",T:Zl,repeated:!0},{no:11,name:"sid",kind:"scalar",T:9},{no:12,name:"stereo",kind:"scalar",T:8},{no:13,name:"disable_red",kind:"scalar",T:8},{no:14,name:"encryption",kind:"enum",T:B.getEnumType(Ft)},{no:15,name:"stream",kind:"scalar",T:9},{no:16,name:"backup_codec_policy",kind:"enum",T:B.getEnumType(K0)},{no:17,name:"audio_features",kind:"enum",T:B.getEnumType(pt),repeated:!0}]),ku=B.makeMessageType("livekit.TrickleRequest",()=>[{no:1,name:"candidateInit",kind:"scalar",T:9},{no:2,name:"target",kind:"enum",T:B.getEnumType(ln)},{no:3,name:"final",kind:"scalar",T:8}]),Tu=B.makeMessageType("livekit.MuteTrackRequest",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"muted",kind:"scalar",T:8}]),ZC=B.makeMessageType("livekit.JoinResponse",()=>[{no:1,name:"room",kind:"message",T:Ga},{no:2,name:"participant",kind:"message",T:Zi},{no:3,name:"other_participants",kind:"message",T:Zi,repeated:!0},{no:4,name:"server_version",kind:"scalar",T:9},{no:5,name:"ice_servers",kind:"message",T:hv,repeated:!0},{no:6,name:"subscriber_primary",kind:"scalar",T:8},{no:7,name:"alternative_url",kind:"scalar",T:9},{no:8,name:"client_configuration",kind:"message",T:sv},{no:9,name:"server_region",kind:"scalar",T:9},{no:10,name:"ping_timeout",kind:"scalar",T:5},{no:11,name:"ping_interval",kind:"scalar",T:5},{no:12,name:"server_info",kind:"message",T:nv},{no:13,name:"sif_trailer",kind:"scalar",T:12},{no:14,name:"enabled_publish_codecs",kind:"message",T:wa,repeated:!0},{no:15,name:"fast_publish",kind:"scalar",T:8}]),YC=B.makeMessageType("livekit.ReconnectResponse",()=>[{no:1,name:"ice_servers",kind:"message",T:hv,repeated:!0},{no:2,name:"client_configuration",kind:"message",T:sv},{no:3,name:"server_info",kind:"message",T:nv},{no:4,name:"last_message_seq",kind:"scalar",T:13}]),Eu=B.makeMessageType("livekit.TrackPublishedResponse",()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"track",kind:"message",T:Cr}]),JC=B.makeMessageType("livekit.TrackUnpublishedResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]),Ji=B.makeMessageType("livekit.SessionDescription",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"sdp",kind:"scalar",T:9},{no:3,name:"id",kind:"scalar",T:13}]),XC=B.makeMessageType("livekit.ParticipantUpdate",()=>[{no:1,name:"participants",kind:"message",T:Zi,repeated:!0}]),Za=B.makeMessageType("livekit.UpdateSubscription",()=>[{no:1,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:2,name:"subscribe",kind:"scalar",T:8},{no:3,name:"participant_tracks",kind:"message",T:tv,repeated:!0}]),lv=B.makeMessageType("livekit.UpdateTrackSettings",()=>[{no:1,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:3,name:"disabled",kind:"scalar",T:8},{no:4,name:"quality",kind:"enum",T:B.getEnumType(Cu)},{no:5,name:"width",kind:"scalar",T:13},{no:6,name:"height",kind:"scalar",T:13},{no:7,name:"fps",kind:"scalar",T:13},{no:8,name:"priority",kind:"scalar",T:13}]),dv=B.makeMessageType("livekit.UpdateLocalAudioTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"features",kind:"enum",T:B.getEnumType(pt),repeated:!0}]),QC=B.makeMessageType("livekit.UpdateLocalVideoTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"width",kind:"scalar",T:13},{no:3,name:"height",kind:"scalar",T:13}]),Ya=B.makeMessageType("livekit.LeaveRequest",()=>[{no:1,name:"can_reconnect",kind:"scalar",T:8},{no:2,name:"reason",kind:"enum",T:B.getEnumType(dn)},{no:3,name:"action",kind:"enum",T:B.getEnumType(Nr)},{no:4,name:"regions",kind:"message",T:uk}]),Nr=B.makeEnum("livekit.LeaveRequest.Action",[{no:0,name:"DISCONNECT"},{no:1,name:"RESUME"},{no:2,name:"RECONNECT"}]),uv=B.makeMessageType("livekit.UpdateVideoLayers",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"layers",kind:"message",T:Hi,repeated:!0}]),fv=B.makeMessageType("livekit.UpdateParticipantMetadata",()=>[{no:1,name:"metadata",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:4,name:"request_id",kind:"scalar",T:13}]),hv=B.makeMessageType("livekit.ICEServer",()=>[{no:1,name:"urls",kind:"scalar",T:9,repeated:!0},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"credential",kind:"scalar",T:9}]),ek=B.makeMessageType("livekit.SpeakersChanged",()=>[{no:1,name:"speakers",kind:"message",T:G0,repeated:!0}]),tk=B.makeMessageType("livekit.RoomUpdate",()=>[{no:1,name:"room",kind:"message",T:Ga}]),nk=B.makeMessageType("livekit.ConnectionQualityInfo",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"quality",kind:"enum",T:B.getEnumType(As)},{no:3,name:"score",kind:"scalar",T:2}]),ik=B.makeMessageType("livekit.ConnectionQualityUpdate",()=>[{no:1,name:"updates",kind:"message",T:nk,repeated:!0}]),rk=B.makeMessageType("livekit.StreamStateInfo",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sid",kind:"scalar",T:9},{no:3,name:"state",kind:"enum",T:B.getEnumType(Gl)}]),sk=B.makeMessageType("livekit.StreamStateUpdate",()=>[{no:1,name:"stream_states",kind:"message",T:rk,repeated:!0}]),Pu=B.makeMessageType("livekit.SubscribedQuality",()=>[{no:1,name:"quality",kind:"enum",T:B.getEnumType(Cu)},{no:2,name:"enabled",kind:"scalar",T:8}]),ok=B.makeMessageType("livekit.SubscribedCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"qualities",kind:"message",T:Pu,repeated:!0}]),ak=B.makeMessageType("livekit.SubscribedQualityUpdate",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_qualities",kind:"message",T:Pu,repeated:!0},{no:3,name:"subscribed_codecs",kind:"message",T:ok,repeated:!0}]),mv=B.makeMessageType("livekit.TrackPermission",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"all_tracks",kind:"scalar",T:8},{no:3,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:4,name:"participant_identity",kind:"scalar",T:9}]),pv=B.makeMessageType("livekit.SubscriptionPermission",()=>[{no:1,name:"all_participants",kind:"scalar",T:8},{no:2,name:"track_permissions",kind:"message",T:mv,repeated:!0}]),ck=B.makeMessageType("livekit.SubscriptionPermissionUpdate",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sid",kind:"scalar",T:9},{no:3,name:"allowed",kind:"scalar",T:8}]),lk=B.makeMessageType("livekit.RoomMovedResponse",()=>[{no:1,name:"room",kind:"message",T:Ga},{no:2,name:"token",kind:"scalar",T:9},{no:3,name:"participant",kind:"message",T:Zi},{no:4,name:"other_participants",kind:"message",T:Zi,repeated:!0}]),gv=B.makeMessageType("livekit.SyncState",()=>[{no:1,name:"answer",kind:"message",T:Ji},{no:2,name:"subscription",kind:"message",T:Za},{no:3,name:"publish_tracks",kind:"message",T:Eu,repeated:!0},{no:4,name:"data_channels",kind:"message",T:yv,repeated:!0},{no:5,name:"offer",kind:"message",T:Ji},{no:6,name:"track_sids_disabled",kind:"scalar",T:9,repeated:!0},{no:7,name:"datachannel_receive_states",kind:"message",T:vv,repeated:!0}]),vv=B.makeMessageType("livekit.DataChannelReceiveState",()=>[{no:1,name:"publisher_sid",kind:"scalar",T:9},{no:2,name:"last_seq",kind:"scalar",T:13}]),yv=B.makeMessageType("livekit.DataChannelInfo",()=>[{no:1,name:"label",kind:"scalar",T:9},{no:2,name:"id",kind:"scalar",T:13},{no:3,name:"target",kind:"enum",T:B.getEnumType(ln)}]),bn=B.makeMessageType("livekit.SimulateScenario",()=>[{no:1,name:"speaker_update",kind:"scalar",T:5,oneof:"scenario"},{no:2,name:"node_failure",kind:"scalar",T:8,oneof:"scenario"},{no:3,name:"migration",kind:"scalar",T:8,oneof:"scenario"},{no:4,name:"server_leave",kind:"scalar",T:8,oneof:"scenario"},{no:5,name:"switch_candidate_protocol",kind:"enum",T:B.getEnumType(KC),oneof:"scenario"},{no:6,name:"subscriber_bandwidth",kind:"scalar",T:3,oneof:"scenario"},{no:7,name:"disconnect_signal_on_resume",kind:"scalar",T:8,oneof:"scenario"},{no:8,name:"disconnect_signal_on_resume_no_messages",kind:"scalar",T:8,oneof:"scenario"},{no:9,name:"leave_request_full_reconnect",kind:"scalar",T:8,oneof:"scenario"}]),bv=B.makeMessageType("livekit.Ping",()=>[{no:1,name:"timestamp",kind:"scalar",T:3},{no:2,name:"rtt",kind:"scalar",T:3}]),dk=B.makeMessageType("livekit.Pong",()=>[{no:1,name:"last_ping_timestamp",kind:"scalar",T:3},{no:2,name:"timestamp",kind:"scalar",T:3}]),uk=B.makeMessageType("livekit.RegionSettings",()=>[{no:1,name:"regions",kind:"message",T:fk,repeated:!0}]),fk=B.makeMessageType("livekit.RegionInfo",()=>[{no:1,name:"region",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9},{no:3,name:"distance",kind:"scalar",T:3}]),hk=B.makeMessageType("livekit.SubscriptionResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"err",kind:"enum",T:B.getEnumType(VC)}]),mk=B.makeMessageType("livekit.RequestResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:13},{no:2,name:"reason",kind:"enum",T:B.getEnumType(Ru)},{no:3,name:"message",kind:"scalar",T:9}]),Ru=B.makeEnum("livekit.RequestResponse.Reason",[{no:0,name:"OK"},{no:1,name:"NOT_FOUND"},{no:2,name:"NOT_ALLOWED"},{no:3,name:"LIMIT_EXCEEDED"}]),pk=B.makeMessageType("livekit.TrackSubscribed",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]);function gk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Jo={exports:{}},vk=Jo.exports,jh;function yk(){return jh||(jh=1,function(t){(function(e,n){t.exports?t.exports=n():e.log=n()})(vk,function(){var e=function(){},n="undefined",i=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"],s={},o=null;function a(h,y){var b=h[y];if(typeof b.bind=="function")return b.bind(h);try{return Function.prototype.bind.call(b,h)}catch{return function(){return Function.prototype.apply.apply(b,[h,arguments])}}}function c(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(h){return h==="debug"&&(h="log"),typeof console===n?!1:h==="trace"&&i?c:console[h]!==void 0?a(console,h):console.log!==void 0?a(console,"log"):e}function d(){for(var h=this.getLevel(),y=0;y<r.length;y++){var b=r[y];this[b]=y<h?e:this.methodFactory(b,h,this.name)}if(this.log=this.debug,typeof console===n&&h<this.levels.SILENT)return"No console available for logging"}function u(h){return function(){typeof console!==n&&(d.call(this),this[h].apply(this,arguments))}}function f(h,y,b){return l(h)||u.apply(this,arguments)}function p(h,y){var b=this,w,C,S,x="loglevel";typeof h=="string"?x+=":"+h:typeof h=="symbol"&&(x=void 0);function T(I){var N=(r[I]||"silent").toUpperCase();if(!(typeof window===n||!x)){try{window.localStorage[x]=N;return}catch{}try{window.document.cookie=encodeURIComponent(x)+"="+N+";"}catch{}}}function E(){var I;if(!(typeof window===n||!x)){try{I=window.localStorage[x]}catch{}if(typeof I===n)try{var N=window.document.cookie,K=encodeURIComponent(x),J=N.indexOf(K+"=");J!==-1&&(I=/^([^;]+)/.exec(N.slice(J+K.length+1))[1])}catch{}return b.levels[I]===void 0&&(I=void 0),I}}function P(){if(!(typeof window===n||!x)){try{window.localStorage.removeItem(x)}catch{}try{window.document.cookie=encodeURIComponent(x)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function _(I){var N=I;if(typeof N=="string"&&b.levels[N.toUpperCase()]!==void 0&&(N=b.levels[N.toUpperCase()]),typeof N=="number"&&N>=0&&N<=b.levels.SILENT)return N;throw new TypeError("log.setLevel() called with invalid level: "+I)}b.name=h,b.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},b.methodFactory=y||f,b.getLevel=function(){return S??C??w},b.setLevel=function(I,N){return S=_(I),N!==!1&&T(S),d.call(b)},b.setDefaultLevel=function(I){C=_(I),E()||b.setLevel(I,!1)},b.resetLevel=function(){S=null,P(),d.call(b)},b.enableAll=function(I){b.setLevel(b.levels.TRACE,I)},b.disableAll=function(I){b.setLevel(b.levels.SILENT,I)},b.rebuild=function(){if(o!==b&&(w=_(o.getLevel())),d.call(b),o===b)for(var I in s)s[I].rebuild()},w=_(o?o.getLevel():"WARN");var k=E();k!=null&&(S=_(k)),d.call(b)}o=new p,o.getLogger=function(y){if(typeof y!="symbol"&&typeof y!="string"||y==="")throw new TypeError("You must supply a name when creating a logger.");var b=s[y];return b||(b=s[y]=new p(y,o.methodFactory)),b};var v=typeof window!==n?window.log:void 0;return o.noConflict=function(){return typeof window!==n&&window.log===o&&(window.log=v),o},o.getLoggers=function(){return s},o.default=o,o})}(Jo)),Jo.exports}var Ja=yk(),Jl;(function(t){t[t.trace=0]="trace",t[t.debug=1]="debug",t[t.info=2]="info",t[t.warn=3]="warn",t[t.error=4]="error",t[t.silent=5]="silent"})(Jl||(Jl={}));var fn;(function(t){t.Default="livekit",t.Room="livekit-room",t.Participant="livekit-participant",t.Track="livekit-track",t.Publication="livekit-track-publication",t.Engine="livekit-engine",t.Signal="livekit-signal",t.PCManager="livekit-pc-manager",t.PCTransport="livekit-pc-transport",t.E2EE="lk-e2ee"})(fn||(fn={}));let Ce=Ja.getLogger("livekit");const bk=Object.values(fn).map(t=>Ja.getLogger(t));Ce.setDefaultLevel(Jl.info);function Gn(t){const e=Ja.getLogger(t);return e.setDefaultLevel(Ce.getLevel()),e}function xk(t,e){for(const n of bk)n.setLevel(t)}const Sk=Ja.getLogger("lk-e2ee"),xs=7e3,wk=[0,300,4*300,9*300,16*300,xs,xs,xs,xs,xs];class Ck{constructor(e){this._retryDelays=e!==void 0?[...e]:wk}nextRetryDelayInMs(e){if(e.retryCount>=this._retryDelays.length)return null;const n=this._retryDelays[e.retryCount];return e.retryCount<=1?n:n+Math.random()*1e3}}function kk(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]]);return n}function A(t,e,n,i){function r(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(d){try{l(i.next(d))}catch(u){o(u)}}function c(d){try{l(i.throw(d))}catch(u){o(u)}}function l(d){d.done?s(d.value):r(d.value).then(a,c)}l((i=i.apply(t,e||[])).next())})}function Lh(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function zn(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof Lh=="function"?Lh(t):t[Symbol.iterator](),n={},i("next"),i("throw"),i("return"),n[Symbol.asyncIterator]=function(){return this},n);function i(s){n[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),r(a,c,o.done,o.value)})}}function r(s,o,a,c){Promise.resolve(c).then(function(l){s({value:l,done:a})},o)}}var Co={exports:{}},Vh;function Tk(){if(Vh)return Co.exports;Vh=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(x,T,E){return Function.prototype.apply.call(x,T,E)},n;t&&typeof t.ownKeys=="function"?n=t.ownKeys:Object.getOwnPropertySymbols?n=function(x){return Object.getOwnPropertyNames(x).concat(Object.getOwnPropertySymbols(x))}:n=function(x){return Object.getOwnPropertyNames(x)};function i(S){console&&console.warn&&console.warn(S)}var r=Number.isNaN||function(x){return x!==x};function s(){s.init.call(this)}Co.exports=s,Co.exports.once=b,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(S){if(typeof S!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof S)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(S){if(typeof S!="number"||S<0||r(S))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+S+".");o=S}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(x){if(typeof x!="number"||x<0||r(x))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+x+".");return this._maxListeners=x,this};function c(S){return S._maxListeners===void 0?s.defaultMaxListeners:S._maxListeners}s.prototype.getMaxListeners=function(){return c(this)},s.prototype.emit=function(x){for(var T=[],E=1;E<arguments.length;E++)T.push(arguments[E]);var P=x==="error",_=this._events;if(_!==void 0)P=P&&_.error===void 0;else if(!P)return!1;if(P){var k;if(T.length>0&&(k=T[0]),k instanceof Error)throw k;var I=new Error("Unhandled error."+(k?" ("+k.message+")":""));throw I.context=k,I}var N=_[x];if(N===void 0)return!1;if(typeof N=="function")e(N,this,T);else for(var K=N.length,J=v(N,K),E=0;E<K;++E)e(J[E],this,T);return!0};function l(S,x,T,E){var P,_,k;if(a(T),_=S._events,_===void 0?(_=S._events=Object.create(null),S._eventsCount=0):(_.newListener!==void 0&&(S.emit("newListener",x,T.listener?T.listener:T),_=S._events),k=_[x]),k===void 0)k=_[x]=T,++S._eventsCount;else if(typeof k=="function"?k=_[x]=E?[T,k]:[k,T]:E?k.unshift(T):k.push(T),P=c(S),P>0&&k.length>P&&!k.warned){k.warned=!0;var I=new Error("Possible EventEmitter memory leak detected. "+k.length+" "+String(x)+" listeners added. Use emitter.setMaxListeners() to increase limit");I.name="MaxListenersExceededWarning",I.emitter=S,I.type=x,I.count=k.length,i(I)}return S}s.prototype.addListener=function(x,T){return l(this,x,T,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(x,T){return l(this,x,T,!0)};function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(S,x,T){var E={fired:!1,wrapFn:void 0,target:S,type:x,listener:T},P=d.bind(E);return P.listener=T,E.wrapFn=P,P}s.prototype.once=function(x,T){return a(T),this.on(x,u(this,x,T)),this},s.prototype.prependOnceListener=function(x,T){return a(T),this.prependListener(x,u(this,x,T)),this},s.prototype.removeListener=function(x,T){var E,P,_,k,I;if(a(T),P=this._events,P===void 0)return this;if(E=P[x],E===void 0)return this;if(E===T||E.listener===T)--this._eventsCount===0?this._events=Object.create(null):(delete P[x],P.removeListener&&this.emit("removeListener",x,E.listener||T));else if(typeof E!="function"){for(_=-1,k=E.length-1;k>=0;k--)if(E[k]===T||E[k].listener===T){I=E[k].listener,_=k;break}if(_<0)return this;_===0?E.shift():h(E,_),E.length===1&&(P[x]=E[0]),P.removeListener!==void 0&&this.emit("removeListener",x,I||T)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(x){var T,E,P;if(E=this._events,E===void 0)return this;if(E.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):E[x]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete E[x]),this;if(arguments.length===0){var _=Object.keys(E),k;for(P=0;P<_.length;++P)k=_[P],k!=="removeListener"&&this.removeAllListeners(k);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(T=E[x],typeof T=="function")this.removeListener(x,T);else if(T!==void 0)for(P=T.length-1;P>=0;P--)this.removeListener(x,T[P]);return this};function f(S,x,T){var E=S._events;if(E===void 0)return[];var P=E[x];return P===void 0?[]:typeof P=="function"?T?[P.listener||P]:[P]:T?y(P):v(P,P.length)}s.prototype.listeners=function(x){return f(this,x,!0)},s.prototype.rawListeners=function(x){return f(this,x,!1)},s.listenerCount=function(S,x){return typeof S.listenerCount=="function"?S.listenerCount(x):p.call(S,x)},s.prototype.listenerCount=p;function p(S){var x=this._events;if(x!==void 0){var T=x[S];if(typeof T=="function")return 1;if(T!==void 0)return T.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function v(S,x){for(var T=new Array(x),E=0;E<x;++E)T[E]=S[E];return T}function h(S,x){for(;x+1<S.length;x++)S[x]=S[x+1];S.pop()}function y(S){for(var x=new Array(S.length),T=0;T<x.length;++T)x[T]=S[T].listener||S[T];return x}function b(S,x){return new Promise(function(T,E){function P(k){S.removeListener(x,_),E(k)}function _(){typeof S.removeListener=="function"&&S.removeListener("error",P),T([].slice.call(arguments))}C(S,x,_,{once:!0}),x!=="error"&&w(S,P,{once:!0})})}function w(S,x,T){typeof S.on=="function"&&C(S,"error",x,T)}function C(S,x,T,E){if(typeof S.on=="function")E.once?S.once(x,T):S.on(x,T);else if(typeof S.addEventListener=="function")S.addEventListener(x,function P(_){E.once&&S.removeEventListener(x,P),T(_)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof S)}return Co.exports}var Nn=Tk();let xv=!0,Sv=!0;function Is(t,e,n){const i=t.match(e);return i&&i.length>=n&&parseFloat(i[n],10)}function rr(t,e,n){if(!t.RTCPeerConnection)return;const i=t.RTCPeerConnection.prototype,r=i.addEventListener;i.addEventListener=function(o,a){if(o!==e)return r.apply(this,arguments);const c=l=>{const d=n(l);d&&(a.handleEvent?a.handleEvent(d):a(d))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(a,c),r.apply(this,[o,c])};const s=i.removeEventListener;i.removeEventListener=function(o,a){if(o!==e||!this._eventMap||!this._eventMap[e])return s.apply(this,arguments);if(!this._eventMap[e].has(a))return s.apply(this,arguments);const c=this._eventMap[e].get(a);return this._eventMap[e].delete(a),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,s.apply(this,[o,c])},Object.defineProperty(i,"on"+e,{get(){return this["_on"+e]},set(o){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),o&&this.addEventListener(e,this["_on"+e]=o)},enumerable:!0,configurable:!0})}function Ek(t){return typeof t!="boolean"?new Error("Argument type: "+typeof t+". Please use a boolean."):(xv=t,t?"adapter.js logging disabled":"adapter.js logging enabled")}function Pk(t){return typeof t!="boolean"?new Error("Argument type: "+typeof t+". Please use a boolean."):(Sv=!t,"adapter.js deprecation warnings "+(t?"disabled":"enabled"))}function wv(){if(typeof window=="object"){if(xv)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Au(t,e){Sv&&console.warn(t+" is deprecated, please use "+e+" instead.")}function Rk(t){const e={browser:null,version:null};if(typeof t>"u"||!t.navigator||!t.navigator.userAgent)return e.browser="Not a browser.",e;const{navigator:n}=t;if(n.userAgentData&&n.userAgentData.brands){const i=n.userAgentData.brands.find(r=>r.brand==="Chromium");if(i)return{browser:"chrome",version:parseInt(i.version,10)}}if(n.mozGetUserMedia)e.browser="firefox",e.version=parseInt(Is(n.userAgent,/Firefox\/(\d+)\./,1));else if(n.webkitGetUserMedia||t.isSecureContext===!1&&t.webkitRTCPeerConnection)e.browser="chrome",e.version=parseInt(Is(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2));else if(t.RTCPeerConnection&&n.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=parseInt(Is(n.userAgent,/AppleWebKit\/(\d+)\./,1)),e.supportsUnifiedPlan=t.RTCRtpTransceiver&&"currentDirection"in t.RTCRtpTransceiver.prototype,e._safariVersion=Is(n.userAgent,/Version\/(\d+(\.?\d+))/,1);else return e.browser="Not a supported browser.",e;return e}function Fh(t){return Object.prototype.toString.call(t)==="[object Object]"}function Cv(t){return Fh(t)?Object.keys(t).reduce(function(e,n){const i=Fh(t[n]),r=i?Cv(t[n]):t[n],s=i&&!Object.keys(r).length;return r===void 0||s?e:Object.assign(e,{[n]:r})},{}):t}function Xl(t,e,n){!e||n.has(e.id)||(n.set(e.id,e),Object.keys(e).forEach(i=>{i.endsWith("Id")?Xl(t,t.get(e[i]),n):i.endsWith("Ids")&&e[i].forEach(r=>{Xl(t,t.get(r),n)})}))}function Uh(t,e,n){const i=n?"outbound-rtp":"inbound-rtp",r=new Map;if(e===null)return r;const s=[];return t.forEach(o=>{o.type==="track"&&o.trackIdentifier===e.id&&s.push(o)}),s.forEach(o=>{t.forEach(a=>{a.type===i&&a.trackId===o.id&&Xl(t,a,r)})}),r}const Bh=wv;function kv(t,e){const n=t&&t.navigator;if(!n.mediaDevices)return;const i=function(a){if(typeof a!="object"||a.mandatory||a.optional)return a;const c={};return Object.keys(a).forEach(l=>{if(l==="require"||l==="advanced"||l==="mediaSource")return;const d=typeof a[l]=="object"?a[l]:{ideal:a[l]};d.exact!==void 0&&typeof d.exact=="number"&&(d.min=d.max=d.exact);const u=function(f,p){return f?f+p.charAt(0).toUpperCase()+p.slice(1):p==="deviceId"?"sourceId":p};if(d.ideal!==void 0){c.optional=c.optional||[];let f={};typeof d.ideal=="number"?(f[u("min",l)]=d.ideal,c.optional.push(f),f={},f[u("max",l)]=d.ideal,c.optional.push(f)):(f[u("",l)]=d.ideal,c.optional.push(f))}d.exact!==void 0&&typeof d.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[u("",l)]=d.exact):["min","max"].forEach(f=>{d[f]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[u(f,l)]=d[f])})}),a.advanced&&(c.optional=(c.optional||[]).concat(a.advanced)),c},r=function(a,c){if(e.version>=61)return c(a);if(a=JSON.parse(JSON.stringify(a)),a&&typeof a.audio=="object"){const l=function(d,u,f){u in d&&!(f in d)&&(d[f]=d[u],delete d[u])};a=JSON.parse(JSON.stringify(a)),l(a.audio,"autoGainControl","googAutoGainControl"),l(a.audio,"noiseSuppression","googNoiseSuppression"),a.audio=i(a.audio)}if(a&&typeof a.video=="object"){let l=a.video.facingMode;l=l&&(typeof l=="object"?l:{ideal:l});const d=e.version<66;if(l&&(l.exact==="user"||l.exact==="environment"||l.ideal==="user"||l.ideal==="environment")&&!(n.mediaDevices.getSupportedConstraints&&n.mediaDevices.getSupportedConstraints().facingMode&&!d)){delete a.video.facingMode;let u;if(l.exact==="environment"||l.ideal==="environment"?u=["back","rear"]:(l.exact==="user"||l.ideal==="user")&&(u=["front"]),u)return n.mediaDevices.enumerateDevices().then(f=>{f=f.filter(v=>v.kind==="videoinput");let p=f.find(v=>u.some(h=>v.label.toLowerCase().includes(h)));return!p&&f.length&&u.includes("back")&&(p=f[f.length-1]),p&&(a.video.deviceId=l.exact?{exact:p.deviceId}:{ideal:p.deviceId}),a.video=i(a.video),Bh("chrome: "+JSON.stringify(a)),c(a)})}a.video=i(a.video)}return Bh("chrome: "+JSON.stringify(a)),c(a)},s=function(a){return e.version>=64?a:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[a.name]||a.name,message:a.message,constraint:a.constraint||a.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},o=function(a,c,l){r(a,d=>{n.webkitGetUserMedia(d,c,u=>{l&&l(s(u))})})};if(n.getUserMedia=o.bind(n),n.mediaDevices.getUserMedia){const a=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(c){return r(c,l=>a(l).then(d=>{if(l.audio&&!d.getAudioTracks().length||l.video&&!d.getVideoTracks().length)throw d.getTracks().forEach(u=>{u.stop()}),new DOMException("","NotFoundError");return d},d=>Promise.reject(s(d))))}}}function Tv(t){t.MediaStream=t.MediaStream||t.webkitMediaStream}function Ev(t){if(typeof t=="object"&&t.RTCPeerConnection&&!("ontrack"in t.RTCPeerConnection.prototype)){Object.defineProperty(t.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(n){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=n)},enumerable:!0,configurable:!0});const e=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=i=>{i.stream.addEventListener("addtrack",r=>{let s;t.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(a=>a.track&&a.track.id===r.track.id):s={track:r.track};const o=new Event("track");o.track=r.track,o.receiver=s,o.transceiver={receiver:s},o.streams=[i.stream],this.dispatchEvent(o)}),i.stream.getTracks().forEach(r=>{let s;t.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(a=>a.track&&a.track.id===r.id):s={track:r};const o=new Event("track");o.track=r,o.receiver=s,o.transceiver={receiver:s},o.streams=[i.stream],this.dispatchEvent(o)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else rr(t,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function Pv(t){if(typeof t=="object"&&t.RTCPeerConnection&&!("getSenders"in t.RTCPeerConnection.prototype)&&"createDTMFSender"in t.RTCPeerConnection.prototype){const e=function(r,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=r.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:r}};if(!t.RTCPeerConnection.prototype.getSenders){t.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const r=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addTrack=function(a,c){let l=r.apply(this,arguments);return l||(l=e(this,a),this._senders.push(l)),l};const s=t.RTCPeerConnection.prototype.removeTrack;t.RTCPeerConnection.prototype.removeTrack=function(a){s.apply(this,arguments);const c=this._senders.indexOf(a);c!==-1&&this._senders.splice(c,1)}}const n=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(s){this._senders=this._senders||[],n.apply(this,[s]),s.getTracks().forEach(o=>{this._senders.push(e(this,o))})};const i=t.RTCPeerConnection.prototype.removeStream;t.RTCPeerConnection.prototype.removeStream=function(s){this._senders=this._senders||[],i.apply(this,[s]),s.getTracks().forEach(o=>{const a=this._senders.find(c=>c.track===o);a&&this._senders.splice(this._senders.indexOf(a),1)})}}else if(typeof t=="object"&&t.RTCPeerConnection&&"getSenders"in t.RTCPeerConnection.prototype&&"createDTMFSender"in t.RTCPeerConnection.prototype&&t.RTCRtpSender&&!("dtmf"in t.RTCRtpSender.prototype)){const e=t.RTCPeerConnection.prototype.getSenders;t.RTCPeerConnection.prototype.getSenders=function(){const i=e.apply(this,[]);return i.forEach(r=>r._pc=this),i},Object.defineProperty(t.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function Rv(t){if(!(typeof t=="object"&&t.RTCPeerConnection&&t.RTCRtpSender&&t.RTCRtpReceiver))return;if(!("getStats"in t.RTCRtpSender.prototype)){const n=t.RTCPeerConnection.prototype.getSenders;n&&(t.RTCPeerConnection.prototype.getSenders=function(){const s=n.apply(this,[]);return s.forEach(o=>o._pc=this),s});const i=t.RTCPeerConnection.prototype.addTrack;i&&(t.RTCPeerConnection.prototype.addTrack=function(){const s=i.apply(this,arguments);return s._pc=this,s}),t.RTCRtpSender.prototype.getStats=function(){const s=this;return this._pc.getStats().then(o=>Uh(o,s.track,!0))}}if(!("getStats"in t.RTCRtpReceiver.prototype)){const n=t.RTCPeerConnection.prototype.getReceivers;n&&(t.RTCPeerConnection.prototype.getReceivers=function(){const r=n.apply(this,[]);return r.forEach(s=>s._pc=this),r}),rr(t,"track",i=>(i.receiver._pc=i.srcElement,i)),t.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(s=>Uh(s,r.track,!1))}}if(!("getStats"in t.RTCRtpSender.prototype&&"getStats"in t.RTCRtpReceiver.prototype))return;const e=t.RTCPeerConnection.prototype.getStats;t.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof t.MediaStreamTrack){const i=arguments[0];let r,s,o;return this.getSenders().forEach(a=>{a.track===i&&(r?o=!0:r=a)}),this.getReceivers().forEach(a=>(a.track===i&&(s?o=!0:s=a),a.track===i)),o||r&&s?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():s?s.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function Av(t){t.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(o=>this._shimmedLocalStreams[o][0])};const e=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addTrack=function(o,a){if(!a)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const c=e.apply(this,arguments);return this._shimmedLocalStreams[a.id]?this._shimmedLocalStreams[a.id].indexOf(c)===-1&&this._shimmedLocalStreams[a.id].push(c):this._shimmedLocalStreams[a.id]=[a,c],c};const n=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(o){this._shimmedLocalStreams=this._shimmedLocalStreams||{},o.getTracks().forEach(l=>{if(this.getSenders().find(u=>u.track===l))throw new DOMException("Track already exists.","InvalidAccessError")});const a=this.getSenders();n.apply(this,arguments);const c=this.getSenders().filter(l=>a.indexOf(l)===-1);this._shimmedLocalStreams[o.id]=[o].concat(c)};const i=t.RTCPeerConnection.prototype.removeStream;t.RTCPeerConnection.prototype.removeStream=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[o.id],i.apply(this,arguments)};const r=t.RTCPeerConnection.prototype.removeTrack;t.RTCPeerConnection.prototype.removeTrack=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},o&&Object.keys(this._shimmedLocalStreams).forEach(a=>{const c=this._shimmedLocalStreams[a].indexOf(o);c!==-1&&this._shimmedLocalStreams[a].splice(c,1),this._shimmedLocalStreams[a].length===1&&delete this._shimmedLocalStreams[a]}),r.apply(this,arguments)}}function Iv(t,e){if(!t.RTCPeerConnection)return;if(t.RTCPeerConnection.prototype.addTrack&&e.version>=65)return Av(t);const n=t.RTCPeerConnection.prototype.getLocalStreams;t.RTCPeerConnection.prototype.getLocalStreams=function(){const d=n.apply(this);return this._reverseStreams=this._reverseStreams||{},d.map(u=>this._reverseStreams[u.id])};const i=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(d){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},d.getTracks().forEach(u=>{if(this.getSenders().find(p=>p.track===u))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[d.id]){const u=new t.MediaStream(d.getTracks());this._streams[d.id]=u,this._reverseStreams[u.id]=d,d=u}i.apply(this,[d])};const r=t.RTCPeerConnection.prototype.removeStream;t.RTCPeerConnection.prototype.removeStream=function(d){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},r.apply(this,[this._streams[d.id]||d]),delete this._reverseStreams[this._streams[d.id]?this._streams[d.id].id:d.id],delete this._streams[d.id]},t.RTCPeerConnection.prototype.addTrack=function(d,u){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const f=[].slice.call(arguments,1);if(f.length!==1||!f[0].getTracks().find(h=>h===d))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(h=>h.track===d))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const v=this._streams[u.id];if(v)v.addTrack(d),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const h=new t.MediaStream([d]);this._streams[u.id]=h,this._reverseStreams[h.id]=u,this.addStream(h)}return this.getSenders().find(h=>h.track===d)};function s(l,d){let u=d.sdp;return Object.keys(l._reverseStreams||[]).forEach(f=>{const p=l._reverseStreams[f],v=l._streams[p.id];u=u.replace(new RegExp(v.id,"g"),p.id)}),new RTCSessionDescription({type:d.type,sdp:u})}function o(l,d){let u=d.sdp;return Object.keys(l._reverseStreams||[]).forEach(f=>{const p=l._reverseStreams[f],v=l._streams[p.id];u=u.replace(new RegExp(p.id,"g"),v.id)}),new RTCSessionDescription({type:d.type,sdp:u})}["createOffer","createAnswer"].forEach(function(l){const d=t.RTCPeerConnection.prototype[l],u={[l](){const f=arguments;return arguments.length&&typeof arguments[0]=="function"?d.apply(this,[v=>{const h=s(this,v);f[0].apply(null,[h])},v=>{f[1]&&f[1].apply(null,v)},arguments[2]]):d.apply(this,arguments).then(v=>s(this,v))}};t.RTCPeerConnection.prototype[l]=u[l]});const a=t.RTCPeerConnection.prototype.setLocalDescription;t.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?a.apply(this,arguments):(arguments[0]=o(this,arguments[0]),a.apply(this,arguments))};const c=Object.getOwnPropertyDescriptor(t.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(t.RTCPeerConnection.prototype,"localDescription",{get(){const l=c.get.apply(this);return l.type===""?l:s(this,l)}}),t.RTCPeerConnection.prototype.removeTrack=function(d){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!d._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(d._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let f;Object.keys(this._streams).forEach(p=>{this._streams[p].getTracks().find(h=>d.track===h)&&(f=this._streams[p])}),f&&(f.getTracks().length===1?this.removeStream(this._reverseStreams[f.id]):f.removeTrack(d.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Ql(t,e){!t.RTCPeerConnection&&t.webkitRTCPeerConnection&&(t.RTCPeerConnection=t.webkitRTCPeerConnection),t.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(n){const i=t.RTCPeerConnection.prototype[n],r={[n](){return arguments[0]=new(n==="addIceCandidate"?t.RTCIceCandidate:t.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};t.RTCPeerConnection.prototype[n]=r[n]})}function Mv(t,e){rr(t,"negotiationneeded",n=>{const i=n.target;if(!((e.version<72||i.getConfiguration&&i.getConfiguration().sdpSemantics==="plan-b")&&i.signalingState!=="stable"))return n})}var $h=Object.freeze({__proto__:null,fixNegotiationNeeded:Mv,shimAddTrackRemoveTrack:Iv,shimAddTrackRemoveTrackWithNative:Av,shimGetSendersWithDtmf:Pv,shimGetUserMedia:kv,shimMediaStream:Tv,shimOnTrack:Ev,shimPeerConnection:Ql,shimSenderReceiverGetStats:Rv});function _v(t,e){const n=t&&t.navigator,i=t&&t.MediaStreamTrack;if(n.getUserMedia=function(r,s,o){Au("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(r).then(s,o)},!(e.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){const r=function(o,a,c){a in o&&!(c in o)&&(o[c]=o[a],delete o[a])},s=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(o){return typeof o=="object"&&typeof o.audio=="object"&&(o=JSON.parse(JSON.stringify(o)),r(o.audio,"autoGainControl","mozAutoGainControl"),r(o.audio,"noiseSuppression","mozNoiseSuppression")),s(o)},i&&i.prototype.getSettings){const o=i.prototype.getSettings;i.prototype.getSettings=function(){const a=o.apply(this,arguments);return r(a,"mozAutoGainControl","autoGainControl"),r(a,"mozNoiseSuppression","noiseSuppression"),a}}if(i&&i.prototype.applyConstraints){const o=i.prototype.applyConstraints;i.prototype.applyConstraints=function(a){return this.kind==="audio"&&typeof a=="object"&&(a=JSON.parse(JSON.stringify(a)),r(a,"autoGainControl","mozAutoGainControl"),r(a,"noiseSuppression","mozNoiseSuppression")),o.apply(this,[a])}}}}function Ak(t,e){t.navigator.mediaDevices&&"getDisplayMedia"in t.navigator.mediaDevices||t.navigator.mediaDevices&&(t.navigator.mediaDevices.getDisplayMedia=function(i){if(!(i&&i.video)){const r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return i.video===!0?i.video={mediaSource:e}:i.video.mediaSource=e,t.navigator.mediaDevices.getUserMedia(i)})}function Nv(t){typeof t=="object"&&t.RTCTrackEvent&&"receiver"in t.RTCTrackEvent.prototype&&!("transceiver"in t.RTCTrackEvent.prototype)&&Object.defineProperty(t.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function ed(t,e){if(typeof t!="object"||!(t.RTCPeerConnection||t.mozRTCPeerConnection))return;!t.RTCPeerConnection&&t.mozRTCPeerConnection&&(t.RTCPeerConnection=t.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(r){const s=t.RTCPeerConnection.prototype[r],o={[r](){return arguments[0]=new(r==="addIceCandidate"?t.RTCIceCandidate:t.RTCSessionDescription)(arguments[0]),s.apply(this,arguments)}};t.RTCPeerConnection.prototype[r]=o[r]});const n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=t.RTCPeerConnection.prototype.getStats;t.RTCPeerConnection.prototype.getStats=function(){const[s,o,a]=arguments;return i.apply(this,[s||null]).then(c=>{if(e.version<53&&!o)try{c.forEach(l=>{l.type=n[l.type]||l.type})}catch(l){if(l.name!=="TypeError")throw l;c.forEach((d,u)=>{c.set(u,Object.assign({},d,{type:n[d.type]||d.type}))})}return c}).then(o,a)}}function Ov(t){if(!(typeof t=="object"&&t.RTCPeerConnection&&t.RTCRtpSender)||t.RTCRtpSender&&"getStats"in t.RTCRtpSender.prototype)return;const e=t.RTCPeerConnection.prototype.getSenders;e&&(t.RTCPeerConnection.prototype.getSenders=function(){const r=e.apply(this,[]);return r.forEach(s=>s._pc=this),r});const n=t.RTCPeerConnection.prototype.addTrack;n&&(t.RTCPeerConnection.prototype.addTrack=function(){const r=n.apply(this,arguments);return r._pc=this,r}),t.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function Dv(t){if(!(typeof t=="object"&&t.RTCPeerConnection&&t.RTCRtpSender)||t.RTCRtpSender&&"getStats"in t.RTCRtpReceiver.prototype)return;const e=t.RTCPeerConnection.prototype.getReceivers;e&&(t.RTCPeerConnection.prototype.getReceivers=function(){const i=e.apply(this,[]);return i.forEach(r=>r._pc=this),i}),rr(t,"track",n=>(n.receiver._pc=n.srcElement,n)),t.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function jv(t){!t.RTCPeerConnection||"removeStream"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.removeStream=function(n){Au("removeStream","removeTrack"),this.getSenders().forEach(i=>{i.track&&n.getTracks().includes(i.track)&&this.removeTrack(i)})})}function Lv(t){t.DataChannel&&!t.RTCDataChannel&&(t.RTCDataChannel=t.DataChannel)}function Vv(t){if(!(typeof t=="object"&&t.RTCPeerConnection))return;const e=t.RTCPeerConnection.prototype.addTransceiver;e&&(t.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let i=arguments[1]&&arguments[1].sendEncodings;i===void 0&&(i=[]),i=[...i];const r=i.length>0;r&&i.forEach(o=>{if("rid"in o&&!/^[a-z0-9]{0,16}$/i.test(o.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in o&&!(parseFloat(o.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in o&&!(parseFloat(o.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const s=e.apply(this,arguments);if(r){const{sender:o}=s,a=o.getParameters();(!("encodings"in a)||a.encodings.length===1&&Object.keys(a.encodings[0]).length===0)&&(a.encodings=i,o.sendEncodings=i,this.setParametersPromises.push(o.setParameters(a).then(()=>{delete o.sendEncodings}).catch(()=>{delete o.sendEncodings})))}return s})}function Fv(t){if(!(typeof t=="object"&&t.RTCRtpSender))return;const e=t.RTCRtpSender.prototype.getParameters;e&&(t.RTCRtpSender.prototype.getParameters=function(){const i=e.apply(this,arguments);return"encodings"in i||(i.encodings=[].concat(this.sendEncodings||[{}])),i})}function Uv(t){if(!(typeof t=="object"&&t.RTCPeerConnection))return;const e=t.RTCPeerConnection.prototype.createOffer;t.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}function Bv(t){if(!(typeof t=="object"&&t.RTCPeerConnection))return;const e=t.RTCPeerConnection.prototype.createAnswer;t.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}var Hh=Object.freeze({__proto__:null,shimAddTransceiver:Vv,shimCreateAnswer:Bv,shimCreateOffer:Uv,shimGetDisplayMedia:Ak,shimGetParameters:Fv,shimGetUserMedia:_v,shimOnTrack:Nv,shimPeerConnection:ed,shimRTCDataChannel:Lv,shimReceiverGetStats:Dv,shimRemoveStream:jv,shimSenderGetStats:Ov});function $v(t){if(!(typeof t!="object"||!t.RTCPeerConnection)){if("getLocalStreams"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in t.RTCPeerConnection.prototype)){const e=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addStream=function(i){this._localStreams||(this._localStreams=[]),this._localStreams.includes(i)||this._localStreams.push(i),i.getAudioTracks().forEach(r=>e.call(this,r,i)),i.getVideoTracks().forEach(r=>e.call(this,r,i))},t.RTCPeerConnection.prototype.addTrack=function(i){for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return s&&s.forEach(a=>{this._localStreams?this._localStreams.includes(a)||this._localStreams.push(a):this._localStreams=[a]}),e.apply(this,arguments)}}"removeStream"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.removeStream=function(n){this._localStreams||(this._localStreams=[]);const i=this._localStreams.indexOf(n);if(i===-1)return;this._localStreams.splice(i,1);const r=n.getTracks();this.getSenders().forEach(s=>{r.includes(s.track)&&this.removeTrack(s)})})}}function Hv(t){if(!(typeof t!="object"||!t.RTCPeerConnection)&&("getRemoteStreams"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in t.RTCPeerConnection.prototype))){Object.defineProperty(t.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(n){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=n),this.addEventListener("track",this._onaddstreampoly=i=>{i.streams.forEach(r=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(r))return;this._remoteStreams.push(r);const s=new Event("addstream");s.stream=r,this.dispatchEvent(s)})})}});const e=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){const i=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(r){r.streams.forEach(s=>{if(i._remoteStreams||(i._remoteStreams=[]),i._remoteStreams.indexOf(s)>=0)return;i._remoteStreams.push(s);const o=new Event("addstream");o.stream=s,i.dispatchEvent(o)})}),e.apply(i,arguments)}}}function zv(t){if(typeof t!="object"||!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype,n=e.createOffer,i=e.createAnswer,r=e.setLocalDescription,s=e.setRemoteDescription,o=e.addIceCandidate;e.createOffer=function(l,d){const u=arguments.length>=2?arguments[2]:arguments[0],f=n.apply(this,[u]);return d?(f.then(l,d),Promise.resolve()):f},e.createAnswer=function(l,d){const u=arguments.length>=2?arguments[2]:arguments[0],f=i.apply(this,[u]);return d?(f.then(l,d),Promise.resolve()):f};let a=function(c,l,d){const u=r.apply(this,[c]);return d?(u.then(l,d),Promise.resolve()):u};e.setLocalDescription=a,a=function(c,l,d){const u=s.apply(this,[c]);return d?(u.then(l,d),Promise.resolve()):u},e.setRemoteDescription=a,a=function(c,l,d){const u=o.apply(this,[c]);return d?(u.then(l,d),Promise.resolve()):u},e.addIceCandidate=a}function Wv(t){const e=t&&t.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const n=e.mediaDevices,i=n.getUserMedia.bind(n);e.mediaDevices.getUserMedia=r=>i(qv(r))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=(function(i,r,s){e.mediaDevices.getUserMedia(i).then(r,s)}).bind(e))}function qv(t){return t&&t.video!==void 0?Object.assign({},t,{video:Cv(t.video)}):t}function Kv(t){if(!t.RTCPeerConnection)return;const e=t.RTCPeerConnection;t.RTCPeerConnection=function(i,r){if(i&&i.iceServers){const s=[];for(let o=0;o<i.iceServers.length;o++){let a=i.iceServers[o];a.urls===void 0&&a.url?(Au("RTCIceServer.url","RTCIceServer.urls"),a=JSON.parse(JSON.stringify(a)),a.urls=a.url,delete a.url,s.push(a)):s.push(i.iceServers[o])}i.iceServers=s}return new e(i,r)},t.RTCPeerConnection.prototype=e.prototype,"generateCertificate"in e&&Object.defineProperty(t.RTCPeerConnection,"generateCertificate",{get(){return e.generateCertificate}})}function Gv(t){typeof t=="object"&&t.RTCTrackEvent&&"receiver"in t.RTCTrackEvent.prototype&&!("transceiver"in t.RTCTrackEvent.prototype)&&Object.defineProperty(t.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Zv(t){const e=t.RTCPeerConnection.prototype.createOffer;t.RTCPeerConnection.prototype.createOffer=function(i){if(i){typeof i.offerToReceiveAudio<"u"&&(i.offerToReceiveAudio=!!i.offerToReceiveAudio);const r=this.getTransceivers().find(o=>o.receiver.track.kind==="audio");i.offerToReceiveAudio===!1&&r?r.direction==="sendrecv"?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":r.direction==="recvonly"&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):i.offerToReceiveAudio===!0&&!r&&this.addTransceiver("audio",{direction:"recvonly"}),typeof i.offerToReceiveVideo<"u"&&(i.offerToReceiveVideo=!!i.offerToReceiveVideo);const s=this.getTransceivers().find(o=>o.receiver.track.kind==="video");i.offerToReceiveVideo===!1&&s?s.direction==="sendrecv"?s.setDirection?s.setDirection("sendonly"):s.direction="sendonly":s.direction==="recvonly"&&(s.setDirection?s.setDirection("inactive"):s.direction="inactive"):i.offerToReceiveVideo===!0&&!s&&this.addTransceiver("video",{direction:"recvonly"})}return e.apply(this,arguments)}}function Yv(t){typeof t!="object"||t.AudioContext||(t.AudioContext=t.webkitAudioContext)}var zh=Object.freeze({__proto__:null,shimAudioContext:Yv,shimCallbacksAPI:zv,shimConstraints:qv,shimCreateOfferLegacy:Zv,shimGetUserMedia:Wv,shimLocalStreamsAPI:$v,shimRTCIceServerUrls:Kv,shimRemoteStreamsAPI:Hv,shimTrackEventTransceiver:Gv}),jc={exports:{}},Wh;function Ik(){return Wh||(Wh=1,function(t){const e={};e.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)},e.localCName=e.generateIdentifier(),e.splitLines=function(n){return n.trim().split(`
|
|
32
|
-
`).map(i=>i.trim())},e.splitSections=function(n){return n.split(`
|
|
33
|
-
m=`).map((r,s)=>(s>0?"m="+r:r).trim()+`\r
|
|
34
|
-
`)},e.getDescription=function(n){const i=e.splitSections(n);return i&&i[0]},e.getMediaSections=function(n){const i=e.splitSections(n);return i.shift(),i},e.matchPrefix=function(n,i){return e.splitLines(n).filter(r=>r.indexOf(i)===0)},e.parseCandidate=function(n){let i;n.indexOf("a=candidate:")===0?i=n.substring(12).split(" "):i=n.substring(10).split(" ");const r={foundation:i[0],component:{1:"rtp",2:"rtcp"}[i[1]]||i[1],protocol:i[2].toLowerCase(),priority:parseInt(i[3],10),ip:i[4],address:i[4],port:parseInt(i[5],10),type:i[7]};for(let s=8;s<i.length;s+=2)switch(i[s]){case"raddr":r.relatedAddress=i[s+1];break;case"rport":r.relatedPort=parseInt(i[s+1],10);break;case"tcptype":r.tcpType=i[s+1];break;case"ufrag":r.ufrag=i[s+1],r.usernameFragment=i[s+1];break;default:r[i[s]]===void 0&&(r[i[s]]=i[s+1]);break}return r},e.writeCandidate=function(n){const i=[];i.push(n.foundation);const r=n.component;r==="rtp"?i.push(1):r==="rtcp"?i.push(2):i.push(r),i.push(n.protocol.toUpperCase()),i.push(n.priority),i.push(n.address||n.ip),i.push(n.port);const s=n.type;return i.push("typ"),i.push(s),s!=="host"&&n.relatedAddress&&n.relatedPort&&(i.push("raddr"),i.push(n.relatedAddress),i.push("rport"),i.push(n.relatedPort)),n.tcpType&&n.protocol.toLowerCase()==="tcp"&&(i.push("tcptype"),i.push(n.tcpType)),(n.usernameFragment||n.ufrag)&&(i.push("ufrag"),i.push(n.usernameFragment||n.ufrag)),"candidate:"+i.join(" ")},e.parseIceOptions=function(n){return n.substring(14).split(" ")},e.parseRtpMap=function(n){let i=n.substring(9).split(" ");const r={payloadType:parseInt(i.shift(),10)};return i=i[0].split("/"),r.name=i[0],r.clockRate=parseInt(i[1],10),r.channels=i.length===3?parseInt(i[2],10):1,r.numChannels=r.channels,r},e.writeRtpMap=function(n){let i=n.payloadType;n.preferredPayloadType!==void 0&&(i=n.preferredPayloadType);const r=n.channels||n.numChannels||1;return"a=rtpmap:"+i+" "+n.name+"/"+n.clockRate+(r!==1?"/"+r:"")+`\r
|
|
35
|
-
`},e.parseExtmap=function(n){const i=n.substring(9).split(" ");return{id:parseInt(i[0],10),direction:i[0].indexOf("/")>0?i[0].split("/")[1]:"sendrecv",uri:i[1],attributes:i.slice(2).join(" ")}},e.writeExtmap=function(n){return"a=extmap:"+(n.id||n.preferredId)+(n.direction&&n.direction!=="sendrecv"?"/"+n.direction:"")+" "+n.uri+(n.attributes?" "+n.attributes:"")+`\r
|
|
36
|
-
`},e.parseFmtp=function(n){const i={};let r;const s=n.substring(n.indexOf(" ")+1).split(";");for(let o=0;o<s.length;o++)r=s[o].trim().split("="),i[r[0].trim()]=r[1];return i},e.writeFmtp=function(n){let i="",r=n.payloadType;if(n.preferredPayloadType!==void 0&&(r=n.preferredPayloadType),n.parameters&&Object.keys(n.parameters).length){const s=[];Object.keys(n.parameters).forEach(o=>{n.parameters[o]!==void 0?s.push(o+"="+n.parameters[o]):s.push(o)}),i+="a=fmtp:"+r+" "+s.join(";")+`\r
|
|
37
|
-
`}return i},e.parseRtcpFb=function(n){const i=n.substring(n.indexOf(" ")+1).split(" ");return{type:i.shift(),parameter:i.join(" ")}},e.writeRtcpFb=function(n){let i="",r=n.payloadType;return n.preferredPayloadType!==void 0&&(r=n.preferredPayloadType),n.rtcpFeedback&&n.rtcpFeedback.length&&n.rtcpFeedback.forEach(s=>{i+="a=rtcp-fb:"+r+" "+s.type+(s.parameter&&s.parameter.length?" "+s.parameter:"")+`\r
|
|
38
|
-
`}),i},e.parseSsrcMedia=function(n){const i=n.indexOf(" "),r={ssrc:parseInt(n.substring(7,i),10)},s=n.indexOf(":",i);return s>-1?(r.attribute=n.substring(i+1,s),r.value=n.substring(s+1)):r.attribute=n.substring(i+1),r},e.parseSsrcGroup=function(n){const i=n.substring(13).split(" ");return{semantics:i.shift(),ssrcs:i.map(r=>parseInt(r,10))}},e.getMid=function(n){const i=e.matchPrefix(n,"a=mid:")[0];if(i)return i.substring(6)},e.parseFingerprint=function(n){const i=n.substring(14).split(" ");return{algorithm:i[0].toLowerCase(),value:i[1].toUpperCase()}},e.getDtlsParameters=function(n,i){return{role:"auto",fingerprints:e.matchPrefix(n+i,"a=fingerprint:").map(e.parseFingerprint)}},e.writeDtlsParameters=function(n,i){let r="a=setup:"+i+`\r
|
|
39
|
-
`;return n.fingerprints.forEach(s=>{r+="a=fingerprint:"+s.algorithm+" "+s.value+`\r
|
|
40
|
-
`}),r},e.parseCryptoLine=function(n){const i=n.substring(9).split(" ");return{tag:parseInt(i[0],10),cryptoSuite:i[1],keyParams:i[2],sessionParams:i.slice(3)}},e.writeCryptoLine=function(n){return"a=crypto:"+n.tag+" "+n.cryptoSuite+" "+(typeof n.keyParams=="object"?e.writeCryptoKeyParams(n.keyParams):n.keyParams)+(n.sessionParams?" "+n.sessionParams.join(" "):"")+`\r
|
|
41
|
-
`},e.parseCryptoKeyParams=function(n){if(n.indexOf("inline:")!==0)return null;const i=n.substring(7).split("|");return{keyMethod:"inline",keySalt:i[0],lifeTime:i[1],mkiValue:i[2]?i[2].split(":")[0]:void 0,mkiLength:i[2]?i[2].split(":")[1]:void 0}},e.writeCryptoKeyParams=function(n){return n.keyMethod+":"+n.keySalt+(n.lifeTime?"|"+n.lifeTime:"")+(n.mkiValue&&n.mkiLength?"|"+n.mkiValue+":"+n.mkiLength:"")},e.getCryptoParameters=function(n,i){return e.matchPrefix(n+i,"a=crypto:").map(e.parseCryptoLine)},e.getIceParameters=function(n,i){const r=e.matchPrefix(n+i,"a=ice-ufrag:")[0],s=e.matchPrefix(n+i,"a=ice-pwd:")[0];return r&&s?{usernameFragment:r.substring(12),password:s.substring(10)}:null},e.writeIceParameters=function(n){let i="a=ice-ufrag:"+n.usernameFragment+`\r
|
|
42
|
-
a=ice-pwd:`+n.password+`\r
|
|
43
|
-
`;return n.iceLite&&(i+=`a=ice-lite\r
|
|
44
|
-
`),i},e.parseRtpParameters=function(n){const i={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},s=e.splitLines(n)[0].split(" ");i.profile=s[2];for(let a=3;a<s.length;a++){const c=s[a],l=e.matchPrefix(n,"a=rtpmap:"+c+" ")[0];if(l){const d=e.parseRtpMap(l),u=e.matchPrefix(n,"a=fmtp:"+c+" ");switch(d.parameters=u.length?e.parseFmtp(u[0]):{},d.rtcpFeedback=e.matchPrefix(n,"a=rtcp-fb:"+c+" ").map(e.parseRtcpFb),i.codecs.push(d),d.name.toUpperCase()){case"RED":case"ULPFEC":i.fecMechanisms.push(d.name.toUpperCase());break}}}e.matchPrefix(n,"a=extmap:").forEach(a=>{i.headerExtensions.push(e.parseExtmap(a))});const o=e.matchPrefix(n,"a=rtcp-fb:* ").map(e.parseRtcpFb);return i.codecs.forEach(a=>{o.forEach(c=>{a.rtcpFeedback.find(d=>d.type===c.type&&d.parameter===c.parameter)||a.rtcpFeedback.push(c)})}),i},e.writeRtpDescription=function(n,i){let r="";r+="m="+n+" ",r+=i.codecs.length>0?"9":"0",r+=" "+(i.profile||"UDP/TLS/RTP/SAVPF")+" ",r+=i.codecs.map(o=>o.preferredPayloadType!==void 0?o.preferredPayloadType:o.payloadType).join(" ")+`\r
|
|
45
|
-
`,r+=`c=IN IP4 0.0.0.0\r
|
|
46
|
-
`,r+=`a=rtcp:9 IN IP4 0.0.0.0\r
|
|
47
|
-
`,i.codecs.forEach(o=>{r+=e.writeRtpMap(o),r+=e.writeFmtp(o),r+=e.writeRtcpFb(o)});let s=0;return i.codecs.forEach(o=>{o.maxptime>s&&(s=o.maxptime)}),s>0&&(r+="a=maxptime:"+s+`\r
|
|
48
|
-
`),i.headerExtensions&&i.headerExtensions.forEach(o=>{r+=e.writeExtmap(o)}),r},e.parseRtpEncodingParameters=function(n){const i=[],r=e.parseRtpParameters(n),s=r.fecMechanisms.indexOf("RED")!==-1,o=r.fecMechanisms.indexOf("ULPFEC")!==-1,a=e.matchPrefix(n,"a=ssrc:").map(f=>e.parseSsrcMedia(f)).filter(f=>f.attribute==="cname"),c=a.length>0&&a[0].ssrc;let l;const d=e.matchPrefix(n,"a=ssrc-group:FID").map(f=>f.substring(17).split(" ").map(v=>parseInt(v,10)));d.length>0&&d[0].length>1&&d[0][0]===c&&(l=d[0][1]),r.codecs.forEach(f=>{if(f.name.toUpperCase()==="RTX"&&f.parameters.apt){let p={ssrc:c,codecPayloadType:parseInt(f.parameters.apt,10)};c&&l&&(p.rtx={ssrc:l}),i.push(p),s&&(p=JSON.parse(JSON.stringify(p)),p.fec={ssrc:c,mechanism:o?"red+ulpfec":"red"},i.push(p))}}),i.length===0&&c&&i.push({ssrc:c});let u=e.matchPrefix(n,"b=");return u.length&&(u[0].indexOf("b=TIAS:")===0?u=parseInt(u[0].substring(7),10):u[0].indexOf("b=AS:")===0?u=parseInt(u[0].substring(5),10)*1e3*.95-2e3*8:u=void 0,i.forEach(f=>{f.maxBitrate=u})),i},e.parseRtcpParameters=function(n){const i={},r=e.matchPrefix(n,"a=ssrc:").map(a=>e.parseSsrcMedia(a)).filter(a=>a.attribute==="cname")[0];r&&(i.cname=r.value,i.ssrc=r.ssrc);const s=e.matchPrefix(n,"a=rtcp-rsize");i.reducedSize=s.length>0,i.compound=s.length===0;const o=e.matchPrefix(n,"a=rtcp-mux");return i.mux=o.length>0,i},e.writeRtcpParameters=function(n){let i="";return n.reducedSize&&(i+=`a=rtcp-rsize\r
|
|
49
|
-
`),n.mux&&(i+=`a=rtcp-mux\r
|
|
50
|
-
`),n.ssrc!==void 0&&n.cname&&(i+="a=ssrc:"+n.ssrc+" cname:"+n.cname+`\r
|
|
51
|
-
`),i},e.parseMsid=function(n){let i;const r=e.matchPrefix(n,"a=msid:");if(r.length===1)return i=r[0].substring(7).split(" "),{stream:i[0],track:i[1]};const s=e.matchPrefix(n,"a=ssrc:").map(o=>e.parseSsrcMedia(o)).filter(o=>o.attribute==="msid");if(s.length>0)return i=s[0].value.split(" "),{stream:i[0],track:i[1]}},e.parseSctpDescription=function(n){const i=e.parseMLine(n),r=e.matchPrefix(n,"a=max-message-size:");let s;r.length>0&&(s=parseInt(r[0].substring(19),10)),isNaN(s)&&(s=65536);const o=e.matchPrefix(n,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substring(12),10),protocol:i.fmt,maxMessageSize:s};const a=e.matchPrefix(n,"a=sctpmap:");if(a.length>0){const c=a[0].substring(10).split(" ");return{port:parseInt(c[0],10),protocol:c[1],maxMessageSize:s}}},e.writeSctpDescription=function(n,i){let r=[];return n.protocol!=="DTLS/SCTP"?r=["m="+n.kind+" 9 "+n.protocol+" "+i.protocol+`\r
|
|
52
|
-
`,`c=IN IP4 0.0.0.0\r
|
|
53
|
-
`,"a=sctp-port:"+i.port+`\r
|
|
54
|
-
`]:r=["m="+n.kind+" 9 "+n.protocol+" "+i.port+`\r
|
|
55
|
-
`,`c=IN IP4 0.0.0.0\r
|
|
56
|
-
`,"a=sctpmap:"+i.port+" "+i.protocol+` 65535\r
|
|
57
|
-
`],i.maxMessageSize!==void 0&&r.push("a=max-message-size:"+i.maxMessageSize+`\r
|
|
58
|
-
`),r.join("")},e.generateSessionId=function(){return Math.random().toString().substr(2,22)},e.writeSessionBoilerplate=function(n,i,r){let s;const o=i!==void 0?i:2;return n?s=n:s=e.generateSessionId(),`v=0\r
|
|
59
|
-
o=`+(r||"thisisadapterortc")+" "+s+" "+o+` IN IP4 127.0.0.1\r
|
|
60
|
-
s=-\r
|
|
61
|
-
t=0 0\r
|
|
62
|
-
`},e.getDirection=function(n,i){const r=e.splitLines(n);for(let s=0;s<r.length;s++)switch(r[s]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[s].substring(2)}return i?e.getDirection(i):"sendrecv"},e.getKind=function(n){return e.splitLines(n)[0].split(" ")[0].substring(2)},e.isRejected=function(n){return n.split(" ",2)[1]==="0"},e.parseMLine=function(n){const r=e.splitLines(n)[0].substring(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},e.parseOLine=function(n){const r=e.matchPrefix(n,"o=")[0].substring(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}},e.isValidSDP=function(n){if(typeof n!="string"||n.length===0)return!1;const i=e.splitLines(n);for(let r=0;r<i.length;r++)if(i[r].length<2||i[r].charAt(1)!=="=")return!1;return!0},t.exports=e}(jc)),jc.exports}var Jv=Ik(),Or=gk(Jv),Mk=$w({__proto__:null,default:Or},[Jv]);function Xo(t){if(!t.RTCIceCandidate||t.RTCIceCandidate&&"foundation"in t.RTCIceCandidate.prototype)return;const e=t.RTCIceCandidate;t.RTCIceCandidate=function(i){if(typeof i=="object"&&i.candidate&&i.candidate.indexOf("a=")===0&&(i=JSON.parse(JSON.stringify(i)),i.candidate=i.candidate.substring(2)),i.candidate&&i.candidate.length){const r=new e(i),s=Or.parseCandidate(i.candidate);for(const o in s)o in r||Object.defineProperty(r,o,{value:s[o]});return r.toJSON=function(){return{candidate:r.candidate,sdpMid:r.sdpMid,sdpMLineIndex:r.sdpMLineIndex,usernameFragment:r.usernameFragment}},r}return new e(i)},t.RTCIceCandidate.prototype=e.prototype,rr(t,"icecandidate",n=>(n.candidate&&Object.defineProperty(n,"candidate",{value:new t.RTCIceCandidate(n.candidate),writable:"false"}),n))}function td(t){!t.RTCIceCandidate||t.RTCIceCandidate&&"relayProtocol"in t.RTCIceCandidate.prototype||rr(t,"icecandidate",e=>{if(e.candidate){const n=Or.parseCandidate(e.candidate.candidate);n.type==="relay"&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[n.priority>>24])}return e})}function Qo(t,e){if(!t.RTCPeerConnection)return;"sctp"in t.RTCPeerConnection.prototype||Object.defineProperty(t.RTCPeerConnection.prototype,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp}});const n=function(a){if(!a||!a.sdp)return!1;const c=Or.splitSections(a.sdp);return c.shift(),c.some(l=>{const d=Or.parseMLine(l);return d&&d.kind==="application"&&d.protocol.indexOf("SCTP")!==-1})},i=function(a){const c=a.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(c===null||c.length<2)return-1;const l=parseInt(c[1],10);return l!==l?-1:l},r=function(a){let c=65536;return e.browser==="firefox"&&(e.version<57?a===-1?c=16384:c=2147483637:e.version<60?c=e.version===57?65535:65536:c=2147483637),c},s=function(a,c){let l=65536;e.browser==="firefox"&&e.version===57&&(l=65535);const d=Or.matchPrefix(a.sdp,"a=max-message-size:");return d.length>0?l=parseInt(d[0].substring(19),10):e.browser==="firefox"&&c!==-1&&(l=2147483637),l},o=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76){const{sdpSemantics:c}=this.getConfiguration();c==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp},enumerable:!0,configurable:!0})}if(n(arguments[0])){const c=i(arguments[0]),l=r(c),d=s(arguments[0],c);let u;l===0&&d===0?u=Number.POSITIVE_INFINITY:l===0||d===0?u=Math.max(l,d):u=Math.min(l,d);const f={};Object.defineProperty(f,"maxMessageSize",{get(){return u}}),this._sctp=f}return o.apply(this,arguments)}}function ea(t){if(!(t.RTCPeerConnection&&"createDataChannel"in t.RTCPeerConnection.prototype))return;function e(i,r){const s=i.send;i.send=function(){const a=arguments[0],c=a.length||a.size||a.byteLength;if(i.readyState==="open"&&r.sctp&&c>r.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+r.sctp.maxMessageSize+" bytes)");return s.apply(i,arguments)}}const n=t.RTCPeerConnection.prototype.createDataChannel;t.RTCPeerConnection.prototype.createDataChannel=function(){const r=n.apply(this,arguments);return e(r,this),r},rr(t,"datachannel",i=>(e(i.channel,i.target),i))}function nd(t){if(!t.RTCPeerConnection||"connectionState"in t.RTCPeerConnection.prototype)return;const e=t.RTCPeerConnection.prototype;Object.defineProperty(e,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(n){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),n&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=n)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(n=>{const i=e[n];e[n]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=r=>{const s=r.target;if(s._lastConnectionState!==s.connectionState){s._lastConnectionState=s.connectionState;const o=new Event("connectionstatechange",r);s.dispatchEvent(o)}return r},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),i.apply(this,arguments)}})}function id(t,e){if(!t.RTCPeerConnection||e.browser==="chrome"&&e.version>=71||e.browser==="safari"&&e._safariVersion>=13.1)return;const n=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(r){if(r&&r.sdp&&r.sdp.indexOf(`
|
|
63
|
-
a=extmap-allow-mixed`)!==-1){const s=r.sdp.split(`
|
|
64
|
-
`).filter(o=>o.trim()!=="a=extmap-allow-mixed").join(`
|
|
65
|
-
`);t.RTCSessionDescription&&r instanceof t.RTCSessionDescription?arguments[0]=new t.RTCSessionDescription({type:r.type,sdp:s}):r.sdp=s}return n.apply(this,arguments)}}function ta(t,e){if(!(t.RTCPeerConnection&&t.RTCPeerConnection.prototype))return;const n=t.RTCPeerConnection.prototype.addIceCandidate;!n||n.length===0||(t.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(e.browser==="chrome"&&e.version<78||e.browser==="firefox"&&e.version<68||e.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function na(t,e){if(!(t.RTCPeerConnection&&t.RTCPeerConnection.prototype))return;const n=t.RTCPeerConnection.prototype.setLocalDescription;!n||n.length===0||(t.RTCPeerConnection.prototype.setLocalDescription=function(){let r=arguments[0]||{};if(typeof r!="object"||r.type&&r.sdp)return n.apply(this,arguments);if(r={type:r.type,sdp:r.sdp},!r.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":r.type="offer";break;default:r.type="answer";break}return r.sdp||r.type!=="offer"&&r.type!=="answer"?n.apply(this,[r]):(r.type==="offer"?this.createOffer:this.createAnswer).apply(this).then(o=>n.apply(this,[o]))})}var _k=Object.freeze({__proto__:null,removeExtmapAllowMixed:id,shimAddIceCandidateNullOrEmpty:ta,shimConnectionState:nd,shimMaxMessageSize:Qo,shimParameterlessSetLocalDescription:na,shimRTCIceCandidate:Xo,shimRTCIceCandidateRelayProtocol:td,shimSendThrowTypeError:ea});function Nk(){let{window:t}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0};const n=wv,i=Rk(t),r={browserDetails:i,commonShim:_k,extractVersion:Is,disableLog:Ek,disableWarnings:Pk,sdp:Mk};switch(i.browser){case"chrome":if(!$h||!Ql||!e.shimChrome)return n("Chrome shim is not included in this adapter release."),r;if(i.version===null)return n("Chrome shim can not determine version, not shimming."),r;n("adapter.js shimming chrome."),r.browserShim=$h,ta(t,i),na(t),kv(t,i),Tv(t),Ql(t,i),Ev(t),Iv(t,i),Pv(t),Rv(t),Mv(t,i),Xo(t),td(t),nd(t),Qo(t,i),ea(t),id(t,i);break;case"firefox":if(!Hh||!ed||!e.shimFirefox)return n("Firefox shim is not included in this adapter release."),r;n("adapter.js shimming firefox."),r.browserShim=Hh,ta(t,i),na(t),_v(t,i),ed(t,i),Nv(t),jv(t),Ov(t),Dv(t),Lv(t),Vv(t),Fv(t),Uv(t),Bv(t),Xo(t),nd(t),Qo(t,i),ea(t);break;case"safari":if(!zh||!e.shimSafari)return n("Safari shim is not included in this adapter release."),r;n("adapter.js shimming safari."),r.browserShim=zh,ta(t,i),na(t),Kv(t),Zv(t),zv(t),$v(t),Hv(t),Gv(t),Wv(t),Yv(t),Xo(t),td(t),Qo(t,i),ea(t),id(t,i);break;default:n("Unsupported browser!");break}return r}Nk({window:typeof window>"u"?void 0:window});const Ok=10,Ss="lk_e2ee",Dk="LKFrameEncryptionKey",jk={sharedKey:!1,ratchetSalt:Dk,ratchetWindowSize:8,failureTolerance:Ok,keyringSize:16};var ui;(function(t){t.SetKey="setKey",t.RatchetRequest="ratchetRequest",t.KeyRatcheted="keyRatcheted"})(ui||(ui={}));var qh;(function(t){t.KeyRatcheted="keyRatcheted"})(qh||(qh={}));var di;(function(t){t.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",t.EncryptionError="encryptionError"})(di||(di={}));var Kh;(function(t){t.Error="cryptorError"})(Kh||(Kh={}));function Lk(){return Vk()||rd()}function rd(){return typeof window.RTCRtpScriptTransform<"u"}function Vk(){return typeof window.RTCRtpSender<"u"&&typeof window.RTCRtpSender.prototype.createEncodedStreams<"u"}class NL extends Nn.EventEmitter{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),this.onKeyRatcheted=(n,i,r)=>{Ce.debug("key ratcheted event received",{ratchetResult:n,participantId:i,keyIndex:r})},this.keyInfoMap=new Map,this.options=Object.assign(Object.assign({},jk),e),this.on(ui.KeyRatcheted,this.onKeyRatcheted)}onSetEncryptionKey(e,n,i){const r={key:e,participantIdentity:n,keyIndex:i};if(!this.options.sharedKey&&!n)throw new Error("participant identity needs to be passed for encryption key if sharedKey option is false");this.keyInfoMap.set("".concat(n??"shared","-").concat(i??0),r),this.emit(ui.SetKey,r)}getKeys(){return Array.from(this.keyInfoMap.values())}getOptions(){return this.options}ratchetKey(e,n){this.emit(ui.RatchetRequest,e,n)}}class ki extends Error{constructor(e,n){super(n||"an error has occured"),this.name="LiveKitError",this.code=e}}var Te;(function(t){t[t.NotAllowed=0]="NotAllowed",t[t.ServerUnreachable=1]="ServerUnreachable",t[t.InternalError=2]="InternalError",t[t.Cancelled=3]="Cancelled",t[t.LeaveRequest=4]="LeaveRequest",t[t.Timeout=5]="Timeout"})(Te||(Te={}));class Ue extends ki{constructor(e,n,i,r){super(1,e),this.name="ConnectionError",this.status=i,this.reason=n,this.context=r,this.reasonName=Te[n]}}class Iu extends ki{constructor(e){super(21,e??"device is unsupported"),this.name="DeviceUnsupportedError"}}class Wn extends ki{constructor(e){super(20,e??"track is invalid"),this.name="TrackInvalidError"}}class Fk extends ki{constructor(e){super(10,e??"unsupported server"),this.name="UnsupportedServer"}}class ht extends ki{constructor(e){super(12,e??"unexpected connection state"),this.name="UnexpectedConnectionState"}}class sd extends ki{constructor(e){super(13,e??"unable to negotiate"),this.name="NegotiationError"}}class Gh extends ki{constructor(e,n){super(15,e),this.name="PublishTrackError",this.status=n}}class Zh extends ki{constructor(e,n){super(15,e),this.reason=n,this.reasonName=typeof n=="string"?n:Ru[n]}}var Ca;(function(t){t.PermissionDenied="PermissionDenied",t.NotFound="NotFound",t.DeviceInUse="DeviceInUse",t.Other="Other"})(Ca||(Ca={}));(function(t){function e(n){if(n&&"name"in n)return n.name==="NotFoundError"||n.name==="DevicesNotFoundError"?t.NotFound:n.name==="NotAllowedError"||n.name==="PermissionDeniedError"?t.PermissionDenied:n.name==="NotReadableError"||n.name==="TrackStartError"?t.DeviceInUse:t.Other}t.getFailure=e})(Ca||(Ca={}));var Yh;(function(t){t[t.InvalidKey=0]="InvalidKey",t[t.MissingKey=1]="MissingKey",t[t.InternalError=2]="InternalError"})(Yh||(Yh={}));var U;(function(t){t.Connected="connected",t.Reconnecting="reconnecting",t.SignalReconnecting="signalReconnecting",t.Reconnected="reconnected",t.Disconnected="disconnected",t.ConnectionStateChanged="connectionStateChanged",t.Moved="moved",t.MediaDevicesChanged="mediaDevicesChanged",t.ParticipantConnected="participantConnected",t.ParticipantDisconnected="participantDisconnected",t.TrackPublished="trackPublished",t.TrackSubscribed="trackSubscribed",t.TrackSubscriptionFailed="trackSubscriptionFailed",t.TrackUnpublished="trackUnpublished",t.TrackUnsubscribed="trackUnsubscribed",t.TrackMuted="trackMuted",t.TrackUnmuted="trackUnmuted",t.LocalTrackPublished="localTrackPublished",t.LocalTrackUnpublished="localTrackUnpublished",t.LocalAudioSilenceDetected="localAudioSilenceDetected",t.ActiveSpeakersChanged="activeSpeakersChanged",t.ParticipantMetadataChanged="participantMetadataChanged",t.ParticipantNameChanged="participantNameChanged",t.ParticipantAttributesChanged="participantAttributesChanged",t.ParticipantActive="participantActive",t.RoomMetadataChanged="roomMetadataChanged",t.DataReceived="dataReceived",t.SipDTMFReceived="sipDTMFReceived",t.TranscriptionReceived="transcriptionReceived",t.ConnectionQualityChanged="connectionQualityChanged",t.TrackStreamStateChanged="trackStreamStateChanged",t.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",t.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",t.AudioPlaybackStatusChanged="audioPlaybackChanged",t.VideoPlaybackStatusChanged="videoPlaybackChanged",t.MediaDevicesError="mediaDevicesError",t.ParticipantPermissionsChanged="participantPermissionsChanged",t.SignalConnected="signalConnected",t.RecordingStatusChanged="recordingStatusChanged",t.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",t.EncryptionError="encryptionError",t.DCBufferStatusChanged="dcBufferStatusChanged",t.ActiveDeviceChanged="activeDeviceChanged",t.ChatMessage="chatMessage",t.LocalTrackSubscribed="localTrackSubscribed",t.MetricsReceived="metricsReceived"})(U||(U={}));var Z;(function(t){t.TrackPublished="trackPublished",t.TrackSubscribed="trackSubscribed",t.TrackSubscriptionFailed="trackSubscriptionFailed",t.TrackUnpublished="trackUnpublished",t.TrackUnsubscribed="trackUnsubscribed",t.TrackMuted="trackMuted",t.TrackUnmuted="trackUnmuted",t.LocalTrackPublished="localTrackPublished",t.LocalTrackUnpublished="localTrackUnpublished",t.ParticipantMetadataChanged="participantMetadataChanged",t.ParticipantNameChanged="participantNameChanged",t.DataReceived="dataReceived",t.SipDTMFReceived="sipDTMFReceived",t.TranscriptionReceived="transcriptionReceived",t.IsSpeakingChanged="isSpeakingChanged",t.ConnectionQualityChanged="connectionQualityChanged",t.TrackStreamStateChanged="trackStreamStateChanged",t.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",t.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",t.MediaDevicesError="mediaDevicesError",t.AudioStreamAcquired="audioStreamAcquired",t.ParticipantPermissionsChanged="participantPermissionsChanged",t.PCTrackAdded="pcTrackAdded",t.AttributesChanged="attributesChanged",t.LocalTrackSubscribed="localTrackSubscribed",t.ChatMessage="chatMessage",t.Active="active"})(Z||(Z={}));var ae;(function(t){t.TransportsCreated="transportsCreated",t.Connected="connected",t.Disconnected="disconnected",t.Resuming="resuming",t.Resumed="resumed",t.Restarting="restarting",t.Restarted="restarted",t.SignalResumed="signalResumed",t.SignalRestarted="signalRestarted",t.Closing="closing",t.MediaTrackAdded="mediaTrackAdded",t.ActiveSpeakersUpdate="activeSpeakersUpdate",t.DataPacketReceived="dataPacketReceived",t.RTPVideoMapUpdate="rtpVideoMapUpdate",t.DCBufferStatusChanged="dcBufferStatusChanged",t.ParticipantUpdate="participantUpdate",t.RoomUpdate="roomUpdate",t.SpeakersChanged="speakersChanged",t.StreamStateChanged="streamStateChanged",t.ConnectionQualityUpdate="connectionQualityUpdate",t.SubscriptionError="subscriptionError",t.SubscriptionPermissionUpdate="subscriptionPermissionUpdate",t.RemoteMute="remoteMute",t.SubscribedQualityUpdate="subscribedQualityUpdate",t.LocalTrackUnpublished="localTrackUnpublished",t.LocalTrackSubscribed="localTrackSubscribed",t.Offline="offline",t.SignalRequestResponse="signalRequestResponse",t.SignalConnected="signalConnected",t.RoomMoved="roomMoved"})(ae||(ae={}));var re;(function(t){t.Message="message",t.Muted="muted",t.Unmuted="unmuted",t.Restarted="restarted",t.Ended="ended",t.Subscribed="subscribed",t.Unsubscribed="unsubscribed",t.UpdateSettings="updateSettings",t.UpdateSubscription="updateSubscription",t.AudioPlaybackStarted="audioPlaybackStarted",t.AudioPlaybackFailed="audioPlaybackFailed",t.AudioSilenceDetected="audioSilenceDetected",t.VisibilityChanged="visibilityChanged",t.VideoDimensionsChanged="videoDimensionsChanged",t.VideoPlaybackStarted="videoPlaybackStarted",t.VideoPlaybackFailed="videoPlaybackFailed",t.ElementAttached="elementAttached",t.ElementDetached="elementDetached",t.UpstreamPaused="upstreamPaused",t.UpstreamResumed="upstreamResumed",t.SubscriptionPermissionChanged="subscriptionPermissionChanged",t.SubscriptionStatusChanged="subscriptionStatusChanged",t.SubscriptionFailed="subscriptionFailed",t.TrackProcessorUpdate="trackProcessorUpdate",t.AudioTrackFeatureUpdate="audioTrackFeatureUpdate",t.TranscriptionReceived="transcriptionReceived",t.TimeSyncUpdate="timeSyncUpdate",t.PreConnectBufferFlushed="preConnectBufferFlushed"})(re||(re={}));function Uk(t){return typeof t>"u"?t:typeof structuredClone=="function"?typeof t=="object"&&t!==null?structuredClone(Object.assign({},t)):structuredClone(t):JSON.parse(JSON.stringify(t))}const Bk=/version\/(\d+(\.?_?\d+)+)/i;let Lc;function $t(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(typeof navigator>"u")return;const n=navigator.userAgent.toLowerCase();if(Lc===void 0||e){const i=$k.find(r=>{let{test:s}=r;return s.test(n)});Lc=i==null?void 0:i.describe(n)}return Lc}const $k=[{test:/firefox|iceweasel|fxios/i,describe(t){return{name:"Firefox",version:ia(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t),os:t.toLowerCase().includes("fxios")?"iOS":void 0,osVersion:Vc(t)}}},{test:/chrom|crios|crmo/i,describe(t){return{name:"Chrome",version:ia(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t),os:t.toLowerCase().includes("crios")?"iOS":void 0,osVersion:Vc(t)}}},{test:/safari|applewebkit/i,describe(t){return{name:"Safari",version:ia(Bk,t),os:t.includes("mobile/")?"iOS":"macOS",osVersion:Vc(t)}}}];function ia(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;const i=e.match(t);return i&&i.length>=n&&i[n]||""}function Vc(t){return t.includes("mac os")?ia(/\(.+?(\d+_\d+(:?_\d+)?)/,t,1).replace(/_/g,"."):void 0}var Hk="2.13.8";const zk=Hk,Wk=16;class bt{}bt.setTimeout=function(){return setTimeout(...arguments)};bt.setInterval=function(){return setInterval(...arguments)};bt.clearTimeout=function(){return clearTimeout(...arguments)};bt.clearInterval=function(){return clearInterval(...arguments)};const qk=5e3,ws=[];var Jt;(function(t){t[t.LOW=0]="LOW",t[t.MEDIUM=1]="MEDIUM",t[t.HIGH=2]="HIGH"})(Jt||(Jt={}));class V extends Nn.EventEmitter{constructor(e,n){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var r;super(),this.attachedElements=[],this.isMuted=!1,this.streamState=V.StreamState.Active,this.isInBackground=!1,this._currentBitrate=0,this.log=Ce,this.appVisibilityChangedListener=()=>{this.backgroundTimeout&&clearTimeout(this.backgroundTimeout),document.visibilityState==="hidden"?this.backgroundTimeout=setTimeout(()=>this.handleAppVisibilityChanged(),qk):this.handleAppVisibilityChanged()},this.log=Gn((r=i.loggerName)!==null&&r!==void 0?r:fn.Track),this.loggerContextCb=i.loggerContextCb,this.setMaxListeners(100),this.kind=n,this._mediaStreamTrack=e,this._mediaStreamID=e.id,this.source=V.Source.Unknown}get logContext(){var e;return Object.assign(Object.assign({},(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this)),we(this))}get currentBitrate(){return this._currentBitrate}get mediaStreamTrack(){return this._mediaStreamTrack}get mediaStreamID(){return this._mediaStreamID}attach(e){let n="audio";this.kind===V.Kind.Video&&(n="video"),this.attachedElements.length===0&&this.kind===V.Kind.Video&&this.addAppVisibilityListener(),e||(n==="audio"&&(ws.forEach(s=>{s.parentElement===null&&!e&&(e=s)}),e&&ws.splice(ws.indexOf(e),1)),e||(e=document.createElement(n))),this.attachedElements.includes(e)||this.attachedElements.push(e),kr(this.mediaStreamTrack,e);const i=e.srcObject.getTracks(),r=i.some(s=>s.kind==="audio");return e.play().then(()=>{this.emit(r?re.AudioPlaybackStarted:re.VideoPlaybackStarted)}).catch(s=>{s.name==="NotAllowedError"?this.emit(r?re.AudioPlaybackFailed:re.VideoPlaybackFailed,s):s.name==="AbortError"?Ce.debug("".concat(r?"audio":"video"," playback aborted, likely due to new play request")):Ce.warn("could not playback ".concat(r?"audio":"video"),s),r&&e&&i.some(o=>o.kind==="video")&&s.name==="NotAllowedError"&&(e.muted=!0,e.play().catch(()=>{}))}),this.emit(re.ElementAttached,e),e}detach(e){try{if(e){Dr(this.mediaStreamTrack,e);const i=this.attachedElements.indexOf(e);return i>=0&&(this.attachedElements.splice(i,1),this.recycleElement(e),this.emit(re.ElementDetached,e)),e}const n=[];return this.attachedElements.forEach(i=>{Dr(this.mediaStreamTrack,i),n.push(i),this.recycleElement(i),this.emit(re.ElementDetached,i)}),this.attachedElements=[],n}finally{this.attachedElements.length===0&&this.removeAppVisibilityListener()}}stop(){this.stopMonitor(),this._mediaStreamTrack.stop()}enable(){this._mediaStreamTrack.enabled=!0}disable(){this._mediaStreamTrack.enabled=!1}stopMonitor(){this.monitorInterval&&clearInterval(this.monitorInterval),this.timeSyncHandle&&cancelAnimationFrame(this.timeSyncHandle)}updateLoggerOptions(e){e.loggerName&&(this.log=Gn(e.loggerName)),e.loggerContextCb&&(this.loggerContextCb=e.loggerContextCb)}recycleElement(e){if(e instanceof HTMLAudioElement){let n=!0;e.pause(),ws.forEach(i=>{i.parentElement||(n=!1)}),n&&ws.push(e)}}handleAppVisibilityChanged(){return A(this,void 0,void 0,function*(){this.isInBackground=document.visibilityState==="hidden",!this.isInBackground&&this.kind===V.Kind.Video&&setTimeout(()=>this.attachedElements.forEach(e=>e.play().catch(()=>{})),0)})}addAppVisibilityListener(){Ot()?(this.isInBackground=document.visibilityState==="hidden",document.addEventListener("visibilitychange",this.appVisibilityChangedListener)):this.isInBackground=!1}removeAppVisibilityListener(){Ot()&&document.removeEventListener("visibilitychange",this.appVisibilityChangedListener)}}function kr(t,e){let n;e.srcObject instanceof MediaStream?n=e.srcObject:n=new MediaStream;let i;t.kind==="audio"?i=n.getAudioTracks():i=n.getVideoTracks(),i.includes(t)||(i.forEach(r=>{n.removeTrack(r)}),n.addTrack(t)),(!Xi()||!(e instanceof HTMLVideoElement))&&(e.autoplay=!0),e.muted=n.getAudioTracks().length===0,e instanceof HTMLVideoElement&&(e.playsInline=!0),e.srcObject!==n&&(e.srcObject=n,(Xi()||qr())&&e instanceof HTMLVideoElement&&setTimeout(()=>{e.srcObject=n,e.play().catch(()=>{})},0))}function Dr(t,e){if(e.srcObject instanceof MediaStream){const n=e.srcObject;n.removeTrack(t),n.getTracks().length>0?e.srcObject=n:e.srcObject=null}}(function(t){let e;(function(l){l.Audio="audio",l.Video="video",l.Unknown="unknown"})(e=t.Kind||(t.Kind={}));let n;(function(l){l.Camera="camera",l.Microphone="microphone",l.ScreenShare="screen_share",l.ScreenShareAudio="screen_share_audio",l.Unknown="unknown"})(n=t.Source||(t.Source={}));let i;(function(l){l.Active="active",l.Paused="paused",l.Unknown="unknown"})(i=t.StreamState||(t.StreamState={}));function r(l){switch(l){case e.Audio:return cn.AUDIO;case e.Video:return cn.VIDEO;default:return cn.DATA}}t.kindToProto=r;function s(l){switch(l){case cn.AUDIO:return e.Audio;case cn.VIDEO:return e.Video;default:return e.Unknown}}t.kindFromProto=s;function o(l){switch(l){case n.Camera:return lt.CAMERA;case n.Microphone:return lt.MICROPHONE;case n.ScreenShare:return lt.SCREEN_SHARE;case n.ScreenShareAudio:return lt.SCREEN_SHARE_AUDIO;default:return lt.UNKNOWN}}t.sourceToProto=o;function a(l){switch(l){case lt.CAMERA:return n.Camera;case lt.MICROPHONE:return n.Microphone;case lt.SCREEN_SHARE:return n.ScreenShare;case lt.SCREEN_SHARE_AUDIO:return n.ScreenShareAudio;default:return n.Unknown}}t.sourceFromProto=a;function c(l){switch(l){case Gl.ACTIVE:return i.Active;case Gl.PAUSED:return i.Paused;default:return i.Unknown}}t.streamStateFromProto=c})(V||(V={}));class je{constructor(e,n,i,r,s){if(typeof e=="object")this.width=e.width,this.height=e.height,this.aspectRatio=e.aspectRatio,this.encoding={maxBitrate:e.maxBitrate,maxFramerate:e.maxFramerate,priority:e.priority};else if(n!==void 0&&i!==void 0)this.width=e,this.height=n,this.aspectRatio=e/n,this.encoding={maxBitrate:i,maxFramerate:r,priority:s};else throw new TypeError("Unsupported options: provide at least width, height and maxBitrate")}get resolution(){return{width:this.width,height:this.height,frameRate:this.encoding.maxFramerate,aspectRatio:this.aspectRatio}}}const Kk=["vp8","h264"],Gk=["vp8","h264","vp9","av1"];function Zk(t){return!!Kk.find(e=>e===t)}var Jh;(function(t){t[t.PREFER_REGRESSION=0]="PREFER_REGRESSION",t[t.SIMULCAST=1]="SIMULCAST",t[t.REGRESSION=2]="REGRESSION"})(Jh||(Jh={}));var od;(function(t){t.telephone={maxBitrate:12e3},t.speech={maxBitrate:24e3},t.music={maxBitrate:48e3},t.musicStereo={maxBitrate:64e3},t.musicHighQuality={maxBitrate:96e3},t.musicHighQualityStereo={maxBitrate:128e3}})(od||(od={}));const zs={h90:new je(160,90,9e4,20),h180:new je(320,180,16e4,20),h216:new je(384,216,18e4,20),h360:new je(640,360,45e4,20),h540:new je(960,540,8e5,25),h720:new je(1280,720,17e5,30),h1080:new je(1920,1080,3e6,30),h1440:new je(2560,1440,5e6,30),h2160:new je(3840,2160,8e6,30)},ad={h120:new je(160,120,7e4,20),h180:new je(240,180,125e3,20),h240:new je(320,240,14e4,20),h360:new je(480,360,33e4,20),h480:new je(640,480,5e5,20),h540:new je(720,540,6e5,25),h720:new je(960,720,13e5,30),h1080:new je(1440,1080,23e5,30),h1440:new je(1920,1440,38e5,30)},Mu={h360fps3:new je(640,360,2e5,3,"medium"),h360fps15:new je(640,360,4e5,15,"medium"),h720fps5:new je(1280,720,8e5,5,"medium"),h720fps15:new je(1280,720,15e5,15,"medium"),h720fps30:new je(1280,720,2e6,30,"medium"),h1080fps15:new je(1920,1080,25e5,15,"medium"),h1080fps30:new je(1920,1080,5e6,30,"medium"),original:new je(0,0,7e6,30,"medium")},Yk="|",Xh="https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension";function Jk(t){const e=t.split(Yk);return e.length>1?[e[0],t.substr(e[0].length+1)]:[t,""]}function jt(t){return A(this,void 0,void 0,function*(){return new Promise(e=>bt.setTimeout(e,t))})}function cd(){return"addTransceiver"in RTCPeerConnection.prototype}function ld(){return"addTrack"in RTCPeerConnection.prototype}function Xk(){if(!("getCapabilities"in RTCRtpSender)||Xi())return!1;const t=RTCRtpSender.getCapabilities("video");let e=!1;if(t){for(const n of t.codecs)if(n.mimeType==="video/AV1"){e=!0;break}}return e}function Qk(){if(!("getCapabilities"in RTCRtpSender)||qr())return!1;if(Xi()){const n=$t();if(n!=null&&n.version&&mi(n.version,"16")<0)return!1}const t=RTCRtpSender.getCapabilities("video");let e=!1;if(t){for(const n of t.codecs)if(n.mimeType==="video/VP9"){e=!0;break}}return e}function Kn(t){return t==="av1"||t==="vp9"}function dd(t){return document?(t||(t=document.createElement("audio")),"setSinkId"in t):!1}function eT(){return typeof RTCPeerConnection>"u"?!1:cd()||ld()}function qr(){var t;return((t=$t())===null||t===void 0?void 0:t.name)==="Firefox"}function Xi(){var t;return((t=$t())===null||t===void 0?void 0:t.name)==="Safari"}function Qh(){const t=$t();return(t==null?void 0:t.name)==="Safari"||(t==null?void 0:t.os)==="iOS"}function tT(){const t=$t();return(t==null?void 0:t.name)==="Safari"&&t.version.startsWith("17.")}function nT(t){return t||(t=$t()),(t==null?void 0:t.name)==="Safari"&&mi(t.version,"18.3")>0}function Xv(){var t,e;return Ot()?(e=(t=navigator.userAgentData)===null||t===void 0?void 0:t.mobile)!==null&&e!==void 0?e:/Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent):!1}function iT(){const t=$t(),e="17.2";if(t)return t.name!=="Safari"&&t.os!=="iOS"||t.os==="iOS"&&t.osVersion&&mi(e,t.osVersion)>=0?!0:t.name==="Safari"&&mi(e,t.version)>=0}function Ot(){return typeof document<"u"}function In(){return navigator.product=="ReactNative"}function ud(t){return t.hostname.endsWith(".livekit.cloud")||t.hostname.endsWith(".livekit.run")}function Qv(){if(global&&global.LiveKitReactNativeGlobal)return global.LiveKitReactNativeGlobal}function ey(){if(!In())return;let t=Qv();if(t)return t.platform}function em(){if(Ot())return window.devicePixelRatio;if(In()){let t=Qv();if(t)return t.devicePixelRatio}return 1}function mi(t,e){const n=t.split("."),i=e.split("."),r=Math.min(n.length,i.length);for(let s=0;s<r;++s){const o=parseInt(n[s],10),a=parseInt(i[s],10);if(o>a)return 1;if(o<a)return-1;if(s===r-1&&o===a)return 0}return t===""&&e!==""?-1:e===""?1:n.length==i.length?0:n.length<i.length?-1:1}function rT(t){for(const e of t)e.target.handleResize(e)}function sT(t){for(const e of t)e.target.handleVisibilityChanged(e)}let Fc=null;const tm=()=>(Fc||(Fc=new ResizeObserver(rT)),Fc);let Uc=null;const nm=()=>(Uc||(Uc=new IntersectionObserver(sT,{root:null,rootMargin:"0px"})),Uc);function oT(){var t;const e=new WC({sdk:rv.JS,protocol:Wk,version:zk});return In()&&(e.os=(t=ey())!==null&&t!==void 0?t:""),e}function im(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:16,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:16,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;const r=document.createElement("canvas");r.width=t,r.height=e;const s=r.getContext("2d");s==null||s.fillRect(0,0,r.width,r.height),i&&s&&(s.beginPath(),s.arc(t/2,e/2,50,0,Math.PI*2,!0),s.closePath(),s.fillStyle="grey",s.fill());const o=r.captureStream(),[a]=o.getTracks();if(!a)throw Error("Could not get empty media stream video track");return a.enabled=n,a}let Cs;function Bc(){if(!Cs){const t=new AudioContext,e=t.createOscillator(),n=t.createGain();n.gain.setValueAtTime(0,0);const i=t.createMediaStreamDestination();if(e.connect(n),n.connect(i),e.start(),[Cs]=i.stream.getAudioTracks(),!Cs)throw Error("Could not get empty media stream audio track");Cs.enabled=!1}return Cs.clone()}class Tr{constructor(e,n){this.onFinally=n,this.promise=new Promise((i,r)=>A(this,void 0,void 0,function*(){this.resolve=i,this.reject=r,e&&(yield e(i,r))})).finally(()=>{var i;return(i=this.onFinally)===null||i===void 0?void 0:i.call(this)})}}function aT(t,e){const n=Object.assign({cloneTrack:!1,fftSize:2048,smoothingTimeConstant:.8,minDecibels:-100,maxDecibels:-80},e),i=Nu();if(!i)throw new Error("Audio Context not supported on this browser");const r=n.cloneTrack?t.mediaStreamTrack.clone():t.mediaStreamTrack,s=i.createMediaStreamSource(new MediaStream([r])),o=i.createAnalyser();o.minDecibels=n.minDecibels,o.maxDecibels=n.maxDecibels,o.fftSize=n.fftSize,o.smoothingTimeConstant=n.smoothingTimeConstant,s.connect(o);const a=new Uint8Array(o.frequencyBinCount);return{calculateVolume:()=>{o.getByteFrequencyData(a);let d=0;for(const f of a)d+=Math.pow(f/255,2);return Math.sqrt(d/a.length)},analyser:o,cleanup:()=>A(this,void 0,void 0,function*(){yield i.close(),n.cloneTrack&&r.stop()})}}function cT(t){return Gk.includes(t)}function fi(t){if(typeof t=="string"||typeof t=="number")return t;if(Array.isArray(t))return t[0];if(t.exact)return Array.isArray(t.exact)?t.exact[0]:t.exact;if(t.ideal)return Array.isArray(t.ideal)?t.ideal[0]:t.ideal;throw Error("could not unwrap constraint")}function lT(t){return t.startsWith("http")?t.replace(/^(http)/,"ws"):t}function fd(t){return t.startsWith("ws")?t.replace(/^(ws)/,"http"):t}function dT(t,e){return t.segments.map(n=>{let{id:i,text:r,language:s,startTime:o,endTime:a,final:c}=n;var l;const d=(l=e.get(i))!==null&&l!==void 0?l:Date.now(),u=Date.now();return c?e.delete(i):e.set(i,d),{id:i,text:r,startTime:Number.parseInt(o.toString()),endTime:Number.parseInt(a.toString()),final:c,language:s,firstReceivedTime:d,lastReceivedTime:u}})}function uT(t){const{id:e,timestamp:n,message:i,editTimestamp:r}=t;return{id:e,timestamp:Number.parseInt(n.toString()),editTimestamp:r?Number.parseInt(r.toString()):void 0,message:i}}function rm(t){switch(t.reason){case Te.LeaveRequest:return t.context;case Te.Cancelled:return dn.CLIENT_INITIATED;case Te.NotAllowed:return dn.USER_REJECTED;case Te.ServerUnreachable:return dn.JOIN_FAILURE;default:return dn.UNKNOWN_REASON}}function ra(t){return t!==void 0?Number(t):void 0}function Li(t){return t!==void 0?BigInt(t):void 0}function jr(t){return!!t&&!(t instanceof MediaStreamTrack)&&t.isLocal}function Tn(t){return!!t&&t.kind==V.Kind.Audio}function ns(t){return!!t&&t.kind==V.Kind.Video}function ii(t){return jr(t)&&ns(t)}function Un(t){return jr(t)&&Tn(t)}function hd(t){return!!t&&!t.isLocal}function fT(t){return!!t&&!t.isLocal}function $c(t){return hd(t)&&ns(t)}function hT(t){return t.isLocal}function mT(t,e){const n=[];let i=new TextEncoder().encode(t);for(;i.length>e;){let r=e;for(;r>0;){const s=i[r];if(s!==void 0&&(s&192)!==128)break;r--}n.push(i.slice(0,r)),i=i.slice(r)}return i.length>0&&n.push(i),n}function ty(t,e,n){var i,r,s,o;const{optionsWithoutProcessor:a,audioProcessor:c,videoProcessor:l}=iy(t??{}),d=e==null?void 0:e.processor,u=n==null?void 0:n.processor,f=a??{};return f.audio===!0&&(f.audio={}),f.video===!0&&(f.video={}),f.audio&&(md(f.audio,e),(i=(s=f.audio).deviceId)!==null&&i!==void 0||(s.deviceId={ideal:"default"}),(c||d)&&(f.audio.processor=c??d)),f.video&&(md(f.video,n),(r=(o=f.video).deviceId)!==null&&r!==void 0||(o.deviceId={ideal:"default"}),(l||u)&&(f.video.processor=l??u)),f}function md(t,e){return Object.keys(e).forEach(n=>{t[n]===void 0&&(t[n]=e[n])}),t}function _u(t){var e,n,i,r;const s={};if(t.video)if(typeof t.video=="object"){const o={},a=o,c=t.video;Object.keys(c).forEach(l=>{switch(l){case"resolution":md(a,c.resolution);break;default:a[l]=c[l]}}),s.video=o,(e=(i=s.video).deviceId)!==null&&e!==void 0||(i.deviceId={ideal:"default"})}else s.video=t.video?{deviceId:{ideal:"default"}}:!1;else s.video=!1;return t.audio?typeof t.audio=="object"?(s.audio=t.audio,(n=(r=s.audio).deviceId)!==null&&n!==void 0||(r.deviceId={ideal:"default"})):s.audio={deviceId:{ideal:"default"}}:s.audio=!1,s}function ny(t){return A(this,arguments,void 0,function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:200;return function*(){const i=Nu();if(i){const r=i.createAnalyser();r.fftSize=2048;const s=r.frequencyBinCount,o=new Uint8Array(s);i.createMediaStreamSource(new MediaStream([e.mediaStreamTrack])).connect(r),yield jt(n),r.getByteTimeDomainData(o);const c=o.some(l=>l!==128&&l!==0);return i.close(),!c}return!1}()})}function Nu(){var t;const e=typeof window<"u"&&(window.AudioContext||window.webkitAudioContext);if(e){const n=new e({latencyHint:"interactive"});if(n.state==="suspended"&&typeof window<"u"&&(!((t=window.document)===null||t===void 0)&&t.body)){const i=()=>A(this,void 0,void 0,function*(){var r;try{n.state==="suspended"&&(yield n.resume())}catch(s){console.warn("Error trying to auto-resume audio context",s)}(r=window.document.body)===null||r===void 0||r.removeEventListener("click",i)});window.document.body.addEventListener("click",i)}return n}}function pT(t){return t==="audioinput"?V.Source.Microphone:t==="videoinput"?V.Source.Camera:V.Source.Unknown}function pd(t){return t===V.Source.Microphone?"audioinput":t===V.Source.Camera?"videoinput":void 0}function gT(t){var e,n;let i=(e=t.video)!==null&&e!==void 0?e:!0;return t.resolution&&t.resolution.width>0&&t.resolution.height>0&&(i=typeof i=="boolean"?{}:i,Xi()?i=Object.assign(Object.assign({},i),{width:{max:t.resolution.width},height:{max:t.resolution.height},frameRate:t.resolution.frameRate}):i=Object.assign(Object.assign({},i),{width:{ideal:t.resolution.width},height:{ideal:t.resolution.height},frameRate:t.resolution.frameRate})),{audio:(n=t.audio)!==null&&n!==void 0?n:!1,video:i,controller:t.controller,selfBrowserSurface:t.selfBrowserSurface,surfaceSwitching:t.surfaceSwitching,systemAudio:t.systemAudio,preferCurrentTab:t.preferCurrentTab}}function sa(t){return t.split("/")[1].toLowerCase()}function vT(t){const e=[];return t.forEach(n=>{n.track!==void 0&&e.push(new Eu({cid:n.track.mediaStreamID,track:n.trackInfo}))}),e}function we(t){return"mediaStreamTrack"in t?{trackID:t.sid,source:t.source,muted:t.isMuted,enabled:t.mediaStreamTrack.enabled,kind:t.kind,streamID:t.mediaStreamID,streamTrackID:t.mediaStreamTrack.id}:{trackID:t.trackSid,enabled:t.isEnabled,muted:t.isMuted,trackInfo:Object.assign({mimeType:t.mimeType,name:t.trackName,encrypted:t.isEncrypted,kind:t.kind,source:t.source},t.track?we(t.track):{})}}function yT(){return typeof RTCRtpReceiver<"u"&&"getSynchronizationSources"in RTCRtpReceiver}function bT(t,e){var n;t===void 0&&(t={}),e===void 0&&(e={});const i=[...Object.keys(e),...Object.keys(t)],r={};for(const s of i)t[s]!==e[s]&&(r[s]=(n=e[s])!==null&&n!==void 0?n:"");return r}function iy(t){const e=Object.assign({},t);let n,i;return typeof e.audio=="object"&&e.audio.processor&&(n=e.audio.processor,e.audio=Object.assign(Object.assign({},e.audio),{processor:void 0})),typeof e.video=="object"&&e.video.processor&&(i=e.video.processor,e.video=Object.assign(Object.assign({},e.video),{processor:void 0})),{audioProcessor:n,videoProcessor:i,optionsWithoutProcessor:Uk(e)}}function xT(t){switch(t){case lt.CAMERA:return V.Source.Camera;case lt.MICROPHONE:return V.Source.Microphone;case lt.SCREEN_SHARE:return V.Source.ScreenShare;case lt.SCREEN_SHARE_AUDIO:return V.Source.ScreenShareAudio;default:return V.Source.Unknown}}class ST extends Nn.EventEmitter{constructor(e){super(),this.onWorkerMessage=n=>{var i,r;const{kind:s,data:o}=n.data;switch(s){case"error":Ce.error(o.error.message),this.emit(di.EncryptionError,o.error);break;case"initAck":o.enabled&&this.keyProvider.getKeys().forEach(a=>{this.postKey(a)});break;case"enable":if(o.enabled&&this.keyProvider.getKeys().forEach(a=>{this.postKey(a)}),this.encryptionEnabled!==o.enabled&&o.participantIdentity===((i=this.room)===null||i===void 0?void 0:i.localParticipant.identity))this.emit(di.ParticipantEncryptionStatusChanged,o.enabled,this.room.localParticipant),this.encryptionEnabled=o.enabled;else if(o.participantIdentity){const a=(r=this.room)===null||r===void 0?void 0:r.getParticipantByIdentity(o.participantIdentity);if(!a)throw TypeError("couldn't set encryption status, participant not found".concat(o.participantIdentity));this.emit(di.ParticipantEncryptionStatusChanged,o.enabled,a)}break;case"ratchetKey":this.keyProvider.emit(ui.KeyRatcheted,o.ratchetResult,o.participantIdentity,o.keyIndex);break}},this.onWorkerError=n=>{Ce.error("e2ee worker encountered an error:",{error:n.error}),this.emit(di.EncryptionError,n.error)},this.keyProvider=e.keyProvider,this.worker=e.worker,this.encryptionEnabled=!1}setup(e){if(!Lk())throw new Iu("tried to setup end-to-end encryption on an unsupported browser");if(Ce.info("setting up e2ee"),e!==this.room){this.room=e,this.setupEventListeners(e,this.keyProvider);const n={kind:"init",data:{keyProviderOptions:this.keyProvider.getOptions(),loglevel:Sk.getLevel()}};this.worker&&(Ce.info("initializing worker",{worker:this.worker}),this.worker.onmessage=this.onWorkerMessage,this.worker.onerror=this.onWorkerError,this.worker.postMessage(n))}}setParticipantCryptorEnabled(e,n){Ce.debug("set e2ee to ".concat(e," for participant ").concat(n)),this.postEnable(e,n)}setSifTrailer(e){!e||e.length===0?Ce.warn("ignoring server sent trailer as it's empty"):this.postSifTrailer(e)}setupEngine(e){e.on(ae.RTPVideoMapUpdate,n=>{this.postRTPMap(n)})}setupEventListeners(e,n){e.on(U.TrackPublished,(i,r)=>this.setParticipantCryptorEnabled(i.trackInfo.encryption!==Ft.NONE,r.identity)),e.on(U.ConnectionStateChanged,i=>{i===ge.Connected&&e.remoteParticipants.forEach(r=>{r.trackPublications.forEach(s=>{this.setParticipantCryptorEnabled(s.trackInfo.encryption!==Ft.NONE,r.identity)})})}).on(U.TrackUnsubscribed,(i,r,s)=>{var o;const a={kind:"removeTransform",data:{participantIdentity:s.identity,trackId:i.mediaStreamID}};(o=this.worker)===null||o===void 0||o.postMessage(a)}).on(U.TrackSubscribed,(i,r,s)=>{this.setupE2EEReceiver(i,s.identity,r.trackInfo)}).on(U.SignalConnected,()=>{if(!this.room)throw new TypeError("expected room to be present on signal connect");n.getKeys().forEach(i=>{this.postKey(i)}),this.setParticipantCryptorEnabled(this.room.localParticipant.isE2EEEnabled,this.room.localParticipant.identity)}),e.localParticipant.on(Z.LocalTrackPublished,i=>A(this,void 0,void 0,function*(){this.setupE2EESender(i.track,i.track.sender)})),n.on(ui.SetKey,i=>this.postKey(i)).on(ui.RatchetRequest,(i,r)=>this.postRatchetRequest(i,r))}postRatchetRequest(e,n){if(!this.worker)throw Error("could not ratchet key, worker is missing");const i={kind:"ratchetRequest",data:{participantIdentity:e,keyIndex:n}};this.worker.postMessage(i)}postKey(e){let{key:n,participantIdentity:i,keyIndex:r}=e;var s;if(!this.worker)throw Error("could not set key, worker is missing");const o={kind:"setKey",data:{participantIdentity:i,isPublisher:i===((s=this.room)===null||s===void 0?void 0:s.localParticipant.identity),key:n,keyIndex:r}};this.worker.postMessage(o)}postEnable(e,n){if(this.worker){const i={kind:"enable",data:{enabled:e,participantIdentity:n}};this.worker.postMessage(i)}else throw new ReferenceError("failed to enable e2ee, worker is not ready")}postRTPMap(e){var n;if(!this.worker)throw TypeError("could not post rtp map, worker is missing");if(!(!((n=this.room)===null||n===void 0)&&n.localParticipant.identity))throw TypeError("could not post rtp map, local participant identity is missing");const i={kind:"setRTPMap",data:{map:e,participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(i)}postSifTrailer(e){if(!this.worker)throw Error("could not post SIF trailer, worker is missing");const n={kind:"setSifTrailer",data:{trailer:e}};this.worker.postMessage(n)}setupE2EEReceiver(e,n,i){if(e.receiver){if(!(i!=null&&i.mimeType)||i.mimeType==="")throw new TypeError("MimeType missing from trackInfo, cannot set up E2EE cryptor");this.handleReceiver(e.receiver,e.mediaStreamID,n,e.kind==="video"?sa(i.mimeType):void 0)}}setupE2EESender(e,n){if(!jr(e)||!n){n||Ce.warn("early return because sender is not ready");return}this.handleSender(n,e.mediaStreamID,void 0)}handleReceiver(e,n,i,r){return A(this,void 0,void 0,function*(){if(this.worker){if(rd()){const s={kind:"decode",participantIdentity:i,trackId:n,codec:r};e.transform=new RTCRtpScriptTransform(this.worker,s)}else{if(Ss in e&&r){const c={kind:"updateCodec",data:{trackId:n,codec:r,participantIdentity:i}};this.worker.postMessage(c);return}let s=e.writableStream,o=e.readableStream;if(!s||!o){const c=e.createEncodedStreams();e.writableStream=c.writable,s=c.writable,e.readableStream=c.readable,o=c.readable}const a={kind:"decode",data:{readableStream:o,writableStream:s,trackId:n,codec:r,participantIdentity:i,isReuse:Ss in e}};this.worker.postMessage(a,[o,s])}e[Ss]=!0}})}handleSender(e,n,i){var r;if(!(Ss in e||!this.worker)){if(!(!((r=this.room)===null||r===void 0)&&r.localParticipant.identity)||this.room.localParticipant.identity==="")throw TypeError("local identity needs to be known in order to set up encrypted sender");if(rd()){Ce.info("initialize script transform");const s={kind:"encode",participantIdentity:this.room.localParticipant.identity,trackId:n,codec:i};e.transform=new RTCRtpScriptTransform(this.worker,s)}else{Ce.info("initialize encoded streams");const s=e.createEncodedStreams(),o={kind:"encode",data:{readableStream:s.readable,writableStream:s.writable,codec:i,trackId:n,participantIdentity:this.room.localParticipant.identity,isReuse:!1}};this.worker.postMessage(o,[s.readable,s.writable])}e[Ss]=!0}}}const Hc="default";class gt{constructor(){this._previousDevices=[]}static getInstance(){return this.instance===void 0&&(this.instance=new gt),this.instance}get previousDevices(){return this._previousDevices}getDevices(e){return A(this,arguments,void 0,function(n){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){var s;if(((s=gt.userMediaPromiseMap)===null||s===void 0?void 0:s.size)>0){Ce.debug("awaiting getUserMedia promise");try{n?yield gt.userMediaPromiseMap.get(n):yield Promise.all(gt.userMediaPromiseMap.values())}catch{Ce.warn("error waiting for media permissons")}}let o=yield navigator.mediaDevices.enumerateDevices();if(r&&!(Xi()&&i.hasDeviceInUse(n))&&(o.filter(c=>c.kind===n).length===0||o.some(c=>{const l=c.label==="",d=n?c.kind===n:!0;return l&&d}))){const c={video:n!=="audioinput"&&n!=="audiooutput",audio:n!=="videoinput"&&{deviceId:{ideal:"default"}}},l=yield navigator.mediaDevices.getUserMedia(c);o=yield navigator.mediaDevices.enumerateDevices(),l.getTracks().forEach(d=>{d.stop()})}return i._previousDevices=o,n&&(o=o.filter(a=>a.kind===n)),o}()})}normalizeDeviceId(e,n,i){return A(this,void 0,void 0,function*(){if(n!==Hc)return n;const r=yield this.getDevices(e),s=r.find(a=>a.deviceId===Hc);if(!s){Ce.warn("could not reliably determine default device");return}const o=r.find(a=>a.deviceId!==Hc&&a.groupId===(i??s.groupId));if(!o){Ce.warn("could not reliably determine default device");return}return o==null?void 0:o.deviceId})}hasDeviceInUse(e){return e?gt.userMediaPromiseMap.has(e):gt.userMediaPromiseMap.size>0}}gt.mediaDeviceKinds=["audioinput","audiooutput","videoinput"];gt.userMediaPromiseMap=new Map;var Ls;(function(t){t[t.WAITING=0]="WAITING",t[t.RUNNING=1]="RUNNING",t[t.COMPLETED=2]="COMPLETED"})(Ls||(Ls={}));class wT{constructor(){this.pendingTasks=new Map,this.taskMutex=new Nt,this.nextTaskIndex=0}run(e){return A(this,void 0,void 0,function*(){const n={id:this.nextTaskIndex++,enqueuedAt:Date.now(),status:Ls.WAITING};this.pendingTasks.set(n.id,n);const i=yield this.taskMutex.lock();try{return n.executedAt=Date.now(),n.status=Ls.RUNNING,yield e()}finally{n.status=Ls.COMPLETED,this.pendingTasks.delete(n.id),i()}})}flush(){return A(this,void 0,void 0,function*(){return this.run(()=>A(this,void 0,void 0,function*(){}))})}snapshot(){return Array.from(this.pendingTasks.values())}}function CT(t,e){const n=new URL(lT(t));return e.forEach((i,r)=>{n.searchParams.set(r,i)}),ry(n,"rtc")}function kT(t){const e=new URL(fd(t));return ry(e,"validate")}function TT(t){return t.endsWith("/")?t:"".concat(t,"/")}function ry(t,e){return t.pathname="".concat(TT(t.pathname)).concat(e),t.toString()}const ET=["syncState","trickle","offer","answer","simulate","leave"];function PT(t){const e=ET.indexOf(t.case)>=0;return Ce.trace("request allowed to bypass queue:",{canPass:e,req:t}),e}var Be;(function(t){t[t.CONNECTING=0]="CONNECTING",t[t.CONNECTED=1]="CONNECTED",t[t.RECONNECTING=2]="RECONNECTING",t[t.DISCONNECTING=3]="DISCONNECTING",t[t.DISCONNECTED=4]="DISCONNECTED"})(Be||(Be={}));class Ou{get currentState(){return this.state}get isDisconnected(){return this.state===Be.DISCONNECTING||this.state===Be.DISCONNECTED}get isEstablishingConnection(){return this.state===Be.CONNECTING||this.state===Be.RECONNECTING}getNextRequestId(){return this._requestId+=1,this._requestId}constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var i;this.rtt=0,this.state=Be.DISCONNECTED,this.log=Ce,this._requestId=0,this.resetCallbacks=()=>{this.onAnswer=void 0,this.onLeave=void 0,this.onLocalTrackPublished=void 0,this.onLocalTrackUnpublished=void 0,this.onNegotiateRequested=void 0,this.onOffer=void 0,this.onRemoteMuteChanged=void 0,this.onSubscribedQualityUpdate=void 0,this.onTokenRefresh=void 0,this.onTrickle=void 0,this.onClose=void 0},this.log=Gn((i=n.loggerName)!==null&&i!==void 0?i:fn.Signal),this.loggerContextCb=n.loggerContextCb,this.useJSON=e,this.requestQueue=new wT,this.queuedRequests=[],this.closingLock=new Nt,this.connectionLock=new Nt,this.state=Be.DISCONNECTED}get logContext(){var e,n;return(n=(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this))!==null&&n!==void 0?n:{}}join(e,n,i,r){return A(this,void 0,void 0,function*(){return this.state=Be.CONNECTING,this.options=i,yield this.connect(e,n,i,r)})}reconnect(e,n,i,r){return A(this,void 0,void 0,function*(){if(!this.options){this.log.warn("attempted to reconnect without signal options being set, ignoring",this.logContext);return}return this.state=Be.RECONNECTING,this.clearPingInterval(),yield this.connect(e,n,Object.assign(Object.assign({},this.options),{reconnect:!0,sid:i,reconnectReason:r}))})}connect(e,n,i,r){this.connectOptions=i;const s=oT(),o=RT(n,s,i),a=CT(e,o),c=kT(a);return new Promise((l,d)=>A(this,void 0,void 0,function*(){const u=yield this.connectionLock.lock();try{const f=()=>A(this,void 0,void 0,function*(){this.close(),clearTimeout(p),d(new Ue("room connection has been cancelled (signal)",Te.Cancelled))}),p=setTimeout(()=>{this.close(),d(new Ue("room connection has timed out (signal)",Te.ServerUnreachable))},i.websocketTimeout);r!=null&&r.aborted&&f(),r==null||r.addEventListener("abort",f);const v=new URL(a);v.searchParams.has("access_token")&&v.searchParams.set("access_token","<redacted>"),this.log.debug("connecting to ".concat(v),Object.assign({reconnect:i.reconnect,reconnectReason:i.reconnectReason},this.logContext)),this.ws&&(yield this.close(!1)),this.ws=new WebSocket(a),this.ws.binaryType="arraybuffer",this.ws.onopen=()=>{clearTimeout(p)},this.ws.onerror=h=>A(this,void 0,void 0,function*(){if(this.state!==Be.CONNECTED){this.state=Be.DISCONNECTED,clearTimeout(p);try{const y=yield fetch(c);if(y.status.toFixed(0).startsWith("4")){const b=yield y.text();d(new Ue(b,Te.NotAllowed,y.status))}else d(new Ue("Encountered unknown websocket error during connection: ".concat(h.toString()),Te.InternalError,y.status))}catch(y){d(new Ue(y instanceof Error?y.message:"server was not reachable",Te.ServerUnreachable))}return}this.handleWSError(h)}),this.ws.onmessage=h=>A(this,void 0,void 0,function*(){var y,b,w;let C;if(typeof h.data=="string"){const S=JSON.parse(h.data);C=Dh.fromJson(S,{ignoreUnknownFields:!0})}else if(h.data instanceof ArrayBuffer)C=Dh.fromBinary(new Uint8Array(h.data));else{this.log.error("could not decode websocket message: ".concat(typeof h.data),this.logContext);return}if(this.state!==Be.CONNECTED){let S=!1;if(((y=C.message)===null||y===void 0?void 0:y.case)==="join"?(this.state=Be.CONNECTED,r==null||r.removeEventListener("abort",f),this.pingTimeoutDuration=C.message.value.pingTimeout,this.pingIntervalDuration=C.message.value.pingInterval,this.pingTimeoutDuration&&this.pingTimeoutDuration>0&&(this.log.debug("ping config",Object.assign(Object.assign({},this.logContext),{timeout:this.pingTimeoutDuration,interval:this.pingIntervalDuration})),this.startPingInterval()),l(C.message.value)):this.state===Be.RECONNECTING&&C.message.case!=="leave"?(this.state=Be.CONNECTED,r==null||r.removeEventListener("abort",f),this.startPingInterval(),((b=C.message)===null||b===void 0?void 0:b.case)==="reconnect"?l(C.message.value):(this.log.debug("declaring signal reconnected without reconnect response received",this.logContext),l(void 0),S=!0)):this.isEstablishingConnection&&C.message.case==="leave"?d(new Ue("Received leave request while trying to (re)connect",Te.LeaveRequest,void 0,C.message.value.reason)):i.reconnect||d(new Ue("did not receive join response, got ".concat((w=C.message)===null||w===void 0?void 0:w.case," instead"),Te.InternalError)),!S)return}this.signalLatency&&(yield jt(this.signalLatency)),this.handleSignalResponse(C)}),this.ws.onclose=h=>{this.isEstablishingConnection&&d(new Ue("Websocket got closed during a (re)connection attempt",Te.InternalError)),this.log.warn("websocket closed",Object.assign(Object.assign({},this.logContext),{reason:h.reason,code:h.code,wasClean:h.wasClean,state:this.state})),this.handleOnClose(h.reason)}}finally{u()}}))}close(){return A(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){const i=yield e.closingLock.lock();try{if(e.clearPingInterval(),n&&(e.state=Be.DISCONNECTING),e.ws){e.ws.onmessage=null,e.ws.onopen=null,e.ws.onclose=null;const r=new Promise(s=>{e.ws?e.ws.onclose=()=>{s()}:s()});e.ws.readyState<e.ws.CLOSING&&(e.ws.close(),yield Promise.race([r,jt(250)])),e.ws=void 0}}finally{n&&(e.state=Be.DISCONNECTED),i()}}()})}sendOffer(e,n){this.log.debug("sending offer",Object.assign(Object.assign({},this.logContext),{offerSdp:e.sdp})),this.sendRequest({case:"offer",value:ka(e,n)})}sendAnswer(e,n){return this.log.debug("sending answer",Object.assign(Object.assign({},this.logContext),{answerSdp:e.sdp})),this.sendRequest({case:"answer",value:ka(e,n)})}sendIceCandidate(e,n){return this.log.debug("sending ice candidate",Object.assign(Object.assign({},this.logContext),{candidate:e})),this.sendRequest({case:"trickle",value:new ku({candidateInit:JSON.stringify(e),target:n})})}sendMuteTrack(e,n){return this.sendRequest({case:"mute",value:new Tu({sid:e,muted:n})})}sendAddTrack(e){return this.sendRequest({case:"addTrack",value:e})}sendUpdateLocalMetadata(e,n){return A(this,arguments,void 0,function(i,r){var s=this;let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return function*(){const a=s.getNextRequestId();return yield s.sendRequest({case:"updateMetadata",value:new fv({requestId:a,metadata:i,name:r,attributes:o})}),a}()})}sendUpdateTrackSettings(e){this.sendRequest({case:"trackSetting",value:e})}sendUpdateSubscription(e){return this.sendRequest({case:"subscription",value:e})}sendSyncState(e){return this.sendRequest({case:"syncState",value:e})}sendUpdateVideoLayers(e,n){return this.sendRequest({case:"updateLayers",value:new uv({trackSid:e,layers:n})})}sendUpdateSubscriptionPermissions(e,n){return this.sendRequest({case:"subscriptionPermission",value:new pv({allParticipants:e,trackPermissions:n})})}sendSimulateScenario(e){return this.sendRequest({case:"simulate",value:e})}sendPing(){return Promise.all([this.sendRequest({case:"ping",value:ze.parse(Date.now())}),this.sendRequest({case:"pingReq",value:new bv({timestamp:ze.parse(Date.now()),rtt:ze.parse(this.rtt)})})])}sendUpdateLocalAudioTrack(e,n){return this.sendRequest({case:"updateAudioTrack",value:new dv({trackSid:e,features:n})})}sendLeave(){return this.sendRequest({case:"leave",value:new Ya({reason:dn.CLIENT_INITIATED,action:Nr.DISCONNECT})})}sendRequest(e){return A(this,arguments,void 0,function(n){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return function*(){if(!r&&!PT(n)&&i.state===Be.RECONNECTING){i.queuedRequests.push(()=>A(i,void 0,void 0,function*(){yield this.sendRequest(n,!0)}));return}if(r||(yield i.requestQueue.flush()),i.signalLatency&&(yield jt(i.signalLatency)),!i.ws||i.ws.readyState!==i.ws.OPEN){i.log.error("cannot send signal request before connected, type: ".concat(n==null?void 0:n.case),i.logContext);return}const o=new GC({message:n});try{i.useJSON?i.ws.send(o.toJsonString()):i.ws.send(o.toBinary())}catch(a){i.log.error("error sending signal message",Object.assign(Object.assign({},i.logContext),{error:a}))}}()})}handleSignalResponse(e){var n,i;const r=e.message;if(r==null){this.log.debug("received unsupported message",this.logContext);return}let s=!1;if(r.case==="answer"){const o=sm(r.value);this.onAnswer&&this.onAnswer(o,r.value.id)}else if(r.case==="offer"){const o=sm(r.value);this.onOffer&&this.onOffer(o,r.value.id)}else if(r.case==="trickle"){const o=JSON.parse(r.value.candidateInit);this.onTrickle&&this.onTrickle(o,r.value.target)}else r.case==="update"?this.onParticipantUpdate&&this.onParticipantUpdate((n=r.value.participants)!==null&&n!==void 0?n:[]):r.case==="trackPublished"?this.onLocalTrackPublished&&this.onLocalTrackPublished(r.value):r.case==="speakersChanged"?this.onSpeakersChanged&&this.onSpeakersChanged((i=r.value.speakers)!==null&&i!==void 0?i:[]):r.case==="leave"?this.onLeave&&this.onLeave(r.value):r.case==="mute"?this.onRemoteMuteChanged&&this.onRemoteMuteChanged(r.value.sid,r.value.muted):r.case==="roomUpdate"?this.onRoomUpdate&&r.value.room&&this.onRoomUpdate(r.value.room):r.case==="connectionQuality"?this.onConnectionQuality&&this.onConnectionQuality(r.value):r.case==="streamStateUpdate"?this.onStreamStateUpdate&&this.onStreamStateUpdate(r.value):r.case==="subscribedQualityUpdate"?this.onSubscribedQualityUpdate&&this.onSubscribedQualityUpdate(r.value):r.case==="subscriptionPermissionUpdate"?this.onSubscriptionPermissionUpdate&&this.onSubscriptionPermissionUpdate(r.value):r.case==="refreshToken"?this.onTokenRefresh&&this.onTokenRefresh(r.value):r.case==="trackUnpublished"?this.onLocalTrackUnpublished&&this.onLocalTrackUnpublished(r.value):r.case==="subscriptionResponse"?this.onSubscriptionError&&this.onSubscriptionError(r.value):r.case==="pong"||(r.case==="pongResp"?(this.rtt=Date.now()-Number.parseInt(r.value.lastPingTimestamp.toString()),this.resetPingTimeout(),s=!0):r.case==="requestResponse"?this.onRequestResponse&&this.onRequestResponse(r.value):r.case==="trackSubscribed"?this.onLocalTrackSubscribed&&this.onLocalTrackSubscribed(r.value.trackSid):r.case==="roomMoved"?(this.onTokenRefresh&&this.onTokenRefresh(r.value.token),this.onRoomMoved&&this.onRoomMoved(r.value)):this.log.debug("unsupported message",Object.assign(Object.assign({},this.logContext),{msgCase:r.case})));s||this.resetPingTimeout()}setReconnected(){for(;this.queuedRequests.length>0;){const e=this.queuedRequests.shift();e&&this.requestQueue.run(e)}}handleOnClose(e){return A(this,void 0,void 0,function*(){if(this.state===Be.DISCONNECTED)return;const n=this.onClose;yield this.close(),this.log.debug("websocket connection closed: ".concat(e),Object.assign(Object.assign({},this.logContext),{reason:e})),n&&n(e)})}handleWSError(e){this.log.error("websocket error",Object.assign(Object.assign({},this.logContext),{error:e}))}resetPingTimeout(){if(this.clearPingTimeout(),!this.pingTimeoutDuration){this.log.warn("ping timeout duration not set",this.logContext);return}this.pingTimeout=bt.setTimeout(()=>{this.log.warn("ping timeout triggered. last pong received at: ".concat(new Date(Date.now()-this.pingTimeoutDuration*1e3).toUTCString()),this.logContext),this.handleOnClose("ping timeout")},this.pingTimeoutDuration*1e3)}clearPingTimeout(){this.pingTimeout&&bt.clearTimeout(this.pingTimeout)}startPingInterval(){if(this.clearPingInterval(),this.resetPingTimeout(),!this.pingIntervalDuration){this.log.warn("ping interval duration not set",this.logContext);return}this.log.debug("start ping interval",this.logContext),this.pingInterval=bt.setInterval(()=>{this.sendPing()},this.pingIntervalDuration*1e3)}clearPingInterval(){this.log.debug("clearing ping interval",this.logContext),this.clearPingTimeout(),this.pingInterval&&bt.clearInterval(this.pingInterval)}}function sm(t){const e={type:"offer",sdp:t.sdp};switch(t.type){case"answer":case"offer":case"pranswer":case"rollback":e.type=t.type;break}return e}function ka(t,e){return new Ji({sdp:t.sdp,type:t.type,id:e})}function RT(t,e,n){var i;const r=new URLSearchParams;return r.set("access_token",t),n.reconnect&&(r.set("reconnect","1"),n.sid&&r.set("sid",n.sid)),r.set("auto_subscribe",n.autoSubscribe?"1":"0"),r.set("sdk",In()?"reactnative":"js"),r.set("version",e.version),r.set("protocol",e.protocol.toString()),e.deviceModel&&r.set("device_model",e.deviceModel),e.os&&r.set("os",e.os),e.osVersion&&r.set("os_version",e.osVersion),e.browser&&r.set("browser",e.browser),e.browserVersion&&r.set("browser_version",e.browserVersion),n.adaptiveStream&&r.set("adaptive_stream","1"),n.reconnectReason&&r.set("reconnect_reason",n.reconnectReason.toString()),!((i=navigator.connection)===null||i===void 0)&&i.type&&r.set("network",navigator.connection.type),r}class om{constructor(){this.buffer=[],this._totalSize=0}push(e){this.buffer.push(e),this._totalSize+=e.data.byteLength}pop(){const e=this.buffer.shift();return e&&(this._totalSize-=e.data.byteLength),e}getAll(){return this.buffer.slice()}popToSequence(e){for(;this.buffer.length>0&&this.buffer[0].sequence<=e;)this.pop()}alignBufferedAmount(e){for(;this.buffer.length>0;){const n=this.buffer[0];if(this._totalSize-n.data.byteLength<=e)break;this.pop()}}get length(){return this.buffer.length}}class AT{constructor(e){this._map=new Map,this._lastCleanup=0,this.ttl=e}set(e,n){const i=Date.now();i-this._lastCleanup>this.ttl/2&&this.cleanup();const r=i+this.ttl;return this._map.set(e,{value:n,expiresAt:r}),this}get(e){const n=this._map.get(e);if(n){if(n.expiresAt<Date.now()){this._map.delete(e);return}return n.value}}has(e){const n=this._map.get(e);return n?n.expiresAt<Date.now()?(this._map.delete(e),!1):!0:!1}delete(e){return this._map.delete(e)}clear(){this._map.clear()}cleanup(){const e=Date.now();for(const[n,i]of this._map.entries())i.expiresAt<e&&this._map.delete(n);this._lastCleanup=e}get size(){return this.cleanup(),this._map.size}forEach(e){this.cleanup();for(const[n,i]of this._map.entries())i.expiresAt>=Date.now()&&e(i.value,n,this.asValueMap())}map(e){this.cleanup();const n=[],i=this.asValueMap();for(const[r,s]of i.entries())n.push(e(s,r,i));return n}asValueMap(){const e=new Map;for(const[n,i]of this._map.entries())i.expiresAt>=Date.now()&&e.set(n,i.value);return e}}var nn={},zc={},Wc={exports:{}},am;function Du(){if(am)return Wc.exports;am=1;var t=Wc.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return e.address!=null?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return e.subtype!=null?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return e.sessionConfig!=null?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var n="candidate:%s %d %s %d %s %d typ %s";return n+=e.raddr!=null?" raddr %s rport %d":"%v%v",n+=e.tcptype!=null?" tcptype %s":"%v",e.generation!=null&&(n+=" generation %d"),n+=e["network-id"]!=null?" network-id %d":"%v",n+=e["network-cost"]!=null?" network-cost %d":"%v",n}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var n="ssrc:%d";return e.attribute!=null&&(n+=" %s",e.value!=null&&(n+=":%s")),n}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return e.maxMessageSize!=null?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(e.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var n="mediaclk:";return n+=e.id!=null?"id=%s %s":"%v%s",n+=e.mediaClockValue!=null?"=%s":"",n+=e.rateNumerator!=null?" rate=%s":"",n+=e.rateDenominator!=null?"/%s":"",n}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};return Object.keys(t).forEach(function(e){var n=t[e];n.forEach(function(i){i.reg||(i.reg=/(.*)/),i.format||(i.format="%s")})}),Wc.exports}var cm;function IT(){return cm||(cm=1,function(t){var e=function(a){return String(Number(a))===a?Number(a):a},n=function(a,c,l,d){if(d&&!l)c[d]=e(a[1]);else for(var u=0;u<l.length;u+=1)a[u+1]!=null&&(c[l[u]]=e(a[u+1]))},i=function(a,c,l){var d=a.name&&a.names;a.push&&!c[a.push]?c[a.push]=[]:d&&!c[a.name]&&(c[a.name]={});var u=a.push?{}:d?c[a.name]:c;n(l.match(a.reg),u,a.names,a.name),a.push&&c[a.push].push(u)},r=Du(),s=RegExp.prototype.test.bind(/^([a-z])=(.*)/);t.parse=function(a){var c={},l=[],d=c;return a.split(/(\r\n|\r|\n)/).filter(s).forEach(function(u){var f=u[0],p=u.slice(2);f==="m"&&(l.push({rtp:[],fmtp:[]}),d=l[l.length-1]);for(var v=0;v<(r[f]||[]).length;v+=1){var h=r[f][v];if(h.reg.test(p))return i(h,d,p)}}),c.media=l,c};var o=function(a,c){var l=c.split(/=(.+)/,2);return l.length===2?a[l[0]]=e(l[1]):l.length===1&&c.length>1&&(a[l[0]]=void 0),a};t.parseParams=function(a){return a.split(/;\s?/).reduce(o,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(a){return a.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(a){for(var c=[],l=a.split(" ").map(e),d=0;d<l.length;d+=3)c.push({component:l[d],ip:l[d+1],port:l[d+2]});return c},t.parseImageAttributes=function(a){return a.split(" ").map(function(c){return c.substring(1,c.length-1).split(",").reduce(o,{})})},t.parseSimulcastStreamList=function(a){return a.split(";").map(function(c){return c.split(",").map(function(l){var d,u=!1;return l[0]!=="~"?d=e(l):(d=e(l.substring(1,l.length)),u=!0),{scid:d,paused:u}})})}}(zc)),zc}var qc,lm;function MT(){if(lm)return qc;lm=1;var t=Du(),e=/%[sdv%]/g,n=function(o){var a=1,c=arguments,l=c.length;return o.replace(e,function(d){if(a>=l)return d;var u=c[a];switch(a+=1,d){case"%%":return"%";case"%s":return String(u);case"%d":return Number(u);case"%v":return""}})},i=function(o,a,c){var l=a.format instanceof Function?a.format(a.push?c:c[a.name]):a.format,d=[o+"="+l];if(a.names)for(var u=0;u<a.names.length;u+=1){var f=a.names[u];a.name?d.push(c[a.name][f]):d.push(c[a.names[u]])}else d.push(c[a.name]);return n.apply(null,d)},r=["v","o","s","i","u","e","p","c","b","t","r","z","a"],s=["i","c","b","a"];return qc=function(o,a){a=a||{},o.version==null&&(o.version=0),o.name==null&&(o.name=" "),o.media.forEach(function(u){u.payloads==null&&(u.payloads="")});var c=a.outerOrder||r,l=a.innerOrder||s,d=[];return c.forEach(function(u){t[u].forEach(function(f){f.name in o&&o[f.name]!=null?d.push(i(u,f,o)):f.push in o&&o[f.push]!=null&&o[f.push].forEach(function(p){d.push(i(u,f,p))})})}),o.media.forEach(function(u){d.push(i("m",t.m[0],u)),l.forEach(function(f){t[f].forEach(function(p){p.name in u&&u[p.name]!=null?d.push(i(f,p,u)):p.push in u&&u[p.push]!=null&&u[p.push].forEach(function(v){d.push(i(f,p,v))})})})}),d.join(`\r
|
|
66
|
-
`)+`\r
|
|
67
|
-
`},qc}var dm;function _T(){if(dm)return nn;dm=1;var t=IT(),e=MT(),n=Du();return nn.grammar=n,nn.write=e,nn.parse=t.parse,nn.parseParams=t.parseParams,nn.parseFmtpConfig=t.parseFmtpConfig,nn.parsePayloads=t.parsePayloads,nn.parseRemoteCandidates=t.parseRemoteCandidates,nn.parseImageAttributes=t.parseImageAttributes,nn.parseSimulcastStreamList=t.parseSimulcastStreamList,nn}var si=_T();function ju(t,e,n){var i,r,s;e===void 0&&(e=50),n===void 0&&(n={});var o=(i=n.isImmediate)!=null&&i,a=(r=n.callback)!=null&&r,c=n.maxWait,l=Date.now(),d=[];function u(){if(c!==void 0){var p=Date.now()-l;if(p+e>=c)return c-p}return e}var f=function(){var p=[].slice.call(arguments),v=this;return new Promise(function(h,y){var b=o&&s===void 0;if(s!==void 0&&clearTimeout(s),s=setTimeout(function(){if(s=void 0,l=Date.now(),!o){var C=t.apply(v,p);a&&a(C),d.forEach(function(S){return(0,S.resolve)(C)}),d=[]}},u()),b){var w=t.apply(v,p);return a&&a(w),h(w)}d.push({resolve:h,reject:y})})};return f.cancel=function(p){s!==void 0&&clearTimeout(s),d.forEach(function(v){return(0,v.reject)(p)}),d=[]},f}const NT=.7,OT=20,Lr={NegotiationStarted:"negotiationStarted",NegotiationComplete:"negotiationComplete",RTPVideoPayloadTypes:"rtpVideoPayloadTypes"};class um extends Nn.EventEmitter{get pc(){return this._pc||(this._pc=this.createPC()),this._pc}constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var i;super(),this.log=Ce,this.ddExtID=0,this.latestOfferId=0,this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate=!1,this.trackBitrates=[],this.remoteStereoMids=[],this.remoteNackMids=[],this.negotiate=ju(r=>A(this,void 0,void 0,function*(){this.emit(Lr.NegotiationStarted);try{yield this.createAndSendOffer()}catch(s){if(r)r(s);else throw s}}),OT),this.close=()=>{this._pc&&(this._pc.close(),this._pc.onconnectionstatechange=null,this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.ondatachannel=null,this._pc.onnegotiationneeded=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ondatachannel=null,this._pc.ontrack=null,this._pc.onconnectionstatechange=null,this._pc.oniceconnectionstatechange=null,this._pc=null)},this.log=Gn((i=n.loggerName)!==null&&i!==void 0?i:fn.PCTransport),this.loggerOptions=n,this.config=e,this._pc=this.createPC()}createPC(){const e=new RTCPeerConnection(this.config);return e.onicecandidate=n=>{var i;n.candidate&&((i=this.onIceCandidate)===null||i===void 0||i.call(this,n.candidate))},e.onicecandidateerror=n=>{var i;(i=this.onIceCandidateError)===null||i===void 0||i.call(this,n)},e.oniceconnectionstatechange=()=>{var n;(n=this.onIceConnectionStateChange)===null||n===void 0||n.call(this,e.iceConnectionState)},e.onsignalingstatechange=()=>{var n;(n=this.onSignalingStatechange)===null||n===void 0||n.call(this,e.signalingState)},e.onconnectionstatechange=()=>{var n;(n=this.onConnectionStateChange)===null||n===void 0||n.call(this,e.connectionState)},e.ondatachannel=n=>{var i;(i=this.onDataChannel)===null||i===void 0||i.call(this,n)},e.ontrack=n=>{var i;(i=this.onTrack)===null||i===void 0||i.call(this,n)},e}get logContext(){var e,n;return Object.assign({},(n=(e=this.loggerOptions).loggerContextCb)===null||n===void 0?void 0:n.call(e))}get isICEConnected(){return this._pc!==null&&(this.pc.iceConnectionState==="connected"||this.pc.iceConnectionState==="completed")}addIceCandidate(e){return A(this,void 0,void 0,function*(){if(this.pc.remoteDescription&&!this.restartingIce)return this.pc.addIceCandidate(e);this.pendingCandidates.push(e)})}setRemoteDescription(e,n){return A(this,void 0,void 0,function*(){var i;if(e.type==="answer"&&this.latestOfferId>0&&n>0&&n!==this.latestOfferId)return this.log.warn("ignoring answer for old offer",Object.assign(Object.assign({},this.logContext),{offerId:n,latestOfferId:this.latestOfferId})),!1;let r;if(e.type==="offer"){let{stereoMids:s,nackMids:o}=DT(e);this.remoteStereoMids=s,this.remoteNackMids=o}else if(e.type==="answer"){const s=si.parse((i=e.sdp)!==null&&i!==void 0?i:"");s.media.forEach(o=>{o.type==="audio"&&this.trackBitrates.some(a=>{if(!a.transceiver||o.mid!=a.transceiver.mid)return!1;let c=0;if(o.rtp.some(d=>d.codec.toUpperCase()===a.codec.toUpperCase()?(c=d.payload,!0):!1),c===0)return!0;let l=!1;for(const d of o.fmtp)if(d.payload===c){d.config=d.config.split(";").filter(u=>!u.includes("maxaveragebitrate")).join(";"),a.maxbr>0&&(d.config+=";maxaveragebitrate=".concat(a.maxbr*1e3)),l=!0;break}return l||a.maxbr>0&&o.fmtp.push({payload:c,config:"maxaveragebitrate=".concat(a.maxbr*1e3)}),!0})}),r=si.write(s)}return yield this.setMungedSDP(e,r,!0),this.pendingCandidates.forEach(s=>{this.pc.addIceCandidate(s)}),this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate?(this.renegotiate=!1,yield this.createAndSendOffer()):e.type==="answer"&&(this.emit(Lr.NegotiationComplete),e.sdp&&si.parse(e.sdp).media.forEach(o=>{o.type==="video"&&this.emit(Lr.RTPVideoPayloadTypes,o.rtp)})),!0})}createAndSendOffer(e){return A(this,void 0,void 0,function*(){var n;const i=this.latestOfferId+1;if(this.latestOfferId=i,this.onOffer===void 0)return;if(e!=null&&e.iceRestart&&(this.log.debug("restarting ICE",this.logContext),this.restartingIce=!0),this._pc&&this._pc.signalingState==="have-local-offer"){const o=this._pc.remoteDescription;if(e!=null&&e.iceRestart&&o)yield this._pc.setRemoteDescription(o);else{this.renegotiate=!0;return}}else if(!this._pc||this._pc.signalingState==="closed"){this.log.warn("could not createOffer with closed peer connection",this.logContext);return}this.log.debug("starting to negotiate",this.logContext);const r=yield this.pc.createOffer(e);this.log.debug("original offer",Object.assign({sdp:r.sdp},this.logContext));const s=si.parse((n=r.sdp)!==null&&n!==void 0?n:"");if(s.media.forEach(o=>{hm(o),o.type==="audio"?fm(o,[],[]):o.type==="video"&&this.trackBitrates.some(a=>{if(!o.msid||!a.cid||!o.msid.includes(a.cid))return!1;let c=0;if(o.rtp.some(d=>d.codec.toUpperCase()===a.codec.toUpperCase()?(c=d.payload,!0):!1),c===0||(Kn(a.codec)&&this.ensureVideoDDExtensionForSVC(o,s),a.codec!=="av1"))return!0;const l=Math.round(a.maxbr*NT);for(const d of o.fmtp)if(d.payload===c){d.config.includes("x-google-start-bitrate")||(d.config+=";x-google-start-bitrate=".concat(l));break}return!0})}),this.latestOfferId>i){this.log.warn("latestOfferId mismatch",Object.assign(Object.assign({},this.logContext),{latestOfferId:this.latestOfferId,offerId:i}));return}yield this.setMungedSDP(r,si.write(s)),this.onOffer(r,this.latestOfferId)})}createAndSetAnswer(){return A(this,void 0,void 0,function*(){var e;const n=yield this.pc.createAnswer(),i=si.parse((e=n.sdp)!==null&&e!==void 0?e:"");return i.media.forEach(r=>{hm(r),r.type==="audio"&&fm(r,this.remoteStereoMids,this.remoteNackMids)}),yield this.setMungedSDP(n,si.write(i)),n})}createDataChannel(e,n){return this.pc.createDataChannel(e,n)}addTransceiver(e,n){return this.pc.addTransceiver(e,n)}addTrack(e){if(!this._pc)throw new ht("PC closed, cannot add track");return this._pc.addTrack(e)}setTrackCodecBitrate(e){this.trackBitrates.push(e)}setConfiguration(e){var n;if(!this._pc)throw new ht("PC closed, cannot configure");return(n=this._pc)===null||n===void 0?void 0:n.setConfiguration(e)}canRemoveTrack(){var e;return!!(!((e=this._pc)===null||e===void 0)&&e.removeTrack)}removeTrack(e){var n;return(n=this._pc)===null||n===void 0?void 0:n.removeTrack(e)}getConnectionState(){var e,n;return(n=(e=this._pc)===null||e===void 0?void 0:e.connectionState)!==null&&n!==void 0?n:"closed"}getICEConnectionState(){var e,n;return(n=(e=this._pc)===null||e===void 0?void 0:e.iceConnectionState)!==null&&n!==void 0?n:"closed"}getSignallingState(){var e,n;return(n=(e=this._pc)===null||e===void 0?void 0:e.signalingState)!==null&&n!==void 0?n:"closed"}getTransceivers(){var e,n;return(n=(e=this._pc)===null||e===void 0?void 0:e.getTransceivers())!==null&&n!==void 0?n:[]}getSenders(){var e,n;return(n=(e=this._pc)===null||e===void 0?void 0:e.getSenders())!==null&&n!==void 0?n:[]}getLocalDescription(){var e;return(e=this._pc)===null||e===void 0?void 0:e.localDescription}getRemoteDescription(){var e;return(e=this.pc)===null||e===void 0?void 0:e.remoteDescription}getStats(){return this.pc.getStats()}getConnectedAddress(){return A(this,void 0,void 0,function*(){var e;if(!this._pc)return;let n="";const i=new Map,r=new Map;if((yield this._pc.getStats()).forEach(a=>{switch(a.type){case"transport":n=a.selectedCandidatePairId;break;case"candidate-pair":n===""&&a.selected&&(n=a.id),i.set(a.id,a);break;case"remote-candidate":r.set(a.id,"".concat(a.address,":").concat(a.port));break}}),n==="")return;const o=(e=i.get(n))===null||e===void 0?void 0:e.remoteCandidateId;if(o!==void 0)return r.get(o)})}setMungedSDP(e,n,i){return A(this,void 0,void 0,function*(){if(n){const r=e.sdp;e.sdp=n;try{this.log.debug("setting munged ".concat(i?"remote":"local"," description"),this.logContext),i?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e);return}catch(s){this.log.warn("not able to set ".concat(e.type,", falling back to unmodified sdp"),Object.assign(Object.assign({},this.logContext),{error:s,sdp:n})),e.sdp=r}}try{i?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e)}catch(r){let s="unknown error";r instanceof Error?s=r.message:typeof r=="string"&&(s=r);const o={error:s,sdp:e.sdp};throw!i&&this.pc.remoteDescription&&(o.remoteSdp=this.pc.remoteDescription),this.log.error("unable to set ".concat(e.type),Object.assign(Object.assign({},this.logContext),{fields:o})),new sd(s)}})}ensureVideoDDExtensionForSVC(e,n){var i,r;if(!((i=e.ext)===null||i===void 0?void 0:i.some(o=>o.uri===Xh))){if(this.ddExtID===0){let o=0;n.media.forEach(a=>{var c;a.type==="video"&&((c=a.ext)===null||c===void 0||c.forEach(l=>{l.value>o&&(o=l.value)}))}),this.ddExtID=o+1}(r=e.ext)===null||r===void 0||r.push({value:this.ddExtID,uri:Xh})}}}function fm(t,e,n){let i=0;t.rtp.some(r=>r.codec==="opus"?(i=r.payload,!0):!1),i>0&&(t.rtcpFb||(t.rtcpFb=[]),n.includes(t.mid)&&!t.rtcpFb.some(r=>r.payload===i&&r.type==="nack")&&t.rtcpFb.push({payload:i,type:"nack"}),e.includes(t.mid)&&t.fmtp.some(r=>r.payload===i?(r.config.includes("stereo=1")||(r.config+=";stereo=1"),!0):!1))}function DT(t){var e;const n=[],i=[],r=si.parse((e=t.sdp)!==null&&e!==void 0?e:"");let s=0;return r.media.forEach(o=>{var a;o.type==="audio"&&(o.rtp.some(c=>c.codec==="opus"?(s=c.payload,!0):!1),!((a=o.rtcpFb)===null||a===void 0)&&a.some(c=>c.payload===s&&c.type==="nack")&&i.push(o.mid),o.fmtp.some(c=>c.payload===s?(c.config.includes("sprop-stereo=1")&&n.push(o.mid),!0):!1))}),{stereoMids:n,nackMids:i}}function hm(t){if(t.connection){const e=t.connection.ip.indexOf(":")>=0;(t.connection.version===4&&e||t.connection.version===6&&!e)&&(t.connection.ip="0.0.0.0",t.connection.version=4)}}const gd="vp8",jT={audioPreset:od.music,dtx:!0,red:!0,forceStereo:!1,simulcast:!0,screenShareEncoding:Mu.h1080fps15.encoding,stopMicTrackOnMute:!1,videoCodec:gd,backupCodec:!0,preConnectBuffer:!1},sy={deviceId:{ideal:"default"},autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,voiceIsolation:!0},oy={deviceId:{ideal:"default"},resolution:zs.h720.resolution},LT={adaptiveStream:!1,dynacast:!1,stopLocalTrackOnUnpublish:!0,reconnectPolicy:new Ck,disconnectOnPageLeave:!0,webAudioMix:!1},Lu={autoSubscribe:!0,maxRetries:1,peerConnectionTimeout:15e3,websocketTimeout:15e3};var Je;(function(t){t[t.NEW=0]="NEW",t[t.CONNECTING=1]="CONNECTING",t[t.CONNECTED=2]="CONNECTED",t[t.FAILED=3]="FAILED",t[t.CLOSING=4]="CLOSING",t[t.CLOSED=5]="CLOSED"})(Je||(Je={}));class VT{get needsPublisher(){return this.isPublisherConnectionRequired}get needsSubscriber(){return this.isSubscriberConnectionRequired}get currentState(){return this.state}constructor(e,n,i){var r;this.peerConnectionTimeout=Lu.peerConnectionTimeout,this.log=Ce,this.updateState=()=>{var s;const o=this.state,a=this.requiredTransports.map(c=>c.getConnectionState());a.every(c=>c==="connected")?this.state=Je.CONNECTED:a.some(c=>c==="failed")?this.state=Je.FAILED:a.some(c=>c==="connecting")?this.state=Je.CONNECTING:a.every(c=>c==="closed")?this.state=Je.CLOSED:a.some(c=>c==="closed")?this.state=Je.CLOSING:a.every(c=>c==="new")&&(this.state=Je.NEW),o!==this.state&&(this.log.debug("pc state change: from ".concat(Je[o]," to ").concat(Je[this.state]),this.logContext),(s=this.onStateChange)===null||s===void 0||s.call(this,this.state,this.publisher.getConnectionState(),this.subscriber.getConnectionState()))},this.log=Gn((r=i.loggerName)!==null&&r!==void 0?r:fn.PCManager),this.loggerOptions=i,this.isPublisherConnectionRequired=!n,this.isSubscriberConnectionRequired=n,this.publisher=new um(e,i),this.subscriber=new um(e,i),this.publisher.onConnectionStateChange=this.updateState,this.subscriber.onConnectionStateChange=this.updateState,this.publisher.onIceConnectionStateChange=this.updateState,this.subscriber.onIceConnectionStateChange=this.updateState,this.publisher.onSignalingStatechange=this.updateState,this.subscriber.onSignalingStatechange=this.updateState,this.publisher.onIceCandidate=s=>{var o;(o=this.onIceCandidate)===null||o===void 0||o.call(this,s,ln.PUBLISHER)},this.subscriber.onIceCandidate=s=>{var o;(o=this.onIceCandidate)===null||o===void 0||o.call(this,s,ln.SUBSCRIBER)},this.subscriber.onDataChannel=s=>{var o;(o=this.onDataChannel)===null||o===void 0||o.call(this,s)},this.subscriber.onTrack=s=>{var o;(o=this.onTrack)===null||o===void 0||o.call(this,s)},this.publisher.onOffer=(s,o)=>{var a;(a=this.onPublisherOffer)===null||a===void 0||a.call(this,s,o)},this.state=Je.NEW,this.connectionLock=new Nt,this.remoteOfferLock=new Nt}get logContext(){var e,n;return Object.assign({},(n=(e=this.loggerOptions).loggerContextCb)===null||n===void 0?void 0:n.call(e))}requirePublisher(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.isPublisherConnectionRequired=e,this.updateState()}requireSubscriber(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.isSubscriberConnectionRequired=e,this.updateState()}createAndSendPublisherOffer(e){return this.publisher.createAndSendOffer(e)}setPublisherAnswer(e,n){return this.publisher.setRemoteDescription(e,n)}removeTrack(e){return this.publisher.removeTrack(e)}close(){return A(this,void 0,void 0,function*(){if(this.publisher&&this.publisher.getSignallingState()!=="closed"){const e=this.publisher;for(const n of e.getSenders())try{e.canRemoveTrack()&&e.removeTrack(n)}catch(i){this.log.warn("could not removeTrack",Object.assign(Object.assign({},this.logContext),{error:i}))}}yield Promise.all([this.publisher.close(),this.subscriber.close()]),this.updateState()})}triggerIceRestart(){return A(this,void 0,void 0,function*(){this.subscriber.restartingIce=!0,this.needsPublisher&&(yield this.createAndSendPublisherOffer({iceRestart:!0}))})}addIceCandidate(e,n){return A(this,void 0,void 0,function*(){n===ln.PUBLISHER?yield this.publisher.addIceCandidate(e):yield this.subscriber.addIceCandidate(e)})}createSubscriberAnswerFromOffer(e,n){return A(this,void 0,void 0,function*(){this.log.debug("received server offer",Object.assign(Object.assign({},this.logContext),{RTCSdpType:e.type,sdp:e.sdp,signalingState:this.subscriber.getSignallingState().toString()}));const i=yield this.remoteOfferLock.lock();try{return(yield this.subscriber.setRemoteDescription(e,n))?yield this.subscriber.createAndSetAnswer():void 0}finally{i()}})}updateConfiguration(e,n){this.publisher.setConfiguration(e),this.subscriber.setConfiguration(e),n&&this.triggerIceRestart()}ensurePCTransportConnection(e,n){return A(this,void 0,void 0,function*(){var i;const r=yield this.connectionLock.lock();try{this.isPublisherConnectionRequired&&this.publisher.getConnectionState()!=="connected"&&this.publisher.getConnectionState()!=="connecting"&&(this.log.debug("negotiation required, start negotiating",this.logContext),this.publisher.negotiate()),yield Promise.all((i=this.requiredTransports)===null||i===void 0?void 0:i.map(s=>this.ensureTransportConnected(s,e,n)))}finally{r()}})}negotiate(e){return A(this,void 0,void 0,function*(){return new Promise((n,i)=>A(this,void 0,void 0,function*(){const r=setTimeout(()=>{i("negotiation timed out")},this.peerConnectionTimeout),s=()=>{clearTimeout(r),i("negotiation aborted")};e.signal.addEventListener("abort",s),this.publisher.once(Lr.NegotiationStarted,()=>{e.signal.aborted||this.publisher.once(Lr.NegotiationComplete,()=>{clearTimeout(r),n()})}),yield this.publisher.negotiate(o=>{clearTimeout(r),i(o)})}))})}addPublisherTransceiver(e,n){return this.publisher.addTransceiver(e,n)}addPublisherTrack(e){return this.publisher.addTrack(e)}createPublisherDataChannel(e,n){return this.publisher.createDataChannel(e,n)}getConnectedAddress(e){return e===ln.PUBLISHER?this.publisher.getConnectedAddress():e===ln.SUBSCRIBER?this.publisher.getConnectedAddress():this.requiredTransports[0].getConnectedAddress()}get requiredTransports(){const e=[];return this.isPublisherConnectionRequired&&e.push(this.publisher),this.isSubscriberConnectionRequired&&e.push(this.subscriber),e}ensureTransportConnected(e,n){return A(this,arguments,void 0,function(i,r){var s=this;let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.peerConnectionTimeout;return function*(){if(i.getConnectionState()!=="connected")return new Promise((c,l)=>A(s,void 0,void 0,function*(){const d=()=>{this.log.warn("abort transport connection",this.logContext),bt.clearTimeout(u),l(new Ue("room connection has been cancelled",Te.Cancelled))};r!=null&&r.signal.aborted&&d(),r==null||r.signal.addEventListener("abort",d);const u=bt.setTimeout(()=>{r==null||r.signal.removeEventListener("abort",d),l(new Ue("could not establish pc connection",Te.InternalError))},o);for(;this.state!==Je.CONNECTED;)if(yield jt(50),r!=null&&r.signal.aborted){l(new Ue("room connection has been cancelled",Te.Cancelled));return}bt.clearTimeout(u),r==null||r.signal.removeEventListener("abort",d),c()}))}()})}}class Qe extends Error{constructor(e,n,i){super(n),this.code=e,this.message=mm(n,Qe.MAX_MESSAGE_BYTES),this.data=i?mm(i,Qe.MAX_DATA_BYTES):void 0}static fromProto(e){return new Qe(e.code,e.message,e.data)}toProto(){return new ev({code:this.code,message:this.message,data:this.data})}static builtIn(e,n){return new Qe(Qe.ErrorCode[e],Qe.ErrorMessage[e],n)}}Qe.MAX_MESSAGE_BYTES=256;Qe.MAX_DATA_BYTES=15360;Qe.ErrorCode={APPLICATION_ERROR:1500,CONNECTION_TIMEOUT:1501,RESPONSE_TIMEOUT:1502,RECIPIENT_DISCONNECTED:1503,RESPONSE_PAYLOAD_TOO_LARGE:1504,SEND_FAILED:1505,UNSUPPORTED_METHOD:1400,RECIPIENT_NOT_FOUND:1401,REQUEST_PAYLOAD_TOO_LARGE:1402,UNSUPPORTED_SERVER:1403,UNSUPPORTED_VERSION:1404};Qe.ErrorMessage={APPLICATION_ERROR:"Application error in method handler",CONNECTION_TIMEOUT:"Connection timeout",RESPONSE_TIMEOUT:"Response timeout",RECIPIENT_DISCONNECTED:"Recipient disconnected",RESPONSE_PAYLOAD_TOO_LARGE:"Response payload too large",SEND_FAILED:"Failed to send",UNSUPPORTED_METHOD:"Method not supported at destination",RECIPIENT_NOT_FOUND:"Recipient not found",REQUEST_PAYLOAD_TOO_LARGE:"Request payload too large",UNSUPPORTED_SERVER:"RPC not supported by server",UNSUPPORTED_VERSION:"Unsupported RPC version"};const ay=15360;function Vu(t){return new TextEncoder().encode(t).length}function mm(t,e){if(Vu(t)<=e)return t;let n=0,i=t.length;const r=new TextEncoder;for(;n<i;){const s=Math.floor((n+i+1)/2);r.encode(t.slice(0,s)).length<=e?n=s:i=s-1}return t.slice(0,n)}const Fu=2e3;function Xa(t,e){if(!e)return 0;let n,i;return"bytesReceived"in t?(n=t.bytesReceived,i=e.bytesReceived):"bytesSent"in t&&(n=t.bytesSent,i=e.bytesSent),n===void 0||i===void 0||t.timestamp===void 0||e.timestamp===void 0?0:(n-i)*8*1e3/(t.timestamp-e.timestamp)}const Uu=typeof MediaRecorder<"u";class FT{constructor(){throw new Error("MediaRecorder is not available in this environment")}}const UT=Uu?MediaRecorder:FT;class BT extends UT{constructor(e,n){if(!Uu)throw new Error("MediaRecorder is not available in this environment");super(new MediaStream([e.mediaStreamTrack]),n);let i,r;const s=()=>r===void 0,o=()=>{this.removeEventListener("dataavailable",i),this.removeEventListener("stop",o),this.removeEventListener("error",a),r==null||r.close(),r=void 0},a=c=>{r==null||r.error(c),this.removeEventListener("dataavailable",i),this.removeEventListener("stop",o),this.removeEventListener("error",a),r=void 0};this.byteStream=new ReadableStream({start:c=>{r=c,i=l=>A(this,void 0,void 0,function*(){const d=yield l.data.arrayBuffer();s()||c.enqueue(new Uint8Array(d))}),this.addEventListener("dataavailable",i)},cancel:()=>{o()}}),this.addEventListener("stop",o),this.addEventListener("error",a)}}function $T(){return Uu}const HT=1e3,zT=1e4;class cy extends V{get sender(){return this._sender}set sender(e){this._sender=e}get constraints(){return this._constraints}get hasPreConnectBuffer(){return!!this.localTrackRecorder}constructor(e,n,i){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,s=arguments.length>4?arguments[4]:void 0;super(e,n,s),this.manuallyStopped=!1,this._isUpstreamPaused=!1,this.handleTrackMuteEvent=()=>this.debouncedTrackMuteHandler().catch(()=>this.log.debug("track mute bounce got cancelled by an unmute event",this.logContext)),this.debouncedTrackMuteHandler=ju(()=>A(this,void 0,void 0,function*(){yield this.pauseUpstream()}),5e3),this.handleTrackUnmuteEvent=()=>A(this,void 0,void 0,function*(){this.debouncedTrackMuteHandler.cancel("unmute"),yield this.resumeUpstream()}),this.handleEnded=()=>{this.isInBackground&&(this.reacquireTrack=!0),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent),this.emit(re.Ended,this)},this.reacquireTrack=!1,this.providedByUser=r,this.muteLock=new Nt,this.pauseUpstreamLock=new Nt,this.processorLock=new Nt,this.restartLock=new Nt,this.setMediaStreamTrack(e,!0),this._constraints=e.getConstraints(),i&&(this._constraints=i)}get id(){return this._mediaStreamTrack.id}get dimensions(){if(this.kind!==V.Kind.Video)return;const{width:e,height:n}=this._mediaStreamTrack.getSettings();if(e&&n)return{width:e,height:n}}get isUpstreamPaused(){return this._isUpstreamPaused}get isUserProvided(){return this.providedByUser}get mediaStreamTrack(){var e,n;return(n=(e=this.processor)===null||e===void 0?void 0:e.processedTrack)!==null&&n!==void 0?n:this._mediaStreamTrack}get isLocal(){return!0}getSourceTrackSettings(){return this._mediaStreamTrack.getSettings()}setMediaStreamTrack(e,n){return A(this,void 0,void 0,function*(){var i;if(e===this._mediaStreamTrack&&!n)return;this._mediaStreamTrack&&(this.attachedElements.forEach(s=>{Dr(this._mediaStreamTrack,s)}),this.debouncedTrackMuteHandler.cancel("new-track"),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent)),this.mediaStream=new MediaStream([e]),e&&(e.addEventListener("ended",this.handleEnded),e.addEventListener("mute",this.handleTrackMuteEvent),e.addEventListener("unmute",this.handleTrackUnmuteEvent),this._constraints=e.getConstraints());let r;if(this.processor&&e){const s=yield this.processorLock.lock();try{if(this.log.debug("restarting processor",this.logContext),this.kind==="unknown")throw TypeError("cannot set processor on track of unknown kind");this.processorElement&&(kr(e,this.processorElement),this.processorElement.muted=!0),yield this.processor.restart({track:e,kind:this.kind,element:this.processorElement}),r=this.processor.processedTrack}finally{s()}}this.sender&&((i=this.sender.transport)===null||i===void 0?void 0:i.state)!=="closed"&&(yield this.sender.replaceTrack(r??e)),!this.providedByUser&&this._mediaStreamTrack!==e&&this._mediaStreamTrack.stop(),this._mediaStreamTrack=e,e&&(this._mediaStreamTrack.enabled=!this.isMuted,yield this.resumeUpstream(),this.attachedElements.forEach(s=>{kr(r??e,s)}))})}waitForDimensions(){return A(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:HT;return function*(){var i;if(e.kind===V.Kind.Audio)throw new Error("cannot get dimensions for audio tracks");((i=$t())===null||i===void 0?void 0:i.os)==="iOS"&&(yield jt(10));const r=Date.now();for(;Date.now()-r<n;){const s=e.dimensions;if(s)return s;yield jt(50)}throw new Wn("unable to get track dimensions after timeout")}()})}setDeviceId(e){return A(this,void 0,void 0,function*(){return this._constraints.deviceId===e&&this._mediaStreamTrack.getSettings().deviceId===fi(e)||(this._constraints.deviceId=e,this.isMuted)?!0:(yield this.restartTrack(),fi(e)===this._mediaStreamTrack.getSettings().deviceId)})}getDeviceId(){return A(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){if(e.source===V.Source.ScreenShare)return;const{deviceId:i,groupId:r}=e._mediaStreamTrack.getSettings(),s=e.kind===V.Kind.Audio?"audioinput":"videoinput";return n?gt.getInstance().normalizeDeviceId(s,i,r):i}()})}mute(){return A(this,void 0,void 0,function*(){return this.setTrackMuted(!0),this})}unmute(){return A(this,void 0,void 0,function*(){return this.setTrackMuted(!1),this})}replaceTrack(e,n){return A(this,void 0,void 0,function*(){if(!this.sender)throw new Wn("unable to replace an unpublished track");let i,r;return typeof n=="boolean"?i=n:n!==void 0&&(i=n.userProvidedTrack,r=n.stopProcessor),this.providedByUser=i??!0,this.log.debug("replace MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(e),r&&this.processor&&(yield this.stopProcessor()),this})}restart(e){return A(this,void 0,void 0,function*(){this.manuallyStopped=!1;const n=yield this.restartLock.lock();try{e||(e=this._constraints);const{deviceId:i,facingMode:r}=e,s=kk(e,["deviceId","facingMode"]);this.log.debug("restarting track with constraints",Object.assign(Object.assign({},this.logContext),{constraints:e}));const o={audio:!1,video:!1};this.kind===V.Kind.Video?o.video=i||r?{deviceId:i,facingMode:r}:!0:o.audio=i?{deviceId:i}:!0,this.attachedElements.forEach(l=>{Dr(this.mediaStreamTrack,l)}),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.stop();const c=(yield navigator.mediaDevices.getUserMedia(o)).getTracks()[0];return yield c.applyConstraints(s),c.addEventListener("ended",this.handleEnded),this.log.debug("re-acquired MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(c),this._constraints=e,this.emit(re.Restarted,this),this.manuallyStopped&&(this.log.warn("track was stopped during a restart, stopping restarted track",this.logContext),this.stop()),this}finally{n()}})}setTrackMuted(e){this.log.debug("setting ".concat(this.kind," track ").concat(e?"muted":"unmuted"),this.logContext),!(this.isMuted===e&&this._mediaStreamTrack.enabled!==e)&&(this.isMuted=e,this._mediaStreamTrack.enabled=!e,this.emit(e?re.Muted:re.Unmuted,this))}get needsReAcquisition(){return this._mediaStreamTrack.readyState!=="live"||this._mediaStreamTrack.muted||!this._mediaStreamTrack.enabled||this.reacquireTrack}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return A(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),Xv()&&(this.log.debug("visibility changed, is in Background: ".concat(this.isInBackground),this.logContext),!this.isInBackground&&this.needsReAcquisition&&!this.isUserProvided&&!this.isMuted&&(this.log.debug("track needs to be reacquired, restarting ".concat(this.source),this.logContext),yield this.restart(),this.reacquireTrack=!1))})}stop(){var e;this.manuallyStopped=!0,super.stop(),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent),(e=this.processor)===null||e===void 0||e.destroy(),this.processor=void 0}pauseUpstream(){return A(this,void 0,void 0,function*(){var e;const n=yield this.pauseUpstreamLock.lock();try{if(this._isUpstreamPaused===!0)return;if(!this.sender){this.log.warn("unable to pause upstream for an unpublished track",this.logContext);return}this._isUpstreamPaused=!0,this.emit(re.UpstreamPaused,this);const i=$t();if((i==null?void 0:i.name)==="Safari"&&mi(i.version,"12.0")<0)throw new Iu("pauseUpstream is not supported on Safari < 12.");((e=this.sender.transport)===null||e===void 0?void 0:e.state)!=="closed"&&(yield this.sender.replaceTrack(null))}finally{n()}})}resumeUpstream(){return A(this,void 0,void 0,function*(){var e;const n=yield this.pauseUpstreamLock.lock();try{if(this._isUpstreamPaused===!1)return;if(!this.sender){this.log.warn("unable to resume upstream for an unpublished track",this.logContext);return}this._isUpstreamPaused=!1,this.emit(re.UpstreamResumed,this),((e=this.sender.transport)===null||e===void 0?void 0:e.state)!=="closed"&&(yield this.sender.replaceTrack(this.mediaStreamTrack))}finally{n()}})}getRTCStatsReport(){return A(this,void 0,void 0,function*(){var e;return!((e=this.sender)===null||e===void 0)&&e.getStats?yield this.sender.getStats():void 0})}setProcessor(e){return A(this,arguments,void 0,function(n){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){var s;const o=yield i.processorLock.lock();try{i.log.debug("setting up processor",i.logContext);const a=document.createElement(i.kind),c={kind:i.kind,track:i._mediaStreamTrack,element:a,audioContext:i.audioContext};if(yield n.init(c),i.log.debug("processor initialized",i.logContext),i.processor&&(yield i.stopProcessor()),i.kind==="unknown")throw TypeError("cannot set processor on track of unknown kind");if(kr(i._mediaStreamTrack,a),a.muted=!0,a.play().catch(l=>i.log.error("failed to play processor element",Object.assign(Object.assign({},i.logContext),{error:l}))),i.processor=n,i.processorElement=a,i.processor.processedTrack){for(const l of i.attachedElements)l!==i.processorElement&&r&&(Dr(i._mediaStreamTrack,l),kr(i.processor.processedTrack,l));yield(s=i.sender)===null||s===void 0?void 0:s.replaceTrack(i.processor.processedTrack)}i.emit(re.TrackProcessorUpdate,i.processor)}finally{o()}}()})}getProcessor(){return this.processor}stopProcessor(){return A(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){var i,r;e.processor&&(e.log.debug("stopping processor",e.logContext),(i=e.processor.processedTrack)===null||i===void 0||i.stop(),yield e.processor.destroy(),e.processor=void 0,n||((r=e.processorElement)===null||r===void 0||r.remove(),e.processorElement=void 0),yield e._mediaStreamTrack.applyConstraints(e._constraints),yield e.setMediaStreamTrack(e._mediaStreamTrack,!0),e.emit(re.TrackProcessorUpdate))}()})}startPreConnectBuffer(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:100;if(!$T()){this.log.warn("MediaRecorder is not available, cannot start preconnect buffer",this.logContext);return}if(!this.localTrackRecorder)this.localTrackRecorder=new BT(this,{mimeType:"audio/webm;codecs=opus"});else{this.log.warn("preconnect buffer already started");return}this.localTrackRecorder.start(e),this.autoStopPreConnectBuffer=setTimeout(()=>{this.log.warn("preconnect buffer timed out, stopping recording automatically",this.logContext),this.stopPreConnectBuffer()},zT)}stopPreConnectBuffer(){clearTimeout(this.autoStopPreConnectBuffer),this.localTrackRecorder&&(this.localTrackRecorder.stop(),this.localTrackRecorder=void 0)}getPreConnectBuffer(){var e;return(e=this.localTrackRecorder)===null||e===void 0?void 0:e.byteStream}}class Ta extends cy{get enhancedNoiseCancellation(){return this.isKrispNoiseFilterEnabled}constructor(e,n){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;super(e,V.Kind.Audio,n,i,s),this.stopOnMute=!1,this.isKrispNoiseFilterEnabled=!1,this.monitorSender=()=>A(this,void 0,void 0,function*(){if(!this.sender){this._currentBitrate=0;return}let o;try{o=yield this.getSenderStats()}catch(a){this.log.error("could not get audio sender stats",Object.assign(Object.assign({},this.logContext),{error:a}));return}o&&this.prevStats&&(this._currentBitrate=Xa(o,this.prevStats)),this.prevStats=o}),this.handleKrispNoiseFilterEnable=()=>{this.isKrispNoiseFilterEnabled=!0,this.log.debug("Krisp noise filter enabled",this.logContext),this.emit(re.AudioTrackFeatureUpdate,this,pt.TF_ENHANCED_NOISE_CANCELLATION,!0)},this.handleKrispNoiseFilterDisable=()=>{this.isKrispNoiseFilterEnabled=!1,this.log.debug("Krisp noise filter disabled",this.logContext),this.emit(re.AudioTrackFeatureUpdate,this,pt.TF_ENHANCED_NOISE_CANCELLATION,!1)},this.audioContext=r,this.checkForSilence()}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return A(this,void 0,void 0,function*(){const n=yield this.muteLock.lock();try{return this.isMuted?(this.log.debug("Track already muted",this.logContext),this):(this.source===V.Source.Microphone&&this.stopOnMute&&!this.isUserProvided&&(this.log.debug("stopping mic track",this.logContext),this._mediaStreamTrack.stop()),yield e.mute.call(this),this)}finally{n()}})}unmute(){const e=Object.create(null,{unmute:{get:()=>super.unmute}});return A(this,void 0,void 0,function*(){const n=yield this.muteLock.lock();try{if(!this.isMuted)return this.log.debug("Track already unmuted",this.logContext),this;const i=this._constraints.deviceId&&this._mediaStreamTrack.getSettings().deviceId!==fi(this._constraints.deviceId);return this.source===V.Source.Microphone&&(this.stopOnMute||this._mediaStreamTrack.readyState==="ended"||i)&&!this.isUserProvided&&(this.log.debug("reacquiring mic track",this.logContext),yield this.restartTrack()),yield e.unmute.call(this),this}finally{n()}})}restartTrack(e){return A(this,void 0,void 0,function*(){let n;if(e){const i=_u({audio:e});typeof i.audio!="boolean"&&(n=i.audio)}yield this.restart(n)})}restart(e){const n=Object.create(null,{restart:{get:()=>super.restart}});return A(this,void 0,void 0,function*(){const i=yield n.restart.call(this,e);return this.checkForSilence(),i})}startMonitor(){Ot()&&(this.monitorInterval||(this.monitorInterval=setInterval(()=>{this.monitorSender()},Fu)))}setProcessor(e){return A(this,void 0,void 0,function*(){var n;const i=yield this.processorLock.lock();try{if(!In()&&!this.audioContext)throw Error("Audio context needs to be set on LocalAudioTrack in order to enable processors");this.processor&&(yield this.stopProcessor());const r={kind:this.kind,track:this._mediaStreamTrack,audioContext:this.audioContext};this.log.debug("setting up audio processor ".concat(e.name),this.logContext),yield e.init(r),this.processor=e,this.processor.processedTrack&&(yield(n=this.sender)===null||n===void 0?void 0:n.replaceTrack(this.processor.processedTrack),this.processor.processedTrack.addEventListener("enable-lk-krisp-noise-filter",this.handleKrispNoiseFilterEnable),this.processor.processedTrack.addEventListener("disable-lk-krisp-noise-filter",this.handleKrispNoiseFilterDisable)),this.emit(re.TrackProcessorUpdate,this.processor)}finally{i()}})}setAudioContext(e){this.audioContext=e}getSenderStats(){return A(this,void 0,void 0,function*(){var e;if(!(!((e=this.sender)===null||e===void 0)&&e.getStats))return;const n=yield this.sender.getStats();let i;return n.forEach(r=>{r.type==="outbound-rtp"&&(i={type:"audio",streamId:r.id,packetsSent:r.packetsSent,packetsLost:r.packetsLost,bytesSent:r.bytesSent,timestamp:r.timestamp,roundTripTime:r.roundTripTime,jitter:r.jitter})}),i})}checkForSilence(){return A(this,void 0,void 0,function*(){const e=yield ny(this);return e&&(this.isMuted||this.log.warn("silence detected on local audio track",this.logContext),this.emit(re.AudioSilenceDetected)),e})}}function WT(t,e,n){switch(t.kind){case"audio":return new Ta(t,e,!1,void 0,n);case"video":return new Ea(t,e,!1,n);default:throw new Wn("unsupported track type: ".concat(t.kind))}}const qT=Object.values(zs),KT=Object.values(ad),GT=Object.values(Mu),ZT=[zs.h180,zs.h360],YT=[ad.h180,ad.h360],JT=t=>[{scaleResolutionDownBy:2,fps:t.encoding.maxFramerate}].map(n=>{var i,r;return new je(Math.floor(t.width/n.scaleResolutionDownBy),Math.floor(t.height/n.scaleResolutionDownBy),Math.max(15e4,Math.floor(t.encoding.maxBitrate/(Math.pow(n.scaleResolutionDownBy,2)*(((i=t.encoding.maxFramerate)!==null&&i!==void 0?i:30)/((r=n.fps)!==null&&r!==void 0?r:30))))),n.fps,t.encoding.priority)}),vd=["q","h","f"];function yd(t,e,n,i){var r,s;let o=i==null?void 0:i.videoEncoding;t&&(o=i==null?void 0:i.screenShareEncoding);const a=i==null?void 0:i.simulcast,c=i==null?void 0:i.scalabilityMode,l=i==null?void 0:i.videoCodec;if(!o&&!a&&!c||!e||!n)return[{}];o||(o=QT(t,e,n,l),Ce.debug("using video encoding",o));const d=o.maxFramerate,u=new je(e,n,o.maxBitrate,o.maxFramerate,o.priority);if(c&&Kn(l)){const v=new ly(c),h=[];if(v.spatial>3)throw new Error("unsupported scalabilityMode: ".concat(c));const y=$t();if(Xi()||In()||(y==null?void 0:y.name)==="Chrome"&&mi(y==null?void 0:y.version,"113")<0){const b=v.suffix=="h"?2:3,w=nT(y);for(let C=0;C<v.spatial;C+=1)h.push({rid:vd[2-C],maxBitrate:o.maxBitrate/Math.pow(b,C),maxFramerate:u.encoding.maxFramerate,scaleResolutionDownBy:w?Math.pow(2,C):void 0});h[0].scalabilityMode=c}else h.push({maxBitrate:o.maxBitrate,maxFramerate:u.encoding.maxFramerate,scalabilityMode:c});return u.encoding.priority&&(h[0].priority=u.encoding.priority,h[0].networkPriority=u.encoding.priority),Ce.debug("using svc encoding",{encodings:h}),h}if(!a)return[o];let f=[];t?f=(r=gm(i==null?void 0:i.screenShareSimulcastLayers))!==null&&r!==void 0?r:pm(t,u):f=(s=gm(i==null?void 0:i.videoSimulcastLayers))!==null&&s!==void 0?s:pm(t,u);let p;if(f.length>0){const v=f[0];f.length>1&&([,p]=f);const h=Math.max(e,n);if(h>=960&&p)return Kc(e,n,[v,p,u],d);if(h>=480)return Kc(e,n,[v,u],d)}return Kc(e,n,[u])}function XT(t,e,n){var i,r,s,o;if(!n.backupCodec||n.backupCodec===!0||n.backupCodec.codec===n.videoCodec)return;e!==n.backupCodec.codec&&Ce.warn("requested a different codec than specified as backup",{serverRequested:e,backup:n.backupCodec.codec}),n.videoCodec=e,n.videoEncoding=n.backupCodec.encoding;const a=t.mediaStreamTrack.getSettings(),c=(i=a.width)!==null&&i!==void 0?i:(r=t.dimensions)===null||r===void 0?void 0:r.width,l=(s=a.height)!==null&&s!==void 0?s:(o=t.dimensions)===null||o===void 0?void 0:o.height;return t.source===V.Source.ScreenShare&&n.simulcast&&(n.simulcast=!1),yd(t.source===V.Source.ScreenShare,c,l,n)}function QT(t,e,n,i){const r=e2(t,e,n);let{encoding:s}=r[0];const o=Math.max(e,n);for(let a=0;a<r.length;a+=1){const c=r[a];if(s=c.encoding,c.width>=o)break}if(i)switch(i){case"av1":s=Object.assign({},s),s.maxBitrate=s.maxBitrate*.7;break;case"vp9":s=Object.assign({},s),s.maxBitrate=s.maxBitrate*.85;break}return s}function e2(t,e,n){if(t)return GT;const i=e>n?e/n:n/e;return Math.abs(i-16/9)<Math.abs(i-4/3)?qT:KT}function pm(t,e){if(t)return JT(e);const{width:n,height:i}=e,r=n>i?n/i:i/n;return Math.abs(r-16/9)<Math.abs(r-4/3)?ZT:YT}function Kc(t,e,n,i){const r=[];if(n.forEach((s,o)=>{if(o>=vd.length)return;const a=Math.min(t,e),l={rid:vd[o],scaleResolutionDownBy:Math.max(1,a/Math.min(s.width,s.height)),maxBitrate:s.encoding.maxBitrate},d=i&&s.encoding.maxFramerate?Math.min(i,s.encoding.maxFramerate):s.encoding.maxFramerate;d&&(l.maxFramerate=d);const u=qr()||o===0;s.encoding.priority&&u&&(l.priority=s.encoding.priority,l.networkPriority=s.encoding.priority),r.push(l)}),In()&&ey()==="ios"){let s;r.forEach(a=>{s?a.maxFramerate&&a.maxFramerate>s&&(s=a.maxFramerate):s=a.maxFramerate});let o=!0;r.forEach(a=>{var c;a.maxFramerate!=s&&(o&&(o=!1,Ce.info("Simulcast on iOS React-Native requires all encodings to share the same framerate.")),Ce.info('Setting framerate of encoding "'.concat((c=a.rid)!==null&&c!==void 0?c:"",'" to ').concat(s)),a.maxFramerate=s)})}return r}function gm(t){if(t)return t.sort((e,n)=>{const{encoding:i}=e,{encoding:r}=n;return i.maxBitrate>r.maxBitrate?1:i.maxBitrate<r.maxBitrate?-1:i.maxBitrate===r.maxBitrate&&i.maxFramerate&&r.maxFramerate?i.maxFramerate>r.maxFramerate?1:-1:0})}class ly{constructor(e){const n=e.match(/^L(\d)T(\d)(h|_KEY|_KEY_SHIFT){0,1}$/);if(!n)throw new Error("invalid scalability mode");if(this.spatial=parseInt(n[1]),this.temporal=parseInt(n[2]),n.length>3)switch(n[3]){case"h":case"_KEY":case"_KEY_SHIFT":this.suffix=n[3]}}toString(){var e;return"L".concat(this.spatial,"T").concat(this.temporal).concat((e=this.suffix)!==null&&e!==void 0?e:"")}}function t2(t){return t.source===V.Source.ScreenShare||t.constraints.height&&fi(t.constraints.height)>=1080?"maintain-resolution":"balanced"}const n2=5e3;class Ea extends cy{get sender(){return this._sender}set sender(e){this._sender=e,this.degradationPreference&&this.setDegradationPreference(this.degradationPreference)}constructor(e,n){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=arguments.length>3?arguments[3]:void 0;super(e,V.Kind.Video,n,i,r),this.simulcastCodecs=new Map,this.degradationPreference="balanced",this.monitorSender=()=>A(this,void 0,void 0,function*(){if(!this.sender){this._currentBitrate=0;return}let s;try{s=yield this.getSenderStats()}catch(a){this.log.error("could not get audio sender stats",Object.assign(Object.assign({},this.logContext),{error:a}));return}const o=new Map(s.map(a=>[a.rid,a]));if(this.prevStats){let a=0;o.forEach((c,l)=>{var d;const u=(d=this.prevStats)===null||d===void 0?void 0:d.get(l);a+=Xa(c,u)}),this._currentBitrate=a}this.prevStats=o}),this.senderLock=new Nt}get isSimulcast(){return!!(this.sender&&this.sender.getParameters().encodings.length>1)}startMonitor(e){var n;if(this.signalClient=e,!Ot())return;const i=(n=this.sender)===null||n===void 0?void 0:n.getParameters();i&&(this.encodings=i.encodings),!this.monitorInterval&&(this.monitorInterval=setInterval(()=>{this.monitorSender()},Fu))}stop(){this._mediaStreamTrack.getConstraints(),this.simulcastCodecs.forEach(e=>{e.mediaStreamTrack.stop()}),super.stop()}pauseUpstream(){const e=Object.create(null,{pauseUpstream:{get:()=>super.pauseUpstream}});return A(this,void 0,void 0,function*(){var n,i,r,s,o;yield e.pauseUpstream.call(this);try{for(var a=!0,c=zn(this.simulcastCodecs.values()),l;l=yield c.next(),n=l.done,!n;a=!0)s=l.value,a=!1,yield(o=s.sender)===null||o===void 0?void 0:o.replaceTrack(null)}catch(d){i={error:d}}finally{try{!a&&!n&&(r=c.return)&&(yield r.call(c))}finally{if(i)throw i.error}}})}resumeUpstream(){const e=Object.create(null,{resumeUpstream:{get:()=>super.resumeUpstream}});return A(this,void 0,void 0,function*(){var n,i,r,s,o;yield e.resumeUpstream.call(this);try{for(var a=!0,c=zn(this.simulcastCodecs.values()),l;l=yield c.next(),n=l.done,!n;a=!0){s=l.value,a=!1;const d=s;yield(o=d.sender)===null||o===void 0?void 0:o.replaceTrack(d.mediaStreamTrack)}}catch(d){i={error:d}}finally{try{!a&&!n&&(r=c.return)&&(yield r.call(c))}finally{if(i)throw i.error}}})}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return A(this,void 0,void 0,function*(){const n=yield this.muteLock.lock();try{return this.isMuted?(this.log.debug("Track already muted",this.logContext),this):(this.source===V.Source.Camera&&!this.isUserProvided&&(this.log.debug("stopping camera track",this.logContext),this._mediaStreamTrack.stop()),yield e.mute.call(this),this)}finally{n()}})}unmute(){const e=Object.create(null,{unmute:{get:()=>super.unmute}});return A(this,void 0,void 0,function*(){const n=yield this.muteLock.lock();try{return this.isMuted?(this.source===V.Source.Camera&&!this.isUserProvided&&(this.log.debug("reacquiring camera track",this.logContext),yield this.restartTrack()),yield e.unmute.call(this),this):(this.log.debug("Track already unmuted",this.logContext),this)}finally{n()}})}setTrackMuted(e){super.setTrackMuted(e);for(const n of this.simulcastCodecs.values())n.mediaStreamTrack.enabled=!e}getSenderStats(){return A(this,void 0,void 0,function*(){var e;if(!(!((e=this.sender)===null||e===void 0)&&e.getStats))return[];const n=[],i=yield this.sender.getStats();return i.forEach(r=>{var s;if(r.type==="outbound-rtp"){const o={type:"video",streamId:r.id,frameHeight:r.frameHeight,frameWidth:r.frameWidth,framesPerSecond:r.framesPerSecond,framesSent:r.framesSent,firCount:r.firCount,pliCount:r.pliCount,nackCount:r.nackCount,packetsSent:r.packetsSent,bytesSent:r.bytesSent,qualityLimitationReason:r.qualityLimitationReason,qualityLimitationDurations:r.qualityLimitationDurations,qualityLimitationResolutionChanges:r.qualityLimitationResolutionChanges,rid:(s=r.rid)!==null&&s!==void 0?s:r.id,retransmittedPacketsSent:r.retransmittedPacketsSent,targetBitrate:r.targetBitrate,timestamp:r.timestamp},a=i.get(r.remoteId);a&&(o.jitter=a.jitter,o.packetsLost=a.packetsLost,o.roundTripTime=a.roundTripTime),n.push(o)}}),n.sort((r,s)=>{var o,a;return((o=s.frameWidth)!==null&&o!==void 0?o:0)-((a=r.frameWidth)!==null&&a!==void 0?a:0)}),n})}setPublishingQuality(e){const n=[];for(let i=Jt.LOW;i<=Jt.HIGH;i+=1)n.push(new Pu({quality:i,enabled:i<=e}));this.log.debug("setting publishing quality. max quality ".concat(e),this.logContext),this.setPublishingLayers(Kn(this.codec),n)}restartTrack(e){return A(this,void 0,void 0,function*(){var n,i,r,s,o;let a;if(e){const u=_u({video:e});typeof u.video!="boolean"&&(a=u.video)}yield this.restart(a);try{for(var c=!0,l=zn(this.simulcastCodecs.values()),d;d=yield l.next(),n=d.done,!n;c=!0){s=d.value,c=!1;const u=s;u.sender&&((o=u.sender.transport)===null||o===void 0?void 0:o.state)!=="closed"&&(u.mediaStreamTrack=this.mediaStreamTrack.clone(),yield u.sender.replaceTrack(u.mediaStreamTrack))}}catch(u){i={error:u}}finally{try{!c&&!n&&(r=l.return)&&(yield r.call(l))}finally{if(i)throw i.error}}})}setProcessor(e){const n=Object.create(null,{setProcessor:{get:()=>super.setProcessor}});return A(this,arguments,void 0,function(i){var r=this;let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){var o,a,c,l,d,u;if(yield n.setProcessor.call(r,i,s),!((d=r.processor)===null||d===void 0)&&d.processedTrack)try{for(var f=!0,p=zn(r.simulcastCodecs.values()),v;v=yield p.next(),o=v.done,!o;f=!0)l=v.value,f=!1,yield(u=l.sender)===null||u===void 0?void 0:u.replaceTrack(r.processor.processedTrack)}catch(h){a={error:h}}finally{try{!f&&!o&&(c=p.return)&&(yield c.call(p))}finally{if(a)throw a.error}}}()})}setDegradationPreference(e){return A(this,void 0,void 0,function*(){if(this.degradationPreference=e,this.sender)try{this.log.debug("setting degradationPreference to ".concat(e),this.logContext);const n=this.sender.getParameters();n.degradationPreference=e,this.sender.setParameters(n)}catch(n){this.log.warn("failed to set degradationPreference",Object.assign({error:n},this.logContext))}})}addSimulcastTrack(e,n){if(this.simulcastCodecs.has(e)){this.log.error("".concat(e," already added, skipping adding simulcast codec"),this.logContext);return}const i={codec:e,mediaStreamTrack:this.mediaStreamTrack.clone(),sender:void 0,encodings:n};return this.simulcastCodecs.set(e,i),i}setSimulcastTrackSender(e,n){const i=this.simulcastCodecs.get(e);i&&(i.sender=n,setTimeout(()=>{this.subscribedCodecs&&this.setPublishingCodecs(this.subscribedCodecs)},n2))}setPublishingCodecs(e){return A(this,void 0,void 0,function*(){var n,i,r,s,o,a,c;if(this.log.debug("setting publishing codecs",Object.assign(Object.assign({},this.logContext),{codecs:e,currentCodec:this.codec})),!this.codec&&e.length>0)return yield this.setPublishingLayers(Kn(e[0].codec),e[0].qualities),[];this.subscribedCodecs=e;const l=[];try{for(n=!0,i=zn(e);r=yield i.next(),s=r.done,!s;n=!0){c=r.value,n=!1;const d=c;if(!this.codec||this.codec===d.codec)yield this.setPublishingLayers(Kn(d.codec),d.qualities);else{const u=this.simulcastCodecs.get(d.codec);if(this.log.debug("try setPublishingCodec for ".concat(d.codec),Object.assign(Object.assign({},this.logContext),{simulcastCodecInfo:u})),!u||!u.sender){for(const f of d.qualities)if(f.enabled){l.push(d.codec);break}}else u.encodings&&(this.log.debug("try setPublishingLayersForSender ".concat(d.codec),this.logContext),yield vm(u.sender,u.encodings,d.qualities,this.senderLock,Kn(d.codec),this.log,this.logContext))}}}catch(d){o={error:d}}finally{try{!n&&!s&&(a=i.return)&&(yield a.call(i))}finally{if(o)throw o.error}}return l})}setPublishingLayers(e,n){return A(this,void 0,void 0,function*(){this.log.debug("setting publishing layers",Object.assign(Object.assign({},this.logContext),{qualities:n})),!(!this.sender||!this.encodings)&&(yield vm(this.sender,this.encodings,n,this.senderLock,e,this.log,this.logContext))})}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return A(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),Xv()&&this.isInBackground&&this.source===V.Source.Camera&&(this._mediaStreamTrack.enabled=!1)})}}function vm(t,e,n,i,r,s,o){return A(this,void 0,void 0,function*(){const a=yield i.lock();s.debug("setPublishingLayersForSender",Object.assign(Object.assign({},o),{sender:t,qualities:n,senderEncodings:e}));try{const c=t.getParameters(),{encodings:l}=c;if(!l)return;if(l.length!==e.length){s.warn("cannot set publishing layers, encodings mismatch",Object.assign(Object.assign({},o),{encodings:l,senderEncodings:e}));return}let d=!1;!1&&l[0].scalabilityMode||(r&&n.some(p=>p.enabled)&&n.forEach(p=>p.enabled=!0),l.forEach((f,p)=>{var v;let h=(v=f.rid)!==null&&v!==void 0?v:"";h===""&&(h="q");const y=dy(h),b=n.find(w=>w.quality===y);b&&f.active!==b.enabled&&(d=!0,f.active=b.enabled,s.debug("setting layer ".concat(b.quality," to ").concat(f.active?"enabled":"disabled"),o),qr()&&(b.enabled?(f.scaleResolutionDownBy=e[p].scaleResolutionDownBy,f.maxBitrate=e[p].maxBitrate,f.maxFrameRate=e[p].maxFrameRate):(f.scaleResolutionDownBy=4,f.maxBitrate=10,f.maxFrameRate=2)))})),d&&(c.encodings=l,s.debug("setting encodings",Object.assign(Object.assign({},o),{encodings:c.encodings})),yield t.setParameters(c))}finally{a()}})}function dy(t){switch(t){case"f":return Jt.HIGH;case"h":return Jt.MEDIUM;case"q":return Jt.LOW;default:return Jt.HIGH}}function ym(t,e,n,i){if(!n)return[new Hi({quality:Jt.HIGH,width:t,height:e,bitrate:0,ssrc:0})];if(i){const r=n[0].scalabilityMode,s=new ly(r),o=[],a=s.suffix=="h"?1.5:2,c=s.suffix=="h"?2:3;for(let l=0;l<s.spatial;l+=1)o.push(new Hi({quality:Math.min(Jt.HIGH,s.spatial-1)-l,width:Math.ceil(t/Math.pow(a,l)),height:Math.ceil(e/Math.pow(a,l)),bitrate:n[0].maxBitrate?Math.ceil(n[0].maxBitrate/Math.pow(c,l)):0,ssrc:0}));return o}return n.map(r=>{var s,o,a;const c=(s=r.scaleResolutionDownBy)!==null&&s!==void 0?s:1;let l=dy((o=r.rid)!==null&&o!==void 0?o:"");return new Hi({quality:l,width:Math.ceil(t/c),height:Math.ceil(e/c),bitrate:(a=r.maxBitrate)!==null&&a!==void 0?a:0,ssrc:0})})}const bm="_lossy",xm="_reliable",i2=2*1e3,Gc="leave-reconnect",r2=3e4;var rn;(function(t){t[t.New=0]="New",t[t.Connected=1]="Connected",t[t.Disconnected=2]="Disconnected",t[t.Reconnecting=3]="Reconnecting",t[t.Closed=4]="Closed"})(rn||(rn={}));class s2 extends Nn.EventEmitter{get isClosed(){return this._isClosed}get pendingReconnect(){return!!this.reconnectTimeout}constructor(e){var n;super(),this.options=e,this.rtcConfig={},this.peerConnectionTimeout=Lu.peerConnectionTimeout,this.fullReconnectOnNext=!1,this.latestRemoteOfferId=0,this.subscriberPrimary=!1,this.pcState=rn.New,this._isClosed=!0,this.pendingTrackResolvers={},this.reconnectAttempts=0,this.reconnectStart=0,this.attemptingReconnect=!1,this.joinAttempts=0,this.maxJoinAttempts=1,this.shouldFailNext=!1,this.log=Ce,this.reliableDataSequence=1,this.reliableMessageBuffer=new om,this.reliableReceivedState=new AT(r2),this.handleDataChannel=i=>A(this,[i],void 0,function(r){var s=this;let{channel:o}=r;return function*(){if(o){if(o.label===xm)s.reliableDCSub=o;else if(o.label===bm)s.lossyDCSub=o;else return;s.log.debug("on data channel ".concat(o.id,", ").concat(o.label),s.logContext),o.onmessage=s.handleDataMessage}}()}),this.handleDataMessage=i=>A(this,void 0,void 0,function*(){var r,s;const o=yield this.dataProcessLock.lock();try{let a;if(i.data instanceof ArrayBuffer)a=i.data;else if(i.data instanceof Blob)a=yield i.data.arrayBuffer();else{this.log.error("unsupported data type",Object.assign(Object.assign({},this.logContext),{data:i.data}));return}const c=Mt.fromBinary(new Uint8Array(a));if(c.sequence>0&&c.participantSid!==""){const l=this.reliableReceivedState.get(c.participantSid);if(l&&c.sequence<=l)return;this.reliableReceivedState.set(c.participantSid,c.sequence)}((r=c.value)===null||r===void 0?void 0:r.case)==="speaker"?this.emit(ae.ActiveSpeakersUpdate,c.value.value.speakers):(((s=c.value)===null||s===void 0?void 0:s.case)==="user"&&a2(c,c.value.value),this.emit(ae.DataPacketReceived,c))}finally{o()}}),this.handleDataError=i=>{const s=i.currentTarget.maxRetransmits===0?"lossy":"reliable";if(i instanceof ErrorEvent&&i.error){const{error:o}=i.error;this.log.error("DataChannel error on ".concat(s,": ").concat(i.message),Object.assign(Object.assign({},this.logContext),{error:o}))}else this.log.error("Unknown DataChannel error on ".concat(s),Object.assign(Object.assign({},this.logContext),{event:i}))},this.handleBufferedAmountLow=i=>{const s=i.currentTarget.maxRetransmits===0?be.LOSSY:be.RELIABLE;this.updateAndEmitDCBufferStatus(s)},this.handleDisconnect=(i,r)=>{if(this._isClosed)return;this.log.warn("".concat(i," disconnected"),this.logContext),this.reconnectAttempts===0&&(this.reconnectStart=Date.now());const s=c=>{this.log.warn("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(c,"ms. giving up"),this.logContext),this.emit(ae.Disconnected),this.close()},o=Date.now()-this.reconnectStart;let a=this.getNextRetryDelay({elapsedMs:o,retryCount:this.reconnectAttempts});if(a===null){s(o);return}i===Gc&&(a=0),this.log.debug("reconnecting in ".concat(a,"ms"),this.logContext),this.clearReconnectTimeout(),this.token&&this.regionUrlProvider&&this.regionUrlProvider.updateToken(this.token),this.reconnectTimeout=bt.setTimeout(()=>this.attemptReconnect(r).finally(()=>this.reconnectTimeout=void 0),a)},this.waitForRestarted=()=>new Promise((i,r)=>{this.pcState===rn.Connected&&i();const s=()=>{this.off(ae.Disconnected,o),i()},o=()=>{this.off(ae.Restarted,s),r()};this.once(ae.Restarted,s),this.once(ae.Disconnected,o)}),this.updateAndEmitDCBufferStatus=i=>{const r=this.isBufferStatusLow(i);typeof r<"u"&&r!==this.dcBufferStatus.get(i)&&(this.dcBufferStatus.set(i,r),this.emit(ae.DCBufferStatusChanged,r,i))},this.isBufferStatusLow=i=>{const r=this.dataChannelForKind(i);if(r)return i===be.RELIABLE&&this.reliableMessageBuffer.alignBufferedAmount(r.bufferedAmount),r.bufferedAmount<=r.bufferedAmountLowThreshold},this.handleBrowserOnLine=()=>{this.client.currentState===Be.RECONNECTING&&(this.clearReconnectTimeout(),this.attemptReconnect(dr.RR_SIGNAL_DISCONNECTED))},this.log=Gn((n=e.loggerName)!==null&&n!==void 0?n:fn.Engine),this.loggerOptions={loggerName:e.loggerName,loggerContextCb:()=>this.logContext},this.client=new Ou(void 0,this.loggerOptions),this.client.signalLatency=this.options.expSignalLatency,this.reconnectPolicy=this.options.reconnectPolicy,this.registerOnLineListener(),this.closingLock=new Nt,this.dataProcessLock=new Nt,this.dcBufferStatus=new Map([[be.LOSSY,!0],[be.RELIABLE,!0]]),this.client.onParticipantUpdate=i=>this.emit(ae.ParticipantUpdate,i),this.client.onConnectionQuality=i=>this.emit(ae.ConnectionQualityUpdate,i),this.client.onRoomUpdate=i=>this.emit(ae.RoomUpdate,i),this.client.onSubscriptionError=i=>this.emit(ae.SubscriptionError,i),this.client.onSubscriptionPermissionUpdate=i=>this.emit(ae.SubscriptionPermissionUpdate,i),this.client.onSpeakersChanged=i=>this.emit(ae.SpeakersChanged,i),this.client.onStreamStateUpdate=i=>this.emit(ae.StreamStateChanged,i),this.client.onRequestResponse=i=>this.emit(ae.SignalRequestResponse,i)}get logContext(){var e,n,i,r,s,o;return{room:(n=(e=this.latestJoinResponse)===null||e===void 0?void 0:e.room)===null||n===void 0?void 0:n.name,roomID:(r=(i=this.latestJoinResponse)===null||i===void 0?void 0:i.room)===null||r===void 0?void 0:r.sid,participant:(o=(s=this.latestJoinResponse)===null||s===void 0?void 0:s.participant)===null||o===void 0?void 0:o.identity,pID:this.participantSid}}join(e,n,i,r){return A(this,void 0,void 0,function*(){this.url=e,this.token=n,this.signalOpts=i,this.maxJoinAttempts=i.maxRetries;try{this.joinAttempts+=1,this.setupSignalClientCallbacks();const s=yield this.client.join(e,n,i,r);return this._isClosed=!1,this.latestJoinResponse=s,this.subscriberPrimary=s.subscriberPrimary,this.pcManager||(yield this.configure(s)),(!this.subscriberPrimary||s.fastPublish)&&this.negotiate(),this.clientConfiguration=s.clientConfiguration,this.emit(ae.SignalConnected,s),s}catch(s){if(s instanceof Ue&&s.reason===Te.ServerUnreachable&&(this.log.warn("Couldn't connect to server, attempt ".concat(this.joinAttempts," of ").concat(this.maxJoinAttempts),this.logContext),this.joinAttempts<this.maxJoinAttempts))return this.join(e,n,i,r);throw s}})}close(){return A(this,void 0,void 0,function*(){const e=yield this.closingLock.lock();if(this.isClosed){e();return}try{this._isClosed=!0,this.joinAttempts=0,this.emit(ae.Closing),this.removeAllListeners(),this.deregisterOnLineListener(),this.clearPendingReconnect(),yield this.cleanupPeerConnections(),yield this.cleanupClient()}finally{e()}})}cleanupPeerConnections(){return A(this,void 0,void 0,function*(){var e;yield(e=this.pcManager)===null||e===void 0?void 0:e.close(),this.pcManager=void 0;const n=i=>{i&&(i.close(),i.onbufferedamountlow=null,i.onclose=null,i.onclosing=null,i.onerror=null,i.onmessage=null,i.onopen=null)};n(this.lossyDC),n(this.lossyDCSub),n(this.reliableDC),n(this.reliableDCSub),this.lossyDC=void 0,this.lossyDCSub=void 0,this.reliableDC=void 0,this.reliableDCSub=void 0,this.reliableMessageBuffer=new om,this.reliableDataSequence=1,this.reliableReceivedState.clear()})}cleanupClient(){return A(this,void 0,void 0,function*(){yield this.client.close(),this.client.resetCallbacks()})}addTrack(e){if(this.pendingTrackResolvers[e.cid])throw new Wn("a track with the same ID has already been published");return new Promise((n,i)=>{const r=setTimeout(()=>{delete this.pendingTrackResolvers[e.cid],i(new Ue("publication of local track timed out, no response from server",Te.Timeout))},1e4);this.pendingTrackResolvers[e.cid]={resolve:s=>{clearTimeout(r),n(s)},reject:()=>{clearTimeout(r),i(new Error("Cancelled publication by calling unpublish"))}},this.client.sendAddTrack(e)})}removeTrack(e){if(e.track&&this.pendingTrackResolvers[e.track.id]){const{reject:n}=this.pendingTrackResolvers[e.track.id];n&&n(),delete this.pendingTrackResolvers[e.track.id]}try{return this.pcManager.removeTrack(e),!0}catch(n){this.log.warn("failed to remove track",Object.assign(Object.assign({},this.logContext),{error:n}))}return!1}updateMuteStatus(e,n){this.client.sendMuteTrack(e,n)}get dataSubscriberReadyState(){var e;return(e=this.reliableDCSub)===null||e===void 0?void 0:e.readyState}getConnectedServerAddress(){return A(this,void 0,void 0,function*(){var e;return(e=this.pcManager)===null||e===void 0?void 0:e.getConnectedAddress()})}setRegionUrlProvider(e){this.regionUrlProvider=e}configure(e){return A(this,void 0,void 0,function*(){var n,i;if(this.pcManager&&this.pcManager.currentState!==Je.NEW)return;this.participantSid=(n=e.participant)===null||n===void 0?void 0:n.sid;const r=this.makeRTCConfiguration(e);this.pcManager=new VT(r,e.subscriberPrimary,this.loggerOptions),this.emit(ae.TransportsCreated,this.pcManager.publisher,this.pcManager.subscriber),this.pcManager.onIceCandidate=(s,o)=>{this.client.sendIceCandidate(s,o)},this.pcManager.onPublisherOffer=(s,o)=>{this.client.sendOffer(s,o)},this.pcManager.onDataChannel=this.handleDataChannel,this.pcManager.onStateChange=(s,o,a)=>A(this,void 0,void 0,function*(){if(this.log.debug("primary PC state changed ".concat(s),this.logContext),["closed","disconnected","failed"].includes(o)&&(this.publisherConnectionPromise=void 0),s===Je.CONNECTED){const d=this.pcState===rn.New;this.pcState=rn.Connected,d&&this.emit(ae.Connected,e)}else s===Je.FAILED&&this.pcState===rn.Connected&&(this.pcState=rn.Disconnected,this.handleDisconnect("peerconnection failed",a==="failed"?dr.RR_SUBSCRIBER_FAILED:dr.RR_PUBLISHER_FAILED));const c=this.client.isDisconnected||this.client.currentState===Be.RECONNECTING,l=[Je.FAILED,Je.CLOSING,Je.CLOSED].includes(s);c&&l&&!this._isClosed&&this.emit(ae.Offline)}),this.pcManager.onTrack=s=>{this.emit(ae.MediaTrackAdded,s.track,s.streams[0],s.receiver)},o2((i=e.serverInfo)===null||i===void 0?void 0:i.protocol)||this.createDataChannels()})}setupSignalClientCallbacks(){this.client.onAnswer=(e,n)=>A(this,void 0,void 0,function*(){this.pcManager&&(this.log.debug("received server answer",Object.assign(Object.assign({},this.logContext),{RTCSdpType:e.type})),yield this.pcManager.setPublisherAnswer(e,n))}),this.client.onTrickle=(e,n)=>{this.pcManager&&(this.log.debug("got ICE candidate from peer",Object.assign(Object.assign({},this.logContext),{candidate:e,target:n})),this.pcManager.addIceCandidate(e,n))},this.client.onOffer=(e,n)=>A(this,void 0,void 0,function*(){if(this.latestRemoteOfferId=n,!this.pcManager)return;const i=yield this.pcManager.createSubscriberAnswerFromOffer(e,n);i&&this.client.sendAnswer(i,n)}),this.client.onLocalTrackPublished=e=>{var n;if(this.log.debug("received trackPublishedResponse",Object.assign(Object.assign({},this.logContext),{cid:e.cid,track:(n=e.track)===null||n===void 0?void 0:n.sid})),!this.pendingTrackResolvers[e.cid]){this.log.error("missing track resolver for ".concat(e.cid),Object.assign(Object.assign({},this.logContext),{cid:e.cid}));return}const{resolve:i}=this.pendingTrackResolvers[e.cid];delete this.pendingTrackResolvers[e.cid],i(e.track)},this.client.onLocalTrackUnpublished=e=>{this.emit(ae.LocalTrackUnpublished,e)},this.client.onLocalTrackSubscribed=e=>{this.emit(ae.LocalTrackSubscribed,e)},this.client.onTokenRefresh=e=>{this.token=e},this.client.onRemoteMuteChanged=(e,n)=>{this.emit(ae.RemoteMute,e,n)},this.client.onSubscribedQualityUpdate=e=>{this.emit(ae.SubscribedQualityUpdate,e)},this.client.onRoomMoved=e=>{var n;this.participantSid=(n=e.participant)===null||n===void 0?void 0:n.sid,this.latestJoinResponse&&(this.latestJoinResponse.room=e.room),this.emit(ae.RoomMoved,e)},this.client.onClose=()=>{this.handleDisconnect("signal",dr.RR_SIGNAL_DISCONNECTED)},this.client.onLeave=e=>{switch(this.log.debug("client leave request",Object.assign(Object.assign({},this.logContext),{reason:e==null?void 0:e.reason})),e.regions&&this.regionUrlProvider&&(this.log.debug("updating regions",this.logContext),this.regionUrlProvider.setServerReportedRegions(e.regions)),e.action){case Nr.DISCONNECT:this.emit(ae.Disconnected,e==null?void 0:e.reason),this.close();break;case Nr.RECONNECT:this.fullReconnectOnNext=!0,this.handleDisconnect(Gc);break;case Nr.RESUME:this.handleDisconnect(Gc)}}}makeRTCConfiguration(e){var n;const i=Object.assign({},this.rtcConfig);if(!((n=this.signalOpts)===null||n===void 0)&&n.e2eeEnabled&&(this.log.debug("E2EE - setting up transports with insertable streams",this.logContext),i.encodedInsertableStreams=!0),e.iceServers&&!i.iceServers){const r=[];e.iceServers.forEach(s=>{const o={urls:s.urls};s.username&&(o.username=s.username),s.credential&&(o.credential=s.credential),r.push(o)}),i.iceServers=r}return e.clientConfiguration&&e.clientConfiguration.forceRelay===Hs.ENABLED&&(i.iceTransportPolicy="relay"),i.sdpSemantics="unified-plan",i.continualGatheringPolicy="gather_continually",i}createDataChannels(){this.pcManager&&(this.lossyDC&&(this.lossyDC.onmessage=null,this.lossyDC.onerror=null),this.reliableDC&&(this.reliableDC.onmessage=null,this.reliableDC.onerror=null),this.lossyDC=this.pcManager.createPublisherDataChannel(bm,{ordered:!1,maxRetransmits:0}),this.reliableDC=this.pcManager.createPublisherDataChannel(xm,{ordered:!0}),this.lossyDC.onmessage=this.handleDataMessage,this.reliableDC.onmessage=this.handleDataMessage,this.lossyDC.onerror=this.handleDataError,this.reliableDC.onerror=this.handleDataError,this.lossyDC.bufferedAmountLowThreshold=65535,this.reliableDC.bufferedAmountLowThreshold=65535,this.lossyDC.onbufferedamountlow=this.handleBufferedAmountLow,this.reliableDC.onbufferedamountlow=this.handleBufferedAmountLow)}createSender(e,n,i){return A(this,void 0,void 0,function*(){if(cd())return yield this.createTransceiverRTCRtpSender(e,n,i);if(ld())return this.log.warn("using add-track fallback",this.logContext),yield this.createRTCRtpSender(e.mediaStreamTrack);throw new ht("Required webRTC APIs not supported on this device")})}createSimulcastSender(e,n,i,r){return A(this,void 0,void 0,function*(){if(cd())return this.createSimulcastTransceiverSender(e,n,i,r);if(ld())return this.log.debug("using add-track fallback",this.logContext),this.createRTCRtpSender(e.mediaStreamTrack);throw new ht("Cannot stream on this device")})}createTransceiverRTCRtpSender(e,n,i){return A(this,void 0,void 0,function*(){if(!this.pcManager)throw new ht("publisher is closed");const r=[];e.mediaStream&&r.push(e.mediaStream),ns(e)&&(e.codec=n.videoCodec);const s={direction:"sendonly",streams:r};return i&&(s.sendEncodings=i),(yield this.pcManager.addPublisherTransceiver(e.mediaStreamTrack,s)).sender})}createSimulcastTransceiverSender(e,n,i,r){return A(this,void 0,void 0,function*(){if(!this.pcManager)throw new ht("publisher is closed");const s={direction:"sendonly"};r&&(s.sendEncodings=r);const o=yield this.pcManager.addPublisherTransceiver(n.mediaStreamTrack,s);if(i.videoCodec)return e.setSimulcastTrackSender(i.videoCodec,o.sender),o.sender})}createRTCRtpSender(e){return A(this,void 0,void 0,function*(){if(!this.pcManager)throw new ht("publisher is closed");return this.pcManager.addPublisherTrack(e)})}attemptReconnect(e){return A(this,void 0,void 0,function*(){var n,i,r;if(!this._isClosed){if(this.attemptingReconnect){Ce.warn("already attempting reconnect, returning early",this.logContext);return}(((n=this.clientConfiguration)===null||n===void 0?void 0:n.resumeConnection)===Hs.DISABLED||((r=(i=this.pcManager)===null||i===void 0?void 0:i.currentState)!==null&&r!==void 0?r:Je.NEW)===Je.NEW)&&(this.fullReconnectOnNext=!0);try{this.attemptingReconnect=!0,this.fullReconnectOnNext?yield this.restartConnection():yield this.resumeConnection(e),this.clearPendingReconnect(),this.fullReconnectOnNext=!1}catch(s){this.reconnectAttempts+=1;let o=!0;s instanceof ht?(this.log.debug("received unrecoverable error",Object.assign(Object.assign({},this.logContext),{error:s})),o=!1):s instanceof ur||(this.fullReconnectOnNext=!0),o?this.handleDisconnect("reconnect",dr.RR_UNKNOWN):(this.log.info("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(Date.now()-this.reconnectStart,"ms. giving up"),this.logContext),this.emit(ae.Disconnected),yield this.close())}finally{this.attemptingReconnect=!1}}})}getNextRetryDelay(e){try{return this.reconnectPolicy.nextRetryDelayInMs(e)}catch(n){this.log.warn("encountered error in reconnect policy",Object.assign(Object.assign({},this.logContext),{error:n}))}return null}restartConnection(e){return A(this,void 0,void 0,function*(){var n,i,r;try{if(!this.url||!this.token)throw new ht("could not reconnect, url or token not saved");this.log.info("reconnecting, attempt: ".concat(this.reconnectAttempts),this.logContext),this.emit(ae.Restarting),this.client.isDisconnected||(yield this.client.sendLeave()),yield this.cleanupPeerConnections(),yield this.cleanupClient();let s;try{if(!this.signalOpts)throw this.log.warn("attempted connection restart, without signal options present",this.logContext),new ur;s=yield this.join(e??this.url,this.token,this.signalOpts)}catch(o){throw o instanceof Ue&&o.reason===Te.NotAllowed?new ht("could not reconnect, token might be expired"):new ur}if(this.shouldFailNext)throw this.shouldFailNext=!1,new Error("simulated failure");if(this.client.setReconnected(),this.emit(ae.SignalRestarted,s),yield this.waitForPCReconnected(),this.client.currentState!==Be.CONNECTED)throw new ur("Signal connection got severed during reconnect");(n=this.regionUrlProvider)===null||n===void 0||n.resetAttempts(),this.emit(ae.Restarted)}catch(s){const o=yield(i=this.regionUrlProvider)===null||i===void 0?void 0:i.getNextBestRegionUrl();if(o){yield this.restartConnection(o);return}else throw(r=this.regionUrlProvider)===null||r===void 0||r.resetAttempts(),s}})}resumeConnection(e){return A(this,void 0,void 0,function*(){var n;if(!this.url||!this.token)throw new ht("could not reconnect, url or token not saved");if(!this.pcManager)throw new ht("publisher and subscriber connections unset");this.log.info("resuming signal connection, attempt ".concat(this.reconnectAttempts),this.logContext),this.emit(ae.Resuming);let i;try{this.setupSignalClientCallbacks(),i=yield this.client.reconnect(this.url,this.token,this.participantSid,e)}catch(r){let s="";throw r instanceof Error&&(s=r.message,this.log.error(r.message,Object.assign(Object.assign({},this.logContext),{error:r}))),r instanceof Ue&&r.reason===Te.NotAllowed?new ht("could not reconnect, token might be expired"):r instanceof Ue&&r.reason===Te.LeaveRequest?r:new ur(s)}if(this.emit(ae.SignalResumed),i){const r=this.makeRTCConfiguration(i);this.pcManager.updateConfiguration(r),this.latestJoinResponse&&(this.latestJoinResponse.serverInfo=i.serverInfo)}else this.log.warn("Did not receive reconnect response",this.logContext);if(this.shouldFailNext)throw this.shouldFailNext=!1,new Error("simulated failure");if(yield this.pcManager.triggerIceRestart(),yield this.waitForPCReconnected(),this.client.currentState!==Be.CONNECTED)throw new ur("Signal connection got severed during reconnect");this.client.setReconnected(),((n=this.reliableDC)===null||n===void 0?void 0:n.readyState)==="open"&&this.reliableDC.id===null&&this.createDataChannels(),i!=null&&i.lastMessageSeq&&this.resendReliableMessagesForResume(i.lastMessageSeq),this.emit(ae.Resumed)})}waitForPCInitialConnection(e,n){return A(this,void 0,void 0,function*(){if(!this.pcManager)throw new ht("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(n,e)})}waitForPCReconnected(){return A(this,void 0,void 0,function*(){this.pcState=rn.Reconnecting,this.log.debug("waiting for peer connection to reconnect",this.logContext);try{if(yield jt(i2),!this.pcManager)throw new ht("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(void 0,this.peerConnectionTimeout),this.pcState=rn.Connected}catch(e){throw this.pcState=rn.Disconnected,new Ue("could not establish PC connection, ".concat(e.message),Te.InternalError)}})}publishRpcResponse(e,n,i,r){return A(this,void 0,void 0,function*(){const s=new Mt({destinationIdentities:[e],kind:be.RELIABLE,value:{case:"rpcResponse",value:new Q0({requestId:n,value:r?{case:"error",value:r.toProto()}:{case:"payload",value:i??""}})}});yield this.sendDataPacket(s,be.RELIABLE)})}publishRpcAck(e,n){return A(this,void 0,void 0,function*(){const i=new Mt({destinationIdentities:[e],kind:be.RELIABLE,value:{case:"rpcAck",value:new X0({requestId:n})}});yield this.sendDataPacket(i,be.RELIABLE)})}sendDataPacket(e,n){return A(this,void 0,void 0,function*(){yield this.ensurePublisherConnected(n),n===be.RELIABLE&&(e.sequence=this.reliableDataSequence,this.reliableDataSequence+=1);const i=e.toBinary(),r=this.dataChannelForKind(n);if(r){if(n===be.RELIABLE&&this.reliableMessageBuffer.push({data:i,sequence:e.sequence}),this.attemptingReconnect)return;r.send(i)}this.updateAndEmitDCBufferStatus(n)})}resendReliableMessagesForResume(e){return A(this,void 0,void 0,function*(){yield this.ensurePublisherConnected(be.RELIABLE);const n=this.dataChannelForKind(be.RELIABLE);n&&(this.reliableMessageBuffer.popToSequence(e),this.reliableMessageBuffer.getAll().forEach(i=>{n.send(i.data)})),this.updateAndEmitDCBufferStatus(be.RELIABLE)})}waitForBufferStatusLow(e){return new Promise((n,i)=>A(this,void 0,void 0,function*(){if(this.isBufferStatusLow(e))n();else{const r=()=>i("Engine closed");for(this.once(ae.Closing,r);!this.dcBufferStatus.get(e);)yield jt(10);this.off(ae.Closing,r),n()}}))}ensureDataTransportConnected(e){return A(this,arguments,void 0,function(n){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.subscriberPrimary;return function*(){var s;if(!i.pcManager)throw new ht("PC manager is closed");const o=r?i.pcManager.subscriber:i.pcManager.publisher,a=r?"Subscriber":"Publisher";if(!o)throw new Ue("".concat(a," connection not set"),Te.InternalError);let c=!1;!r&&!i.dataChannelForKind(n,r)&&(i.createDataChannels(),c=!0),!c&&!r&&!i.pcManager.publisher.isICEConnected&&i.pcManager.publisher.getICEConnectionState()!=="checking"&&(c=!0),c&&i.negotiate();const l=i.dataChannelForKind(n,r);if((l==null?void 0:l.readyState)==="open")return;const d=new Date().getTime()+i.peerConnectionTimeout;for(;new Date().getTime()<d;){if(o.isICEConnected&&((s=i.dataChannelForKind(n,r))===null||s===void 0?void 0:s.readyState)==="open")return;yield jt(50)}throw new Ue("could not establish ".concat(a," connection, state: ").concat(o.getICEConnectionState()),Te.InternalError)}()})}ensurePublisherConnected(e){return A(this,void 0,void 0,function*(){this.publisherConnectionPromise||(this.publisherConnectionPromise=this.ensureDataTransportConnected(e,!1)),yield this.publisherConnectionPromise})}verifyTransport(){return!(!this.pcManager||this.pcManager.currentState!==Je.CONNECTED||!this.client.ws||this.client.ws.readyState===WebSocket.CLOSED)}negotiate(){return A(this,void 0,void 0,function*(){return new Promise((e,n)=>A(this,void 0,void 0,function*(){if(!this.pcManager){n(new sd("PC manager is closed"));return}this.pcManager.requirePublisher(),this.pcManager.publisher.getTransceivers().length==0&&!this.lossyDC&&!this.reliableDC&&this.createDataChannels();const i=new AbortController,r=()=>{i.abort(),this.log.debug("engine disconnected while negotiation was ongoing",this.logContext),e()};this.isClosed&&n("cannot negotiate on closed engine"),this.on(ae.Closing,r),this.pcManager.publisher.once(Lr.RTPVideoPayloadTypes,s=>{const o=new Map;s.forEach(a=>{const c=a.codec.toLowerCase();cT(c)&&o.set(a.payload,c)}),this.emit(ae.RTPVideoMapUpdate,o)});try{yield this.pcManager.negotiate(i),e()}catch(s){s instanceof sd&&(this.fullReconnectOnNext=!0),this.handleDisconnect("negotiation",dr.RR_UNKNOWN),n(s)}finally{this.off(ae.Closing,r)}}))})}dataChannelForKind(e,n){if(n){if(e===be.LOSSY)return this.lossyDCSub;if(e===be.RELIABLE)return this.reliableDCSub}else{if(e===be.LOSSY)return this.lossyDC;if(e===be.RELIABLE)return this.reliableDC}}sendSyncState(e,n){var i,r;if(!this.pcManager){this.log.warn("sync state cannot be sent without peer connection setup",this.logContext);return}const s=this.pcManager.subscriber.getLocalDescription(),o=this.pcManager.subscriber.getRemoteDescription(),a=(r=(i=this.signalOpts)===null||i===void 0?void 0:i.autoSubscribe)!==null&&r!==void 0?r:!0,c=new Array,l=new Array;e.forEach(d=>{d.isDesired!==a&&c.push(d.trackSid),d.isEnabled||l.push(d.trackSid)}),this.client.sendSyncState(new gv({answer:s?ka({sdp:s.sdp,type:s.type}):void 0,offer:o?ka({sdp:o.sdp,type:o.type}):void 0,subscription:new Za({trackSids:c,subscribe:!a,participantTracks:[]}),publishTracks:vT(n),dataChannels:this.dataChannelsInfo(),trackSidsDisabled:l,datachannelReceiveStates:this.reliableReceivedState.map((d,u)=>new vv({publisherSid:u,lastSeq:d}))}))}failNext(){this.shouldFailNext=!0}dataChannelsInfo(){const e=[],n=(i,r)=>{(i==null?void 0:i.id)!==void 0&&i.id!==null&&e.push(new yv({label:i.label,id:i.id,target:r}))};return n(this.dataChannelForKind(be.LOSSY),ln.PUBLISHER),n(this.dataChannelForKind(be.RELIABLE),ln.PUBLISHER),n(this.dataChannelForKind(be.LOSSY,!0),ln.SUBSCRIBER),n(this.dataChannelForKind(be.RELIABLE,!0),ln.SUBSCRIBER),e}clearReconnectTimeout(){this.reconnectTimeout&&bt.clearTimeout(this.reconnectTimeout)}clearPendingReconnect(){this.clearReconnectTimeout(),this.reconnectAttempts=0}registerOnLineListener(){Ot()&&window.addEventListener("online",this.handleBrowserOnLine)}deregisterOnLineListener(){Ot()&&window.removeEventListener("online",this.handleBrowserOnLine)}}class ur extends Error{}function o2(t){return t!==void 0&&t>13}function a2(t,e){const n=t.participantIdentity?t.participantIdentity:e.participantIdentity;t.participantIdentity=n,e.participantIdentity=n;const i=t.destinationIdentities.length!==0?t.destinationIdentities:e.destinationIdentities;t.destinationIdentities=i,e.destinationIdentities=i}class bd{constructor(e,n){this.lastUpdateAt=0,this.settingsCacheTime=3e3,this.attemptedRegions=[],this.serverUrl=new URL(e),this.token=n}updateToken(e){this.token=e}isCloud(){return ud(this.serverUrl)}getServerUrl(){return this.serverUrl}getNextBestRegionUrl(e){return A(this,void 0,void 0,function*(){if(!this.isCloud())throw Error("region availability is only supported for LiveKit Cloud domains");(!this.regionSettings||Date.now()-this.lastUpdateAt>this.settingsCacheTime)&&(this.regionSettings=yield this.fetchRegionSettings(e));const n=this.regionSettings.regions.filter(i=>!this.attemptedRegions.find(r=>r.url===i.url));if(n.length>0){const i=n[0];return this.attemptedRegions.push(i),Ce.debug("next region: ".concat(i.region)),i.url}else return null})}resetAttempts(){this.attemptedRegions=[]}fetchRegionSettings(e){return A(this,void 0,void 0,function*(){const n=yield fetch("".concat(c2(this.serverUrl),"/regions"),{headers:{authorization:"Bearer ".concat(this.token)},signal:e});if(n.ok){const i=yield n.json();return this.lastUpdateAt=Date.now(),i}else throw new Ue("Could not fetch region settings: ".concat(n.statusText),n.status===401?Te.NotAllowed:Te.InternalError,n.status)})}setServerReportedRegions(e){this.regionSettings=e,this.lastUpdateAt=Date.now()}}function c2(t){return"".concat(t.protocol.replace("ws","http"),"//").concat(t.host,"/settings")}class uy{get info(){return this._info}constructor(e,n,i){this.reader=n,this.totalByteSize=i,this._info=e,this.bytesReceived=0}}class l2 extends uy{handleChunkReceived(e){var n;this.bytesReceived+=e.content.byteLength;const i=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;(n=this.onProgress)===null||n===void 0||n.call(this,i)}[Symbol.asyncIterator](){const e=this.reader.getReader();return{next:()=>A(this,void 0,void 0,function*(){try{const{done:n,value:i}=yield e.read();return n?{done:!0,value:void 0}:(this.handleChunkReceived(i),{done:!1,value:i.content})}catch{return{done:!0,value:void 0}}}),return(){return A(this,void 0,void 0,function*(){return e.releaseLock(),{done:!0,value:void 0}})}}}readAll(){return A(this,void 0,void 0,function*(){var e,n,i,r;let s=new Set;try{for(var o=!0,a=zn(this),c;c=yield a.next(),e=c.done,!e;o=!0){r=c.value,o=!1;const l=r;s.add(l)}}catch(l){n={error:l}}finally{try{!o&&!e&&(i=a.return)&&(yield i.call(a))}finally{if(n)throw n.error}}return Array.from(s)})}}class d2 extends uy{constructor(e,n,i){super(e,n,i),this.receivedChunks=new Map}handleChunkReceived(e){var n;const i=ra(e.chunkIndex),r=this.receivedChunks.get(i);if(r&&r.version>e.version)return;this.receivedChunks.set(i,e),this.bytesReceived+=e.content.byteLength;const s=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;(n=this.onProgress)===null||n===void 0||n.call(this,s)}[Symbol.asyncIterator](){const e=this.reader.getReader(),n=new TextDecoder;return{next:()=>A(this,void 0,void 0,function*(){try{const{done:i,value:r}=yield e.read();return i?{done:!0,value:void 0}:(this.handleChunkReceived(r),{done:!1,value:n.decode(r.content)})}catch{return{done:!0,value:void 0}}}),return(){return A(this,void 0,void 0,function*(){return e.releaseLock(),{done:!0,value:void 0}})}}}readAll(){return A(this,void 0,void 0,function*(){var e,n,i,r;let s="";try{for(var o=!0,a=zn(this),c;c=yield a.next(),e=c.done,!e;o=!0)r=c.value,o=!1,s+=r}catch(l){n={error:l}}finally{try{!o&&!e&&(i=a.return)&&(yield i.call(a))}finally{if(n)throw n.error}}return s})}}class fy{constructor(e,n,i){this.writableStream=e,this.defaultWriter=e.getWriter(),this.onClose=i,this.info=n}write(e){return this.defaultWriter.write(e)}close(){return A(this,void 0,void 0,function*(){var e;yield this.defaultWriter.close(),this.defaultWriter.releaseLock(),(e=this.onClose)===null||e===void 0||e.call(this)})}}class u2 extends fy{}class f2 extends fy{}class hy extends V{constructor(e,n,i,r,s){super(e,i,s),this.sid=n,this.receiver=r}get isLocal(){return!1}setMuted(e){this.isMuted!==e&&(this.isMuted=e,this._mediaStreamTrack.enabled=!e,this.emit(e?re.Muted:re.Unmuted,this))}setMediaStream(e){this.mediaStream=e;const n=i=>{i.track===this._mediaStreamTrack&&(e.removeEventListener("removetrack",n),this.receiver&&"playoutDelayHint"in this.receiver&&(this.receiver.playoutDelayHint=void 0),this.receiver=void 0,this._currentBitrate=0,this.emit(re.Ended,this))};e.addEventListener("removetrack",n)}start(){this.startMonitor(),super.enable()}stop(){this.stopMonitor(),super.disable()}getRTCStatsReport(){return A(this,void 0,void 0,function*(){var e;return!((e=this.receiver)===null||e===void 0)&&e.getStats?yield this.receiver.getStats():void 0})}setPlayoutDelay(e){this.receiver?"playoutDelayHint"in this.receiver?this.receiver.playoutDelayHint=e:this.log.warn("Playout delay not supported in this browser"):this.log.warn("Cannot set playout delay, track already ended")}getPlayoutDelay(){if(this.receiver){if("playoutDelayHint"in this.receiver)return this.receiver.playoutDelayHint;this.log.warn("Playout delay not supported in this browser")}else this.log.warn("Cannot get playout delay, track already ended");return 0}startMonitor(){this.monitorInterval||(this.monitorInterval=setInterval(()=>this.monitorReceiver(),Fu)),yT()&&this.registerTimeSyncUpdate()}registerTimeSyncUpdate(){const e=()=>{var n;this.timeSyncHandle=requestAnimationFrame(()=>e());const i=(n=this.receiver)===null||n===void 0?void 0:n.getSynchronizationSources()[0];if(i){const{timestamp:r,rtpTimestamp:s}=i;s&&this.rtpTimestamp!==s&&(this.emit(re.TimeSyncUpdate,{timestamp:r,rtpTimestamp:s}),this.rtpTimestamp=s)}};e()}}class my extends hy{constructor(e,n,i,r,s,o){super(e,n,V.Kind.Audio,i,o),this.monitorReceiver=()=>A(this,void 0,void 0,function*(){if(!this.receiver){this._currentBitrate=0;return}const a=yield this.getReceiverStats();a&&this.prevStats&&this.receiver&&(this._currentBitrate=Xa(a,this.prevStats)),this.prevStats=a}),this.audioContext=r,this.webAudioPluginNodes=[],s&&(this.sinkId=s.deviceId)}setVolume(e){var n;for(const i of this.attachedElements)this.audioContext?(n=this.gainNode)===null||n===void 0||n.gain.setTargetAtTime(e,0,.1):i.volume=e;In()&&this._mediaStreamTrack._setVolume(e),this.elementVolume=e}getVolume(){if(this.elementVolume)return this.elementVolume;if(In())return 1;let e=0;return this.attachedElements.forEach(n=>{n.volume>e&&(e=n.volume)}),e}setSinkId(e){return A(this,void 0,void 0,function*(){this.sinkId=e,yield Promise.all(this.attachedElements.map(n=>{if(dd(n))return n.setSinkId(e)}))})}attach(e){const n=this.attachedElements.length===0;return e?super.attach(e):e=super.attach(),this.sinkId&&dd(e)&&e.setSinkId(this.sinkId).catch(i=>{this.log.error("Failed to set sink id on remote audio track",i,this.logContext)}),this.audioContext&&n&&(this.log.debug("using audio context mapping",this.logContext),this.connectWebAudio(this.audioContext,e),e.volume=0,e.muted=!0),this.elementVolume&&this.setVolume(this.elementVolume),e}detach(e){let n;return e?(n=super.detach(e),this.audioContext&&(this.attachedElements.length>0?this.connectWebAudio(this.audioContext,this.attachedElements[0]):this.disconnectWebAudio())):(n=super.detach(),this.disconnectWebAudio()),n}setAudioContext(e){this.audioContext=e,e&&this.attachedElements.length>0?this.connectWebAudio(e,this.attachedElements[0]):e||this.disconnectWebAudio()}setWebAudioPlugins(e){this.webAudioPluginNodes=e,this.attachedElements.length>0&&this.audioContext&&this.connectWebAudio(this.audioContext,this.attachedElements[0])}connectWebAudio(e,n){this.disconnectWebAudio(),this.sourceNode=e.createMediaStreamSource(n.srcObject);let i=this.sourceNode;this.webAudioPluginNodes.forEach(r=>{i.connect(r),i=r}),this.gainNode=e.createGain(),i.connect(this.gainNode),this.gainNode.connect(e.destination),this.elementVolume&&this.gainNode.gain.setTargetAtTime(this.elementVolume,0,.1),e.state!=="running"&&e.resume().then(()=>{e.state!=="running"&&this.emit(re.AudioPlaybackFailed,new Error("Audio Context couldn't be started automatically"))}).catch(r=>{this.emit(re.AudioPlaybackFailed,r)})}disconnectWebAudio(){var e,n;(e=this.gainNode)===null||e===void 0||e.disconnect(),(n=this.sourceNode)===null||n===void 0||n.disconnect(),this.gainNode=void 0,this.sourceNode=void 0}getReceiverStats(){return A(this,void 0,void 0,function*(){if(!this.receiver||!this.receiver.getStats)return;const e=yield this.receiver.getStats();let n;return e.forEach(i=>{i.type==="inbound-rtp"&&(n={type:"audio",streamId:i.id,timestamp:i.timestamp,jitter:i.jitter,bytesReceived:i.bytesReceived,concealedSamples:i.concealedSamples,concealmentEvents:i.concealmentEvents,silentConcealedSamples:i.silentConcealedSamples,silentConcealmentEvents:i.silentConcealmentEvents,totalAudioEnergy:i.totalAudioEnergy,totalSamplesDuration:i.totalSamplesDuration})}),n})}}const Zc=100;class h2 extends hy{constructor(e,n,i,r,s){super(e,n,V.Kind.Video,i,s),this.elementInfos=[],this.monitorReceiver=()=>A(this,void 0,void 0,function*(){if(!this.receiver){this._currentBitrate=0;return}const o=yield this.getReceiverStats();o&&this.prevStats&&this.receiver&&(this._currentBitrate=Xa(o,this.prevStats)),this.prevStats=o}),this.debouncedHandleResize=ju(()=>{this.updateDimensions()},Zc),this.adaptiveStreamSettings=r}get isAdaptiveStream(){return this.adaptiveStreamSettings!==void 0}get mediaStreamTrack(){return this._mediaStreamTrack}setMuted(e){super.setMuted(e),this.attachedElements.forEach(n=>{e?Dr(this._mediaStreamTrack,n):kr(this._mediaStreamTrack,n)})}attach(e){if(e?super.attach(e):e=super.attach(),this.adaptiveStreamSettings&&this.elementInfos.find(n=>n.element===e)===void 0){const n=new m2(e);this.observeElementInfo(n)}return e}observeElementInfo(e){this.adaptiveStreamSettings&&this.elementInfos.find(n=>n===e)===void 0?(e.handleResize=()=>{this.debouncedHandleResize()},e.handleVisibilityChanged=()=>{this.updateVisibility()},this.elementInfos.push(e),e.observe(),this.debouncedHandleResize(),this.updateVisibility()):this.log.warn("visibility resize observer not triggered",this.logContext)}stopObservingElementInfo(e){if(!this.isAdaptiveStream){this.log.warn("stopObservingElementInfo ignored",this.logContext);return}const n=this.elementInfos.filter(i=>i===e);for(const i of n)i.stopObserving();this.elementInfos=this.elementInfos.filter(i=>i!==e),this.updateVisibility(),this.debouncedHandleResize()}detach(e){let n=[];if(e)return this.stopObservingElement(e),super.detach(e);n=super.detach();for(const i of n)this.stopObservingElement(i);return n}getDecoderImplementation(){var e;return(e=this.prevStats)===null||e===void 0?void 0:e.decoderImplementation}getReceiverStats(){return A(this,void 0,void 0,function*(){if(!this.receiver||!this.receiver.getStats)return;const e=yield this.receiver.getStats();let n,i="",r=new Map;return e.forEach(s=>{s.type==="inbound-rtp"?(i=s.codecId,n={type:"video",streamId:s.id,framesDecoded:s.framesDecoded,framesDropped:s.framesDropped,framesReceived:s.framesReceived,packetsReceived:s.packetsReceived,packetsLost:s.packetsLost,frameWidth:s.frameWidth,frameHeight:s.frameHeight,pliCount:s.pliCount,firCount:s.firCount,nackCount:s.nackCount,jitter:s.jitter,timestamp:s.timestamp,bytesReceived:s.bytesReceived,decoderImplementation:s.decoderImplementation}):s.type==="codec"&&r.set(s.id,s)}),n&&i!==""&&r.get(i)&&(n.mimeType=r.get(i).mimeType),n})}stopObservingElement(e){const n=this.elementInfos.filter(i=>i.element===e);for(const i of n)this.stopObservingElementInfo(i)}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return A(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),this.isAdaptiveStream&&this.updateVisibility()})}updateVisibility(){var e,n;const i=this.elementInfos.reduce((a,c)=>Math.max(a,c.visibilityChangedAt||0),0),r=!((n=(e=this.adaptiveStreamSettings)===null||e===void 0?void 0:e.pauseVideoInBackground)!==null&&n!==void 0)||n?this.isInBackground:!1,s=this.elementInfos.some(a=>a.pictureInPicture),o=this.elementInfos.some(a=>a.visible)&&!r||s;if(this.lastVisible!==o){if(!o&&Date.now()-i<Zc){bt.setTimeout(()=>{this.updateVisibility()},Zc);return}this.lastVisible=o,this.emit(re.VisibilityChanged,o,this)}}updateDimensions(){var e,n;let i=0,r=0;const s=this.getPixelDensity();for(const o of this.elementInfos){const a=o.width()*s,c=o.height()*s;a+c>i+r&&(i=a,r=c)}((e=this.lastDimensions)===null||e===void 0?void 0:e.width)===i&&((n=this.lastDimensions)===null||n===void 0?void 0:n.height)===r||(this.lastDimensions={width:i,height:r},this.emit(re.VideoDimensionsChanged,this.lastDimensions,this))}getPixelDensity(){var e;const n=(e=this.adaptiveStreamSettings)===null||e===void 0?void 0:e.pixelDensity;return n==="screen"?em():n||(em()>2?2:1)}}class m2{get visible(){return this.isPiP||this.isIntersecting}get pictureInPicture(){return this.isPiP}constructor(e,n){this.onVisibilityChanged=i=>{var r;const{target:s,isIntersecting:o}=i;s===this.element&&(this.isIntersecting=o,this.isPiP=ks(this.element),this.visibilityChangedAt=Date.now(),(r=this.handleVisibilityChanged)===null||r===void 0||r.call(this))},this.onEnterPiP=()=>{var i,r,s;(r=(i=window.documentPictureInPicture)===null||i===void 0?void 0:i.window)===null||r===void 0||r.addEventListener("pagehide",this.onLeavePiP),this.isPiP=ks(this.element),(s=this.handleVisibilityChanged)===null||s===void 0||s.call(this)},this.onLeavePiP=()=>{var i;this.isPiP=ks(this.element),(i=this.handleVisibilityChanged)===null||i===void 0||i.call(this)},this.element=e,this.isIntersecting=n??xd(e),this.isPiP=Ot()&&ks(e),this.visibilityChangedAt=0}width(){return this.element.clientWidth}height(){return this.element.clientHeight}observe(){var e,n,i;this.isIntersecting=xd(this.element),this.isPiP=ks(this.element),this.element.handleResize=()=>{var r;(r=this.handleResize)===null||r===void 0||r.call(this)},this.element.handleVisibilityChanged=this.onVisibilityChanged,nm().observe(this.element),tm().observe(this.element),this.element.addEventListener("enterpictureinpicture",this.onEnterPiP),this.element.addEventListener("leavepictureinpicture",this.onLeavePiP),(e=window.documentPictureInPicture)===null||e===void 0||e.addEventListener("enter",this.onEnterPiP),(i=(n=window.documentPictureInPicture)===null||n===void 0?void 0:n.window)===null||i===void 0||i.addEventListener("pagehide",this.onLeavePiP)}stopObserving(){var e,n,i,r,s;(e=nm())===null||e===void 0||e.unobserve(this.element),(n=tm())===null||n===void 0||n.unobserve(this.element),this.element.removeEventListener("enterpictureinpicture",this.onEnterPiP),this.element.removeEventListener("leavepictureinpicture",this.onLeavePiP),(i=window.documentPictureInPicture)===null||i===void 0||i.removeEventListener("enter",this.onEnterPiP),(s=(r=window.documentPictureInPicture)===null||r===void 0?void 0:r.window)===null||s===void 0||s.removeEventListener("pagehide",this.onLeavePiP)}}function ks(t){var e,n;return document.pictureInPictureElement===t?!0:!((e=window.documentPictureInPicture)===null||e===void 0)&&e.window?xd(t,(n=window.documentPictureInPicture)===null||n===void 0?void 0:n.window):!1}function xd(t,e){const n=e||window;let i=t.offsetTop,r=t.offsetLeft;const s=t.offsetWidth,o=t.offsetHeight,{hidden:a}=t,{display:c}=getComputedStyle(t);for(;t.offsetParent;)t=t.offsetParent,i+=t.offsetTop,r+=t.offsetLeft;return i<n.pageYOffset+n.innerHeight&&r<n.pageXOffset+n.innerWidth&&i+o>n.pageYOffset&&r+s>n.pageXOffset&&!a&&c!=="none"}class Bn extends Nn.EventEmitter{constructor(e,n,i,r){var s;super(),this.metadataMuted=!1,this.encryption=Ft.NONE,this.log=Ce,this.handleMuted=()=>{this.emit(re.Muted)},this.handleUnmuted=()=>{this.emit(re.Unmuted)},this.log=Gn((s=r==null?void 0:r.loggerName)!==null&&s!==void 0?s:fn.Publication),this.loggerContextCb=this.loggerContextCb,this.setMaxListeners(100),this.kind=e,this.trackSid=n,this.trackName=i,this.source=V.Source.Unknown}setTrack(e){this.track&&(this.track.off(re.Muted,this.handleMuted),this.track.off(re.Unmuted,this.handleUnmuted)),this.track=e,e&&(e.on(re.Muted,this.handleMuted),e.on(re.Unmuted,this.handleUnmuted))}get logContext(){var e;return Object.assign(Object.assign({},(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this)),we(this))}get isMuted(){return this.metadataMuted}get isEnabled(){return!0}get isSubscribed(){return this.track!==void 0}get isEncrypted(){return this.encryption!==Ft.NONE}get audioTrack(){if(Tn(this.track))return this.track}get videoTrack(){if(ns(this.track))return this.track}updateInfo(e){this.trackSid=e.sid,this.trackName=e.name,this.source=V.sourceFromProto(e.source),this.mimeType=e.mimeType,this.kind===V.Kind.Video&&e.width>0&&(this.dimensions={width:e.width,height:e.height},this.simulcasted=e.simulcast),this.encryption=e.encryption,this.trackInfo=e,this.log.debug("update publication info",Object.assign(Object.assign({},this.logContext),{info:e}))}}(function(t){(function(e){e.Desired="desired",e.Subscribed="subscribed",e.Unsubscribed="unsubscribed"})(t.SubscriptionStatus||(t.SubscriptionStatus={})),function(e){e.Allowed="allowed",e.NotAllowed="not_allowed"}(t.PermissionStatus||(t.PermissionStatus={}))})(Bn||(Bn={}));class Sd extends Bn{get isUpstreamPaused(){var e;return(e=this.track)===null||e===void 0?void 0:e.isUpstreamPaused}constructor(e,n,i,r){super(e,n.sid,n.name,r),this.track=void 0,this.handleTrackEnded=()=>{this.emit(re.Ended)},this.updateInfo(n),this.setTrack(i)}setTrack(e){this.track&&this.track.off(re.Ended,this.handleTrackEnded),super.setTrack(e),e&&e.on(re.Ended,this.handleTrackEnded)}get isMuted(){return this.track?this.track.isMuted:super.isMuted}get audioTrack(){return super.audioTrack}get videoTrack(){return super.videoTrack}get isLocal(){return!0}mute(){return A(this,void 0,void 0,function*(){var e;return(e=this.track)===null||e===void 0?void 0:e.mute()})}unmute(){return A(this,void 0,void 0,function*(){var e;return(e=this.track)===null||e===void 0?void 0:e.unmute()})}pauseUpstream(){return A(this,void 0,void 0,function*(){var e;yield(e=this.track)===null||e===void 0?void 0:e.pauseUpstream()})}resumeUpstream(){return A(this,void 0,void 0,function*(){var e;yield(e=this.track)===null||e===void 0?void 0:e.resumeUpstream()})}getTrackFeatures(){var e;if(Tn(this.track)){const n=this.track.getSourceTrackSettings(),i=new Set;return n.autoGainControl&&i.add(pt.TF_AUTO_GAIN_CONTROL),n.echoCancellation&&i.add(pt.TF_ECHO_CANCELLATION),n.noiseSuppression&&i.add(pt.TF_NOISE_SUPPRESSION),n.channelCount&&n.channelCount>1&&i.add(pt.TF_STEREO),!((e=this.options)===null||e===void 0)&&e.dtx||i.add(pt.TF_NO_DTX),this.track.enhancedNoiseCancellation&&i.add(pt.TF_ENHANCED_NOISE_CANCELLATION),Array.from(i.values())}else return[]}}function Qa(t,e){return A(this,void 0,void 0,function*(){t??(t={});let n=!1;const{audioProcessor:i,videoProcessor:r,optionsWithoutProcessor:s}=iy(t);let o=s.audio,a=s.video;if(i&&typeof s.audio=="object"&&(s.audio.processor=i),r&&typeof s.video=="object"&&(s.video.processor=r),t.audio&&typeof s.audio=="object"&&typeof s.audio.deviceId=="string"){const u=s.audio.deviceId;s.audio.deviceId={exact:u},n=!0,o=Object.assign(Object.assign({},s.audio),{deviceId:{ideal:u}})}if(s.video&&typeof s.video=="object"&&typeof s.video.deviceId=="string"){const u=s.video.deviceId;s.video.deviceId={exact:u},n=!0,a=Object.assign(Object.assign({},s.video),{deviceId:{ideal:u}})}(s.audio===!0||typeof s.audio=="object"&&!s.audio.deviceId)&&(s.audio={deviceId:"default"}),s.video===!0?s.video={deviceId:"default"}:typeof s.video=="object"&&!s.video.deviceId&&(s.video.deviceId="default");const c=ty(s,sy,oy),l=_u(c),d=navigator.mediaDevices.getUserMedia(l);s.audio&&(gt.userMediaPromiseMap.set("audioinput",d),d.catch(()=>gt.userMediaPromiseMap.delete("audioinput"))),s.video&&(gt.userMediaPromiseMap.set("videoinput",d),d.catch(()=>gt.userMediaPromiseMap.delete("videoinput")));try{const u=yield d;return yield Promise.all(u.getTracks().map(f=>A(this,void 0,void 0,function*(){const p=f.kind==="audio";let v=p?c.audio:c.video;(typeof v=="boolean"||!v)&&(v={});let h;const y=p?l.audio:l.video;typeof y!="boolean"&&(h=y);const b=f.getSettings().deviceId;h!=null&&h.deviceId&&fi(h.deviceId)!==b?h.deviceId=b:h||(h={deviceId:b});const w=WT(f,h,e);return w.kind===V.Kind.Video?w.source=V.Source.Camera:w.kind===V.Kind.Audio&&(w.source=V.Source.Microphone),w.mediaStream=u,Tn(w)&&i?yield w.setProcessor(i):ns(w)&&r&&(yield w.setProcessor(r)),w})))}catch(u){if(!n)throw u;return Qa(Object.assign(Object.assign({},t),{audio:o,video:a}),e)}})}function p2(t){return A(this,void 0,void 0,function*(){return(yield Qa({audio:!1,video:!0}))[0]})}function g2(t){return A(this,void 0,void 0,function*(){return(yield Qa({audio:!0,video:!1}))[0]})}var ci;(function(t){t.Excellent="excellent",t.Good="good",t.Poor="poor",t.Lost="lost",t.Unknown="unknown"})(ci||(ci={}));function v2(t){switch(t){case As.EXCELLENT:return ci.Excellent;case As.GOOD:return ci.Good;case As.POOR:return ci.Poor;case As.LOST:return ci.Lost;default:return ci.Unknown}}class py extends Nn.EventEmitter{get logContext(){var e,n;return Object.assign({},(n=(e=this.loggerOptions)===null||e===void 0?void 0:e.loggerContextCb)===null||n===void 0?void 0:n.call(e))}get isEncrypted(){return this.trackPublications.size>0&&Array.from(this.trackPublications.values()).every(e=>e.isEncrypted)}get isAgent(){var e;return((e=this.permissions)===null||e===void 0?void 0:e.agent)||this.kind===Yi.AGENT}get isActive(){var e;return((e=this.participantInfo)===null||e===void 0?void 0:e.state)===_r.ACTIVE}get kind(){return this._kind}get attributes(){return Object.freeze(Object.assign({},this._attributes))}constructor(e,n,i,r,s,o){let a=arguments.length>6&&arguments[6]!==void 0?arguments[6]:Yi.STANDARD;var c;super(),this.audioLevel=0,this.isSpeaking=!1,this._connectionQuality=ci.Unknown,this.log=Ce,this.log=Gn((c=o==null?void 0:o.loggerName)!==null&&c!==void 0?c:fn.Participant),this.loggerOptions=o,this.setMaxListeners(100),this.sid=e,this.identity=n,this.name=i,this.metadata=r,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this._kind=a,this._attributes=s??{}}getTrackPublications(){return Array.from(this.trackPublications.values())}getTrackPublication(e){for(const[,n]of this.trackPublications)if(n.source===e)return n}getTrackPublicationByName(e){for(const[,n]of this.trackPublications)if(n.trackName===e)return n}waitUntilActive(){return this.isActive?Promise.resolve():this.activeFuture?this.activeFuture.promise:(this.activeFuture=new Tr,this.once(Z.Active,()=>{var e,n;(n=(e=this.activeFuture)===null||e===void 0?void 0:e.resolve)===null||n===void 0||n.call(e),this.activeFuture=void 0}),this.activeFuture.promise)}get connectionQuality(){return this._connectionQuality}get isCameraEnabled(){var e;const n=this.getTrackPublication(V.Source.Camera);return!(!((e=n==null?void 0:n.isMuted)!==null&&e!==void 0)||e)}get isMicrophoneEnabled(){var e;const n=this.getTrackPublication(V.Source.Microphone);return!(!((e=n==null?void 0:n.isMuted)!==null&&e!==void 0)||e)}get isScreenShareEnabled(){return!!this.getTrackPublication(V.Source.ScreenShare)}get isLocal(){return!1}get joinedAt(){return this.participantInfo?new Date(Number.parseInt(this.participantInfo.joinedAt.toString())*1e3):new Date}updateInfo(e){var n;return this.participantInfo&&this.participantInfo.sid===e.sid&&this.participantInfo.version>e.version?!1:(this.identity=e.identity,this.sid=e.sid,this._setName(e.name),this._setMetadata(e.metadata),this._setAttributes(e.attributes),e.state===_r.ACTIVE&&((n=this.participantInfo)===null||n===void 0?void 0:n.state)!==_r.ACTIVE&&this.emit(Z.Active),e.permission&&this.setPermissions(e.permission),this.participantInfo=e,!0)}_setMetadata(e){const n=this.metadata!==e,i=this.metadata;this.metadata=e,n&&this.emit(Z.ParticipantMetadataChanged,i)}_setName(e){const n=this.name!==e;this.name=e,n&&this.emit(Z.ParticipantNameChanged,e)}_setAttributes(e){const n=bT(this.attributes,e);this._attributes=e,Object.keys(n).length>0&&this.emit(Z.AttributesChanged,n)}setPermissions(e){var n,i,r,s,o,a;const c=this.permissions,l=e.canPublish!==((n=this.permissions)===null||n===void 0?void 0:n.canPublish)||e.canSubscribe!==((i=this.permissions)===null||i===void 0?void 0:i.canSubscribe)||e.canPublishData!==((r=this.permissions)===null||r===void 0?void 0:r.canPublishData)||e.hidden!==((s=this.permissions)===null||s===void 0?void 0:s.hidden)||e.recorder!==((o=this.permissions)===null||o===void 0?void 0:o.recorder)||e.canPublishSources.length!==this.permissions.canPublishSources.length||e.canPublishSources.some((d,u)=>{var f;return d!==((f=this.permissions)===null||f===void 0?void 0:f.canPublishSources[u])})||e.canSubscribeMetrics!==((a=this.permissions)===null||a===void 0?void 0:a.canSubscribeMetrics);return this.permissions=e,l&&this.emit(Z.ParticipantPermissionsChanged,c),l}setIsSpeaking(e){e!==this.isSpeaking&&(this.isSpeaking=e,e&&(this.lastSpokeAt=new Date),this.emit(Z.IsSpeakingChanged,e))}setConnectionQuality(e){const n=this._connectionQuality;this._connectionQuality=v2(e),n!==this._connectionQuality&&this.emit(Z.ConnectionQualityChanged,this._connectionQuality)}setDisconnected(){var e,n;this.activeFuture&&((n=(e=this.activeFuture).reject)===null||n===void 0||n.call(e,new Error("Participant disconnected")),this.activeFuture=void 0)}setAudioContext(e){this.audioContext=e,this.audioTrackPublications.forEach(n=>Tn(n.track)&&n.track.setAudioContext(e))}addTrackPublication(e){e.on(re.Muted,()=>{this.emit(Z.TrackMuted,e)}),e.on(re.Unmuted,()=>{this.emit(Z.TrackUnmuted,e)});const n=e;switch(n.track&&(n.track.sid=e.trackSid),this.trackPublications.set(e.trackSid,e),e.kind){case V.Kind.Audio:this.audioTrackPublications.set(e.trackSid,e);break;case V.Kind.Video:this.videoTrackPublications.set(e.trackSid,e);break}}}function y2(t){var e,n,i;if(!t.participantSid&&!t.participantIdentity)throw new Error("Invalid track permission, must provide at least one of participantIdentity and participantSid");return new mv({participantIdentity:(e=t.participantIdentity)!==null&&e!==void 0?e:"",participantSid:(n=t.participantSid)!==null&&n!==void 0?n:"",allTracks:(i=t.allowAll)!==null&&i!==void 0?i:!1,trackSids:t.allowedTrackSids||[]})}const Sm=15e3;class b2 extends py{constructor(e,n,i,r,s){super(e,n,void 0,void 0,void 0,{loggerName:r.loggerName,loggerContextCb:()=>this.engine.logContext}),this.pendingPublishing=new Set,this.pendingPublishPromises=new Map,this.participantTrackPermissions=[],this.allParticipantsAllowedToSubscribe=!0,this.encryptionType=Ft.NONE,this.enabledPublishVideoCodecs=[],this.pendingAcks=new Map,this.pendingResponses=new Map,this.handleReconnecting=()=>{this.reconnectFuture||(this.reconnectFuture=new Tr)},this.handleReconnected=()=>{var o,a;(a=(o=this.reconnectFuture)===null||o===void 0?void 0:o.resolve)===null||a===void 0||a.call(o),this.reconnectFuture=void 0,this.updateTrackSubscriptionPermissions()},this.handleDisconnected=()=>{var o,a,c,l,d,u;this.reconnectFuture&&(this.reconnectFuture.promise.catch(f=>this.log.warn(f.message,this.logContext)),(a=(o=this.reconnectFuture)===null||o===void 0?void 0:o.reject)===null||a===void 0||a.call(o,"Got disconnected during reconnection attempt"),this.reconnectFuture=void 0),this.signalConnectedFuture&&((l=(c=this.signalConnectedFuture).reject)===null||l===void 0||l.call(c,"Got disconnected without signal connected"),this.signalConnectedFuture=void 0),(u=(d=this.activeAgentFuture)===null||d===void 0?void 0:d.reject)===null||u===void 0||u.call(d,"Got disconnected without active agent present"),this.activeAgentFuture=void 0,this.firstActiveAgent=void 0},this.handleSignalConnected=o=>{var a,c;o.participant&&this.updateInfo(o.participant),this.signalConnectedFuture||(this.signalConnectedFuture=new Tr),(c=(a=this.signalConnectedFuture).resolve)===null||c===void 0||c.call(a)},this.handleSignalRequestResponse=o=>{const{requestId:a,reason:c,message:l}=o,d=this.pendingSignalRequests.get(a);d&&(c!==Ru.OK&&d.reject(new Zh(l,c)),this.pendingSignalRequests.delete(a))},this.handleDataPacket=o=>{switch(o.value.case){case"rpcResponse":let a=o.value.value,c=null,l=null;a.value.case==="payload"?c=a.value.value:a.value.case==="error"&&(l=Qe.fromProto(a.value.value)),this.handleIncomingRpcResponse(a.requestId,c,l);break;case"rpcAck":let d=o.value.value;this.handleIncomingRpcAck(d.requestId);break}},this.updateTrackSubscriptionPermissions=()=>{this.log.debug("updating track subscription permissions",Object.assign(Object.assign({},this.logContext),{allParticipantsAllowed:this.allParticipantsAllowedToSubscribe,participantTrackPermissions:this.participantTrackPermissions})),this.engine.client.sendUpdateSubscriptionPermissions(this.allParticipantsAllowedToSubscribe,this.participantTrackPermissions.map(o=>y2(o)))},this.onTrackUnmuted=o=>{this.onTrackMuted(o,o.isUpstreamPaused)},this.onTrackMuted=(o,a)=>{if(a===void 0&&(a=!0),!o.sid){this.log.error("could not update mute status for unpublished track",Object.assign(Object.assign({},this.logContext),we(o)));return}this.engine.updateMuteStatus(o.sid,a)},this.onTrackUpstreamPaused=o=>{this.log.debug("upstream paused",Object.assign(Object.assign({},this.logContext),we(o))),this.onTrackMuted(o,!0)},this.onTrackUpstreamResumed=o=>{this.log.debug("upstream resumed",Object.assign(Object.assign({},this.logContext),we(o))),this.onTrackMuted(o,o.isMuted)},this.onTrackFeatureUpdate=o=>{const a=this.audioTrackPublications.get(o.sid);if(!a){this.log.warn("Could not update local audio track settings, missing publication for track ".concat(o.sid),this.logContext);return}this.engine.client.sendUpdateLocalAudioTrack(a.trackSid,a.getTrackFeatures())},this.handleSubscribedQualityUpdate=o=>A(this,void 0,void 0,function*(){var a,c,l,d,u;if(!(!((u=this.roomOptions)===null||u===void 0)&&u.dynacast))return;const f=this.videoTrackPublications.get(o.trackSid);if(!f){this.log.warn("received subscribed quality update for unknown track",Object.assign(Object.assign({},this.logContext),{trackSid:o.trackSid}));return}if(!f.videoTrack)return;const p=yield f.videoTrack.setPublishingCodecs(o.subscribedCodecs);try{for(var v=!0,h=zn(p),y;y=yield h.next(),a=y.done,!a;v=!0){d=y.value,v=!1;const b=d;Zk(b)&&(this.log.debug("publish ".concat(b," for ").concat(f.videoTrack.sid),Object.assign(Object.assign({},this.logContext),we(f))),yield this.publishAdditionalCodecForTrack(f.videoTrack,b,f.options))}}catch(b){c={error:b}}finally{try{!v&&!a&&(l=h.return)&&(yield l.call(h))}finally{if(c)throw c.error}}}),this.handleLocalTrackUnpublished=o=>{const a=this.trackPublications.get(o.trackSid);if(!a){this.log.warn("received unpublished event for unknown track",Object.assign(Object.assign({},this.logContext),{trackSid:o.trackSid}));return}this.unpublishTrack(a.track)},this.handleTrackEnded=o=>A(this,void 0,void 0,function*(){if(o.source===V.Source.ScreenShare||o.source===V.Source.ScreenShareAudio)this.log.debug("unpublishing local track due to TrackEnded",Object.assign(Object.assign({},this.logContext),we(o))),this.unpublishTrack(o);else if(o.isUserProvided)yield o.mute();else if(Un(o)||ii(o))try{if(Ot())try{const a=yield navigator==null?void 0:navigator.permissions.query({name:o.source===V.Source.Camera?"camera":"microphone"});if(a&&a.state==="denied")throw this.log.warn("user has revoked access to ".concat(o.source),Object.assign(Object.assign({},this.logContext),we(o))),a.onchange=()=>{a.state!=="denied"&&(o.isMuted||o.restartTrack(),a.onchange=null)},new Error("GetUserMedia Permission denied")}catch{}o.isMuted||(this.log.debug("track ended, attempting to use a different device",Object.assign(Object.assign({},this.logContext),we(o))),Un(o)?yield o.restartTrack({deviceId:"default"}):yield o.restartTrack())}catch{this.log.warn("could not restart track, muting instead",Object.assign(Object.assign({},this.logContext),we(o))),yield o.mute()}}),this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this.engine=i,this.roomOptions=r,this.setupEngine(i),this.activeDeviceMap=new Map([["audioinput","default"],["videoinput","default"],["audiooutput","default"]]),this.pendingSignalRequests=new Map,this.rpcHandlers=s}get lastCameraError(){return this.cameraError}get lastMicrophoneError(){return this.microphoneError}get isE2EEEnabled(){return this.encryptionType!==Ft.NONE}getTrackPublication(e){const n=super.getTrackPublication(e);if(n)return n}getTrackPublicationByName(e){const n=super.getTrackPublicationByName(e);if(n)return n}setupEngine(e){this.engine=e,this.engine.on(ae.RemoteMute,(n,i)=>{const r=this.trackPublications.get(n);!r||!r.track||(i?r.mute():r.unmute())}),this.engine.on(ae.Connected,this.handleReconnected).on(ae.SignalConnected,this.handleSignalConnected).on(ae.SignalRestarted,this.handleReconnected).on(ae.SignalResumed,this.handleReconnected).on(ae.Restarting,this.handleReconnecting).on(ae.Resuming,this.handleReconnecting).on(ae.LocalTrackUnpublished,this.handleLocalTrackUnpublished).on(ae.SubscribedQualityUpdate,this.handleSubscribedQualityUpdate).on(ae.Disconnected,this.handleDisconnected).on(ae.SignalRequestResponse,this.handleSignalRequestResponse).on(ae.DataPacketReceived,this.handleDataPacket),this.signalConnectedFuture=void 0}setMetadata(e){return A(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({metadata:e})})}setName(e){return A(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({name:e})})}setAttributes(e){return A(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({attributes:e})})}requestMetadataUpdate(e){return A(this,arguments,void 0,function(n){var i=this;let{metadata:r,name:s,attributes:o}=n;return function*(){return new Promise((a,c)=>A(i,void 0,void 0,function*(){var l,d;try{let u=!1;const f=yield this.engine.client.sendUpdateLocalMetadata((l=r??this.metadata)!==null&&l!==void 0?l:"",(d=s??this.name)!==null&&d!==void 0?d:"",o),p=performance.now();for(this.pendingSignalRequests.set(f,{resolve:a,reject:v=>{c(v),u=!0},values:{name:s,metadata:r,attributes:o}});performance.now()-p<5e3&&!u;){if((!s||this.name===s)&&(!r||this.metadata===r)&&(!o||Object.entries(o).every(v=>{let[h,y]=v;return this.attributes[h]===y||y===""&&!this.attributes[h]}))){this.pendingSignalRequests.delete(f),a();return}yield jt(50)}c(new Zh("Request to update local metadata timed out","TimeoutError"))}catch(u){u instanceof Error&&c(u)}}))}()})}setCameraEnabled(e,n,i){return this.setTrackEnabled(V.Source.Camera,e,n,i)}setMicrophoneEnabled(e,n,i){return this.setTrackEnabled(V.Source.Microphone,e,n,i)}setScreenShareEnabled(e,n,i){return this.setTrackEnabled(V.Source.ScreenShare,e,n,i)}setPermissions(e){const n=this.permissions,i=super.setPermissions(e);return i&&n&&this.emit(Z.ParticipantPermissionsChanged,n),i}setE2EEEnabled(e){return A(this,void 0,void 0,function*(){this.encryptionType=e?Ft.GCM:Ft.NONE,yield this.republishAllTracks(void 0,!1)})}setTrackEnabled(e,n,i,r){return A(this,void 0,void 0,function*(){var s,o;this.log.debug("setTrackEnabled",Object.assign(Object.assign({},this.logContext),{source:e,enabled:n})),this.republishPromise&&(yield this.republishPromise);let a=this.getTrackPublication(e);if(n)if(a)yield a.unmute();else{let c;if(this.pendingPublishing.has(e)){const l=yield this.waitForPendingPublicationOfSource(e);return l||this.log.info("waiting for pending publication promise timed out",Object.assign(Object.assign({},this.logContext),{source:e})),yield l==null?void 0:l.unmute(),l}this.pendingPublishing.add(e);try{switch(e){case V.Source.Camera:c=yield this.createTracks({video:(s=i)!==null&&s!==void 0?s:!0});break;case V.Source.Microphone:c=yield this.createTracks({audio:(o=i)!==null&&o!==void 0?o:!0});break;case V.Source.ScreenShare:c=yield this.createScreenTracks(Object.assign({},i));break;default:throw new Wn(e)}}catch(l){throw c==null||c.forEach(d=>{d.stop()}),l instanceof Error&&this.emit(Z.MediaDevicesError,l,pd(e)),this.pendingPublishing.delete(e),l}for(const l of c)e===V.Source.Microphone&&Tn(l)&&(r!=null&&r.preConnectBuffer)&&(this.log.info("starting preconnect buffer for microphone",Object.assign({},this.logContext)),l.startPreConnectBuffer());try{const l=[];for(const u of c)this.log.info("publishing track",Object.assign(Object.assign({},this.logContext),we(u))),l.push(this.publishTrack(u,r));[a]=yield Promise.all(l)}catch(l){throw c==null||c.forEach(d=>{d.stop()}),l}finally{this.pendingPublishing.delete(e)}}else if(!(a!=null&&a.track)&&this.pendingPublishing.has(e)&&(a=yield this.waitForPendingPublicationOfSource(e),a||this.log.info("waiting for pending publication promise timed out",Object.assign(Object.assign({},this.logContext),{source:e}))),a&&a.track)if(e===V.Source.ScreenShare){a=yield this.unpublishTrack(a.track);const c=this.getTrackPublication(V.Source.ScreenShareAudio);c&&c.track&&this.unpublishTrack(c.track)}else yield a.mute();return a})}enableCameraAndMicrophone(){return A(this,void 0,void 0,function*(){if(!(this.pendingPublishing.has(V.Source.Camera)||this.pendingPublishing.has(V.Source.Microphone))){this.pendingPublishing.add(V.Source.Camera),this.pendingPublishing.add(V.Source.Microphone);try{const e=yield this.createTracks({audio:!0,video:!0});yield Promise.all(e.map(n=>this.publishTrack(n)))}finally{this.pendingPublishing.delete(V.Source.Camera),this.pendingPublishing.delete(V.Source.Microphone)}}})}createTracks(e){return A(this,void 0,void 0,function*(){var n,i;e??(e={});const r=ty(e,(n=this.roomOptions)===null||n===void 0?void 0:n.audioCaptureDefaults,(i=this.roomOptions)===null||i===void 0?void 0:i.videoCaptureDefaults);try{return(yield Qa(r,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext})).map(a=>(Tn(a)&&(this.microphoneError=void 0,a.setAudioContext(this.audioContext),a.source=V.Source.Microphone,this.emit(Z.AudioStreamAcquired)),ns(a)&&(this.cameraError=void 0,a.source=V.Source.Camera),a))}catch(s){throw s instanceof Error&&(e.audio&&(this.microphoneError=s),e.video&&(this.cameraError=s)),s}})}createScreenTracks(e){return A(this,void 0,void 0,function*(){if(e===void 0&&(e={}),navigator.mediaDevices.getDisplayMedia===void 0)throw new Iu("getDisplayMedia not supported");e.resolution===void 0&&!tT()&&(e.resolution=Mu.h1080fps30.resolution);const n=gT(e),i=yield navigator.mediaDevices.getDisplayMedia(n),r=i.getVideoTracks();if(r.length===0)throw new Wn("no video track found");const s=new Ea(r[0],void 0,!1,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});s.source=V.Source.ScreenShare,e.contentHint&&(s.mediaStreamTrack.contentHint=e.contentHint);const o=[s];if(i.getAudioTracks().length>0){this.emit(Z.AudioStreamAcquired);const a=new Ta(i.getAudioTracks()[0],void 0,!1,this.audioContext,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});a.source=V.Source.ScreenShareAudio,o.push(a)}return o})}publishTrack(e,n){return A(this,void 0,void 0,function*(){return this.publishOrRepublishTrack(e,n)})}publishOrRepublishTrack(e,n){return A(this,arguments,void 0,function(i,r){var s=this;let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return function*(){var a,c,l,d;Un(i)&&i.setAudioContext(s.audioContext),yield(a=s.reconnectFuture)===null||a===void 0?void 0:a.promise,s.republishPromise&&!o&&(yield s.republishPromise),jr(i)&&s.pendingPublishPromises.has(i)&&(yield s.pendingPublishPromises.get(i));let u;if(i instanceof MediaStreamTrack)u=i.getConstraints();else{u=i.constraints;let b;switch(i.source){case V.Source.Microphone:b="audioinput";break;case V.Source.Camera:b="videoinput"}b&&s.activeDeviceMap.has(b)&&(u=Object.assign(Object.assign({},u),{deviceId:s.activeDeviceMap.get(b)}))}if(i instanceof MediaStreamTrack)switch(i.kind){case"audio":i=new Ta(i,u,!0,s.audioContext,{loggerName:s.roomOptions.loggerName,loggerContextCb:()=>s.logContext});break;case"video":i=new Ea(i,u,!0,{loggerName:s.roomOptions.loggerName,loggerContextCb:()=>s.logContext});break;default:throw new Wn("unsupported MediaStreamTrack kind ".concat(i.kind))}else i.updateLoggerOptions({loggerName:s.roomOptions.loggerName,loggerContextCb:()=>s.logContext});let f;if(s.trackPublications.forEach(b=>{b.track&&b.track===i&&(f=b)}),f)return s.log.warn("track has already been published, skipping",Object.assign(Object.assign({},s.logContext),we(f))),f;const p="channelCount"in i.mediaStreamTrack.getSettings()&&i.mediaStreamTrack.getSettings().channelCount===2||i.mediaStreamTrack.getConstraints().channelCount===2,v=(c=r==null?void 0:r.forceStereo)!==null&&c!==void 0?c:p;v&&(r||(r={}),r.dtx===void 0&&s.log.info("Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work.",Object.assign(Object.assign({},s.logContext),we(i))),r.red===void 0&&s.log.info("Opus RED will be disabled for stereo tracks by default. Enable them explicitly to make it work."),(l=r.dtx)!==null&&l!==void 0||(r.dtx=!1),(d=r.red)!==null&&d!==void 0||(r.red=!1));const h=Object.assign(Object.assign({},s.roomOptions.publishDefaults),r);!iT()&&s.roomOptions.e2ee&&(s.log.info("End-to-end encryption is set up, simulcast publishing will be disabled on Safari versions and iOS browsers running iOS < v17.2",Object.assign({},s.logContext)),h.simulcast=!1),h.source&&(i.source=h.source);const y=new Promise((b,w)=>A(s,void 0,void 0,function*(){try{if(this.engine.client.currentState!==Be.CONNECTED){this.log.debug("deferring track publication until signal is connected",Object.assign(Object.assign({},this.logContext),{track:we(i)}));const C=setTimeout(()=>{w(new Gh("publishing rejected as engine not connected within timeout",408))},15e3);yield this.waitUntilEngineConnected(),clearTimeout(C);const S=yield this.publish(i,h,v);b(S)}else try{const C=yield this.publish(i,h,v);b(C)}catch(C){w(C)}}catch(C){w(C)}}));s.pendingPublishPromises.set(i,y);try{return yield y}catch(b){throw b}finally{s.pendingPublishPromises.delete(i)}}()})}waitUntilEngineConnected(){return this.signalConnectedFuture||(this.signalConnectedFuture=new Tr),this.signalConnectedFuture.promise}hasPermissionsToPublish(e){if(!this.permissions)return this.log.warn("no permissions present for publishing track",Object.assign(Object.assign({},this.logContext),we(e))),!1;const{canPublish:n,canPublishSources:i}=this.permissions;return n&&(i.length===0||i.map(r=>xT(r)).includes(e.source))?!0:(this.log.warn("insufficient permissions to publish",Object.assign(Object.assign({},this.logContext),we(e))),!1)}publish(e,n,i){return A(this,void 0,void 0,function*(){var r,s,o,a,c,l,d,u,f,p;if(!this.hasPermissionsToPublish(e))throw new Gh("failed to publish track, insufficient permissions",403);Array.from(this.trackPublications.values()).find(_=>jr(e)&&_.source===e.source)&&e.source!==V.Source.Unknown&&this.log.info("publishing a second track with the same source: ".concat(e.source),Object.assign(Object.assign({},this.logContext),we(e))),n.stopMicTrackOnMute&&Tn(e)&&(e.stopOnMute=!0),e.source===V.Source.ScreenShare&&qr()&&(n.simulcast=!1),n.videoCodec==="av1"&&!Xk()&&(n.videoCodec=void 0),n.videoCodec==="vp9"&&!Qk()&&(n.videoCodec=void 0),n.videoCodec===void 0&&(n.videoCodec=gd),this.enabledPublishVideoCodecs.length>0&&(this.enabledPublishVideoCodecs.some(_=>n.videoCodec===sa(_.mime))||(n.videoCodec=sa(this.enabledPublishVideoCodecs[0].mime)));const h=n.videoCodec;e.on(re.Muted,this.onTrackMuted),e.on(re.Unmuted,this.onTrackUnmuted),e.on(re.Ended,this.handleTrackEnded),e.on(re.UpstreamPaused,this.onTrackUpstreamPaused),e.on(re.UpstreamResumed,this.onTrackUpstreamResumed),e.on(re.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate);const y=[],b=!(!((r=n.dtx)!==null&&r!==void 0)||r),w=e.getSourceTrackSettings();w.autoGainControl&&y.push(pt.TF_AUTO_GAIN_CONTROL),w.echoCancellation&&y.push(pt.TF_ECHO_CANCELLATION),w.noiseSuppression&&y.push(pt.TF_NOISE_SUPPRESSION),w.channelCount&&w.channelCount>1&&y.push(pt.TF_STEREO),b&&y.push(pt.TF_NO_DTX),Un(e)&&e.hasPreConnectBuffer&&y.push(pt.TF_PRECONNECT_BUFFER);const C=new Yl({cid:e.mediaStreamTrack.id,name:n.name,type:V.kindToProto(e.kind),muted:e.isMuted,source:V.sourceToProto(e.source),disableDtx:b,encryption:this.encryptionType,stereo:i,disableRed:this.isE2EEEnabled||!(!((s=n.red)!==null&&s!==void 0)||s),stream:n==null?void 0:n.stream,backupCodecPolicy:n==null?void 0:n.backupCodecPolicy,audioFeatures:y});let S;if(e.kind===V.Kind.Video){let _={width:0,height:0};try{_=yield e.waitForDimensions()}catch{const I=(a=(o=this.roomOptions.videoCaptureDefaults)===null||o===void 0?void 0:o.resolution)!==null&&a!==void 0?a:zs.h720.resolution;_={width:I.width,height:I.height},this.log.error("could not determine track dimensions, using defaults",Object.assign(Object.assign(Object.assign({},this.logContext),we(e)),{dims:_}))}C.width=_.width,C.height=_.height,ii(e)&&(Kn(h)&&(e.source===V.Source.ScreenShare&&(n.scalabilityMode="L1T3","contentHint"in e.mediaStreamTrack&&(e.mediaStreamTrack.contentHint="motion",this.log.info("forcing contentHint to motion for screenshare with SVC codecs",Object.assign(Object.assign({},this.logContext),we(e))))),n.scalabilityMode=(c=n.scalabilityMode)!==null&&c!==void 0?c:"L3T3_KEY"),C.simulcastCodecs=[new Zl({codec:h,cid:e.mediaStreamTrack.id})],n.backupCodec===!0&&(n.backupCodec={codec:gd}),n.backupCodec&&h!==n.backupCodec.codec&&C.encryption===Ft.NONE&&(this.roomOptions.dynacast||(this.roomOptions.dynacast=!0),C.simulcastCodecs.push(new Zl({codec:n.backupCodec.codec,cid:""})))),S=yd(e.source===V.Source.ScreenShare,C.width,C.height,n),C.layers=ym(C.width,C.height,S,Kn(n.videoCodec))}else e.kind===V.Kind.Audio&&(S=[{maxBitrate:(l=n.audioPreset)===null||l===void 0?void 0:l.maxBitrate,priority:(u=(d=n.audioPreset)===null||d===void 0?void 0:d.priority)!==null&&u!==void 0?u:"high",networkPriority:(p=(f=n.audioPreset)===null||f===void 0?void 0:f.priority)!==null&&p!==void 0?p:"high"}]);if(!this.engine||this.engine.isClosed)throw new ht("cannot publish track when not connected");const x=()=>A(this,void 0,void 0,function*(){var _,k,I;if(!this.engine.pcManager)throw new ht("pcManager is not ready");if(e.sender=yield this.engine.createSender(e,n,S),ii(e)&&((_=n.degradationPreference)!==null&&_!==void 0||(n.degradationPreference=t2(e)),e.setDegradationPreference(n.degradationPreference)),S)if(qr()&&e.kind===V.Kind.Audio){let N;for(const K of this.engine.pcManager.publisher.getTransceivers())if(K.sender===e.sender){N=K;break}N&&this.engine.pcManager.publisher.setTrackCodecBitrate({transceiver:N,codec:"opus",maxbr:!((k=S[0])===null||k===void 0)&&k.maxBitrate?S[0].maxBitrate/1e3:0})}else e.codec&&Kn(e.codec)&&(!((I=S[0])===null||I===void 0)&&I.maxBitrate)&&this.engine.pcManager.publisher.setTrackCodecBitrate({cid:C.cid,codec:e.codec,maxbr:S[0].maxBitrate/1e3});yield this.engine.negotiate()});let T;const E=new Promise((_,k)=>A(this,void 0,void 0,function*(){var I;try{T=yield this.engine.addTrack(C),_(T)}catch(N){e.sender&&(!((I=this.engine.pcManager)===null||I===void 0)&&I.publisher)&&(this.engine.pcManager.publisher.removeTrack(e.sender),yield this.engine.negotiate().catch(K=>{this.log.error("failed to negotiate after removing track due to failed add track request",Object.assign(Object.assign(Object.assign({},this.logContext),we(e)),{error:K}))})),k(N)}}));if(this.enabledPublishVideoCodecs.length>0)T=(yield Promise.all([E,x()]))[0];else{T=yield E;let _;if(T.codecs.forEach(k=>{_===void 0&&(_=k.mimeType)}),_&&e.kind===V.Kind.Video){const k=sa(_);k!==h&&(this.log.debug("falling back to server selected codec",Object.assign(Object.assign(Object.assign({},this.logContext),we(e)),{codec:k})),n.videoCodec=k,S=yd(e.source===V.Source.ScreenShare,C.width,C.height,n))}yield x()}const P=new Sd(e.kind,T,e,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});if(P.options=n,e.sid=T.sid,this.log.debug("publishing ".concat(e.kind," with encodings"),Object.assign(Object.assign({},this.logContext),{encodings:S,trackInfo:T})),ii(e)?e.startMonitor(this.engine.client):Un(e)&&e.startMonitor(),this.addTrackPublication(P),this.emit(Z.LocalTrackPublished,P),Un(e)&&T.audioFeatures.includes(pt.TF_PRECONNECT_BUFFER)){const _=e.getPreConnectBuffer();this.on(Z.LocalTrackSubscribed,k=>{if(k.trackSid===T.sid){if(!e.hasPreConnectBuffer){this.log.warn("subscribe event came to late, buffer already closed",this.logContext);return}this.log.debug("finished recording preconnect buffer",Object.assign(Object.assign({},this.logContext),we(e))),e.stopPreConnectBuffer()}}),_&&new Promise((I,N)=>A(this,void 0,void 0,function*(){var K,J,se,ie,X,O;try{this.log.debug("waiting for agent",Object.assign(Object.assign({},this.logContext),we(e)));const te=setTimeout(()=>{N(new Error("agent not active within 10 seconds"))},1e4),j=yield this.waitUntilActiveAgentPresent();clearTimeout(te),this.log.debug("sending preconnect buffer",Object.assign(Object.assign({},this.logContext),we(e)));const q=yield this.streamBytes({name:"preconnect-buffer",mimeType:"audio/opus",topic:"lk.agent.pre-connect-audio-buffer",destinationIdentities:[j.identity],attributes:{trackId:P.trackSid,sampleRate:String((X=w.sampleRate)!==null&&X!==void 0?X:"48000"),channels:String((O=w.channelCount)!==null&&O!==void 0?O:"1")}});try{for(var oe=!0,L=zn(_),F;F=yield L.next(),K=F.done,!K;oe=!0){ie=F.value,oe=!1;const ee=ie;yield q.write(ee)}}catch(ee){J={error:ee}}finally{try{!oe&&!K&&(se=L.return)&&(yield se.call(L))}finally{if(J)throw J.error}}yield q.close(),I()}catch(te){N(te)}})).then(()=>{this.log.debug("preconnect buffer sent successfully",Object.assign(Object.assign({},this.logContext),we(e)))}).catch(I=>{this.log.error("error sending preconnect buffer",Object.assign(Object.assign(Object.assign({},this.logContext),we(e)),{error:I}))})}return P})}get isLocal(){return!0}publishAdditionalCodecForTrack(e,n,i){return A(this,void 0,void 0,function*(){var r;if(this.encryptionType!==Ft.NONE)return;let s;if(this.trackPublications.forEach(p=>{p.track&&p.track===e&&(s=p)}),!s)throw new Wn("track is not published");if(!ii(e))throw new Wn("track is not a video track");const o=Object.assign(Object.assign({},(r=this.roomOptions)===null||r===void 0?void 0:r.publishDefaults),i),a=XT(e,n,o);if(!a){this.log.info("backup codec has been disabled, ignoring request to add additional codec for track",Object.assign(Object.assign({},this.logContext),we(e)));return}const c=e.addSimulcastTrack(n,a);if(!c)return;const l=new Yl({cid:c.mediaStreamTrack.id,type:V.kindToProto(e.kind),muted:e.isMuted,source:V.sourceToProto(e.source),sid:e.sid,simulcastCodecs:[{codec:o.videoCodec,cid:c.mediaStreamTrack.id}]});if(l.layers=ym(l.width,l.height,a),!this.engine||this.engine.isClosed)throw new ht("cannot publish track when not connected");const d=()=>A(this,void 0,void 0,function*(){yield this.engine.createSimulcastSender(e,c,o,a),yield this.engine.negotiate()}),f=(yield Promise.all([this.engine.addTrack(l),d()]))[0];this.log.debug("published ".concat(n," for track ").concat(e.sid),Object.assign(Object.assign({},this.logContext),{encodings:a,trackInfo:f}))})}unpublishTrack(e,n){return A(this,void 0,void 0,function*(){var i,r;if(jr(e)){const l=this.pendingPublishPromises.get(e);l&&(this.log.info("awaiting publish promise before attempting to unpublish",Object.assign(Object.assign({},this.logContext),we(e))),yield l)}const s=this.getPublicationForTrack(e),o=s?we(s):void 0;if(this.log.debug("unpublishing track",Object.assign(Object.assign({},this.logContext),o)),!s||!s.track){this.log.warn("track was not unpublished because no publication was found",Object.assign(Object.assign({},this.logContext),o));return}e=s.track,e.off(re.Muted,this.onTrackMuted),e.off(re.Unmuted,this.onTrackUnmuted),e.off(re.Ended,this.handleTrackEnded),e.off(re.UpstreamPaused,this.onTrackUpstreamPaused),e.off(re.UpstreamResumed,this.onTrackUpstreamResumed),e.off(re.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate),n===void 0&&(n=(r=(i=this.roomOptions)===null||i===void 0?void 0:i.stopLocalTrackOnUnpublish)!==null&&r!==void 0?r:!0),n?e.stop():e.stopMonitor();let a=!1;const c=e.sender;if(e.sender=void 0,this.engine.pcManager&&this.engine.pcManager.currentState<Je.FAILED&&c)try{for(const l of this.engine.pcManager.publisher.getTransceivers())l.sender===c&&(l.direction="inactive",a=!0);if(this.engine.removeTrack(c)&&(a=!0),ii(e)){for(const[,l]of e.simulcastCodecs)l.sender&&(this.engine.removeTrack(l.sender)&&(a=!0),l.sender=void 0);e.simulcastCodecs.clear()}}catch(l){this.log.warn("failed to unpublish track",Object.assign(Object.assign(Object.assign({},this.logContext),o),{error:l}))}switch(this.trackPublications.delete(s.trackSid),s.kind){case V.Kind.Audio:this.audioTrackPublications.delete(s.trackSid);break;case V.Kind.Video:this.videoTrackPublications.delete(s.trackSid);break}return this.emit(Z.LocalTrackUnpublished,s),s.setTrack(void 0),a&&(yield this.engine.negotiate()),s})}unpublishTracks(e){return A(this,void 0,void 0,function*(){return(yield Promise.all(e.map(i=>this.unpublishTrack(i)))).filter(i=>!!i)})}republishAllTracks(e){return A(this,arguments,void 0,function(n){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){i.republishPromise&&(yield i.republishPromise),i.republishPromise=new Promise((s,o)=>A(i,void 0,void 0,function*(){try{const a=[];this.trackPublications.forEach(c=>{c.track&&(n&&(c.options=Object.assign(Object.assign({},c.options),n)),a.push(c))}),yield Promise.all(a.map(c=>A(this,void 0,void 0,function*(){const l=c.track;yield this.unpublishTrack(l,!1),r&&!l.isMuted&&l.source!==V.Source.ScreenShare&&l.source!==V.Source.ScreenShareAudio&&(Un(l)||ii(l))&&!l.isUserProvided&&(this.log.debug("restarting existing track",Object.assign(Object.assign({},this.logContext),{track:c.trackSid})),yield l.restartTrack()),yield this.publishOrRepublishTrack(l,c.options,!0)}))),s()}catch(a){o(a)}finally{this.republishPromise=void 0}})),yield i.republishPromise}()})}publishData(e){return A(this,arguments,void 0,function(n){var i=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return function*(){const s=r.reliable?be.RELIABLE:be.LOSSY,o=r.destinationIdentities,a=r.topic,c=new Mt({kind:s,value:{case:"user",value:new Z0({participantIdentity:i.identity,payload:n,destinationIdentities:o,topic:a})}});yield i.engine.sendDataPacket(c,s)}()})}publishDtmf(e,n){return A(this,void 0,void 0,function*(){const i=new Mt({kind:be.RELIABLE,value:{case:"sipDtmf",value:new Y0({code:e,digit:n})}});yield this.engine.sendDataPacket(i,be.RELIABLE)})}sendChatMessage(e,n){return A(this,void 0,void 0,function*(){const i={id:crypto.randomUUID(),message:e,timestamp:Date.now(),attachedFiles:n==null?void 0:n.attachments},r=new Mt({value:{case:"chatMessage",value:new Hl(Object.assign(Object.assign({},i),{timestamp:ze.parse(i.timestamp)}))}});return yield this.engine.sendDataPacket(r,be.RELIABLE),this.emit(Z.ChatMessage,i),i})}editChatMessage(e,n){return A(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},n),{message:e,editTimestamp:Date.now()}),r=new Mt({value:{case:"chatMessage",value:new Hl(Object.assign(Object.assign({},i),{timestamp:ze.parse(i.timestamp),editTimestamp:ze.parse(i.editTimestamp)}))}});return yield this.engine.sendDataPacket(r,be.RELIABLE),this.emit(Z.ChatMessage,i),i})}sendText(e,n){return A(this,void 0,void 0,function*(){var i;const r=crypto.randomUUID(),o=new TextEncoder().encode(e).byteLength,a=(i=n==null?void 0:n.attachments)===null||i===void 0?void 0:i.map(()=>crypto.randomUUID()),c=new Array(a?a.length+1:1).fill(0),l=(u,f)=>{var p;c[f]=u;const v=c.reduce((h,y)=>h+y,0);(p=n==null?void 0:n.onProgress)===null||p===void 0||p.call(n,v)},d=yield this.streamText({streamId:r,totalSize:o,destinationIdentities:n==null?void 0:n.destinationIdentities,topic:n==null?void 0:n.topic,attachedStreamIds:a,attributes:n==null?void 0:n.attributes});return yield d.write(e),l(1,0),yield d.close(),n!=null&&n.attachments&&a&&(yield Promise.all(n.attachments.map((u,f)=>A(this,void 0,void 0,function*(){return this._sendFile(a[f],u,{topic:n.topic,mimeType:u.type,onProgress:p=>{l(p,f+1)}})})))),d.info})}streamText(e){return A(this,void 0,void 0,function*(){var n,i;const r=(n=e==null?void 0:e.streamId)!==null&&n!==void 0?n:crypto.randomUUID(),s={id:r,mimeType:"text/plain",timestamp:Date.now(),topic:(i=e==null?void 0:e.topic)!==null&&i!==void 0?i:"",size:e==null?void 0:e.totalSize,attributes:e==null?void 0:e.attributes},o=new Wl({streamId:r,mimeType:s.mimeType,topic:s.topic,timestamp:Li(s.timestamp),totalLength:Li(e==null?void 0:e.totalSize),attributes:s.attributes,contentHeader:{case:"textHeader",value:new av({version:e==null?void 0:e.version,attachedStreamIds:e==null?void 0:e.attachedStreamIds,replyToStreamId:e==null?void 0:e.replyToStreamId,operationType:(e==null?void 0:e.type)==="update"?zl.UPDATE:zl.CREATE})}}),a=e==null?void 0:e.destinationIdentities,c=new Mt({destinationIdentities:a,value:{case:"streamHeader",value:o}});yield this.engine.sendDataPacket(c,be.RELIABLE);let l=0;const d=this,u=new WritableStream({write(v){return A(this,void 0,void 0,function*(){for(const h of mT(v,Sm)){yield d.engine.waitForBufferStatusLow(be.RELIABLE);const y=new ql({content:h,streamId:r,chunkIndex:Li(l)}),b=new Mt({destinationIdentities:a,value:{case:"streamChunk",value:y}});yield d.engine.sendDataPacket(b,be.RELIABLE),l+=1}})},close(){return A(this,void 0,void 0,function*(){const v=new Kl({streamId:r}),h=new Mt({destinationIdentities:a,value:{case:"streamTrailer",value:v}});yield d.engine.sendDataPacket(h,be.RELIABLE)})},abort(v){console.log("Sink error:",v)}});let f=()=>A(this,void 0,void 0,function*(){yield p.close()});d.engine.once(ae.Closing,f);const p=new u2(u,s,()=>this.engine.off(ae.Closing,f));return p})}sendFile(e,n){return A(this,void 0,void 0,function*(){const i=crypto.randomUUID();return yield this._sendFile(i,e,n),{id:i}})}_sendFile(e,n,i){return A(this,void 0,void 0,function*(){var r;const s=yield this.streamBytes({streamId:e,totalSize:n.size,name:n.name,mimeType:(r=i==null?void 0:i.mimeType)!==null&&r!==void 0?r:n.type,topic:i==null?void 0:i.topic,destinationIdentities:i==null?void 0:i.destinationIdentities}),o=n.stream().getReader();for(;;){const{done:a,value:c}=yield o.read();if(a)break;yield s.write(c)}return yield s.close(),s.info})}streamBytes(e){return A(this,void 0,void 0,function*(){var n,i,r,s,o;const a=(n=e==null?void 0:e.streamId)!==null&&n!==void 0?n:crypto.randomUUID(),c=e==null?void 0:e.destinationIdentities,l={id:a,mimeType:(i=e==null?void 0:e.mimeType)!==null&&i!==void 0?i:"application/octet-stream",topic:(r=e==null?void 0:e.topic)!==null&&r!==void 0?r:"",timestamp:Date.now(),attributes:e==null?void 0:e.attributes,size:e==null?void 0:e.totalSize,name:(s=e==null?void 0:e.name)!==null&&s!==void 0?s:"unknown"},d=new Wl({totalLength:Li((o=l.size)!==null&&o!==void 0?o:0),mimeType:l.mimeType,streamId:a,topic:l.topic,timestamp:Li(Date.now()),attributes:l.attributes,contentHeader:{case:"byteHeader",value:new cv({name:l.name})}}),u=new Mt({destinationIdentities:c,value:{case:"streamHeader",value:d}});yield this.engine.sendDataPacket(u,be.RELIABLE);let f=0;const p=new Nt,v=this.engine,h=this.log,y=new WritableStream({write(w){return A(this,void 0,void 0,function*(){const C=yield p.lock();let S=0;try{for(;S<w.byteLength;){const x=w.slice(S,S+Sm);yield v.waitForBufferStatusLow(be.RELIABLE);const T=new Mt({destinationIdentities:c,value:{case:"streamChunk",value:new ql({content:x,streamId:a,chunkIndex:Li(f)})}});yield v.sendDataPacket(T,be.RELIABLE),f+=1,S+=x.byteLength}}finally{C()}})},close(){return A(this,void 0,void 0,function*(){const w=new Kl({streamId:a}),C=new Mt({destinationIdentities:c,value:{case:"streamTrailer",value:w}});yield v.sendDataPacket(C,be.RELIABLE)})},abort(w){h.error("Sink error:",w)}});return new f2(y,l)})}performRpc(e){return A(this,arguments,void 0,function(n){var i=this;let{destinationIdentity:r,method:s,payload:o,responseTimeout:a=1e4}=n;return function*(){return new Promise((l,d)=>A(i,void 0,void 0,function*(){var u,f,p,v;if(Vu(o)>ay){d(Qe.builtIn("REQUEST_PAYLOAD_TOO_LARGE"));return}if(!((f=(u=this.engine.latestJoinResponse)===null||u===void 0?void 0:u.serverInfo)===null||f===void 0)&&f.version&&mi((v=(p=this.engine.latestJoinResponse)===null||p===void 0?void 0:p.serverInfo)===null||v===void 0?void 0:v.version,"1.8.0")<0){d(Qe.builtIn("UNSUPPORTED_SERVER"));return}const h=crypto.randomUUID();yield this.publishRpcRequest(r,h,s,o,a-2e3);const y=setTimeout(()=>{this.pendingAcks.delete(h),d(Qe.builtIn("CONNECTION_TIMEOUT")),this.pendingResponses.delete(h),clearTimeout(b)},2e3);this.pendingAcks.set(h,{resolve:()=>{clearTimeout(y)},participantIdentity:r});const b=setTimeout(()=>{this.pendingResponses.delete(h),d(Qe.builtIn("RESPONSE_TIMEOUT"))},a);this.pendingResponses.set(h,{resolve:(w,C)=>{clearTimeout(b),this.pendingAcks.has(h)&&(console.warn("RPC response received before ack",h),this.pendingAcks.delete(h),clearTimeout(y)),C?d(C):l(w??"")},participantIdentity:r})}))}()})}registerRpcMethod(e,n){this.rpcHandlers.has(e)&&this.log.warn("you're overriding the RPC handler for method ".concat(e,", in the future this will throw an error")),this.rpcHandlers.set(e,n)}unregisterRpcMethod(e){this.rpcHandlers.delete(e)}setTrackSubscriptionPermissions(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];this.participantTrackPermissions=n,this.allParticipantsAllowedToSubscribe=e,this.engine.client.isDisconnected||this.updateTrackSubscriptionPermissions()}handleIncomingRpcAck(e){const n=this.pendingAcks.get(e);n?(n.resolve(),this.pendingAcks.delete(e)):console.error("Ack received for unexpected RPC request",e)}handleIncomingRpcResponse(e,n,i){const r=this.pendingResponses.get(e);r?(r.resolve(n,i),this.pendingResponses.delete(e)):console.error("Response received for unexpected RPC request",e)}publishRpcRequest(e,n,i,r,s){return A(this,void 0,void 0,function*(){const o=new Mt({destinationIdentities:[e],kind:be.RELIABLE,value:{case:"rpcRequest",value:new J0({id:n,method:i,payload:r,responseTimeoutMs:s,version:1})}});yield this.engine.sendDataPacket(o,be.RELIABLE)})}handleParticipantDisconnected(e){for(const[n,{participantIdentity:i}]of this.pendingAcks)i===e&&this.pendingAcks.delete(n);for(const[n,{participantIdentity:i,resolve:r}]of this.pendingResponses)i===e&&(r(null,Qe.builtIn("RECIPIENT_DISCONNECTED")),this.pendingResponses.delete(n))}setEnabledPublishCodecs(e){this.enabledPublishVideoCodecs=e.filter(n=>n.mime.split("/")[0].toLowerCase()==="video")}updateInfo(e){return super.updateInfo(e)?(e.tracks.forEach(n=>{var i,r;const s=this.trackPublications.get(n.sid);if(s){const o=s.isMuted||((r=(i=s.track)===null||i===void 0?void 0:i.isUpstreamPaused)!==null&&r!==void 0?r:!1);o!==n.muted&&(this.log.debug("updating server mute state after reconcile",Object.assign(Object.assign(Object.assign({},this.logContext),we(s)),{mutedOnServer:o})),this.engine.client.sendMuteTrack(n.sid,o))}}),!0):!1}setActiveAgent(e){var n,i,r,s;this.firstActiveAgent=e,e&&!this.firstActiveAgent&&(this.firstActiveAgent=e),e?(i=(n=this.activeAgentFuture)===null||n===void 0?void 0:n.resolve)===null||i===void 0||i.call(n,e):(s=(r=this.activeAgentFuture)===null||r===void 0?void 0:r.reject)===null||s===void 0||s.call(r,"Agent disconnected"),this.activeAgentFuture=void 0}waitUntilActiveAgentPresent(){return this.firstActiveAgent?Promise.resolve(this.firstActiveAgent):(this.activeAgentFuture||(this.activeAgentFuture=new Tr),this.activeAgentFuture.promise)}getPublicationForTrack(e){let n;return this.trackPublications.forEach(i=>{const r=i.track;r&&(e instanceof MediaStreamTrack?(Un(r)||ii(r))&&r.mediaStreamTrack===e&&(n=i):e===r&&(n=i))}),n}waitForPendingPublicationOfSource(e){return A(this,void 0,void 0,function*(){const i=Date.now();for(;Date.now()<i+1e4;){const r=Array.from(this.pendingPublishPromises.entries()).find(s=>{let[o]=s;return o.source===e});if(r)return r[1];yield jt(20)}})}}class Pa extends Bn{constructor(e,n,i,r){super(e,n.sid,n.name,r),this.track=void 0,this.allowed=!0,this.disabled=!1,this.currentVideoQuality=Jt.HIGH,this.handleEnded=s=>{this.setTrack(void 0),this.emit(re.Ended,s)},this.handleVisibilityChange=s=>{this.log.debug("adaptivestream video visibility ".concat(this.trackSid,", visible=").concat(s),this.logContext),this.disabled=!s,this.emitTrackUpdate()},this.handleVideoDimensionsChange=s=>{this.log.debug("adaptivestream video dimensions ".concat(s.width,"x").concat(s.height),this.logContext),this.videoDimensions=s,this.emitTrackUpdate()},this.subscribed=i,this.updateInfo(n)}setSubscribed(e){const n=this.subscriptionStatus,i=this.permissionStatus;this.subscribed=e,e&&(this.allowed=!0);const r=new Za({trackSids:[this.trackSid],subscribe:this.subscribed,participantTracks:[new tv({participantSid:"",trackSids:[this.trackSid]})]});this.emit(re.UpdateSubscription,r),this.emitSubscriptionUpdateIfChanged(n),this.emitPermissionUpdateIfChanged(i)}get subscriptionStatus(){return this.subscribed===!1?Bn.SubscriptionStatus.Unsubscribed:super.isSubscribed?Bn.SubscriptionStatus.Subscribed:Bn.SubscriptionStatus.Desired}get permissionStatus(){return this.allowed?Bn.PermissionStatus.Allowed:Bn.PermissionStatus.NotAllowed}get isSubscribed(){return this.subscribed===!1?!1:super.isSubscribed}get isDesired(){return this.subscribed!==!1}get isEnabled(){return!this.disabled}get isLocal(){return!1}setEnabled(e){!this.isManualOperationAllowed()||this.disabled===!e||(this.disabled=!e,this.emitTrackUpdate())}setVideoQuality(e){!this.isManualOperationAllowed()||this.currentVideoQuality===e||(this.currentVideoQuality=e,this.videoDimensions=void 0,this.emitTrackUpdate())}setVideoDimensions(e){var n,i;this.isManualOperationAllowed()&&(((n=this.videoDimensions)===null||n===void 0?void 0:n.width)===e.width&&((i=this.videoDimensions)===null||i===void 0?void 0:i.height)===e.height||($c(this.track)&&(this.videoDimensions=e),this.currentVideoQuality=void 0,this.emitTrackUpdate()))}setVideoFPS(e){this.isManualOperationAllowed()&&$c(this.track)&&this.fps!==e&&(this.fps=e,this.emitTrackUpdate())}get videoQuality(){return this.currentVideoQuality}setTrack(e){const n=this.subscriptionStatus,i=this.permissionStatus,r=this.track;r!==e&&(r&&(r.off(re.VideoDimensionsChanged,this.handleVideoDimensionsChange),r.off(re.VisibilityChanged,this.handleVisibilityChange),r.off(re.Ended,this.handleEnded),r.detach(),r.stopMonitor(),this.emit(re.Unsubscribed,r)),super.setTrack(e),e&&(e.sid=this.trackSid,e.on(re.VideoDimensionsChanged,this.handleVideoDimensionsChange),e.on(re.VisibilityChanged,this.handleVisibilityChange),e.on(re.Ended,this.handleEnded),this.emit(re.Subscribed,e)),this.emitPermissionUpdateIfChanged(i),this.emitSubscriptionUpdateIfChanged(n))}setAllowed(e){const n=this.subscriptionStatus,i=this.permissionStatus;this.allowed=e,this.emitPermissionUpdateIfChanged(i),this.emitSubscriptionUpdateIfChanged(n)}setSubscriptionError(e){this.emit(re.SubscriptionFailed,e)}updateInfo(e){super.updateInfo(e);const n=this.metadataMuted;this.metadataMuted=e.muted,this.track?this.track.setMuted(e.muted):n!==e.muted&&this.emit(e.muted?re.Muted:re.Unmuted)}emitSubscriptionUpdateIfChanged(e){const n=this.subscriptionStatus;e!==n&&this.emit(re.SubscriptionStatusChanged,n,e)}emitPermissionUpdateIfChanged(e){this.permissionStatus!==e&&this.emit(re.SubscriptionPermissionChanged,this.permissionStatus,e)}isManualOperationAllowed(){return this.kind===V.Kind.Video&&this.isAdaptiveStream?(this.log.warn("adaptive stream is enabled, cannot change video track settings",this.logContext),!1):this.isDesired?!0:(this.log.warn("cannot update track settings when not subscribed",this.logContext),!1)}get isAdaptiveStream(){return $c(this.track)&&this.track.isAdaptiveStream}emitTrackUpdate(){const e=new lv({trackSids:[this.trackSid],disabled:this.disabled,fps:this.fps});this.videoDimensions?(e.width=Math.ceil(this.videoDimensions.width),e.height=Math.ceil(this.videoDimensions.height)):this.currentVideoQuality!==void 0?e.quality=this.currentVideoQuality:e.quality=Jt.HIGH,this.emit(re.UpdateSettings,e)}}class Ra extends py{static fromParticipantInfo(e,n,i){return new Ra(e,n.sid,n.identity,n.name,n.metadata,n.attributes,i,n.kind)}get logContext(){return Object.assign(Object.assign({},super.logContext),{rpID:this.sid,remoteParticipant:this.identity})}constructor(e,n,i,r,s,o,a){let c=arguments.length>7&&arguments[7]!==void 0?arguments[7]:Yi.STANDARD;super(n,i||"",r,s,o,a,c),this.signalClient=e,this.trackPublications=new Map,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.volumeMap=new Map}addTrackPublication(e){super.addTrackPublication(e),e.on(re.UpdateSettings,n=>{this.log.debug("send update settings",Object.assign(Object.assign({},this.logContext),we(e))),this.signalClient.sendUpdateTrackSettings(n)}),e.on(re.UpdateSubscription,n=>{n.participantTracks.forEach(i=>{i.participantSid=this.sid}),this.signalClient.sendUpdateSubscription(n)}),e.on(re.SubscriptionPermissionChanged,n=>{this.emit(Z.TrackSubscriptionPermissionChanged,e,n)}),e.on(re.SubscriptionStatusChanged,n=>{this.emit(Z.TrackSubscriptionStatusChanged,e,n)}),e.on(re.Subscribed,n=>{this.emit(Z.TrackSubscribed,n,e)}),e.on(re.Unsubscribed,n=>{this.emit(Z.TrackUnsubscribed,n,e)}),e.on(re.SubscriptionFailed,n=>{this.emit(Z.TrackSubscriptionFailed,e.trackSid,n)})}getTrackPublication(e){const n=super.getTrackPublication(e);if(n)return n}getTrackPublicationByName(e){const n=super.getTrackPublicationByName(e);if(n)return n}setVolume(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:V.Source.Microphone;this.volumeMap.set(n,e);const i=this.getTrackPublication(n);i&&i.track&&i.track.setVolume(e)}getVolume(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:V.Source.Microphone;const n=this.getTrackPublication(e);return n&&n.track?n.track.getVolume():this.volumeMap.get(e)}addSubscribedMediaTrack(e,n,i,r,s,o){let a=this.getTrackPublicationBySid(n);if(a||n.startsWith("TR")||this.trackPublications.forEach(d=>{!a&&e.kind===d.kind.toString()&&(a=d)}),!a){if(o===0){this.log.error("could not find published track",Object.assign(Object.assign({},this.logContext),{trackSid:n})),this.emit(Z.TrackSubscriptionFailed,n);return}o===void 0&&(o=20),setTimeout(()=>{this.addSubscribedMediaTrack(e,n,i,r,s,o-1)},150);return}if(e.readyState==="ended"){this.log.error("unable to subscribe because MediaStreamTrack is ended. Do not call MediaStreamTrack.stop()",Object.assign(Object.assign({},this.logContext),we(a))),this.emit(Z.TrackSubscriptionFailed,n);return}const c=e.kind==="video";let l;return c?l=new h2(e,n,r,s):l=new my(e,n,r,this.audioContext,this.audioOutput),l.source=a.source,l.isMuted=a.isMuted,l.setMediaStream(i),l.start(),a.setTrack(l),this.volumeMap.has(a.source)&&hd(l)&&Tn(l)&&l.setVolume(this.volumeMap.get(a.source)),a}get hasMetadata(){return!!this.participantInfo}getTrackPublicationBySid(e){return this.trackPublications.get(e)}updateInfo(e){if(!super.updateInfo(e))return!1;const n=new Map,i=new Map;return e.tracks.forEach(r=>{var s,o;let a=this.getTrackPublicationBySid(r.sid);if(a)a.updateInfo(r);else{const c=V.kindFromProto(r.type);if(!c)return;a=new Pa(c,r,(s=this.signalClient.connectOptions)===null||s===void 0?void 0:s.autoSubscribe,{loggerContextCb:()=>this.logContext,loggerName:(o=this.loggerOptions)===null||o===void 0?void 0:o.loggerName}),a.updateInfo(r),i.set(r.sid,a);const l=Array.from(this.trackPublications.values()).find(d=>d.source===(a==null?void 0:a.source));l&&a.source!==V.Source.Unknown&&this.log.debug("received a second track publication for ".concat(this.identity," with the same source: ").concat(a.source),Object.assign(Object.assign({},this.logContext),{oldTrack:we(l),newTrack:we(a)})),this.addTrackPublication(a)}n.set(r.sid,a)}),this.trackPublications.forEach(r=>{n.has(r.trackSid)||(this.log.trace("detected removed track on remote participant, unpublishing",Object.assign(Object.assign({},this.logContext),we(r))),this.unpublishTrack(r.trackSid,!0))}),i.forEach(r=>{this.emit(Z.TrackPublished,r)}),!0}unpublishTrack(e,n){const i=this.trackPublications.get(e);if(!i)return;const{track:r}=i;switch(r&&(r.stop(),i.setTrack(void 0)),this.trackPublications.delete(e),i.kind){case V.Kind.Audio:this.audioTrackPublications.delete(e);break;case V.Kind.Video:this.videoTrackPublications.delete(e);break}n&&this.emit(Z.TrackUnpublished,i)}setAudioOutput(e){return A(this,void 0,void 0,function*(){this.audioOutput=e;const n=[];this.audioTrackPublications.forEach(i=>{var r;Tn(i.track)&&hd(i.track)&&n.push(i.track.setSinkId((r=e.deviceId)!==null&&r!==void 0?r:"default"))}),yield Promise.all(n)})}emit(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return this.log.trace("participant event",Object.assign(Object.assign({},this.logContext),{event:e,args:i})),super.emit(e,...i)}}var ge;(function(t){t.Disconnected="disconnected",t.Connecting="connecting",t.Connected="connected",t.Reconnecting="reconnecting",t.SignalReconnecting="signalReconnecting"})(ge||(ge={}));const x2=4*1e3;class pi extends Nn.EventEmitter{constructor(e){var n,i,r,s;if(super(),n=this,this.state=ge.Disconnected,this.activeSpeakers=[],this.isE2EEEnabled=!1,this.audioEnabled=!0,this.isVideoPlaybackBlocked=!1,this.log=Ce,this.bufferedEvents=[],this.isResuming=!1,this.byteStreamControllers=new Map,this.textStreamControllers=new Map,this.byteStreamHandlers=new Map,this.textStreamHandlers=new Map,this.rpcHandlers=new Map,this.connect=(o,a,c)=>A(this,void 0,void 0,function*(){var l;if(!eT())throw In()?Error("WebRTC isn't detected, have you called registerGlobals?"):Error("LiveKit doesn't seem to be supported on this browser. Try to update your browser and make sure no browser extensions are disabling webRTC.");const d=yield this.disconnectLock.lock();if(this.state===ge.Connected)return this.log.info("already connected to room ".concat(this.name),this.logContext),d(),Promise.resolve();if(this.connectFuture)return d(),this.connectFuture.promise;this.setAndEmitConnectionState(ge.Connecting),((l=this.regionUrlProvider)===null||l===void 0?void 0:l.getServerUrl().toString())!==o&&(this.regionUrl=void 0,this.regionUrlProvider=void 0),ud(new URL(o))&&(this.regionUrlProvider===void 0?this.regionUrlProvider=new bd(o,a):this.regionUrlProvider.updateToken(a),this.regionUrlProvider.fetchRegionSettings().then(p=>{var v;(v=this.regionUrlProvider)===null||v===void 0||v.setServerReportedRegions(p)}).catch(p=>{this.log.warn("could not fetch region settings",Object.assign(Object.assign({},this.logContext),{error:p}))}));const u=(p,v,h)=>A(this,void 0,void 0,function*(){var y,b;this.abortController&&this.abortController.abort();const w=new AbortController;this.abortController=w,d==null||d();try{yield this.attemptConnection(h??o,a,c,w),this.abortController=void 0,p()}catch(C){if(this.regionUrlProvider&&C instanceof Ue&&C.reason!==Te.Cancelled&&C.reason!==Te.NotAllowed){let S=null;try{S=yield this.regionUrlProvider.getNextBestRegionUrl((y=this.abortController)===null||y===void 0?void 0:y.signal)}catch(x){if(x instanceof Ue&&(x.status===401||x.reason===Te.Cancelled)){this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),v(x);return}}S&&!(!((b=this.abortController)===null||b===void 0)&&b.signal.aborted)?(this.log.info("Initial connection failed with ConnectionError: ".concat(C.message,". Retrying with another region: ").concat(S),this.logContext),this.recreateEngine(),yield u(p,v,S)):(this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,rm(C)),v(C))}else{let S=dn.UNKNOWN_REASON;C instanceof Ue&&(S=rm(C)),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,S),v(C)}}}),f=this.regionUrl;return this.regionUrl=void 0,this.connectFuture=new Tr((p,v)=>{u(p,v,f)},()=>{this.clearConnectionFutures()}),this.connectFuture.promise}),this.connectSignal=(o,a,c,l,d,u)=>A(this,void 0,void 0,function*(){var f,p,v;const h=yield c.join(o,a,{autoSubscribe:l.autoSubscribe,adaptiveStream:typeof d.adaptiveStream=="object"?!0:d.adaptiveStream,maxRetries:l.maxRetries,e2eeEnabled:!!this.e2eeManager,websocketTimeout:l.websocketTimeout},u.signal);let y=h.serverInfo;if(y||(y={version:h.serverVersion,region:h.serverRegion}),this.serverInfo=y,this.log.debug("connected to Livekit Server ".concat(Object.entries(y).map(b=>{let[w,C]=b;return"".concat(w,": ").concat(C)}).join(", ")),{room:(f=h.room)===null||f===void 0?void 0:f.name,roomSid:(p=h.room)===null||p===void 0?void 0:p.sid,identity:(v=h.participant)===null||v===void 0?void 0:v.identity}),!y.version)throw new Fk("unknown server version");return y.version==="0.15.1"&&this.options.dynacast&&(this.log.debug("disabling dynacast due to server version",this.logContext),d.dynacast=!1),h}),this.applyJoinResponse=o=>{const a=o.participant;if(this.localParticipant.sid=a.sid,this.localParticipant.identity=a.identity,this.localParticipant.setEnabledPublishCodecs(o.enabledPublishCodecs),this.options.e2ee&&this.e2eeManager)try{this.e2eeManager.setSifTrailer(o.sifTrailer)}catch(c){this.log.error(c instanceof Error?c.message:"Could not set SifTrailer",Object.assign(Object.assign({},this.logContext),{error:c}))}this.handleParticipantUpdates([a,...o.otherParticipants]),o.room&&this.handleRoomUpdate(o.room)},this.attemptConnection=(o,a,c,l)=>A(this,void 0,void 0,function*(){var d,u;this.state===ge.Reconnecting||this.isResuming||!((d=this.engine)===null||d===void 0)&&d.pendingReconnect?(this.log.info("Reconnection attempt replaced by new connection attempt",this.logContext),this.recreateEngine()):this.maybeCreateEngine(),!((u=this.regionUrlProvider)===null||u===void 0)&&u.isCloud()&&this.engine.setRegionUrlProvider(this.regionUrlProvider),this.acquireAudioContext(),this.connOptions=Object.assign(Object.assign({},Lu),c),this.connOptions.rtcConfig&&(this.engine.rtcConfig=this.connOptions.rtcConfig),this.connOptions.peerConnectionTimeout&&(this.engine.peerConnectionTimeout=this.connOptions.peerConnectionTimeout);try{const f=yield this.connectSignal(o,a,this.engine,this.connOptions,this.options,l);this.applyJoinResponse(f),this.setupLocalParticipantEvents(),this.emit(U.SignalConnected)}catch(f){yield this.engine.close(),this.recreateEngine();const p=new Ue("could not establish signal connection",Te.ServerUnreachable);throw f instanceof Error&&(p.message="".concat(p.message,": ").concat(f.message)),f instanceof Ue&&(p.reason=f.reason,p.status=f.status),this.log.debug("error trying to establish signal connection",Object.assign(Object.assign({},this.logContext),{error:f})),p}if(l.signal.aborted)throw yield this.engine.close(),this.recreateEngine(),new Ue("Connection attempt aborted",Te.Cancelled);try{yield this.engine.waitForPCInitialConnection(this.connOptions.peerConnectionTimeout,l)}catch(f){throw yield this.engine.close(),this.recreateEngine(),f}Ot()&&this.options.disconnectOnPageLeave&&(window.addEventListener("pagehide",this.onPageLeave),window.addEventListener("beforeunload",this.onPageLeave)),Ot()&&document.addEventListener("freeze",this.onPageLeave),this.setAndEmitConnectionState(ge.Connected),this.emit(U.Connected),this.registerConnectionReconcile()}),this.disconnect=function(){for(var o=arguments.length,a=new Array(o),c=0;c<o;c++)a[c]=arguments[c];return A(n,[...a],void 0,function(){var l=this;let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){var u,f,p,v;const h=yield l.disconnectLock.lock();try{if(l.state===ge.Disconnected){l.log.debug("already disconnected",l.logContext);return}l.log.info("disconnect from room",Object.assign({},l.logContext)),(l.state===ge.Connecting||l.state===ge.Reconnecting||l.isResuming)&&(l.log.warn("abort connection attempt",l.logContext),(u=l.abortController)===null||u===void 0||u.abort(),(p=(f=l.connectFuture)===null||f===void 0?void 0:f.reject)===null||p===void 0||p.call(f,new Ue("Client initiated disconnect",Te.Cancelled)),l.connectFuture=void 0),!((v=l.engine)===null||v===void 0)&&v.client.isDisconnected||(yield l.engine.client.sendLeave()),l.engine&&(yield l.engine.close()),l.handleDisconnect(d,dn.CLIENT_INITIATED),l.engine=void 0}finally{h()}}()})},this.onPageLeave=()=>A(this,void 0,void 0,function*(){this.log.info("Page leave detected, disconnecting",this.logContext),yield this.disconnect()}),this.startAudio=()=>A(this,void 0,void 0,function*(){const o=[],a=$t();if(a&&a.os==="iOS"){const c="livekit-dummy-audio-el";let l=document.getElementById(c);if(!l){l=document.createElement("audio"),l.id=c,l.autoplay=!0,l.hidden=!0;const d=Bc();d.enabled=!0;const u=new MediaStream([d]);l.srcObject=u,document.addEventListener("visibilitychange",()=>{l&&(l.srcObject=document.hidden?null:u,document.hidden||(this.log.debug("page visible again, triggering startAudio to resume playback and update playback status",this.logContext),this.startAudio()))}),document.body.append(l),this.once(U.Disconnected,()=>{l==null||l.remove(),l=null})}o.push(l)}this.remoteParticipants.forEach(c=>{c.audioTrackPublications.forEach(l=>{l.track&&l.track.attachedElements.forEach(d=>{o.push(d)})})});try{yield Promise.all([this.acquireAudioContext(),...o.map(c=>(c.muted=!1,c.play()))]),this.handleAudioPlaybackStarted()}catch(c){throw this.handleAudioPlaybackFailed(c),c}}),this.startVideo=()=>A(this,void 0,void 0,function*(){const o=[];for(const a of this.remoteParticipants.values())a.videoTrackPublications.forEach(c=>{var l;(l=c.track)===null||l===void 0||l.attachedElements.forEach(d=>{o.includes(d)||o.push(d)})});yield Promise.all(o.map(a=>a.play())).then(()=>{this.handleVideoPlaybackStarted()}).catch(a=>{a.name==="NotAllowedError"?this.handleVideoPlaybackFailed():this.log.warn("Resuming video playback failed, make sure you call `startVideo` directly in a user gesture handler",this.logContext)})}),this.handleRestarting=()=>{this.clearConnectionReconcile(),this.isResuming=!1;for(const o of this.remoteParticipants.values())this.handleParticipantDisconnected(o.identity,o);this.setAndEmitConnectionState(ge.Reconnecting)&&this.emit(U.Reconnecting)},this.handleSignalRestarted=o=>A(this,void 0,void 0,function*(){this.log.debug("signal reconnected to server, region ".concat(o.serverRegion),Object.assign(Object.assign({},this.logContext),{region:o.serverRegion})),this.bufferedEvents=[],this.applyJoinResponse(o);try{yield this.localParticipant.republishAllTracks(void 0,!0)}catch(a){this.log.error("error trying to re-publish tracks after reconnection",Object.assign(Object.assign({},this.logContext),{error:a}))}try{yield this.engine.waitForRestarted(),this.log.debug("fully reconnected to server",Object.assign(Object.assign({},this.logContext),{region:o.serverRegion}))}catch{return}this.setAndEmitConnectionState(ge.Connected),this.emit(U.Reconnected),this.registerConnectionReconcile(),this.emitBufferedEvents()}),this.handleParticipantUpdates=o=>{o.forEach(a=>{var c;if(a.identity===this.localParticipant.identity){this.localParticipant.updateInfo(a);return}a.identity===""&&(a.identity=(c=this.sidToIdentity.get(a.sid))!==null&&c!==void 0?c:"");let l=this.remoteParticipants.get(a.identity);a.state===_r.DISCONNECTED?this.handleParticipantDisconnected(a.identity,l):l=this.getOrCreateParticipant(a.identity,a)})},this.handleActiveSpeakersUpdate=o=>{const a=[],c={};o.forEach(l=>{if(c[l.sid]=!0,l.sid===this.localParticipant.sid)this.localParticipant.audioLevel=l.level,this.localParticipant.setIsSpeaking(!0),a.push(this.localParticipant);else{const d=this.getRemoteParticipantBySid(l.sid);d&&(d.audioLevel=l.level,d.setIsSpeaking(!0),a.push(d))}}),c[this.localParticipant.sid]||(this.localParticipant.audioLevel=0,this.localParticipant.setIsSpeaking(!1)),this.remoteParticipants.forEach(l=>{c[l.sid]||(l.audioLevel=0,l.setIsSpeaking(!1))}),this.activeSpeakers=a,this.emitWhenConnected(U.ActiveSpeakersChanged,a)},this.handleSpeakersChanged=o=>{const a=new Map;this.activeSpeakers.forEach(l=>{const d=this.remoteParticipants.get(l.identity);d&&d.sid!==l.sid||a.set(l.sid,l)}),o.forEach(l=>{let d=this.getRemoteParticipantBySid(l.sid);l.sid===this.localParticipant.sid&&(d=this.localParticipant),d&&(d.audioLevel=l.level,d.setIsSpeaking(l.active),l.active?a.set(l.sid,d):a.delete(l.sid))});const c=Array.from(a.values());c.sort((l,d)=>d.audioLevel-l.audioLevel),this.activeSpeakers=c,this.emitWhenConnected(U.ActiveSpeakersChanged,c)},this.handleStreamStateUpdate=o=>{o.streamStates.forEach(a=>{const c=this.getRemoteParticipantBySid(a.participantSid);if(!c)return;const l=c.getTrackPublicationBySid(a.trackSid);if(!l||!l.track)return;const d=V.streamStateFromProto(a.state);d!==l.track.streamState&&(l.track.streamState=d,c.emit(Z.TrackStreamStateChanged,l,l.track.streamState),this.emitWhenConnected(U.TrackStreamStateChanged,l,l.track.streamState,c))})},this.handleSubscriptionPermissionUpdate=o=>{const a=this.getRemoteParticipantBySid(o.participantSid);if(!a)return;const c=a.getTrackPublicationBySid(o.trackSid);c&&c.setAllowed(o.allowed)},this.handleSubscriptionError=o=>{const a=Array.from(this.remoteParticipants.values()).find(l=>l.trackPublications.has(o.trackSid));if(!a)return;const c=a.getTrackPublicationBySid(o.trackSid);c&&c.setSubscriptionError(o.err)},this.handleDataPacket=o=>{const a=this.remoteParticipants.get(o.participantIdentity);if(o.value.case==="user")this.handleUserPacket(a,o.value.value,o.kind);else if(o.value.case==="transcription")this.handleTranscription(a,o.value.value);else if(o.value.case==="sipDtmf")this.handleSipDtmf(a,o.value.value);else if(o.value.case==="chatMessage")this.handleChatMessage(a,o.value.value);else if(o.value.case==="metrics")this.handleMetrics(o.value.value,a);else if(o.value.case==="streamHeader")this.handleStreamHeader(o.value.value,o.participantIdentity);else if(o.value.case==="streamChunk")this.handleStreamChunk(o.value.value);else if(o.value.case==="streamTrailer")this.handleStreamTrailer(o.value.value);else if(o.value.case==="rpcRequest"){const c=o.value.value;this.handleIncomingRpcRequest(o.participantIdentity,c.id,c.method,c.payload,c.responseTimeoutMs,c.version)}},this.handleUserPacket=(o,a,c)=>{this.emit(U.DataReceived,a.payload,o,c,a.topic),o==null||o.emit(Z.DataReceived,a.payload,c)},this.handleSipDtmf=(o,a)=>{this.emit(U.SipDTMFReceived,a,o),o==null||o.emit(Z.SipDTMFReceived,a)},this.bufferedSegments=new Map,this.handleTranscription=(o,a)=>{const c=a.transcribedParticipantIdentity===this.localParticipant.identity?this.localParticipant:this.getParticipantByIdentity(a.transcribedParticipantIdentity),l=c==null?void 0:c.trackPublications.get(a.trackId),d=dT(a,this.transcriptionReceivedTimes);l==null||l.emit(re.TranscriptionReceived,d),c==null||c.emit(Z.TranscriptionReceived,d,l),this.emit(U.TranscriptionReceived,d,c,l)},this.handleChatMessage=(o,a)=>{const c=uT(a);this.emit(U.ChatMessage,c,o)},this.handleMetrics=(o,a)=>{this.emit(U.MetricsReceived,o,a)},this.handleAudioPlaybackStarted=()=>{this.canPlaybackAudio||(this.audioEnabled=!0,this.emit(U.AudioPlaybackStatusChanged,!0))},this.handleAudioPlaybackFailed=o=>{this.log.warn("could not playback audio",Object.assign(Object.assign({},this.logContext),{error:o})),this.canPlaybackAudio&&(this.audioEnabled=!1,this.emit(U.AudioPlaybackStatusChanged,!1))},this.handleVideoPlaybackStarted=()=>{this.isVideoPlaybackBlocked&&(this.isVideoPlaybackBlocked=!1,this.emit(U.VideoPlaybackStatusChanged,!0))},this.handleVideoPlaybackFailed=()=>{this.isVideoPlaybackBlocked||(this.isVideoPlaybackBlocked=!0,this.emit(U.VideoPlaybackStatusChanged,!1))},this.handleDeviceChange=()=>A(this,void 0,void 0,function*(){var o;((o=$t())===null||o===void 0?void 0:o.os)!=="iOS"&&(yield this.selectDefaultDevices()),this.emit(U.MediaDevicesChanged)}),this.handleRoomUpdate=o=>{const a=this.roomInfo;this.roomInfo=o,a&&a.metadata!==o.metadata&&this.emitWhenConnected(U.RoomMetadataChanged,o.metadata),(a==null?void 0:a.activeRecording)!==o.activeRecording&&this.emitWhenConnected(U.RecordingStatusChanged,o.activeRecording)},this.handleConnectionQualityUpdate=o=>{o.updates.forEach(a=>{if(a.participantSid===this.localParticipant.sid){this.localParticipant.setConnectionQuality(a.quality);return}const c=this.getRemoteParticipantBySid(a.participantSid);c&&c.setConnectionQuality(a.quality)})},this.onLocalParticipantMetadataChanged=o=>{this.emit(U.ParticipantMetadataChanged,o,this.localParticipant)},this.onLocalParticipantNameChanged=o=>{this.emit(U.ParticipantNameChanged,o,this.localParticipant)},this.onLocalAttributesChanged=o=>{this.emit(U.ParticipantAttributesChanged,o,this.localParticipant)},this.onLocalTrackMuted=o=>{this.emit(U.TrackMuted,o,this.localParticipant)},this.onLocalTrackUnmuted=o=>{this.emit(U.TrackUnmuted,o,this.localParticipant)},this.onTrackProcessorUpdate=o=>{var a;(a=o==null?void 0:o.onPublish)===null||a===void 0||a.call(o,this)},this.onLocalTrackPublished=o=>A(this,void 0,void 0,function*(){var a,c,l,d,u,f;(a=o.track)===null||a===void 0||a.on(re.TrackProcessorUpdate,this.onTrackProcessorUpdate),(c=o.track)===null||c===void 0||c.on(re.Restarted,this.onLocalTrackRestarted),(u=(d=(l=o.track)===null||l===void 0?void 0:l.getProcessor())===null||d===void 0?void 0:d.onPublish)===null||u===void 0||u.call(d,this),this.emit(U.LocalTrackPublished,o,this.localParticipant),Un(o.track)&&(yield o.track.checkForSilence())&&this.emit(U.LocalAudioSilenceDetected,o);const p=yield(f=o.track)===null||f===void 0?void 0:f.getDeviceId(!1),v=pd(o.source);v&&p&&p!==this.localParticipant.activeDeviceMap.get(v)&&(this.localParticipant.activeDeviceMap.set(v,p),this.emit(U.ActiveDeviceChanged,v,p))}),this.onLocalTrackUnpublished=o=>{var a,c;(a=o.track)===null||a===void 0||a.off(re.TrackProcessorUpdate,this.onTrackProcessorUpdate),(c=o.track)===null||c===void 0||c.off(re.Restarted,this.onLocalTrackRestarted),this.emit(U.LocalTrackUnpublished,o,this.localParticipant)},this.onLocalTrackRestarted=o=>A(this,void 0,void 0,function*(){const a=yield o.getDeviceId(!1),c=pd(o.source);c&&a&&a!==this.localParticipant.activeDeviceMap.get(c)&&(this.log.debug("local track restarted, setting ".concat(c," ").concat(a," active"),this.logContext),this.localParticipant.activeDeviceMap.set(c,a),this.emit(U.ActiveDeviceChanged,c,a))}),this.onLocalConnectionQualityChanged=o=>{this.emit(U.ConnectionQualityChanged,o,this.localParticipant)},this.onMediaDevicesError=(o,a)=>{this.emit(U.MediaDevicesError,o,a)},this.onLocalParticipantPermissionsChanged=o=>{this.emit(U.ParticipantPermissionsChanged,o,this.localParticipant)},this.onLocalChatMessageSent=o=>{this.emit(U.ChatMessage,o,this.localParticipant)},this.setMaxListeners(100),this.remoteParticipants=new Map,this.sidToIdentity=new Map,this.options=Object.assign(Object.assign({},LT),e),this.log=Gn((i=this.options.loggerName)!==null&&i!==void 0?i:fn.Room),this.transcriptionReceivedTimes=new Map,this.options.audioCaptureDefaults=Object.assign(Object.assign({},sy),e==null?void 0:e.audioCaptureDefaults),this.options.videoCaptureDefaults=Object.assign(Object.assign({},oy),e==null?void 0:e.videoCaptureDefaults),this.options.publishDefaults=Object.assign(Object.assign({},jT),e==null?void 0:e.publishDefaults),this.maybeCreateEngine(),this.disconnectLock=new Nt,this.localParticipant=new b2("","",this.engine,this.options,this.rpcHandlers),this.options.videoCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("videoinput",fi(this.options.videoCaptureDefaults.deviceId)),this.options.audioCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("audioinput",fi(this.options.audioCaptureDefaults.deviceId)),!((r=this.options.audioOutput)===null||r===void 0)&&r.deviceId&&this.switchActiveDevice("audiooutput",fi(this.options.audioOutput.deviceId)).catch(o=>this.log.warn("Could not set audio output: ".concat(o.message),this.logContext)),this.options.e2ee&&this.setupE2EE(),Ot()){const o=new AbortController;(s=navigator.mediaDevices)===null||s===void 0||s.addEventListener("devicechange",this.handleDeviceChange,{signal:o.signal}),pi.cleanupRegistry&&pi.cleanupRegistry.register(this,()=>{o.abort()})}}registerTextStreamHandler(e,n){if(this.textStreamHandlers.has(e))throw new TypeError('A text stream handler for topic "'.concat(e,'" has already been set.'));this.textStreamHandlers.set(e,n)}unregisterTextStreamHandler(e){this.textStreamHandlers.delete(e)}registerByteStreamHandler(e,n){if(this.byteStreamHandlers.has(e))throw new TypeError('A byte stream handler for topic "'.concat(e,'" has already been set.'));this.byteStreamHandlers.set(e,n)}unregisterByteStreamHandler(e){this.byteStreamHandlers.delete(e)}registerRpcMethod(e,n){if(this.rpcHandlers.has(e))throw Error("RPC handler already registered for method ".concat(e,", unregisterRpcMethod before trying to register again"));this.rpcHandlers.set(e,n)}unregisterRpcMethod(e){this.rpcHandlers.delete(e)}handleIncomingRpcRequest(e,n,i,r,s,o){return A(this,void 0,void 0,function*(){if(yield this.engine.publishRpcAck(e,n),o!==1){yield this.engine.publishRpcResponse(e,n,null,Qe.builtIn("UNSUPPORTED_VERSION"));return}const a=this.rpcHandlers.get(i);if(!a){yield this.engine.publishRpcResponse(e,n,null,Qe.builtIn("UNSUPPORTED_METHOD"));return}let c=null,l=null;try{const d=yield a({requestId:n,callerIdentity:e,payload:r,responseTimeout:s});Vu(d)>ay?(c=Qe.builtIn("RESPONSE_PAYLOAD_TOO_LARGE"),console.warn("RPC Response payload too large for ".concat(i))):l=d}catch(d){d instanceof Qe?c=d:(console.warn("Uncaught error returned by RPC handler for ".concat(i,". Returning APPLICATION_ERROR instead."),d),c=Qe.builtIn("APPLICATION_ERROR"))}yield this.engine.publishRpcResponse(e,n,l,c)})}setE2EEEnabled(e){return A(this,void 0,void 0,function*(){if(this.e2eeManager)yield Promise.all([this.localParticipant.setE2EEEnabled(e)]),this.localParticipant.identity!==""&&this.e2eeManager.setParticipantCryptorEnabled(e,this.localParticipant.identity);else throw Error("e2ee not configured, please set e2ee settings within the room options")})}setupE2EE(){var e;this.options.e2ee&&("e2eeManager"in this.options.e2ee?this.e2eeManager=this.options.e2ee.e2eeManager:this.e2eeManager=new ST(this.options.e2ee),this.e2eeManager.on(di.ParticipantEncryptionStatusChanged,(n,i)=>{hT(i)&&(this.isE2EEEnabled=n),this.emit(U.ParticipantEncryptionStatusChanged,n,i)}),this.e2eeManager.on(di.EncryptionError,n=>this.emit(U.EncryptionError,n)),(e=this.e2eeManager)===null||e===void 0||e.setup(this))}get logContext(){var e;return{room:this.name,roomID:(e=this.roomInfo)===null||e===void 0?void 0:e.sid,participant:this.localParticipant.identity,pID:this.localParticipant.sid}}get isRecording(){var e,n;return(n=(e=this.roomInfo)===null||e===void 0?void 0:e.activeRecording)!==null&&n!==void 0?n:!1}getSid(){return A(this,void 0,void 0,function*(){return this.state===ge.Disconnected?"":this.roomInfo&&this.roomInfo.sid!==""?this.roomInfo.sid:new Promise((e,n)=>{const i=r=>{r.sid!==""&&(this.engine.off(ae.RoomUpdate,i),e(r.sid))};this.engine.on(ae.RoomUpdate,i),this.once(U.Disconnected,()=>{this.engine.off(ae.RoomUpdate,i),n("Room disconnected before room server id was available")})})})}get name(){var e,n;return(n=(e=this.roomInfo)===null||e===void 0?void 0:e.name)!==null&&n!==void 0?n:""}get metadata(){var e;return(e=this.roomInfo)===null||e===void 0?void 0:e.metadata}get numParticipants(){var e,n;return(n=(e=this.roomInfo)===null||e===void 0?void 0:e.numParticipants)!==null&&n!==void 0?n:0}get numPublishers(){var e,n;return(n=(e=this.roomInfo)===null||e===void 0?void 0:e.numPublishers)!==null&&n!==void 0?n:0}maybeCreateEngine(){this.engine&&!this.engine.isClosed||(this.engine=new s2(this.options),this.engine.on(ae.ParticipantUpdate,this.handleParticipantUpdates).on(ae.RoomUpdate,this.handleRoomUpdate).on(ae.SpeakersChanged,this.handleSpeakersChanged).on(ae.StreamStateChanged,this.handleStreamStateUpdate).on(ae.ConnectionQualityUpdate,this.handleConnectionQualityUpdate).on(ae.SubscriptionError,this.handleSubscriptionError).on(ae.SubscriptionPermissionUpdate,this.handleSubscriptionPermissionUpdate).on(ae.MediaTrackAdded,(e,n,i)=>{this.onTrackAdded(e,n,i)}).on(ae.Disconnected,e=>{this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,e)}).on(ae.ActiveSpeakersUpdate,this.handleActiveSpeakersUpdate).on(ae.DataPacketReceived,this.handleDataPacket).on(ae.Resuming,()=>{this.clearConnectionReconcile(),this.isResuming=!0,this.log.info("Resuming signal connection",this.logContext),this.setAndEmitConnectionState(ge.SignalReconnecting)&&this.emit(U.SignalReconnecting)}).on(ae.Resumed,()=>{this.registerConnectionReconcile(),this.isResuming=!1,this.log.info("Resumed signal connection",this.logContext),this.updateSubscriptions(),this.emitBufferedEvents(),this.setAndEmitConnectionState(ge.Connected)&&this.emit(U.Reconnected)}).on(ae.SignalResumed,()=>{this.bufferedEvents=[],(this.state===ge.Reconnecting||this.isResuming)&&this.sendSyncState()}).on(ae.Restarting,this.handleRestarting).on(ae.SignalRestarted,this.handleSignalRestarted).on(ae.Offline,()=>{this.setAndEmitConnectionState(ge.Reconnecting)&&this.emit(U.Reconnecting)}).on(ae.DCBufferStatusChanged,(e,n)=>{this.emit(U.DCBufferStatusChanged,e,n)}).on(ae.LocalTrackSubscribed,e=>{const n=this.localParticipant.getTrackPublications().find(i=>{let{trackSid:r}=i;return r===e});if(!n){this.log.warn("could not find local track subscription for subscribed event",this.logContext);return}this.localParticipant.emit(Z.LocalTrackSubscribed,n),this.emitWhenConnected(U.LocalTrackSubscribed,n,this.localParticipant)}).on(ae.RoomMoved,e=>{this.log.debug("room moved",e),e.room&&this.handleRoomUpdate(e.room),this.remoteParticipants.forEach((n,i)=>{this.handleParticipantDisconnected(i,n)}),this.emit(U.Moved,e.room.name),e.participant?this.handleParticipantUpdates([e.participant,...e.otherParticipants]):this.handleParticipantUpdates(e.otherParticipants)}),this.localParticipant&&this.localParticipant.setupEngine(this.engine),this.e2eeManager&&this.e2eeManager.setupEngine(this.engine))}static getLocalDevices(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return gt.getInstance().getDevices(e,n)}prepareConnection(e,n){return A(this,void 0,void 0,function*(){if(this.state===ge.Disconnected){this.log.debug("prepareConnection to ".concat(e),this.logContext);try{if(ud(new URL(e))&&n){this.regionUrlProvider=new bd(e,n);const i=yield this.regionUrlProvider.getNextBestRegionUrl();i&&this.state===ge.Disconnected&&(this.regionUrl=i,yield fetch(fd(i),{method:"HEAD"}),this.log.debug("prepared connection to ".concat(i),this.logContext))}else yield fetch(fd(e),{method:"HEAD"})}catch(i){this.log.warn("could not prepare connection",Object.assign(Object.assign({},this.logContext),{error:i}))}}})}getParticipantByIdentity(e){return this.localParticipant.identity===e?this.localParticipant:this.remoteParticipants.get(e)}clearConnectionFutures(){this.connectFuture=void 0}simulateScenario(e,n){return A(this,void 0,void 0,function*(){let i=()=>{},r;switch(e){case"signal-reconnect":yield this.engine.client.handleOnClose("simulate disconnect");break;case"speaker":r=new bn({scenario:{case:"speakerUpdate",value:3}});break;case"node-failure":r=new bn({scenario:{case:"nodeFailure",value:!0}});break;case"server-leave":r=new bn({scenario:{case:"serverLeave",value:!0}});break;case"migration":r=new bn({scenario:{case:"migration",value:!0}});break;case"resume-reconnect":this.engine.failNext(),yield this.engine.client.handleOnClose("simulate resume-disconnect");break;case"disconnect-signal-on-resume":i=()=>A(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),r=new bn({scenario:{case:"disconnectSignalOnResume",value:!0}});break;case"disconnect-signal-on-resume-no-messages":i=()=>A(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),r=new bn({scenario:{case:"disconnectSignalOnResumeNoMessages",value:!0}});break;case"full-reconnect":this.engine.fullReconnectOnNext=!0,yield this.engine.client.handleOnClose("simulate full-reconnect");break;case"force-tcp":case"force-tls":r=new bn({scenario:{case:"switchCandidateProtocol",value:e==="force-tls"?2:1}}),i=()=>A(this,void 0,void 0,function*(){const s=this.engine.client.onLeave;s&&s(new Ya({reason:dn.CLIENT_INITIATED,action:Nr.RECONNECT}))});break;case"subscriber-bandwidth":if(n===void 0||typeof n!="number")throw new Error("subscriber-bandwidth requires a number as argument");r=new bn({scenario:{case:"subscriberBandwidth",value:Li(n)}});break;case"leave-full-reconnect":r=new bn({scenario:{case:"leaveRequestFullReconnect",value:!0}})}r&&(yield this.engine.client.sendSimulateScenario(r),yield i())})}get canPlaybackAudio(){return this.audioEnabled}get canPlaybackVideo(){return!this.isVideoPlaybackBlocked}getActiveDevice(e){return this.localParticipant.activeDeviceMap.get(e)}switchActiveDevice(e,n){return A(this,arguments,void 0,function(i,r){var s=this;let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return function*(){var a,c,l,d,u,f,p;let v=!0,h=!1;const y=o?{exact:r}:r;if(i==="audioinput"){h=s.localParticipant.audioTrackPublications.size===0;const b=(a=s.getActiveDevice(i))!==null&&a!==void 0?a:s.options.audioCaptureDefaults.deviceId;s.options.audioCaptureDefaults.deviceId=y;const w=Array.from(s.localParticipant.audioTrackPublications.values()).filter(S=>S.source===V.Source.Microphone);try{v=(yield Promise.all(w.map(S=>{var x;return(x=S.audioTrack)===null||x===void 0?void 0:x.setDeviceId(y)}))).every(S=>S===!0)}catch(S){throw s.options.audioCaptureDefaults.deviceId=b,S}const C=w.some(S=>{var x,T;return(T=(x=S.track)===null||x===void 0?void 0:x.isMuted)!==null&&T!==void 0?T:!1});v&&C&&(h=!0)}else if(i==="videoinput"){h=s.localParticipant.videoTrackPublications.size===0;const b=(c=s.getActiveDevice(i))!==null&&c!==void 0?c:s.options.videoCaptureDefaults.deviceId;s.options.videoCaptureDefaults.deviceId=y;const w=Array.from(s.localParticipant.videoTrackPublications.values()).filter(C=>C.source===V.Source.Camera);try{v=(yield Promise.all(w.map(C=>{var S;return(S=C.videoTrack)===null||S===void 0?void 0:S.setDeviceId(y)}))).every(C=>C===!0)}catch(C){throw s.options.videoCaptureDefaults.deviceId=b,C}}else if(i==="audiooutput"){if(h=!0,!dd()&&!s.options.webAudioMix||s.options.webAudioMix&&s.audioContext&&!("setSinkId"in s.audioContext))throw new Error("cannot switch audio output, setSinkId not supported");s.options.webAudioMix&&(r=(l=yield gt.getInstance().normalizeDeviceId("audiooutput",r))!==null&&l!==void 0?l:""),(d=(p=s.options).audioOutput)!==null&&d!==void 0||(p.audioOutput={});const b=(u=s.getActiveDevice(i))!==null&&u!==void 0?u:s.options.audioOutput.deviceId;s.options.audioOutput.deviceId=r;try{s.options.webAudioMix&&((f=s.audioContext)===null||f===void 0||f.setSinkId(r)),yield Promise.all(Array.from(s.remoteParticipants.values()).map(w=>w.setAudioOutput({deviceId:r})))}catch(w){throw s.options.audioOutput.deviceId=b,w}}return h&&(s.localParticipant.activeDeviceMap.set(i,r),s.emit(U.ActiveDeviceChanged,i,r)),v}()})}setupLocalParticipantEvents(){this.localParticipant.on(Z.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).on(Z.ParticipantNameChanged,this.onLocalParticipantNameChanged).on(Z.AttributesChanged,this.onLocalAttributesChanged).on(Z.TrackMuted,this.onLocalTrackMuted).on(Z.TrackUnmuted,this.onLocalTrackUnmuted).on(Z.LocalTrackPublished,this.onLocalTrackPublished).on(Z.LocalTrackUnpublished,this.onLocalTrackUnpublished).on(Z.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).on(Z.MediaDevicesError,this.onMediaDevicesError).on(Z.AudioStreamAcquired,this.startAudio).on(Z.ChatMessage,this.onLocalChatMessageSent).on(Z.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged)}recreateEngine(){var e;(e=this.engine)===null||e===void 0||e.close(),this.engine=void 0,this.isResuming=!1,this.remoteParticipants.clear(),this.sidToIdentity.clear(),this.bufferedEvents=[],this.maybeCreateEngine()}onTrackAdded(e,n,i){if(this.state===ge.Connecting||this.state===ge.Reconnecting){const d=()=>{this.onTrackAdded(e,n,i),u()},u=()=>{this.off(U.Reconnected,d),this.off(U.Connected,d),this.off(U.Disconnected,u)};this.once(U.Reconnected,d),this.once(U.Connected,d),this.once(U.Disconnected,u);return}if(this.state===ge.Disconnected){this.log.warn("skipping incoming track after Room disconnected",this.logContext);return}if(e.readyState==="ended"){this.log.info("skipping incoming track as it already ended",this.logContext);return}const r=Jk(n.id),s=r[0];let o=r[1],a=e.id;if(o&&o.startsWith("TR")&&(a=o),s===this.localParticipant.sid){this.log.warn("tried to create RemoteParticipant for local participant",this.logContext);return}const c=Array.from(this.remoteParticipants.values()).find(d=>d.sid===s);if(!c){this.log.error("Tried to add a track for a participant, that's not present. Sid: ".concat(s),this.logContext);return}let l;this.options.adaptiveStream&&(typeof this.options.adaptiveStream=="object"?l=this.options.adaptiveStream:l={}),c.addSubscribedMediaTrack(e,a,n,i,l)}handleDisconnect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,n=arguments.length>1?arguments[1]:void 0;var i;if(this.clearConnectionReconcile(),this.isResuming=!1,this.bufferedEvents=[],this.transcriptionReceivedTimes.clear(),this.state!==ge.Disconnected){this.regionUrl=void 0;try{this.remoteParticipants.forEach(r=>{r.trackPublications.forEach(s=>{r.unpublishTrack(s.trackSid)})}),this.localParticipant.trackPublications.forEach(r=>{var s,o,a;r.track&&this.localParticipant.unpublishTrack(r.track,e),e?((s=r.track)===null||s===void 0||s.detach(),(o=r.track)===null||o===void 0||o.stop()):(a=r.track)===null||a===void 0||a.stopMonitor()}),this.localParticipant.off(Z.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).off(Z.ParticipantNameChanged,this.onLocalParticipantNameChanged).off(Z.AttributesChanged,this.onLocalAttributesChanged).off(Z.TrackMuted,this.onLocalTrackMuted).off(Z.TrackUnmuted,this.onLocalTrackUnmuted).off(Z.LocalTrackPublished,this.onLocalTrackPublished).off(Z.LocalTrackUnpublished,this.onLocalTrackUnpublished).off(Z.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).off(Z.MediaDevicesError,this.onMediaDevicesError).off(Z.AudioStreamAcquired,this.startAudio).off(Z.ChatMessage,this.onLocalChatMessageSent).off(Z.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged),this.localParticipant.trackPublications.clear(),this.localParticipant.videoTrackPublications.clear(),this.localParticipant.audioTrackPublications.clear(),this.remoteParticipants.clear(),this.sidToIdentity.clear(),this.activeSpeakers=[],this.audioContext&&typeof this.options.webAudioMix=="boolean"&&(this.audioContext.close(),this.audioContext=void 0),Ot()&&(window.removeEventListener("beforeunload",this.onPageLeave),window.removeEventListener("pagehide",this.onPageLeave),window.removeEventListener("freeze",this.onPageLeave),(i=navigator.mediaDevices)===null||i===void 0||i.removeEventListener("devicechange",this.handleDeviceChange))}finally{this.setAndEmitConnectionState(ge.Disconnected),this.emit(U.Disconnected,n)}}}handleParticipantDisconnected(e,n){var i;this.remoteParticipants.delete(e),n&&(n.trackPublications.forEach(r=>{n.unpublishTrack(r.trackSid,!0)}),this.emit(U.ParticipantDisconnected,n),n.setDisconnected(),(i=this.localParticipant)===null||i===void 0||i.handleParticipantDisconnected(n.identity))}handleStreamHeader(e,n){return A(this,void 0,void 0,function*(){var i;if(e.contentHeader.case==="byteHeader"){const r=this.byteStreamHandlers.get(e.topic);if(!r){this.log.debug("ignoring incoming byte stream due to no handler for topic",e.topic);return}let s;const o={id:e.streamId,name:(i=e.contentHeader.value.name)!==null&&i!==void 0?i:"unknown",mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:ra(e.timestamp),attributes:e.attributes},a=new ReadableStream({start:c=>{s=c,this.byteStreamControllers.set(e.streamId,{info:o,controller:s,startTime:Date.now()})}});r(new l2(o,a,ra(e.totalLength)),{identity:n})}else if(e.contentHeader.case==="textHeader"){const r=this.textStreamHandlers.get(e.topic);if(!r){this.log.debug("ignoring incoming text stream due to no handler for topic",e.topic);return}let s;const o={id:e.streamId,mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:Number(e.timestamp),attributes:e.attributes},a=new ReadableStream({start:c=>{s=c,this.textStreamControllers.set(e.streamId,{info:o,controller:s,startTime:Date.now()})}});r(new d2(o,a,ra(e.totalLength)),{identity:n})}})}handleStreamChunk(e){const n=this.byteStreamControllers.get(e.streamId);n&&e.content.length>0&&n.controller.enqueue(e);const i=this.textStreamControllers.get(e.streamId);i&&e.content.length>0&&i.controller.enqueue(e)}handleStreamTrailer(e){const n=this.textStreamControllers.get(e.streamId);n&&(n.info.attributes=Object.assign(Object.assign({},n.info.attributes),e.attributes),n.controller.close(),this.textStreamControllers.delete(e.streamId));const i=this.byteStreamControllers.get(e.streamId);i&&(i.info.attributes=Object.assign(Object.assign({},i.info.attributes),e.attributes),i.controller.close(),this.byteStreamControllers.delete(e.streamId))}selectDefaultDevices(){return A(this,void 0,void 0,function*(){var e,n,i;const r=gt.getInstance().previousDevices,s=yield gt.getInstance().getDevices(void 0,!1),o=$t();if((o==null?void 0:o.name)==="Chrome"&&o.os!=="iOS")for(let c of s){const l=r.find(d=>d.deviceId===c.deviceId);l&&l.label!==""&&l.kind===c.kind&&l.label!==c.label&&this.getActiveDevice(c.kind)==="default"&&this.emit(U.ActiveDeviceChanged,c.kind,c.deviceId)}const a=["audiooutput","audioinput","videoinput"];for(let c of a){const l=pT(c),d=this.localParticipant.getTrackPublication(l);if(d&&(!((e=d.track)===null||e===void 0)&&e.isUserProvided))continue;const u=s.filter(p=>p.kind===c),f=this.getActiveDevice(c);if(f===((n=r.filter(p=>p.kind===c)[0])===null||n===void 0?void 0:n.deviceId)&&u.length>0&&((i=u[0])===null||i===void 0?void 0:i.deviceId)!==f){yield this.switchActiveDevice(c,u[0].deviceId);continue}c==="audioinput"&&!Qh()||c==="videoinput"||u.length>0&&!u.find(p=>p.deviceId===this.getActiveDevice(c))&&(c!=="audiooutput"||!Qh())&&(yield this.switchActiveDevice(c,u[0].deviceId))}})}acquireAudioContext(){return A(this,void 0,void 0,function*(){var e,n;if(typeof this.options.webAudioMix!="boolean"&&this.options.webAudioMix.audioContext?this.audioContext=this.options.webAudioMix.audioContext:(!this.audioContext||this.audioContext.state==="closed")&&(this.audioContext=(e=Nu())!==null&&e!==void 0?e:void 0),this.options.webAudioMix&&this.remoteParticipants.forEach(r=>r.setAudioContext(this.audioContext)),this.localParticipant.setAudioContext(this.audioContext),this.audioContext&&this.audioContext.state==="suspended")try{yield Promise.race([this.audioContext.resume(),jt(200)])}catch(r){this.log.warn("Could not resume audio context",Object.assign(Object.assign({},this.logContext),{error:r}))}const i=((n=this.audioContext)===null||n===void 0?void 0:n.state)==="running";i!==this.canPlaybackAudio&&(this.audioEnabled=i,this.emit(U.AudioPlaybackStatusChanged,i))})}createParticipant(e,n){var i;let r;return n?r=Ra.fromParticipantInfo(this.engine.client,n,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName}):r=new Ra(this.engine.client,"",e,void 0,void 0,void 0,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName}),this.options.webAudioMix&&r.setAudioContext(this.audioContext),!((i=this.options.audioOutput)===null||i===void 0)&&i.deviceId&&r.setAudioOutput(this.options.audioOutput).catch(s=>this.log.warn("Could not set audio output: ".concat(s.message),this.logContext)),r}getOrCreateParticipant(e,n){if(this.remoteParticipants.has(e)){const r=this.remoteParticipants.get(e);return n&&r.updateInfo(n)&&this.sidToIdentity.set(n.sid,n.identity),r}const i=this.createParticipant(e,n);return this.remoteParticipants.set(e,i),this.sidToIdentity.set(n.sid,n.identity),this.emitWhenConnected(U.ParticipantConnected,i),i.on(Z.TrackPublished,r=>{this.emitWhenConnected(U.TrackPublished,r,i)}).on(Z.TrackSubscribed,(r,s)=>{r.kind===V.Kind.Audio?(r.on(re.AudioPlaybackStarted,this.handleAudioPlaybackStarted),r.on(re.AudioPlaybackFailed,this.handleAudioPlaybackFailed)):r.kind===V.Kind.Video&&(r.on(re.VideoPlaybackFailed,this.handleVideoPlaybackFailed),r.on(re.VideoPlaybackStarted,this.handleVideoPlaybackStarted)),this.emit(U.TrackSubscribed,r,s,i)}).on(Z.TrackUnpublished,r=>{this.emit(U.TrackUnpublished,r,i)}).on(Z.TrackUnsubscribed,(r,s)=>{this.emit(U.TrackUnsubscribed,r,s,i)}).on(Z.TrackMuted,r=>{this.emitWhenConnected(U.TrackMuted,r,i)}).on(Z.TrackUnmuted,r=>{this.emitWhenConnected(U.TrackUnmuted,r,i)}).on(Z.ParticipantMetadataChanged,r=>{this.emitWhenConnected(U.ParticipantMetadataChanged,r,i)}).on(Z.ParticipantNameChanged,r=>{this.emitWhenConnected(U.ParticipantNameChanged,r,i)}).on(Z.AttributesChanged,r=>{this.emitWhenConnected(U.ParticipantAttributesChanged,r,i)}).on(Z.ConnectionQualityChanged,r=>{this.emitWhenConnected(U.ConnectionQualityChanged,r,i)}).on(Z.ParticipantPermissionsChanged,r=>{this.emitWhenConnected(U.ParticipantPermissionsChanged,r,i)}).on(Z.TrackSubscriptionStatusChanged,(r,s)=>{this.emitWhenConnected(U.TrackSubscriptionStatusChanged,r,s,i)}).on(Z.TrackSubscriptionFailed,(r,s)=>{this.emit(U.TrackSubscriptionFailed,r,i,s)}).on(Z.TrackSubscriptionPermissionChanged,(r,s)=>{this.emitWhenConnected(U.TrackSubscriptionPermissionChanged,r,s,i)}).on(Z.Active,()=>{this.emitWhenConnected(U.ParticipantActive,i),i.kind===Yi.AGENT&&this.localParticipant.setActiveAgent(i)}),n&&i.updateInfo(n),i}sendSyncState(){const e=Array.from(this.remoteParticipants.values()).reduce((i,r)=>(i.push(...r.getTrackPublications()),i),[]),n=this.localParticipant.getTrackPublications();this.engine.sendSyncState(e,n)}updateSubscriptions(){for(const e of this.remoteParticipants.values())for(const n of e.videoTrackPublications.values())n.isSubscribed&&fT(n)&&n.emitTrackUpdate()}getRemoteParticipantBySid(e){const n=this.sidToIdentity.get(e);if(n)return this.remoteParticipants.get(n)}registerConnectionReconcile(){this.clearConnectionReconcile();let e=0;this.connectionReconcileInterval=bt.setInterval(()=>{!this.engine||this.engine.isClosed||!this.engine.verifyTransport()?(e++,this.log.warn("detected connection state mismatch",Object.assign(Object.assign({},this.logContext),{numFailures:e,engine:this.engine?{closed:this.engine.isClosed,transportsConnected:this.engine.verifyTransport()}:void 0})),e>=3&&(this.recreateEngine(),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,dn.STATE_MISMATCH))):e=0},x2)}clearConnectionReconcile(){this.connectionReconcileInterval&&bt.clearInterval(this.connectionReconcileInterval)}setAndEmitConnectionState(e){return e===this.state?!1:(this.state=e,this.emit(U.ConnectionStateChanged,this.state),!0)}emitBufferedEvents(){this.bufferedEvents.forEach(e=>{let[n,i]=e;this.emit(n,...i)}),this.bufferedEvents=[]}emitWhenConnected(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];if(this.state===ge.Reconnecting||this.isResuming||!this.engine||this.engine.pendingReconnect)this.bufferedEvents.push([e,i]);else if(this.state===ge.Connected)return this.emit(e,...i);return!1}simulateParticipants(e){return A(this,void 0,void 0,function*(){var n,i;const r=Object.assign({audio:!0,video:!0,useRealTracks:!1},e.publish),s=Object.assign({count:9,audio:!1,video:!0,aspectRatios:[1.66,1.7,1.3]},e.participants);if(this.handleDisconnect(),this.roomInfo=new Ga({sid:"RM_SIMULATED",name:"simulated-room",emptyTimeout:0,maxParticipants:0,creationTime:ze.parse(new Date().getTime()),metadata:"",numParticipants:1,numPublishers:1,turnPassword:"",enabledCodecs:[],activeRecording:!1}),this.localParticipant.updateInfo(new Zi({identity:"simulated-local",name:"local-name"})),this.setupLocalParticipantEvents(),this.emit(U.SignalConnected),this.emit(U.Connected),this.setAndEmitConnectionState(ge.Connected),r.video){const o=new Sd(V.Kind.Video,new Cr({source:lt.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:cn.AUDIO,name:"video-dummy"}),new Ea(r.useRealTracks?(yield window.navigator.mediaDevices.getUserMedia({video:!0})).getVideoTracks()[0]:im(160*((n=s.aspectRatios[0])!==null&&n!==void 0?n:1),160,!0,!0),void 0,!1,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(o),this.localParticipant.emit(Z.LocalTrackPublished,o)}if(r.audio){const o=new Sd(V.Kind.Audio,new Cr({source:lt.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:cn.AUDIO}),new Ta(r.useRealTracks?(yield navigator.mediaDevices.getUserMedia({audio:!0})).getAudioTracks()[0]:Bc(),void 0,!1,this.audioContext,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(o),this.localParticipant.emit(Z.LocalTrackPublished,o)}for(let o=0;o<s.count-1;o+=1){let a=new Zi({sid:Math.floor(Math.random()*1e4).toString(),identity:"simulated-".concat(o),state:_r.ACTIVE,tracks:[],joinedAt:ze.parse(Date.now())});const c=this.getOrCreateParticipant(a.identity,a);if(s.video){const l=im(160*((i=s.aspectRatios[o%s.aspectRatios.length])!==null&&i!==void 0?i:1),160,!1,!0),d=new Cr({source:lt.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:cn.AUDIO});c.addSubscribedMediaTrack(l,d.sid,new MediaStream([l]),new RTCRtpReceiver),a.tracks=[...a.tracks,d]}if(s.audio){const l=Bc(),d=new Cr({source:lt.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:cn.AUDIO});c.addSubscribedMediaTrack(l,d.sid,new MediaStream([l]),new RTCRtpReceiver),a.tracks=[...a.tracks,d]}c.updateInfo(a)}})}emit(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];if(e!==U.ActiveSpeakersChanged&&e!==U.TranscriptionReceived){const s=gy(i).filter(o=>o!==void 0);this.log.debug("room event ".concat(e),Object.assign(Object.assign({},this.logContext),{event:e,args:s}))}return super.emit(e,...i)}}pi.cleanupRegistry=typeof FinalizationRegistry<"u"&&new FinalizationRegistry(t=>{t()});function gy(t){return t.map(e=>{if(e)return Array.isArray(e)?gy(e):typeof e=="object"?"logContext"in e?e.logContext:void 0:e})}var an;(function(t){t[t.IDLE=0]="IDLE",t[t.RUNNING=1]="RUNNING",t[t.SKIPPED=2]="SKIPPED",t[t.SUCCESS=3]="SUCCESS",t[t.FAILED=4]="FAILED"})(an||(an={}));class Ti extends Nn.EventEmitter{constructor(e,n){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};super(),this.status=an.IDLE,this.logs=[],this.options={},this.url=e,this.token=n,this.name=this.constructor.name,this.room=new pi(i.roomOptions),this.connectOptions=i.connectOptions,this.options=i}run(e){return A(this,void 0,void 0,function*(){if(this.status!==an.IDLE)throw Error("check is running already");this.setStatus(an.RUNNING);try{yield this.perform()}catch(n){n instanceof Error&&(this.options.errorsAsWarnings?this.appendWarning(n.message):this.appendError(n.message))}return yield this.disconnect(),yield new Promise(n=>setTimeout(n,500)),this.status!==an.SKIPPED&&this.setStatus(this.isSuccess()?an.SUCCESS:an.FAILED),e&&e(),this.getInfo()})}isSuccess(){return!this.logs.some(e=>e.level==="error")}connect(e){return A(this,void 0,void 0,function*(){return this.room.state===ge.Connected?this.room:(e||(e=this.url),yield this.room.connect(e,this.token,this.connectOptions),this.room)})}disconnect(){return A(this,void 0,void 0,function*(){this.room&&this.room.state!==ge.Disconnected&&(yield this.room.disconnect(),yield new Promise(e=>setTimeout(e,500)))})}skip(){this.setStatus(an.SKIPPED)}switchProtocol(e){return A(this,void 0,void 0,function*(){let n=!1,i=!1;if(this.room.on(U.Reconnecting,()=>{n=!0}),this.room.once(U.Reconnected,()=>{i=!0}),this.room.simulateScenario("force-".concat(e)),yield new Promise(s=>setTimeout(s,1e3)),!n)return;const r=Date.now()+1e4;for(;Date.now()<r;){if(i)return;yield jt(100)}throw new Error("Could not reconnect using ".concat(e," protocol after 10 seconds"))})}appendMessage(e){this.logs.push({level:"info",message:e}),this.emit("update",this.getInfo())}appendWarning(e){this.logs.push({level:"warning",message:e}),this.emit("update",this.getInfo())}appendError(e){this.logs.push({level:"error",message:e}),this.emit("update",this.getInfo())}setStatus(e){this.status=e,this.emit("update",this.getInfo())}get engine(){var e;return(e=this.room)===null||e===void 0?void 0:e.engine}getInfo(){return{logs:this.logs,name:this.name,status:this.status,description:this.description}}}class S2 extends Ti{get description(){return"Cloud regions"}perform(){return A(this,void 0,void 0,function*(){const e=new bd(this.url,this.token);if(!e.isCloud()){this.skip();return}const n=[],i=new Set;for(let s=0;s<3;s++){const o=yield e.getNextBestRegionUrl();if(!o)break;if(i.has(o))continue;i.add(o);const a=yield this.checkCloudRegion(o);this.appendMessage("".concat(a.region," RTT: ").concat(a.rtt,"ms, duration: ").concat(a.duration,"ms")),n.push(a)}n.sort((s,o)=>(s.duration-o.duration)*.5+(s.rtt-o.rtt)*.5);const r=n[0];this.bestStats=r,this.appendMessage("best Cloud region: ".concat(r.region))})}getInfo(){const e=super.getInfo();return e.data=this.bestStats,e}checkCloudRegion(e){return A(this,void 0,void 0,function*(){var n,i;yield this.connect(e),this.options.protocol==="tcp"&&(yield this.switchProtocol("tcp"));const r=(n=this.room.serverInfo)===null||n===void 0?void 0:n.region;if(!r)throw new Error("Region not found");const s=yield this.room.localParticipant.streamText({topic:"test"}),o=1e3,c=1e6/o,l="A".repeat(o),d=Date.now();for(let v=0;v<c;v++)yield s.write(l);yield s.close();const u=Date.now(),f=yield(i=this.room.engine.pcManager)===null||i===void 0?void 0:i.publisher.getStats(),p={region:r,rtt:1e4,duration:u-d};return f==null||f.forEach(v=>{v.type==="candidate-pair"&&v.nominated&&(p.rtt=v.currentRoundTripTime*1e3)}),yield this.disconnect(),p})}}const Yc=1e4;class w2 extends Ti{get description(){return"Connection via UDP vs TCP"}perform(){return A(this,void 0,void 0,function*(){const e=yield this.checkConnectionProtocol("udp"),n=yield this.checkConnectionProtocol("tcp");this.bestStats=e,e.qualityLimitationDurations.bandwidth-n.qualityLimitationDurations.bandwidth>.5||(e.packetsLost-n.packetsLost)/e.packetsSent>.01?(this.appendMessage("best connection quality via tcp"),this.bestStats=n):this.appendMessage("best connection quality via udp");const i=this.bestStats;this.appendMessage("upstream bitrate: ".concat((i.bitrateTotal/i.count/1e3/1e3).toFixed(2)," mbps")),this.appendMessage("RTT: ".concat((i.rttTotal/i.count*1e3).toFixed(2)," ms")),this.appendMessage("jitter: ".concat((i.jitterTotal/i.count*1e3).toFixed(2)," ms")),i.packetsLost>0&&this.appendWarning("packets lost: ".concat((i.packetsLost/i.packetsSent*100).toFixed(2),"%")),i.qualityLimitationDurations.bandwidth>1&&this.appendWarning("bandwidth limited ".concat((i.qualityLimitationDurations.bandwidth/(Yc/1e3)*100).toFixed(2),"%")),i.qualityLimitationDurations.cpu>0&&this.appendWarning("cpu limited ".concat((i.qualityLimitationDurations.cpu/(Yc/1e3)*100).toFixed(2),"%"))})}getInfo(){const e=super.getInfo();return e.data=this.bestStats,e}checkConnectionProtocol(e){return A(this,void 0,void 0,function*(){yield this.connect(),e==="tcp"?yield this.switchProtocol("tcp"):yield this.switchProtocol("udp");const n=document.createElement("canvas");n.width=1280,n.height=720;const i=n.getContext("2d");if(!i)throw new Error("Could not get canvas context");let r=0;const s=()=>{r=(r+1)%360,i.fillStyle="hsl(".concat(r,", 100%, 50%)"),i.fillRect(0,0,n.width,n.height),requestAnimationFrame(s)};s();const a=n.captureStream(30).getVideoTracks()[0],l=(yield this.room.localParticipant.publishTrack(a,{simulcast:!1,degradationPreference:"maintain-resolution",videoEncoding:{maxBitrate:2e6}})).track,d={protocol:e,packetsLost:0,packetsSent:0,qualityLimitationDurations:{},rttTotal:0,jitterTotal:0,bitrateTotal:0,count:0},u=setInterval(()=>A(this,void 0,void 0,function*(){const f=yield l.getRTCStatsReport();f==null||f.forEach(p=>{p.type==="outbound-rtp"?(d.packetsSent=p.packetsSent,d.qualityLimitationDurations=p.qualityLimitationDurations,d.bitrateTotal+=p.targetBitrate,d.count++):p.type==="remote-inbound-rtp"&&(d.packetsLost=p.packetsLost,d.rttTotal+=p.roundTripTime,d.jitterTotal+=p.jitter)})}),1e3);return yield new Promise(f=>setTimeout(f,Yc)),clearInterval(u),a.stop(),n.remove(),yield this.disconnect(),d})}}class C2 extends Ti{get description(){return"Can publish audio"}perform(){return A(this,void 0,void 0,function*(){var e;const n=yield this.connect(),i=yield g2();if(yield ny(i,1e3))throw new Error("unable to detect audio from microphone");this.appendMessage("detected audio from microphone"),n.localParticipant.publishTrack(i),yield new Promise(a=>setTimeout(a,3e3));const s=yield(e=i.sender)===null||e===void 0?void 0:e.getStats();if(!s)throw new Error("Could not get RTCStats");let o=0;if(s.forEach(a=>{a.type==="outbound-rtp"&&(a.kind==="audio"||!a.kind&&a.mediaType==="audio")&&(o=a.packetsSent)}),o===0)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(o," audio packets"))})}}class k2 extends Ti{get description(){return"Can publish video"}perform(){return A(this,void 0,void 0,function*(){var e;const n=yield this.connect(),i=yield p2();yield this.checkForVideo(i.mediaStreamTrack),n.localParticipant.publishTrack(i),yield new Promise(o=>setTimeout(o,5e3));const r=yield(e=i.sender)===null||e===void 0?void 0:e.getStats();if(!r)throw new Error("Could not get RTCStats");let s=0;if(r.forEach(o=>{o.type==="outbound-rtp"&&(o.kind==="video"||!o.kind&&o.mediaType==="video")&&(s+=o.packetsSent)}),s===0)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(s," video packets"))})}checkForVideo(e){return A(this,void 0,void 0,function*(){const n=new MediaStream;n.addTrack(e.clone());const i=document.createElement("video");i.srcObject=n,i.muted=!0,yield new Promise(r=>{i.onplay=()=>{setTimeout(()=>{var s,o,a,c;const l=document.createElement("canvas"),d=e.getSettings(),u=(o=(s=d.width)!==null&&s!==void 0?s:i.videoWidth)!==null&&o!==void 0?o:1280,f=(c=(a=d.height)!==null&&a!==void 0?a:i.videoHeight)!==null&&c!==void 0?c:720;l.width=u,l.height=f;const p=l.getContext("2d");p.drawImage(i,0,0);const h=p.getImageData(0,0,l.width,l.height).data;let y=!0;for(let b=0;b<h.length;b+=4)if(h[b]!==0||h[b+1]!==0||h[b+2]!==0){y=!1;break}y?this.appendError("camera appears to be producing only black frames"):this.appendMessage("received video frames"),r()},1e3)},i.play()}),n.getTracks().forEach(r=>r.stop()),i.remove()})}}class T2 extends Ti{get description(){return"Resuming connection after interruption"}perform(){return A(this,void 0,void 0,function*(){var e;const n=yield this.connect();let i=!1,r=!1,s;const o=new Promise(l=>{setTimeout(l,5e3),s=l}),a=()=>{i=!0};n.on(U.SignalReconnecting,a).on(U.Reconnecting,a).on(U.Reconnected,()=>{r=!0,s(!0)}),(e=n.engine.client.ws)===null||e===void 0||e.close();const c=n.engine.client.onClose;if(c&&c(""),yield o,i){if(!r||n.state!==ge.Connected)throw this.appendWarning("reconnection is only possible in Redis-based configurations"),new Error("Not able to reconnect")}else throw new Error("Did not attempt to reconnect")})}}class E2 extends Ti{get description(){return"Can connect via TURN"}perform(){return A(this,void 0,void 0,function*(){var e,n;const i=new Ou,r=yield i.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3});let s=!1,o=!1,a=!1;for(let c of r.iceServers)for(let l of c.urls)l.startsWith("turn:")?(o=!0,a=!0):l.startsWith("turns:")&&(o=!0,a=!0,s=!0),l.startsWith("stun:")&&(a=!0);a?o&&!s&&this.appendWarning("TURN is configured server side, but TURN/TLS is unavailable."):this.appendWarning("No STUN servers configured on server side."),yield i.close(),!((n=(e=this.connectOptions)===null||e===void 0?void 0:e.rtcConfig)===null||n===void 0)&&n.iceServers||o?yield this.room.connect(this.url,this.token,{rtcConfig:{iceTransportPolicy:"relay"}}):(this.appendWarning("No TURN servers configured."),this.skip(),yield new Promise(c=>setTimeout(c,0)))})}}class P2 extends Ti{get description(){return"Establishing WebRTC connection"}perform(){return A(this,void 0,void 0,function*(){let e=!1,n=!1;this.room.on(U.SignalConnected,()=>{const i=this.room.engine.client.onTrickle;this.room.engine.client.onTrickle=(r,s)=>{if(r.candidate){const o=new RTCIceCandidate(r);let a="".concat(o.protocol," ").concat(o.address,":").concat(o.port," ").concat(o.type);o.address&&(R2(o.address)?a+=" (private)":o.protocol==="tcp"&&o.tcpType==="passive"?(e=!0,a+=" (passive)"):o.protocol==="udp"&&(n=!0)),this.appendMessage(a)}i&&i(r,s)},this.room.engine.pcManager&&(this.room.engine.pcManager.subscriber.onIceCandidateError=r=>{r instanceof RTCPeerConnectionIceErrorEvent&&this.appendWarning("error with ICE candidate: ".concat(r.errorCode," ").concat(r.errorText," ").concat(r.url))})});try{yield this.connect(),Ce.info("now the room is connected")}catch(i){throw this.appendWarning("ports need to be open on firewall in order to connect."),i}e||this.appendWarning("Server is not configured for ICE/TCP"),n||this.appendWarning("No public IPv4 UDP candidates were found. Your server is likely not configured correctly")})}}function R2(t){const e=t.split(".");if(e.length===4){if(e[0]==="10")return!0;if(e[0]==="192"&&e[1]==="168")return!0;if(e[0]==="172"){const n=parseInt(e[1],10);if(n>=16&&n<=31)return!0}}return!1}class A2 extends Ti{get description(){return"Connecting to signal connection via WebSocket"}perform(){return A(this,void 0,void 0,function*(){var e,n,i;(this.url.startsWith("ws:")||this.url.startsWith("http:"))&&this.appendWarning("Server is insecure, clients may block connections to it");let r=new Ou;const s=yield r.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3});this.appendMessage("Connected to server, version ".concat(s.serverVersion,".")),((e=s.serverInfo)===null||e===void 0?void 0:e.edition)===iv.Cloud&&(!((n=s.serverInfo)===null||n===void 0)&&n.region)&&this.appendMessage("LiveKit Cloud: ".concat((i=s.serverInfo)===null||i===void 0?void 0:i.region)),yield r.close()})}}class OL extends Nn.EventEmitter{constructor(e,n){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};super(),this.options={},this.checkResults=new Map,this.url=e,this.token=n,this.options=i}getNextCheckId(){const e=this.checkResults.size;return this.checkResults.set(e,{logs:[],status:an.IDLE,name:"",description:""}),e}updateCheck(e,n){this.checkResults.set(e,n),this.emit("checkUpdate",e,n)}isSuccess(){return Array.from(this.checkResults.values()).every(e=>e.status!==an.FAILED)}getResults(){return Array.from(this.checkResults.values())}createAndRunCheck(e){return A(this,void 0,void 0,function*(){const n=this.getNextCheckId(),i=new e(this.url,this.token,this.options),r=o=>{this.updateCheck(n,o)};i.on("update",r);const s=yield i.run();return i.off("update",r),s})}checkWebsocket(){return A(this,void 0,void 0,function*(){return this.createAndRunCheck(A2)})}checkWebRTC(){return A(this,void 0,void 0,function*(){return this.createAndRunCheck(P2)})}checkTURN(){return A(this,void 0,void 0,function*(){return this.createAndRunCheck(E2)})}checkReconnect(){return A(this,void 0,void 0,function*(){return this.createAndRunCheck(T2)})}checkPublishAudio(){return A(this,void 0,void 0,function*(){return this.createAndRunCheck(C2)})}checkPublishVideo(){return A(this,void 0,void 0,function*(){return this.createAndRunCheck(k2)})}checkConnectionProtocol(){return A(this,void 0,void 0,function*(){const e=yield this.createAndRunCheck(w2);if(e.data&&"protocol"in e.data){const n=e.data;this.options.protocol=n.protocol}return e})}checkCloudRegion(){return A(this,void 0,void 0,function*(){return this.createAndRunCheck(S2)})}}const Bu=R.createContext({});function $u(t){const e=R.useRef(null);return e.current===null&&(e.current=t()),e.current}const Hu=typeof window<"u",vy=Hu?R.useLayoutEffect:R.useEffect,ec=R.createContext(null);function zu(t,e){t.indexOf(e)===-1&&t.push(e)}function Wu(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Zn=(t,e,n)=>n>e?e:n<t?t:n;function wd(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let is=()=>{},Yn=()=>{};process.env.NODE_ENV!=="production"&&(is=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(wd(e,n))},Yn=(t,e,n)=>{if(!t)throw new Error(wd(e,n))});const Jn={},yy=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function by(t){return typeof t=="object"&&t!==null}const xy=t=>/^0[^.\s]+$/u.test(t);function qu(t){let e;return()=>(e===void 0&&(e=t()),e)}const Xt=t=>t,I2=(t,e)=>n=>e(t(n)),ao=(...t)=>t.reduce(I2),Ws=(t,e,n)=>{const i=e-t;return i===0?1:(n-t)/i};class Ku{constructor(){this.subscriptions=[]}add(e){return zu(this.subscriptions,e),()=>Wu(this.subscriptions,e)}notify(e,n,i){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,n,i);else for(let s=0;s<r;s++){const o=this.subscriptions[s];o&&o(e,n,i)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const un=t=>t*1e3,En=t=>t/1e3;function Sy(t,e){return e?t*(1e3/e):0}const wm=new Set;function Gu(t,e,n){t||wm.has(e)||(console.warn(wd(e,n)),wm.add(e))}const wy=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,M2=1e-7,_2=12;function N2(t,e,n,i,r){let s,o,a=0;do o=e+(n-e)/2,s=wy(o,i,r)-t,s>0?n=o:e=o;while(Math.abs(s)>M2&&++a<_2);return o}function co(t,e,n,i){if(t===e&&n===i)return Xt;const r=s=>N2(s,0,1,t,n);return s=>s===0||s===1?s:wy(r(s),e,i)}const Cy=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,ky=t=>e=>1-t(1-e),Ty=co(.33,1.53,.69,.99),Zu=ky(Ty),Ey=Cy(Zu),Py=t=>(t*=2)<1?.5*Zu(t):.5*(2-Math.pow(2,-10*(t-1))),Yu=t=>1-Math.sin(Math.acos(t)),Ry=ky(Yu),Ay=Cy(Yu),O2=co(.42,0,1,1),D2=co(0,0,.58,1),Iy=co(.42,0,.58,1),j2=t=>Array.isArray(t)&&typeof t[0]!="number",My=t=>Array.isArray(t)&&typeof t[0]=="number",Cm={linear:Xt,easeIn:O2,easeInOut:Iy,easeOut:D2,circIn:Yu,circInOut:Ay,circOut:Ry,backIn:Zu,backInOut:Ey,backOut:Ty,anticipate:Py},L2=t=>typeof t=="string",km=t=>{if(My(t)){Yn(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,i,r]=t;return co(e,n,i,r)}else if(L2(t))return Yn(Cm[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),Cm[t];return t},ko=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function V2(t,e){let n=new Set,i=new Set,r=!1,s=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function c(d){o.has(d)&&(l.schedule(d),t()),d(a)}const l={schedule:(d,u=!1,f=!1)=>{const v=f&&r?n:i;return u&&o.add(d),v.has(d)||v.add(d),d},cancel:d=>{i.delete(d),o.delete(d)},process:d=>{if(a=d,r){s=!0;return}r=!0,[n,i]=[i,n],n.forEach(c),n.clear(),r=!1,s&&(s=!1,l.process(d))}};return l}const F2=40;function _y(t,e){let n=!1,i=!0;const r={delta:0,timestamp:0,isProcessing:!1},s=()=>n=!0,o=ko.reduce((C,S)=>(C[S]=V2(s),C),{}),{setup:a,read:c,resolveKeyframes:l,preUpdate:d,update:u,preRender:f,render:p,postRender:v}=o,h=()=>{const C=Jn.useManualTiming?r.timestamp:performance.now();n=!1,Jn.useManualTiming||(r.delta=i?1e3/60:Math.max(Math.min(C-r.timestamp,F2),1)),r.timestamp=C,r.isProcessing=!0,a.process(r),c.process(r),l.process(r),d.process(r),u.process(r),f.process(r),p.process(r),v.process(r),r.isProcessing=!1,n&&e&&(i=!1,t(h))},y=()=>{n=!0,i=!0,r.isProcessing||t(h)};return{schedule:ko.reduce((C,S)=>{const x=o[S];return C[S]=(T,E=!1,P=!1)=>(n||y(),x.schedule(T,E,P)),C},{}),cancel:C=>{for(let S=0;S<ko.length;S++)o[ko[S]].cancel(C)},state:r,steps:o}}const{schedule:We,cancel:gi,state:vt,steps:Jc}=_y(typeof requestAnimationFrame<"u"?requestAnimationFrame:Xt,!0);let oa;function U2(){oa=void 0}const Dt={now:()=>(oa===void 0&&Dt.set(vt.isProcessing||Jn.useManualTiming?vt.timestamp:performance.now()),oa),set:t=>{oa=t,queueMicrotask(U2)}},Ny=t=>e=>typeof e=="string"&&e.startsWith(t),Ju=Ny("--"),B2=Ny("var(--"),Xu=t=>B2(t)?$2.test(t.split("/*")[0].trim()):!1,$2=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,rs={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},qs={...rs,transform:t=>Zn(0,1,t)},To={...rs,default:1},Vs=t=>Math.round(t*1e5)/1e5,Qu=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function H2(t){return t==null}const z2=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,ef=(t,e)=>n=>!!(typeof n=="string"&&z2.test(n)&&n.startsWith(t)||e&&!H2(n)&&Object.prototype.hasOwnProperty.call(n,e)),Oy=(t,e,n)=>i=>{if(typeof i!="string")return i;const[r,s,o,a]=i.match(Qu);return{[t]:parseFloat(r),[e]:parseFloat(s),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},W2=t=>Zn(0,255,t),Xc={...rs,transform:t=>Math.round(W2(t))},Ui={test:ef("rgb","red"),parse:Oy("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:i=1})=>"rgba("+Xc.transform(t)+", "+Xc.transform(e)+", "+Xc.transform(n)+", "+Vs(qs.transform(i))+")"};function q2(t){let e="",n="",i="",r="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),i=t.substring(5,7),r=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),i=t.substring(3,4),r=t.substring(4,5),e+=e,n+=n,i+=i,r+=r),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(i,16),alpha:r?parseInt(r,16)/255:1}}const Cd={test:ef("#"),parse:q2,transform:Ui.transform},lo=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),oi=lo("deg"),Pn=lo("%"),he=lo("px"),K2=lo("vh"),G2=lo("vw"),Tm={...Pn,parse:t=>Pn.parse(t)/100,transform:t=>Pn.transform(t*100)},Er={test:ef("hsl","hue"),parse:Oy("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:i=1})=>"hsla("+Math.round(t)+", "+Pn.transform(Vs(e))+", "+Pn.transform(Vs(n))+", "+Vs(qs.transform(i))+")"},ct={test:t=>Ui.test(t)||Cd.test(t)||Er.test(t),parse:t=>Ui.test(t)?Ui.parse(t):Er.test(t)?Er.parse(t):Cd.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Ui.transform(t):Er.transform(t),getAnimatableNone:t=>{const e=ct.parse(t);return e.alpha=0,ct.transform(e)}},Z2=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Y2(t){var e,n;return isNaN(t)&&typeof t=="string"&&(((e=t.match(Qu))==null?void 0:e.length)||0)+(((n=t.match(Z2))==null?void 0:n.length)||0)>0}const Dy="number",jy="color",J2="var",X2="var(",Em="${}",Q2=/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 Ks(t){const e=t.toString(),n=[],i={color:[],number:[],var:[]},r=[];let s=0;const a=e.replace(Q2,c=>(ct.test(c)?(i.color.push(s),r.push(jy),n.push(ct.parse(c))):c.startsWith(X2)?(i.var.push(s),r.push(J2),n.push(c)):(i.number.push(s),r.push(Dy),n.push(parseFloat(c))),++s,Em)).split(Em);return{values:n,split:a,indexes:i,types:r}}function Ly(t){return Ks(t).values}function Vy(t){const{split:e,types:n}=Ks(t),i=e.length;return r=>{let s="";for(let o=0;o<i;o++)if(s+=e[o],r[o]!==void 0){const a=n[o];a===Dy?s+=Vs(r[o]):a===jy?s+=ct.transform(r[o]):s+=r[o]}return s}}const eE=t=>typeof t=="number"?0:ct.test(t)?ct.getAnimatableNone(t):t;function tE(t){const e=Ly(t);return Vy(t)(e.map(eE))}const vi={test:Y2,parse:Ly,createTransformer:Vy,getAnimatableNone:tE};function Qc(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function nE({hue:t,saturation:e,lightness:n,alpha:i}){t/=360,e/=100,n/=100;let r=0,s=0,o=0;if(!e)r=s=o=n;else{const a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;r=Qc(c,a,t+1/3),s=Qc(c,a,t),o=Qc(c,a,t-1/3)}return{red:Math.round(r*255),green:Math.round(s*255),blue:Math.round(o*255),alpha:i}}function Aa(t,e){return n=>n>0?e:t}const Ge=(t,e,n)=>t+(e-t)*n,el=(t,e,n)=>{const i=t*t,r=n*(e*e-i)+i;return r<0?0:Math.sqrt(r)},iE=[Cd,Ui,Er],rE=t=>iE.find(e=>e.test(t));function Pm(t){const e=rE(t);if(is(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===Er&&(n=nE(n)),n}const Rm=(t,e)=>{const n=Pm(t),i=Pm(e);if(!n||!i)return Aa(t,e);const r={...n};return s=>(r.red=el(n.red,i.red,s),r.green=el(n.green,i.green,s),r.blue=el(n.blue,i.blue,s),r.alpha=Ge(n.alpha,i.alpha,s),Ui.transform(r))},kd=new Set(["none","hidden"]);function sE(t,e){return kd.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function oE(t,e){return n=>Ge(t,e,n)}function tf(t){return typeof t=="number"?oE:typeof t=="string"?Xu(t)?Aa:ct.test(t)?Rm:lE:Array.isArray(t)?Fy:typeof t=="object"?ct.test(t)?Rm:aE:Aa}function Fy(t,e){const n=[...t],i=n.length,r=t.map((s,o)=>tf(s)(s,e[o]));return s=>{for(let o=0;o<i;o++)n[o]=r[o](s);return n}}function aE(t,e){const n={...t,...e},i={};for(const r in n)t[r]!==void 0&&e[r]!==void 0&&(i[r]=tf(t[r])(t[r],e[r]));return r=>{for(const s in i)n[s]=i[s](r);return n}}function cE(t,e){const n=[],i={color:0,var:0,number:0};for(let r=0;r<e.values.length;r++){const s=e.types[r],o=t.indexes[s][i[s]],a=t.values[o]??0;n[r]=a,i[s]++}return n}const lE=(t,e)=>{const n=vi.createTransformer(e),i=Ks(t),r=Ks(e);return i.indexes.var.length===r.indexes.var.length&&i.indexes.color.length===r.indexes.color.length&&i.indexes.number.length>=r.indexes.number.length?kd.has(t)&&!r.values.length||kd.has(e)&&!i.values.length?sE(t,e):ao(Fy(cE(i,r),r.values),n):(is(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),Aa(t,e))};function Uy(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?Ge(t,e,n):tf(t)(t,e)}const dE=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>We.update(e,n),stop:()=>gi(e),now:()=>vt.isProcessing?vt.timestamp:Dt.now()}},By=(t,e,n=10)=>{let i="";const r=Math.max(Math.round(e/n),2);for(let s=0;s<r;s++)i+=Math.round(t(s/(r-1))*1e4)/1e4+", ";return`linear(${i.substring(0,i.length-2)})`},Ia=2e4;function nf(t){let e=0;const n=50;let i=t.next(e);for(;!i.done&&e<Ia;)e+=n,i=t.next(e);return e>=Ia?1/0:e}function uE(t,e=100,n){const i=n({...t,keyframes:[0,e]}),r=Math.min(nf(i),Ia);return{type:"keyframes",ease:s=>i.next(r*s).value/e,duration:En(r)}}const fE=5;function $y(t,e,n){const i=Math.max(e-fE,0);return Sy(n-t(i),e-i)}const Ke={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},tl=.001;function hE({duration:t=Ke.duration,bounce:e=Ke.bounce,velocity:n=Ke.velocity,mass:i=Ke.mass}){let r,s;is(t<=un(Ke.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-e;o=Zn(Ke.minDamping,Ke.maxDamping,o),t=Zn(Ke.minDuration,Ke.maxDuration,En(t)),o<1?(r=l=>{const d=l*o,u=d*t,f=d-n,p=Td(l,o),v=Math.exp(-u);return tl-f/p*v},s=l=>{const u=l*o*t,f=u*n+n,p=Math.pow(o,2)*Math.pow(l,2)*t,v=Math.exp(-u),h=Td(Math.pow(l,2),o);return(-r(l)+tl>0?-1:1)*((f-p)*v)/h}):(r=l=>{const d=Math.exp(-l*t),u=(l-n)*t+1;return-tl+d*u},s=l=>{const d=Math.exp(-l*t),u=(n-l)*(t*t);return d*u});const a=5/t,c=pE(r,s,a);if(t=un(t),isNaN(c))return{stiffness:Ke.stiffness,damping:Ke.damping,duration:t};{const l=Math.pow(c,2)*i;return{stiffness:l,damping:o*2*Math.sqrt(i*l),duration:t}}}const mE=12;function pE(t,e,n){let i=n;for(let r=1;r<mE;r++)i=i-t(i)/e(i);return i}function Td(t,e){return t*Math.sqrt(1-e*e)}const gE=["duration","bounce"],vE=["stiffness","damping","mass"];function Am(t,e){return e.some(n=>t[n]!==void 0)}function yE(t){let e={velocity:Ke.velocity,stiffness:Ke.stiffness,damping:Ke.damping,mass:Ke.mass,isResolvedFromDuration:!1,...t};if(!Am(t,vE)&&Am(t,gE))if(t.visualDuration){const n=t.visualDuration,i=2*Math.PI/(n*1.2),r=i*i,s=2*Zn(.05,1,1-(t.bounce||0))*Math.sqrt(r);e={...e,mass:Ke.mass,stiffness:r,damping:s}}else{const n=hE(t);e={...e,...n,mass:Ke.mass},e.isResolvedFromDuration=!0}return e}function Ma(t=Ke.visualDuration,e=Ke.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:i,restDelta:r}=n;const s=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],a={done:!1,value:s},{stiffness:c,damping:l,mass:d,duration:u,velocity:f,isResolvedFromDuration:p}=yE({...n,velocity:-En(n.velocity||0)}),v=f||0,h=l/(2*Math.sqrt(c*d)),y=o-s,b=En(Math.sqrt(c/d)),w=Math.abs(y)<5;i||(i=w?Ke.restSpeed.granular:Ke.restSpeed.default),r||(r=w?Ke.restDelta.granular:Ke.restDelta.default);let C;if(h<1){const x=Td(b,h);C=T=>{const E=Math.exp(-h*b*T);return o-E*((v+h*b*y)/x*Math.sin(x*T)+y*Math.cos(x*T))}}else if(h===1)C=x=>o-Math.exp(-b*x)*(y+(v+b*y)*x);else{const x=b*Math.sqrt(h*h-1);C=T=>{const E=Math.exp(-h*b*T),P=Math.min(x*T,300);return o-E*((v+h*b*y)*Math.sinh(P)+x*y*Math.cosh(P))/x}}const S={calculatedDuration:p&&u||null,next:x=>{const T=C(x);if(p)a.done=x>=u;else{let E=x===0?v:0;h<1&&(E=x===0?un(v):$y(C,x,T));const P=Math.abs(E)<=i,_=Math.abs(o-T)<=r;a.done=P&&_}return a.value=a.done?o:T,a},toString:()=>{const x=Math.min(nf(S),Ia),T=By(E=>S.next(x*E).value,x,30);return x+"ms "+T},toTransition:()=>{}};return S}Ma.applyToOptions=t=>{const e=uE(t,100,Ma);return t.ease=e.ease,t.duration=un(e.duration),t.type="keyframes",t};function Ed({keyframes:t,velocity:e=0,power:n=.8,timeConstant:i=325,bounceDamping:r=10,bounceStiffness:s=500,modifyTarget:o,min:a,max:c,restDelta:l=.5,restSpeed:d}){const u=t[0],f={done:!1,value:u},p=P=>a!==void 0&&P<a||c!==void 0&&P>c,v=P=>a===void 0?c:c===void 0||Math.abs(a-P)<Math.abs(c-P)?a:c;let h=n*e;const y=u+h,b=o===void 0?y:o(y);b!==y&&(h=b-u);const w=P=>-h*Math.exp(-P/i),C=P=>b+w(P),S=P=>{const _=w(P),k=C(P);f.done=Math.abs(_)<=l,f.value=f.done?b:k};let x,T;const E=P=>{p(f.value)&&(x=P,T=Ma({keyframes:[f.value,v(f.value)],velocity:$y(C,P,f.value),damping:r,stiffness:s,restDelta:l,restSpeed:d}))};return E(0),{calculatedDuration:null,next:P=>{let _=!1;return!T&&x===void 0&&(_=!0,S(P),E(P)),x!==void 0&&P>=x?T.next(P-x):(!_&&S(P),f)}}}function bE(t,e,n){const i=[],r=n||Jn.mix||Uy,s=t.length-1;for(let o=0;o<s;o++){let a=r(t[o],t[o+1]);if(e){const c=Array.isArray(e)?e[o]||Xt:e;a=ao(c,a)}i.push(a)}return i}function xE(t,e,{clamp:n=!0,ease:i,mixer:r}={}){const s=t.length;if(Yn(s===e.length,"Both input and output ranges must be the same length","range-length"),s===1)return()=>e[0];if(s===2&&e[0]===e[1])return()=>e[1];const o=t[0]===t[1];t[0]>t[s-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=bE(e,i,r),c=a.length,l=d=>{if(o&&d<t[0])return e[0];let u=0;if(c>1)for(;u<t.length-2&&!(d<t[u+1]);u++);const f=Ws(t[u],t[u+1],d);return a[u](f)};return n?d=>l(Zn(t[0],t[s-1],d)):l}function SE(t,e){const n=t[t.length-1];for(let i=1;i<=e;i++){const r=Ws(0,e,i);t.push(Ge(n,1,r))}}function wE(t){const e=[0];return SE(e,t.length-1),e}function CE(t,e){return t.map(n=>n*e)}function kE(t,e){return t.map(()=>e||Iy).splice(0,t.length-1)}function Pr({duration:t=300,keyframes:e,times:n,ease:i="easeInOut"}){const r=j2(i)?i.map(km):km(i),s={done:!1,value:e[0]},o=CE(n&&n.length===e.length?n:wE(e),t),a=xE(o,e,{ease:Array.isArray(r)?r:kE(e,r)});return{calculatedDuration:t,next:c=>(s.value=a(c),s.done=c>=t,s)}}const TE=t=>t!==null;function rf(t,{repeat:e,repeatType:n="loop"},i,r=1){const s=t.filter(TE),a=r<0||e&&n!=="loop"&&e%2===1?0:s.length-1;return!a||i===void 0?s[a]:i}const EE={decay:Ed,inertia:Ed,tween:Pr,keyframes:Pr,spring:Ma};function Hy(t){typeof t.type=="string"&&(t.type=EE[t.type])}class sf{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const PE=t=>t/100;class of extends sf{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{var i,r;const{motionValue:n}=this.options;n&&n.updatedAt!==Dt.now()&&this.tick(Dt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(r=(i=this.options).onStop)==null||r.call(i))},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;Hy(e);const{type:n=Pr,repeat:i=0,repeatDelay:r=0,repeatType:s,velocity:o=0}=e;let{keyframes:a}=e;const c=n||Pr;process.env.NODE_ENV!=="production"&&c!==Pr&&Yn(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),c!==Pr&&typeof a[0]!="number"&&(this.mixKeyframes=ao(PE,Uy(a[0],a[1])),a=[0,100]);const l=c({...e,keyframes:a});s==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...a].reverse(),velocity:-o})),l.calculatedDuration===null&&(l.calculatedDuration=nf(l));const{calculatedDuration:d}=l;this.calculatedDuration=d,this.resolvedDuration=d+r,this.totalDuration=this.resolvedDuration*(i+1)-r,this.generator=l}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:i,totalDuration:r,mixKeyframes:s,mirroredGenerator:o,resolvedDuration:a,calculatedDuration:c}=this;if(this.startTime===null)return i.next(0);const{delay:l=0,keyframes:d,repeat:u,repeatType:f,repeatDelay:p,type:v,onUpdate:h,finalKeyframe:y}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const b=this.currentTime-l*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?b<0:b>r;this.currentTime=Math.max(b,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let C=this.currentTime,S=i;if(u){const P=Math.min(this.currentTime,r)/a;let _=Math.floor(P),k=P%1;!k&&P>=1&&(k=1),k===1&&_--,_=Math.min(_,u+1),!!(_%2)&&(f==="reverse"?(k=1-k,p&&(k-=p/a)):f==="mirror"&&(S=o)),C=Zn(0,1,k)*a}const x=w?{done:!1,value:d[0]}:S.next(C);s&&(x.value=s(x.value));let{done:T}=x;!w&&c!==null&&(T=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const E=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&T);return E&&v!==Ed&&(x.value=rf(d,this.options,y,this.speed)),h&&h(x.value),E&&this.finish(),x}then(e,n){return this.finished.then(e,n)}get duration(){return En(this.calculatedDuration)}get time(){return En(this.currentTime)}set time(e){var n;e=un(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),(n=this.driver)==null||n.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(Dt.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=En(this.currentTime))}play(){var r,s;if(this.isStopped)return;const{driver:e=dE,startTime:n}=this.options;this.driver||(this.driver=e(o=>this.tick(o))),(s=(r=this.options).onPlay)==null||s.call(r);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(Dt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var e,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(e=this.options).onComplete)==null||n.call(e)}cancel(){var e,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(e=this.options).onCancel)==null||n.call(e)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),e.observe(this)}}function RE(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const Bi=t=>t*180/Math.PI,Pd=t=>{const e=Bi(Math.atan2(t[1],t[0]));return Rd(e)},AE={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Pd,rotateZ:Pd,skewX:t=>Bi(Math.atan(t[1])),skewY:t=>Bi(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Rd=t=>(t=t%360,t<0&&(t+=360),t),Im=Pd,Mm=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),_m=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),IE={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Mm,scaleY:_m,scale:t=>(Mm(t)+_m(t))/2,rotateX:t=>Rd(Bi(Math.atan2(t[6],t[5]))),rotateY:t=>Rd(Bi(Math.atan2(-t[2],t[0]))),rotateZ:Im,rotate:Im,skewX:t=>Bi(Math.atan(t[4])),skewY:t=>Bi(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Ad(t){return t.includes("scale")?1:0}function Id(t,e){if(!t||t==="none")return Ad(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let i,r;if(n)i=IE,r=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);i=AE,r=a}if(!r)return Ad(e);const s=i[e],o=r[1].split(",").map(_E);return typeof s=="function"?s(o):o[s]}const ME=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return Id(n,e)};function _E(t){return parseFloat(t.trim())}const ss=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],os=new Set(ss),Nm=t=>t===rs||t===he,NE=new Set(["x","y","z"]),OE=ss.filter(t=>!NE.has(t));function DE(t){const e=[];return OE.forEach(n=>{const i=t.getValue(n);i!==void 0&&(e.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),e}const zi={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>Id(e,"x"),y:(t,{transform:e})=>Id(e,"y")};zi.translateX=zi.x;zi.translateY=zi.y;const Wi=new Set;let Md=!1,_d=!1,Nd=!1;function zy(){if(_d){const t=Array.from(Wi).filter(i=>i.needsMeasurement),e=new Set(t.map(i=>i.element)),n=new Map;e.forEach(i=>{const r=DE(i);r.length&&(n.set(i,r),i.render())}),t.forEach(i=>i.measureInitialState()),e.forEach(i=>{i.render();const r=n.get(i);r&&r.forEach(([s,o])=>{var a;(a=i.getValue(s))==null||a.set(o)})}),t.forEach(i=>i.measureEndState()),t.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}_d=!1,Md=!1,Wi.forEach(t=>t.complete(Nd)),Wi.clear()}function Wy(){Wi.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(_d=!0)})}function jE(){Nd=!0,Wy(),zy(),Nd=!1}class af{constructor(e,n,i,r,s,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=i,this.motionValue=r,this.element=s,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(Wi.add(this),Md||(Md=!0,We.read(Wy),We.resolveKeyframes(zy))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:i,motionValue:r}=this;if(e[0]===null){const s=r==null?void 0:r.get(),o=e[e.length-1];if(s!==void 0)e[0]=s;else if(i&&n){const a=i.readValue(n,o);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=o),r&&s===void 0&&r.set(e[0])}RE(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Wi.delete(this)}cancel(){this.state==="scheduled"&&(Wi.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const LE=t=>t.startsWith("--");function VE(t,e,n){LE(e)?t.style.setProperty(e,n):t.style[e]=n}const FE=qu(()=>window.ScrollTimeline!==void 0),UE={};function BE(t,e){const n=qu(t);return()=>UE[e]??n()}const qy=BE(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Ms=([t,e,n,i])=>`cubic-bezier(${t}, ${e}, ${n}, ${i})`,Om={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Ms([0,.65,.55,1]),circOut:Ms([.55,0,1,.45]),backIn:Ms([.31,.01,.66,-.59]),backOut:Ms([.33,1.53,.69,.99])};function Ky(t,e){if(t)return typeof t=="function"?qy()?By(t,e):"ease-out":My(t)?Ms(t):Array.isArray(t)?t.map(n=>Ky(n,e)||Om.easeOut):Om[t]}function $E(t,e,n,{delay:i=0,duration:r=300,repeat:s=0,repeatType:o="loop",ease:a="easeOut",times:c}={},l=void 0){const d={[e]:n};c&&(d.offset=c);const u=Ky(a,r);Array.isArray(u)&&(d.easing=u);const f={delay:i,duration:r,easing:Array.isArray(u)?"linear":u,fill:"both",iterations:s+1,direction:o==="reverse"?"alternate":"normal"};return l&&(f.pseudoElement=l),t.animate(d,f)}function Gy(t){return typeof t=="function"&&"applyToOptions"in t}function HE({type:t,...e}){return Gy(t)&&qy()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class zE extends sf{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:i,keyframes:r,pseudoElement:s,allowFlatten:o=!1,finalKeyframe:a,onComplete:c}=e;this.isPseudoElement=!!s,this.allowFlatten=o,this.options=e,Yn(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const l=HE(e);this.animation=$E(n,i,r,l,s),l.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!s){const d=rf(r,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(d):VE(n,i,d),this.animation.cancel()}c==null||c(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var e,n;(n=(e=this.animation).finish)==null||n.call(e)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var e,n;this.isPseudoElement||(n=(e=this.animation).commitStyles)==null||n.call(e)}get duration(){var n,i;const e=((i=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:i.call(n).duration)||0;return En(Number(e))}get time(){return En(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=un(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){var i;return this.allowFlatten&&((i=this.animation.effect)==null||i.updateTiming({easing:"linear"})),this.animation.onfinish=null,e&&FE()?(this.animation.timeline=e,Xt):n(this)}}const Zy={anticipate:Py,backInOut:Ey,circInOut:Ay};function WE(t){return t in Zy}function qE(t){typeof t.ease=="string"&&WE(t.ease)&&(t.ease=Zy[t.ease])}const Dm=10;class KE extends zE{constructor(e){qE(e),Hy(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:i,onComplete:r,element:s,...o}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new of({...o,autoplay:!1}),c=un(this.finishedTime??this.time);n.setWithVelocity(a.sample(c-Dm).value,a.sample(c).value,Dm),a.stop()}}const jm=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(vi.test(t)||t==="0")&&!t.startsWith("url("));function GE(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function ZE(t,e,n,i){const r=t[0];if(r===null)return!1;if(e==="display"||e==="visibility")return!0;const s=t[t.length-1],o=jm(r,e),a=jm(s,e);return is(o===a,`You are trying to animate ${e} from "${r}" to "${s}". "${o?s:r}" is not an animatable value.`,"value-not-animatable"),!o||!a?!1:GE(t)||(n==="spring"||Gy(n))&&i}function Od(t){t.duration=0,t.type}const YE=new Set(["opacity","clipPath","filter","transform"]),JE=qu(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function XE(t){var d;const{motionValue:e,name:n,repeatDelay:i,repeatType:r,damping:s,type:o}=t;if(!(((d=e==null?void 0:e.owner)==null?void 0:d.current)instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:l}=e.owner.getProps();return JE()&&n&&YE.has(n)&&(n!=="transform"||!l)&&!c&&!i&&r!=="mirror"&&s!==0&&o!=="inertia"}const QE=40;class eP extends sf{constructor({autoplay:e=!0,delay:n=0,type:i="keyframes",repeat:r=0,repeatDelay:s=0,repeatType:o="loop",keyframes:a,name:c,motionValue:l,element:d,...u}){var v;super(),this.stop=()=>{var h,y;this._animation&&(this._animation.stop(),(h=this.stopTimeline)==null||h.call(this)),(y=this.keyframeResolver)==null||y.cancel()},this.createdAt=Dt.now();const f={autoplay:e,delay:n,type:i,repeat:r,repeatDelay:s,repeatType:o,name:c,motionValue:l,element:d,...u},p=(d==null?void 0:d.KeyframeResolver)||af;this.keyframeResolver=new p(a,(h,y,b)=>this.onKeyframesResolved(h,y,f,!b),c,l,d),(v=this.keyframeResolver)==null||v.scheduleResolve()}onKeyframesResolved(e,n,i,r){this.keyframeResolver=void 0;const{name:s,type:o,velocity:a,delay:c,isHandoff:l,onUpdate:d}=i;this.resolvedAt=Dt.now(),ZE(e,s,o,a)||((Jn.instantAnimations||!c)&&(d==null||d(rf(e,i,n))),e[0]=e[e.length-1],Od(i),i.repeat=0);const f={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>QE?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...i,keyframes:e},p=!l&&XE(f)?new KE({...f,element:f.motionValue.owner.current}):new of(f);p.finished.then(()=>this.notifyFinished()).catch(Xt),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){var e;return this._animation||((e=this.keyframeResolver)==null||e.resume(),jE()),this._animation}get duration(){return this.animation.duration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var e;this._animation&&this.animation.cancel(),(e=this.keyframeResolver)==null||e.cancel()}}const tP=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function nP(t){const e=tP.exec(t);if(!e)return[,];const[,n,i,r]=e;return[`--${n??i}`,r]}const iP=4;function Yy(t,e,n=1){Yn(n<=iP,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[i,r]=nP(t);if(!i)return;const s=window.getComputedStyle(e).getPropertyValue(i);if(s){const o=s.trim();return yy(o)?parseFloat(o):o}return Xu(r)?Yy(r,e,n+1):r}function cf(t,e){return(t==null?void 0:t[e])??(t==null?void 0:t.default)??t}const Jy=new Set(["width","height","top","left","right","bottom",...ss]),rP={test:t=>t==="auto",parse:t=>t},Xy=t=>e=>e.test(t),Qy=[rs,he,Pn,oi,G2,K2,rP],Lm=t=>Qy.find(Xy(t));function sP(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||xy(t):!0}const oP=new Set(["brightness","contrast","saturate","opacity"]);function aP(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[i]=n.match(Qu)||[];if(!i)return t;const r=n.replace(i,"");let s=oP.has(e)?1:0;return i!==n&&(s*=100),e+"("+s+r+")"}const cP=/\b([a-z-]*)\(.*?\)/gu,Dd={...vi,getAnimatableNone:t=>{const e=t.match(cP);return e?e.map(aP).join(" "):t}},Vm={...rs,transform:Math.round},lP={rotate:oi,rotateX:oi,rotateY:oi,rotateZ:oi,scale:To,scaleX:To,scaleY:To,scaleZ:To,skew:oi,skewX:oi,skewY:oi,distance:he,translateX:he,translateY:he,translateZ:he,x:he,y:he,z:he,perspective:he,transformPerspective:he,opacity:qs,originX:Tm,originY:Tm,originZ:he},lf={borderWidth:he,borderTopWidth:he,borderRightWidth:he,borderBottomWidth:he,borderLeftWidth:he,borderRadius:he,radius:he,borderTopLeftRadius:he,borderTopRightRadius:he,borderBottomRightRadius:he,borderBottomLeftRadius:he,width:he,maxWidth:he,height:he,maxHeight:he,top:he,right:he,bottom:he,left:he,padding:he,paddingTop:he,paddingRight:he,paddingBottom:he,paddingLeft:he,margin:he,marginTop:he,marginRight:he,marginBottom:he,marginLeft:he,backgroundPositionX:he,backgroundPositionY:he,...lP,zIndex:Vm,fillOpacity:qs,strokeOpacity:qs,numOctaves:Vm},dP={...lf,color:ct,backgroundColor:ct,outlineColor:ct,fill:ct,stroke:ct,borderColor:ct,borderTopColor:ct,borderRightColor:ct,borderBottomColor:ct,borderLeftColor:ct,filter:Dd,WebkitFilter:Dd},eb=t=>dP[t];function tb(t,e){let n=eb(t);return n!==Dd&&(n=vi),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const uP=new Set(["auto","none","0"]);function fP(t,e,n){let i=0,r;for(;i<t.length&&!r;){const s=t[i];typeof s=="string"&&!uP.has(s)&&Ks(s).values.length&&(r=t[i]),i++}if(r&&n)for(const s of e)t[s]=tb(n,r)}class hP extends af{constructor(e,n,i,r,s){super(e,n,i,r,s,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:i}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<e.length;c++){let l=e[c];if(typeof l=="string"&&(l=l.trim(),Xu(l))){const d=Yy(l,n.current);d!==void 0&&(e[c]=d),c===e.length-1&&(this.finalKeyframe=l)}}if(this.resolveNoneKeyframes(),!Jy.has(i)||e.length!==2)return;const[r,s]=e,o=Lm(r),a=Lm(s);if(o!==a)if(Nm(o)&&Nm(a))for(let c=0;c<e.length;c++){const l=e[c];typeof l=="string"&&(e[c]=parseFloat(l))}else zi[i]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,i=[];for(let r=0;r<e.length;r++)(e[r]===null||sP(e[r]))&&i.push(r);i.length&&fP(e,i,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:i}=this;if(!e||!e.current)return;i==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=zi[i](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const r=n[n.length-1];r!==void 0&&e.getValue(i,r).jump(r,!1)}measureEndState(){var a;const{element:e,name:n,unresolvedKeyframes:i}=this;if(!e||!e.current)return;const r=e.getValue(n);r&&r.jump(this.measuredOrigin,!1);const s=i.length-1,o=i[s];i[s]=zi[n](e.measureViewportBox(),window.getComputedStyle(e.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),(a=this.removedTransforms)!=null&&a.length&&this.removedTransforms.forEach(([c,l])=>{e.getValue(c).set(l)}),this.resolveNoneKeyframes()}}function mP(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let i=document;const r=(n==null?void 0:n[t])??i.querySelectorAll(t);return r?Array.from(r):[]}return Array.from(t)}const nb=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function ib(t){return by(t)&&"offsetHeight"in t}const Fm=30,pP=t=>!isNaN(parseFloat(t));class gP{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=i=>{var s;const r=Dt.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(i),this.current!==this.prev&&((s=this.events.change)==null||s.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=Dt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=pP(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&Gu(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Ku);const i=this.events[e].add(n);return e==="change"?()=>{i(),We.read(()=>{this.events.change.getSize()||this.stop()})}:i}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,i){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-i}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var e;(e=this.events.change)==null||e.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=Dt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Fm)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Fm);return Sy(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var e,n;(e=this.dependents)==null||e.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Kr(t,e){return new gP(t,e)}const{schedule:df}=_y(queueMicrotask,!1),sn={x:!1,y:!1};function rb(){return sn.x||sn.y}function vP(t){return t==="x"||t==="y"?sn[t]?null:(sn[t]=!0,()=>{sn[t]=!1}):sn.x||sn.y?null:(sn.x=sn.y=!0,()=>{sn.x=sn.y=!1})}function sb(t,e){const n=mP(t),i=new AbortController,r={passive:!0,...e,signal:i.signal};return[n,r,()=>i.abort()]}function Um(t){return!(t.pointerType==="touch"||rb())}function yP(t,e,n={}){const[i,r,s]=sb(t,n),o=a=>{if(!Um(a))return;const{target:c}=a,l=e(c,a);if(typeof l!="function"||!c)return;const d=u=>{Um(u)&&(l(u),c.removeEventListener("pointerleave",d))};c.addEventListener("pointerleave",d,r)};return i.forEach(a=>{a.addEventListener("pointerenter",o,r)}),s}const ob=(t,e)=>e?t===e?!0:ob(t,e.parentElement):!1,uf=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,bP=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function xP(t){return bP.has(t.tagName)||t.tabIndex!==-1}const aa=new WeakSet;function Bm(t){return e=>{e.key==="Enter"&&t(e)}}function nl(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const SP=(t,e)=>{const n=t.currentTarget;if(!n)return;const i=Bm(()=>{if(aa.has(n))return;nl(n,"down");const r=Bm(()=>{nl(n,"up")}),s=()=>nl(n,"cancel");n.addEventListener("keyup",r,e),n.addEventListener("blur",s,e)});n.addEventListener("keydown",i,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),e)};function $m(t){return uf(t)&&!rb()}function wP(t,e,n={}){const[i,r,s]=sb(t,n),o=a=>{const c=a.currentTarget;if(!$m(a))return;aa.add(c);const l=e(c,a),d=(p,v)=>{window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",f),aa.has(c)&&aa.delete(c),$m(p)&&typeof l=="function"&&l(p,{success:v})},u=p=>{d(p,c===window||c===document||n.useGlobalTarget||ob(c,p.target))},f=p=>{d(p,!1)};window.addEventListener("pointerup",u,r),window.addEventListener("pointercancel",f,r)};return i.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,r),ib(a)&&(a.addEventListener("focus",l=>SP(l,r)),!xP(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),s}function ab(t){return by(t)&&"ownerSVGElement"in t}function CP(t){return ab(t)&&t.tagName==="svg"}const Tt=t=>!!(t&&t.getVelocity),kP=[...Qy,ct,vi],TP=t=>kP.find(Xy(t)),ff=R.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});class EP extends g.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const i=n.offsetParent,r=ib(i)&&i.offsetWidth||0,s=this.props.sizeRef.current;s.height=n.offsetHeight||0,s.width=n.offsetWidth||0,s.top=n.offsetTop,s.left=n.offsetLeft,s.right=r-s.width-s.left}return null}componentDidUpdate(){}render(){return this.props.children}}function PP({children:t,isPresent:e,anchorX:n,root:i}){const r=R.useId(),s=R.useRef(null),o=R.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=R.useContext(ff);return R.useInsertionEffect(()=>{const{width:c,height:l,top:d,left:u,right:f}=o.current;if(e||!s.current||!c||!l)return;const p=n==="left"?`left: ${u}`:`right: ${f}`;s.current.dataset.motionPopId=r;const v=document.createElement("style");a&&(v.nonce=a);const h=i??document.head;return h.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
68
|
-
[data-motion-pop-id="${r}"] {
|
|
1
|
+
"use strict";var rl=Object.defineProperty;var al=(e,t,n)=>t in e?rl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var me=(e,t,n)=>al(e,typeof t!="symbol"?t+"":t,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("react"),a=require("react/jsx-runtime"),I=require("livekit-client"),ue=require("@livekit/components-react"),Bi=require("sonner"),ll=require("@phosphor-icons/react"),un=require("class-variance-authority"),cl=require("clsx"),dl=require("@radix-ui/react-toggle"),ul=require("@radix-ui/react-select"),pe=require("lucide-react"),Be=require("@mui/icons-material"),hl=require("react-dom/client");function ps(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const h=ps(y),ml=ps(dl),Ee=ps(ul),gs=y.createContext({});function xs(e){const t=y.useRef(null);return t.current===null&&(t.current=e()),t.current}const ys=typeof window<"u",$i=ys?y.useLayoutEffect:y.useEffect,hn=y.createContext(null);function bs(e,t){e.indexOf(t)===-1&&e.push(t)}function vs(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const $e=(e,t,n)=>n>t?t:n<e?e:n;function Hn(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let gt=()=>{},Oe=()=>{};process.env.NODE_ENV!=="production"&&(gt=(e,t,n)=>{!e&&typeof console<"u"&&console.warn(Hn(t,n))},Oe=(e,t,n)=>{if(!e)throw new Error(Hn(t,n))});const _e={},Oi=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function _i(e){return typeof e=="object"&&e!==null}const Hi=e=>/^0[^.\s]+$/u.test(e);function ws(e){let t;return()=>(t===void 0&&(t=e()),t)}const Ae=e=>e,fl=(e,t)=>n=>t(e(n)),Lt=(...e)=>e.reduce(fl),Nt=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class Ss{constructor(){this.subscriptions=[]}add(t){return bs(this.subscriptions,t),()=>vs(this.subscriptions,t)}notify(t,n,s){const o=this.subscriptions.length;if(o)if(o===1)this.subscriptions[0](t,n,s);else for(let r=0;r<o;r++){const i=this.subscriptions[r];i&&i(t,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Ve=e=>e*1e3,Pe=e=>e/1e3;function Zi(e,t){return t?e*(1e3/t):0}const ro=new Set;function Cs(e,t,n){e||ro.has(t)||(console.warn(Hn(t,n)),ro.add(t))}const Ui=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,pl=1e-7,gl=12;function xl(e,t,n,s,o){let r,i,l=0;do i=t+(n-t)/2,r=Ui(i,s,o)-e,r>0?n=i:t=i;while(Math.abs(r)>pl&&++l<gl);return i}function Bt(e,t,n,s){if(e===t&&n===s)return Ae;const o=r=>xl(r,0,1,e,n);return r=>r===0||r===1?r:Ui(o(r),t,s)}const zi=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Wi=e=>t=>1-e(1-t),Ki=Bt(.33,1.53,.69,.99),ks=Wi(Ki),Gi=zi(ks),Yi=e=>(e*=2)<1?.5*ks(e):.5*(2-Math.pow(2,-10*(e-1))),js=e=>1-Math.sin(Math.acos(e)),qi=Wi(js),Xi=zi(js),yl=Bt(.42,0,1,1),bl=Bt(0,0,.58,1),Ji=Bt(.42,0,.58,1),vl=e=>Array.isArray(e)&&typeof e[0]!="number",Qi=e=>Array.isArray(e)&&typeof e[0]=="number",ao={linear:Ae,easeIn:yl,easeInOut:Ji,easeOut:bl,circIn:js,circInOut:Xi,circOut:qi,backIn:ks,backInOut:Gi,backOut:Ki,anticipate:Yi},wl=e=>typeof e=="string",lo=e=>{if(Qi(e)){Oe(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,s,o]=e;return Bt(t,n,s,o)}else if(wl(e))return Oe(ao[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),ao[e];return e},zt=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Sl(e,t){let n=new Set,s=new Set,o=!1,r=!1;const i=new WeakSet;let l={delta:0,timestamp:0,isProcessing:!1};function c(u){i.has(u)&&(d.schedule(u),e()),u(l)}const d={schedule:(u,m=!1,f=!1)=>{const g=f&&o?n:s;return m&&i.add(u),g.has(u)||g.add(u),u},cancel:u=>{s.delete(u),i.delete(u)},process:u=>{if(l=u,o){r=!0;return}o=!0,[n,s]=[s,n],n.forEach(c),n.clear(),o=!1,r&&(r=!1,d.process(u))}};return d}const Cl=40;function er(e,t){let n=!1,s=!0;const o={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,i=zt.reduce((S,w)=>(S[w]=Sl(r),S),{}),{setup:l,read:c,resolveKeyframes:d,preUpdate:u,update:m,preRender:f,render:p,postRender:g}=i,x=()=>{const S=_e.useManualTiming?o.timestamp:performance.now();n=!1,_e.useManualTiming||(o.delta=s?1e3/60:Math.max(Math.min(S-o.timestamp,Cl),1)),o.timestamp=S,o.isProcessing=!0,l.process(o),c.process(o),d.process(o),u.process(o),m.process(o),f.process(o),p.process(o),g.process(o),o.isProcessing=!1,n&&t&&(s=!1,e(x))},v=()=>{n=!0,s=!0,o.isProcessing||e(x)};return{schedule:zt.reduce((S,w)=>{const C=i[w];return S[w]=(A,j=!1,k=!1)=>(n||v(),C.schedule(A,j,k)),S},{}),cancel:S=>{for(let w=0;w<zt.length;w++)i[zt[w]].cancel(S)},state:o,steps:i}}const{schedule:ie,cancel:ze,state:xe,steps:wn}=er(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ae,!0);let Qt;function kl(){Qt=void 0}const Se={now:()=>(Qt===void 0&&Se.set(xe.isProcessing||_e.useManualTiming?xe.timestamp:performance.now()),Qt),set:e=>{Qt=e,queueMicrotask(kl)}},tr=e=>t=>typeof t=="string"&&t.startsWith(e),Es=tr("--"),jl=tr("var(--"),As=e=>jl(e)?El.test(e.split("/*")[0].trim()):!1,El=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,xt={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Pt={...xt,transform:e=>$e(0,1,e)},Wt={...xt,default:1},At=e=>Math.round(e*1e5)/1e5,Ms=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Al(e){return e==null}const Ml=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Ts=(e,t)=>n=>!!(typeof n=="string"&&Ml.test(n)&&n.startsWith(e)||t&&!Al(n)&&Object.prototype.hasOwnProperty.call(n,t)),nr=(e,t,n)=>s=>{if(typeof s!="string")return s;const[o,r,i,l]=s.match(Ms);return{[e]:parseFloat(o),[t]:parseFloat(r),[n]:parseFloat(i),alpha:l!==void 0?parseFloat(l):1}},Tl=e=>$e(0,255,e),Sn={...xt,transform:e=>Math.round(Tl(e))},Xe={test:Ts("rgb","red"),parse:nr("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+Sn.transform(e)+", "+Sn.transform(t)+", "+Sn.transform(n)+", "+At(Pt.transform(s))+")"};function Vl(e){let t="",n="",s="",o="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),s=e.substring(5,7),o=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),s=e.substring(3,4),o=e.substring(4,5),t+=t,n+=n,s+=s,o+=o),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:o?parseInt(o,16)/255:1}}const Zn={test:Ts("#"),parse:Vl,transform:Xe.transform},$t=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Ue=$t("deg"),Re=$t("%"),U=$t("px"),Nl=$t("vh"),Pl=$t("vw"),co={...Re,parse:e=>Re.parse(e)/100,transform:e=>Re.transform(e*100)},it={test:Ts("hsl","hue"),parse:nr("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+Re.transform(At(t))+", "+Re.transform(At(n))+", "+At(Pt.transform(s))+")"},fe={test:e=>Xe.test(e)||Zn.test(e)||it.test(e),parse:e=>Xe.test(e)?Xe.parse(e):it.test(e)?it.parse(e):Zn.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Xe.transform(e):it.transform(e),getAnimatableNone:e=>{const t=fe.parse(e);return t.alpha=0,fe.transform(t)}},Rl=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Il(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(Ms))==null?void 0:t.length)||0)+(((n=e.match(Rl))==null?void 0:n.length)||0)>0}const sr="number",or="color",Dl="var",Fl="var(",uo="${}",Ll=/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 Rt(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},o=[];let r=0;const l=t.replace(Ll,c=>(fe.test(c)?(s.color.push(r),o.push(or),n.push(fe.parse(c))):c.startsWith(Fl)?(s.var.push(r),o.push(Dl),n.push(c)):(s.number.push(r),o.push(sr),n.push(parseFloat(c))),++r,uo)).split(uo);return{values:n,split:l,indexes:s,types:o}}function ir(e){return Rt(e).values}function rr(e){const{split:t,types:n}=Rt(e),s=t.length;return o=>{let r="";for(let i=0;i<s;i++)if(r+=t[i],o[i]!==void 0){const l=n[i];l===sr?r+=At(o[i]):l===or?r+=fe.transform(o[i]):r+=o[i]}return r}}const Bl=e=>typeof e=="number"?0:fe.test(e)?fe.getAnimatableNone(e):e;function $l(e){const t=ir(e);return rr(e)(t.map(Bl))}const We={test:Il,parse:ir,createTransformer:rr,getAnimatableNone:$l};function Cn(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 Ol({hue:e,saturation:t,lightness:n,alpha:s}){e/=360,t/=100,n/=100;let o=0,r=0,i=0;if(!t)o=r=i=n;else{const l=n<.5?n*(1+t):n+t-n*t,c=2*n-l;o=Cn(c,l,e+1/3),r=Cn(c,l,e),i=Cn(c,l,e-1/3)}return{red:Math.round(o*255),green:Math.round(r*255),blue:Math.round(i*255),alpha:s}}function rn(e,t){return n=>n>0?t:e}const le=(e,t,n)=>e+(t-e)*n,kn=(e,t,n)=>{const s=e*e,o=n*(t*t-s)+s;return o<0?0:Math.sqrt(o)},_l=[Zn,Xe,it],Hl=e=>_l.find(t=>t.test(e));function ho(e){const t=Hl(e);if(gt(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!t)return!1;let n=t.parse(e);return t===it&&(n=Ol(n)),n}const mo=(e,t)=>{const n=ho(e),s=ho(t);if(!n||!s)return rn(e,t);const o={...n};return r=>(o.red=kn(n.red,s.red,r),o.green=kn(n.green,s.green,r),o.blue=kn(n.blue,s.blue,r),o.alpha=le(n.alpha,s.alpha,r),Xe.transform(o))},Un=new Set(["none","hidden"]);function Zl(e,t){return Un.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Ul(e,t){return n=>le(e,t,n)}function Vs(e){return typeof e=="number"?Ul:typeof e=="string"?As(e)?rn:fe.test(e)?mo:Kl:Array.isArray(e)?ar:typeof e=="object"?fe.test(e)?mo:zl:rn}function ar(e,t){const n=[...e],s=n.length,o=e.map((r,i)=>Vs(r)(r,t[i]));return r=>{for(let i=0;i<s;i++)n[i]=o[i](r);return n}}function zl(e,t){const n={...e,...t},s={};for(const o in n)e[o]!==void 0&&t[o]!==void 0&&(s[o]=Vs(e[o])(e[o],t[o]));return o=>{for(const r in s)n[r]=s[r](o);return n}}function Wl(e,t){const n=[],s={color:0,var:0,number:0};for(let o=0;o<t.values.length;o++){const r=t.types[o],i=e.indexes[r][s[r]],l=e.values[i]??0;n[o]=l,s[r]++}return n}const Kl=(e,t)=>{const n=We.createTransformer(t),s=Rt(e),o=Rt(t);return s.indexes.var.length===o.indexes.var.length&&s.indexes.color.length===o.indexes.color.length&&s.indexes.number.length>=o.indexes.number.length?Un.has(e)&&!o.values.length||Un.has(t)&&!s.values.length?Zl(e,t):Lt(ar(Wl(s,o),o.values),n):(gt(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),rn(e,t))};function lr(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?le(e,t,n):Vs(e)(e,t)}const Gl=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>ie.update(t,n),stop:()=>ze(t),now:()=>xe.isProcessing?xe.timestamp:Se.now()}},cr=(e,t,n=10)=>{let s="";const o=Math.max(Math.round(t/n),2);for(let r=0;r<o;r++)s+=Math.round(e(r/(o-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},an=2e4;function Ns(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<an;)t+=n,s=e.next(t);return t>=an?1/0:t}function Yl(e,t=100,n){const s=n({...e,keyframes:[0,t]}),o=Math.min(Ns(s),an);return{type:"keyframes",ease:r=>s.next(o*r).value/t,duration:Pe(o)}}const ql=5;function dr(e,t,n){const s=Math.max(t-ql,0);return Zi(n-e(s),t-s)}const ae={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},jn=.001;function Xl({duration:e=ae.duration,bounce:t=ae.bounce,velocity:n=ae.velocity,mass:s=ae.mass}){let o,r;gt(e<=Ve(ae.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let i=1-t;i=$e(ae.minDamping,ae.maxDamping,i),e=$e(ae.minDuration,ae.maxDuration,Pe(e)),i<1?(o=d=>{const u=d*i,m=u*e,f=u-n,p=zn(d,i),g=Math.exp(-m);return jn-f/p*g},r=d=>{const m=d*i*e,f=m*n+n,p=Math.pow(i,2)*Math.pow(d,2)*e,g=Math.exp(-m),x=zn(Math.pow(d,2),i);return(-o(d)+jn>0?-1:1)*((f-p)*g)/x}):(o=d=>{const u=Math.exp(-d*e),m=(d-n)*e+1;return-jn+u*m},r=d=>{const u=Math.exp(-d*e),m=(n-d)*(e*e);return u*m});const l=5/e,c=Ql(o,r,l);if(e=Ve(e),isNaN(c))return{stiffness:ae.stiffness,damping:ae.damping,duration:e};{const d=Math.pow(c,2)*s;return{stiffness:d,damping:i*2*Math.sqrt(s*d),duration:e}}}const Jl=12;function Ql(e,t,n){let s=n;for(let o=1;o<Jl;o++)s=s-e(s)/t(s);return s}function zn(e,t){return e*Math.sqrt(1-t*t)}const ec=["duration","bounce"],tc=["stiffness","damping","mass"];function fo(e,t){return t.some(n=>e[n]!==void 0)}function nc(e){let t={velocity:ae.velocity,stiffness:ae.stiffness,damping:ae.damping,mass:ae.mass,isResolvedFromDuration:!1,...e};if(!fo(e,tc)&&fo(e,ec))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),o=s*s,r=2*$e(.05,1,1-(e.bounce||0))*Math.sqrt(o);t={...t,mass:ae.mass,stiffness:o,damping:r}}else{const n=Xl(e);t={...t,...n,mass:ae.mass},t.isResolvedFromDuration=!0}return t}function ln(e=ae.visualDuration,t=ae.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:s,restDelta:o}=n;const r=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],l={done:!1,value:r},{stiffness:c,damping:d,mass:u,duration:m,velocity:f,isResolvedFromDuration:p}=nc({...n,velocity:-Pe(n.velocity||0)}),g=f||0,x=d/(2*Math.sqrt(c*u)),v=i-r,E=Pe(Math.sqrt(c/u)),b=Math.abs(v)<5;s||(s=b?ae.restSpeed.granular:ae.restSpeed.default),o||(o=b?ae.restDelta.granular:ae.restDelta.default);let S;if(x<1){const C=zn(E,x);S=A=>{const j=Math.exp(-x*E*A);return i-j*((g+x*E*v)/C*Math.sin(C*A)+v*Math.cos(C*A))}}else if(x===1)S=C=>i-Math.exp(-E*C)*(v+(g+E*v)*C);else{const C=E*Math.sqrt(x*x-1);S=A=>{const j=Math.exp(-x*E*A),k=Math.min(C*A,300);return i-j*((g+x*E*v)*Math.sinh(k)+C*v*Math.cosh(k))/C}}const w={calculatedDuration:p&&m||null,next:C=>{const A=S(C);if(p)l.done=C>=m;else{let j=C===0?g:0;x<1&&(j=C===0?Ve(g):dr(S,C,A));const k=Math.abs(j)<=s,D=Math.abs(i-A)<=o;l.done=k&&D}return l.value=l.done?i:A,l},toString:()=>{const C=Math.min(Ns(w),an),A=cr(j=>w.next(C*j).value,C,30);return C+"ms "+A},toTransition:()=>{}};return w}ln.applyToOptions=e=>{const t=Yl(e,100,ln);return e.ease=t.ease,e.duration=Ve(t.duration),e.type="keyframes",e};function Wn({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:o=10,bounceStiffness:r=500,modifyTarget:i,min:l,max:c,restDelta:d=.5,restSpeed:u}){const m=e[0],f={done:!1,value:m},p=k=>l!==void 0&&k<l||c!==void 0&&k>c,g=k=>l===void 0?c:c===void 0||Math.abs(l-k)<Math.abs(c-k)?l:c;let x=n*t;const v=m+x,E=i===void 0?v:i(v);E!==v&&(x=E-m);const b=k=>-x*Math.exp(-k/s),S=k=>E+b(k),w=k=>{const D=b(k),L=S(k);f.done=Math.abs(D)<=d,f.value=f.done?E:L};let C,A;const j=k=>{p(f.value)&&(C=k,A=ln({keyframes:[f.value,g(f.value)],velocity:dr(S,k,f.value),damping:o,stiffness:r,restDelta:d,restSpeed:u}))};return j(0),{calculatedDuration:null,next:k=>{let D=!1;return!A&&C===void 0&&(D=!0,w(k),j(k)),C!==void 0&&k>=C?A.next(k-C):(!D&&w(k),f)}}}function sc(e,t,n){const s=[],o=n||_e.mix||lr,r=e.length-1;for(let i=0;i<r;i++){let l=o(e[i],e[i+1]);if(t){const c=Array.isArray(t)?t[i]||Ae:t;l=Lt(c,l)}s.push(l)}return s}function oc(e,t,{clamp:n=!0,ease:s,mixer:o}={}){const r=e.length;if(Oe(r===t.length,"Both input and output ranges must be the same length","range-length"),r===1)return()=>t[0];if(r===2&&t[0]===t[1])return()=>t[1];const i=e[0]===e[1];e[0]>e[r-1]&&(e=[...e].reverse(),t=[...t].reverse());const l=sc(t,s,o),c=l.length,d=u=>{if(i&&u<e[0])return t[0];let m=0;if(c>1)for(;m<e.length-2&&!(u<e[m+1]);m++);const f=Nt(e[m],e[m+1],u);return l[m](f)};return n?u=>d($e(e[0],e[r-1],u)):d}function ic(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const o=Nt(0,t,s);e.push(le(n,1,o))}}function rc(e){const t=[0];return ic(t,e.length-1),t}function ac(e,t){return e.map(n=>n*t)}function lc(e,t){return e.map(()=>t||Ji).splice(0,e.length-1)}function rt({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const o=vl(s)?s.map(lo):lo(s),r={done:!1,value:t[0]},i=ac(n&&n.length===t.length?n:rc(t),e),l=oc(i,t,{ease:Array.isArray(o)?o:lc(t,o)});return{calculatedDuration:e,next:c=>(r.value=l(c),r.done=c>=e,r)}}const cc=e=>e!==null;function Ps(e,{repeat:t,repeatType:n="loop"},s,o=1){const r=e.filter(cc),l=o<0||t&&n!=="loop"&&t%2===1?0:r.length-1;return!l||s===void 0?r[l]:s}const dc={decay:Wn,inertia:Wn,tween:rt,keyframes:rt,spring:ln};function ur(e){typeof e.type=="string"&&(e.type=dc[e.type])}class Rs{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 uc=e=>e/100;class Is extends Rs{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{var s,o;const{motionValue:n}=this.options;n&&n.updatedAt!==Se.now()&&this.tick(Se.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(o=(s=this.options).onStop)==null||o.call(s))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;ur(t);const{type:n=rt,repeat:s=0,repeatDelay:o=0,repeatType:r,velocity:i=0}=t;let{keyframes:l}=t;const c=n||rt;process.env.NODE_ENV!=="production"&&c!==rt&&Oe(l.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${l}`,"spring-two-frames"),c!==rt&&typeof l[0]!="number"&&(this.mixKeyframes=Lt(uc,lr(l[0],l[1])),l=[0,100]);const d=c({...t,keyframes:l});r==="mirror"&&(this.mirroredGenerator=c({...t,keyframes:[...l].reverse(),velocity:-i})),d.calculatedDuration===null&&(d.calculatedDuration=Ns(d));const{calculatedDuration:u}=d;this.calculatedDuration=u,this.resolvedDuration=u+o,this.totalDuration=this.resolvedDuration*(s+1)-o,this.generator=d}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:s,totalDuration:o,mixKeyframes:r,mirroredGenerator:i,resolvedDuration:l,calculatedDuration:c}=this;if(this.startTime===null)return s.next(0);const{delay:d=0,keyframes:u,repeat:m,repeatType:f,repeatDelay:p,type:g,onUpdate:x,finalKeyframe:v}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-o/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const E=this.currentTime-d*(this.playbackSpeed>=0?1:-1),b=this.playbackSpeed>=0?E<0:E>o;this.currentTime=Math.max(E,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=o);let S=this.currentTime,w=s;if(m){const k=Math.min(this.currentTime,o)/l;let D=Math.floor(k),L=k%1;!L&&k>=1&&(L=1),L===1&&D--,D=Math.min(D,m+1),!!(D%2)&&(f==="reverse"?(L=1-L,p&&(L-=p/l)):f==="mirror"&&(w=i)),S=$e(0,1,L)*l}const C=b?{done:!1,value:u[0]}:w.next(S);r&&(C.value=r(C.value));let{done:A}=C;!b&&c!==null&&(A=this.playbackSpeed>=0?this.currentTime>=o:this.currentTime<=0);const j=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&A);return j&&g!==Wn&&(C.value=Ps(u,this.options,v,this.speed)),x&&x(C.value),j&&this.finish(),C}then(t,n){return this.finished.then(t,n)}get duration(){return Pe(this.calculatedDuration)}get time(){return Pe(this.currentTime)}set time(t){var n;t=Ve(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(Se.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=Pe(this.currentTime))}play(){var o,r;if(this.isStopped)return;const{driver:t=Gl,startTime:n}=this.options;this.driver||(this.driver=t(i=>this.tick(i))),(r=(o=this.options).onPlay)==null||r.call(o);const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),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(Se.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 hc(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Je=e=>e*180/Math.PI,Kn=e=>{const t=Je(Math.atan2(e[1],e[0]));return Gn(t)},mc={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Kn,rotateZ:Kn,skewX:e=>Je(Math.atan(e[1])),skewY:e=>Je(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Gn=e=>(e=e%360,e<0&&(e+=360),e),po=Kn,go=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),xo=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),fc={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:go,scaleY:xo,scale:e=>(go(e)+xo(e))/2,rotateX:e=>Gn(Je(Math.atan2(e[6],e[5]))),rotateY:e=>Gn(Je(Math.atan2(-e[2],e[0]))),rotateZ:po,rotate:po,skewX:e=>Je(Math.atan(e[4])),skewY:e=>Je(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Yn(e){return e.includes("scale")?1:0}function qn(e,t){if(!e||e==="none")return Yn(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,o;if(n)s=fc,o=n;else{const l=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=mc,o=l}if(!o)return Yn(t);const r=s[t],i=o[1].split(",").map(gc);return typeof r=="function"?r(i):i[r]}const pc=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return qn(n,t)};function gc(e){return parseFloat(e.trim())}const yt=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],bt=new Set(yt),yo=e=>e===xt||e===U,xc=new Set(["x","y","z"]),yc=yt.filter(e=>!xc.has(e));function bc(e){const t=[];return yc.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const Qe={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})=>qn(t,"x"),y:(e,{transform:t})=>qn(t,"y")};Qe.translateX=Qe.x;Qe.translateY=Qe.y;const et=new Set;let Xn=!1,Jn=!1,Qn=!1;function hr(){if(Jn){const e=Array.from(et).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const o=bc(s);o.length&&(n.set(s,o),s.render())}),e.forEach(s=>s.measureInitialState()),t.forEach(s=>{s.render();const o=n.get(s);o&&o.forEach(([r,i])=>{var l;(l=s.getValue(r))==null||l.set(i)})}),e.forEach(s=>s.measureEndState()),e.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}Jn=!1,Xn=!1,et.forEach(e=>e.complete(Qn)),et.clear()}function mr(){et.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Jn=!0)})}function vc(){Qn=!0,mr(),hr(),Qn=!1}class Ds{constructor(t,n,s,o,r,i=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=s,this.motionValue=o,this.element=r,this.isAsync=i}scheduleResolve(){this.state="scheduled",this.isAsync?(et.add(this),Xn||(Xn=!0,ie.read(mr),ie.resolveKeyframes(hr))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:s,motionValue:o}=this;if(t[0]===null){const r=o==null?void 0:o.get(),i=t[t.length-1];if(r!==void 0)t[0]=r;else if(s&&n){const l=s.readValue(n,i);l!=null&&(t[0]=l)}t[0]===void 0&&(t[0]=i),o&&r===void 0&&o.set(t[0])}hc(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),et.delete(this)}cancel(){this.state==="scheduled"&&(et.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const wc=e=>e.startsWith("--");function Sc(e,t,n){wc(t)?e.style.setProperty(t,n):e.style[t]=n}const Cc=ws(()=>window.ScrollTimeline!==void 0),kc={};function jc(e,t){const n=ws(e);return()=>kc[t]??n()}const fr=jc(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Et=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,bo={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Et([0,.65,.55,1]),circOut:Et([.55,0,1,.45]),backIn:Et([.31,.01,.66,-.59]),backOut:Et([.33,1.53,.69,.99])};function pr(e,t){if(e)return typeof e=="function"?fr()?cr(e,t):"ease-out":Qi(e)?Et(e):Array.isArray(e)?e.map(n=>pr(n,t)||bo.easeOut):bo[e]}function Ec(e,t,n,{delay:s=0,duration:o=300,repeat:r=0,repeatType:i="loop",ease:l="easeOut",times:c}={},d=void 0){const u={[t]:n};c&&(u.offset=c);const m=pr(l,o);Array.isArray(m)&&(u.easing=m);const f={delay:s,duration:o,easing:Array.isArray(m)?"linear":m,fill:"both",iterations:r+1,direction:i==="reverse"?"alternate":"normal"};return d&&(f.pseudoElement=d),e.animate(u,f)}function gr(e){return typeof e=="function"&&"applyToOptions"in e}function Ac({type:e,...t}){return gr(e)&&fr()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class Mc extends Rs{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:n,name:s,keyframes:o,pseudoElement:r,allowFlatten:i=!1,finalKeyframe:l,onComplete:c}=t;this.isPseudoElement=!!r,this.allowFlatten=i,this.options=t,Oe(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const d=Ac(t);this.animation=Ec(n,s,o,d,r),d.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const u=Ps(o,this.options,l,this.speed);this.updateMotionValue?this.updateMotionValue(u):Sc(n,s,u),this.animation.cancel()}c==null||c(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var 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,s;const t=((s=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:s.call(n).duration)||0;return Pe(Number(t))}get time(){return Pe(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=Ve(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 s;return this.allowFlatten&&((s=this.animation.effect)==null||s.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&Cc()?(this.animation.timeline=t,Ae):n(this)}}const xr={anticipate:Yi,backInOut:Gi,circInOut:Xi};function Tc(e){return e in xr}function Vc(e){typeof e.ease=="string"&&Tc(e.ease)&&(e.ease=xr[e.ease])}const vo=10;class Nc extends Mc{constructor(t){Vc(t),ur(t),super(t),t.startTime&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:s,onComplete:o,element:r,...i}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const l=new Is({...i,autoplay:!1}),c=Ve(this.finishedTime??this.time);n.setWithVelocity(l.sample(c-vo).value,l.sample(c).value,vo),l.stop()}}const wo=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(We.test(e)||e==="0")&&!e.startsWith("url("));function Pc(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 Rc(e,t,n,s){const o=e[0];if(o===null)return!1;if(t==="display"||t==="visibility")return!0;const r=e[e.length-1],i=wo(o,t),l=wo(r,t);return gt(i===l,`You are trying to animate ${t} from "${o}" to "${r}". "${i?r:o}" is not an animatable value.`,"value-not-animatable"),!i||!l?!1:Pc(e)||(n==="spring"||gr(n))&&s}function es(e){e.duration=0,e.type}const Ic=new Set(["opacity","clipPath","filter","transform"]),Dc=ws(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Fc(e){var u;const{motionValue:t,name:n,repeatDelay:s,repeatType:o,damping:r,type:i}=e;if(!(((u=t==null?void 0:t.owner)==null?void 0:u.current)instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:d}=t.owner.getProps();return Dc()&&n&&Ic.has(n)&&(n!=="transform"||!d)&&!c&&!s&&o!=="mirror"&&r!==0&&i!=="inertia"}const Lc=40;class Bc extends Rs{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:o=0,repeatDelay:r=0,repeatType:i="loop",keyframes:l,name:c,motionValue:d,element:u,...m}){var g;super(),this.stop=()=>{var x,v;this._animation&&(this._animation.stop(),(x=this.stopTimeline)==null||x.call(this)),(v=this.keyframeResolver)==null||v.cancel()},this.createdAt=Se.now();const f={autoplay:t,delay:n,type:s,repeat:o,repeatDelay:r,repeatType:i,name:c,motionValue:d,element:u,...m},p=(u==null?void 0:u.KeyframeResolver)||Ds;this.keyframeResolver=new p(l,(x,v,E)=>this.onKeyframesResolved(x,v,f,!E),c,d,u),(g=this.keyframeResolver)==null||g.scheduleResolve()}onKeyframesResolved(t,n,s,o){this.keyframeResolver=void 0;const{name:r,type:i,velocity:l,delay:c,isHandoff:d,onUpdate:u}=s;this.resolvedAt=Se.now(),Rc(t,r,i,l)||((_e.instantAnimations||!c)&&(u==null||u(Ps(t,s,n))),t[0]=t[t.length-1],es(s),s.repeat=0);const f={startTime:o?this.resolvedAt?this.resolvedAt-this.createdAt>Lc?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},p=!d&&Fc(f)?new Nc({...f,element:f.motionValue.owner.current}):new Is(f);p.finished.then(()=>this.notifyFinished()).catch(Ae),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}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(),vc()),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 $c=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Oc(e){const t=$c.exec(e);if(!t)return[,];const[,n,s,o]=t;return[`--${n??s}`,o]}const _c=4;function yr(e,t,n=1){Oe(n<=_c,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,o]=Oc(e);if(!s)return;const r=window.getComputedStyle(t).getPropertyValue(s);if(r){const i=r.trim();return Oi(i)?parseFloat(i):i}return As(o)?yr(o,t,n+1):o}function Fs(e,t){return(e==null?void 0:e[t])??(e==null?void 0:e.default)??e}const br=new Set(["width","height","top","left","right","bottom",...yt]),Hc={test:e=>e==="auto",parse:e=>e},vr=e=>t=>t.test(e),wr=[xt,U,Re,Ue,Pl,Nl,Hc],So=e=>wr.find(vr(e));function Zc(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Hi(e):!0}const Uc=new Set(["brightness","contrast","saturate","opacity"]);function zc(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(Ms)||[];if(!s)return e;const o=n.replace(s,"");let r=Uc.has(t)?1:0;return s!==n&&(r*=100),t+"("+r+o+")"}const Wc=/\b([a-z-]*)\(.*?\)/gu,ts={...We,getAnimatableNone:e=>{const t=e.match(Wc);return t?t.map(zc).join(" "):e}},Co={...xt,transform:Math.round},Kc={rotate:Ue,rotateX:Ue,rotateY:Ue,rotateZ:Ue,scale:Wt,scaleX:Wt,scaleY:Wt,scaleZ:Wt,skew:Ue,skewX:Ue,skewY:Ue,distance:U,translateX:U,translateY:U,translateZ:U,x:U,y:U,z:U,perspective:U,transformPerspective:U,opacity:Pt,originX:co,originY:co,originZ:U},Ls={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,...Kc,zIndex:Co,fillOpacity:Pt,strokeOpacity:Pt,numOctaves:Co},Gc={...Ls,color:fe,backgroundColor:fe,outlineColor:fe,fill:fe,stroke:fe,borderColor:fe,borderTopColor:fe,borderRightColor:fe,borderBottomColor:fe,borderLeftColor:fe,filter:ts,WebkitFilter:ts},Sr=e=>Gc[e];function Cr(e,t){let n=Sr(e);return n!==ts&&(n=We),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Yc=new Set(["auto","none","0"]);function qc(e,t,n){let s=0,o;for(;s<e.length&&!o;){const r=e[s];typeof r=="string"&&!Yc.has(r)&&Rt(r).values.length&&(o=e[s]),s++}if(o&&n)for(const r of t)e[r]=Cr(n,o)}class Xc extends Ds{constructor(t,n,s,o,r){super(t,n,s,o,r,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<t.length;c++){let d=t[c];if(typeof d=="string"&&(d=d.trim(),As(d))){const u=yr(d,n.current);u!==void 0&&(t[c]=u),c===t.length-1&&(this.finalKeyframe=d)}}if(this.resolveNoneKeyframes(),!br.has(s)||t.length!==2)return;const[o,r]=t,i=So(o),l=So(r);if(i!==l)if(yo(i)&&yo(l))for(let c=0;c<t.length;c++){const d=t[c];typeof d=="string"&&(t[c]=parseFloat(d))}else Qe[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let o=0;o<t.length;o++)(t[o]===null||Zc(t[o]))&&s.push(o);s.length&&qc(t,s,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:s}=this;if(!t||!t.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Qe[s](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const o=n[n.length-1];o!==void 0&&t.getValue(s,o).jump(o,!1)}measureEndState(){var l;const{element:t,name:n,unresolvedKeyframes:s}=this;if(!t||!t.current)return;const o=t.getValue(n);o&&o.jump(this.measuredOrigin,!1);const r=s.length-1,i=s[r];s[r]=Qe[n](t.measureViewportBox(),window.getComputedStyle(t.current)),i!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=i),(l=this.removedTransforms)!=null&&l.length&&this.removedTransforms.forEach(([c,d])=>{t.getValue(c).set(d)}),this.resolveNoneKeyframes()}}function Jc(e,t,n){if(e instanceof EventTarget)return[e];if(typeof e=="string"){let s=document;const o=(n==null?void 0:n[e])??s.querySelectorAll(e);return o?Array.from(o):[]}return Array.from(e)}const kr=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function jr(e){return _i(e)&&"offsetHeight"in e}const ko=30,Qc=e=>!isNaN(parseFloat(e));class ed{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{var r;const o=Se.now();if(this.updatedAt!==o&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&((r=this.events.change)==null||r.notify(this.current),this.dependents))for(const i of this.dependents)i.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Se.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Qc(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&Cs(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new Ss);const s=this.events[t].add(n);return t==="change"?()=>{s(),ie.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}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=Se.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>ko)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,ko);return Zi(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 mt(e,t){return new ed(e,t)}const{schedule:Bs}=er(queueMicrotask,!1),Te={x:!1,y:!1};function Er(){return Te.x||Te.y}function td(e){return e==="x"||e==="y"?Te[e]?null:(Te[e]=!0,()=>{Te[e]=!1}):Te.x||Te.y?null:(Te.x=Te.y=!0,()=>{Te.x=Te.y=!1})}function Ar(e,t){const n=Jc(e),s=new AbortController,o={passive:!0,...t,signal:s.signal};return[n,o,()=>s.abort()]}function jo(e){return!(e.pointerType==="touch"||Er())}function nd(e,t,n={}){const[s,o,r]=Ar(e,n),i=l=>{if(!jo(l))return;const{target:c}=l,d=t(c,l);if(typeof d!="function"||!c)return;const u=m=>{jo(m)&&(d(m),c.removeEventListener("pointerleave",u))};c.addEventListener("pointerleave",u,o)};return s.forEach(l=>{l.addEventListener("pointerenter",i,o)}),r}const Mr=(e,t)=>t?e===t?!0:Mr(e,t.parentElement):!1,$s=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,sd=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function od(e){return sd.has(e.tagName)||e.tabIndex!==-1}const en=new WeakSet;function Eo(e){return t=>{t.key==="Enter"&&e(t)}}function En(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const id=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=Eo(()=>{if(en.has(n))return;En(n,"down");const o=Eo(()=>{En(n,"up")}),r=()=>En(n,"cancel");n.addEventListener("keyup",o,t),n.addEventListener("blur",r,t)});n.addEventListener("keydown",s,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),t)};function Ao(e){return $s(e)&&!Er()}function rd(e,t,n={}){const[s,o,r]=Ar(e,n),i=l=>{const c=l.currentTarget;if(!Ao(l))return;en.add(c);const d=t(c,l),u=(p,g)=>{window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",f),en.has(c)&&en.delete(c),Ao(p)&&typeof d=="function"&&d(p,{success:g})},m=p=>{u(p,c===window||c===document||n.useGlobalTarget||Mr(c,p.target))},f=p=>{u(p,!1)};window.addEventListener("pointerup",m,o),window.addEventListener("pointercancel",f,o)};return s.forEach(l=>{(n.useGlobalTarget?window:l).addEventListener("pointerdown",i,o),jr(l)&&(l.addEventListener("focus",d=>id(d,o)),!od(l)&&!l.hasAttribute("tabindex")&&(l.tabIndex=0))}),r}function Tr(e){return _i(e)&&"ownerSVGElement"in e}function ad(e){return Tr(e)&&e.tagName==="svg"}const be=e=>!!(e&&e.getVelocity),ld=[...wr,fe,We],cd=e=>ld.find(vr(e)),Os=y.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class dd extends h.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=n.offsetParent,o=jr(s)&&s.offsetWidth||0,r=this.props.sizeRef.current;r.height=n.offsetHeight||0,r.width=n.offsetWidth||0,r.top=n.offsetTop,r.left=n.offsetLeft,r.right=o-r.width-r.left}return null}componentDidUpdate(){}render(){return this.props.children}}function ud({children:e,isPresent:t,anchorX:n,root:s}){const o=y.useId(),r=y.useRef(null),i=y.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:l}=y.useContext(Os);return y.useInsertionEffect(()=>{const{width:c,height:d,top:u,left:m,right:f}=i.current;if(t||!r.current||!c||!d)return;const p=n==="left"?`left: ${m}`:`right: ${f}`;r.current.dataset.motionPopId=o;const g=document.createElement("style");l&&(g.nonce=l);const x=s??document.head;return x.appendChild(g),g.sheet&&g.sheet.insertRule(`
|
|
2
|
+
[data-motion-pop-id="${o}"] {
|
|
69
3
|
position: absolute !important;
|
|
70
4
|
width: ${c}px !important;
|
|
71
|
-
height: ${
|
|
5
|
+
height: ${d}px !important;
|
|
72
6
|
${p}px !important;
|
|
73
|
-
top: ${
|
|
7
|
+
top: ${u}px !important;
|
|
74
8
|
}
|
|
75
|
-
`),()=>{h.contains(v)&&h.removeChild(v)}},[e]),m.jsx(EP,{isPresent:e,childRef:s,sizeRef:o,children:g.cloneElement(t,{ref:s})})}const RP=({children:t,initial:e,isPresent:n,onExitComplete:i,custom:r,presenceAffectsLayout:s,mode:o,anchorX:a,root:c})=>{const l=$u(AP),d=R.useId();let u=!0,f=R.useMemo(()=>(u=!1,{id:d,initial:e,isPresent:n,custom:r,onExitComplete:p=>{l.set(p,!0);for(const v of l.values())if(!v)return;i&&i()},register:p=>(l.set(p,!1),()=>l.delete(p))}),[n,l,i]);return s&&u&&(f={...f}),R.useMemo(()=>{l.forEach((p,v)=>l.set(v,!1))},[n]),g.useEffect(()=>{!n&&!l.size&&i&&i()},[n]),o==="popLayout"&&(t=m.jsx(PP,{isPresent:n,anchorX:a,root:c,children:t})),m.jsx(ec.Provider,{value:f,children:t})};function AP(){return new Map}function cb(t=!0){const e=R.useContext(ec);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:r}=e,s=R.useId();R.useEffect(()=>{if(t)return r(s)},[t]);const o=R.useCallback(()=>t&&i&&i(s),[s,i,t]);return!n&&i?[!1,o]:[!0]}const Eo=t=>t.key||"";function Hm(t){const e=[];return R.Children.forEach(t,n=>{R.isValidElement(n)&&e.push(n)}),e}const Vr=({children:t,custom:e,initial:n=!0,onExitComplete:i,presenceAffectsLayout:r=!0,mode:s="sync",propagate:o=!1,anchorX:a="left",root:c})=>{const[l,d]=cb(o),u=R.useMemo(()=>Hm(t),[t]),f=o&&!l?[]:u.map(Eo),p=R.useRef(!0),v=R.useRef(u),h=$u(()=>new Map),[y,b]=R.useState(u),[w,C]=R.useState(u);vy(()=>{p.current=!1,v.current=u;for(let T=0;T<w.length;T++){const E=Eo(w[T]);f.includes(E)?h.delete(E):h.get(E)!==!0&&h.set(E,!1)}},[w,f.length,f.join("-")]);const S=[];if(u!==y){let T=[...u];for(let E=0;E<w.length;E++){const P=w[E],_=Eo(P);f.includes(_)||(T.splice(E,0,P),S.push(P))}return s==="wait"&&S.length&&(T=S),C(Hm(T)),b(u),null}process.env.NODE_ENV!=="production"&&s==="wait"&&w.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:x}=R.useContext(Bu);return m.jsx(m.Fragment,{children:w.map(T=>{const E=Eo(T),P=o&&!l?!1:u===w||f.includes(E),_=()=>{if(h.has(E))h.set(E,!0);else return;let k=!0;h.forEach(I=>{I||(k=!1)}),k&&(x==null||x(),C(v.current),o&&(d==null||d()),i&&i())};return m.jsx(RP,{isPresent:P,initial:!p.current||n?void 0:!1,custom:e,presenceAffectsLayout:r,mode:s,root:c,onExitComplete:P?void 0:_,anchorX:a,children:T},E)})})},lb=R.createContext({strict:!1}),zm={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"]},Gr={};for(const t in zm)Gr[t]={isEnabled:e=>zm[t].some(n=>!!e[n])};function IP(t){for(const e in t)Gr[e]={...Gr[e],...t[e]}}const MP=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 _a(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||MP.has(t)}let db=t=>!_a(t);function _P(t){typeof t=="function"&&(db=e=>e.startsWith("on")?!_a(e):t(e))}try{_P(require("@emotion/is-prop-valid").default)}catch{}function NP(t,e,n){const i={};for(const r in t)r==="values"&&typeof t.values=="object"||(db(r)||n===!0&&_a(r)||!e&&!_a(r)||t.draggable&&r.startsWith("onDrag"))&&(i[r]=t[r]);return i}const tc=R.createContext({});function nc(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Gs(t){return typeof t=="string"||Array.isArray(t)}const hf=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],mf=["initial",...hf];function ic(t){return nc(t.animate)||mf.some(e=>Gs(t[e]))}function ub(t){return!!(ic(t)||t.variants)}function OP(t,e){if(ic(t)){const{initial:n,animate:i}=t;return{initial:n===!1||Gs(n)?n:void 0,animate:Gs(i)?i:void 0}}return t.inherit!==!1?e:{}}function DP(t){const{initial:e,animate:n}=OP(t,R.useContext(tc));return R.useMemo(()=>({initial:e,animate:n}),[Wm(e),Wm(n)])}function Wm(t){return Array.isArray(t)?t.join(" "):t}const Zs={};function jP(t){for(const e in t)Zs[e]=t[e],Ju(e)&&(Zs[e].isCSSVariable=!0)}function fb(t,{layout:e,layoutId:n}){return os.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Zs[t]||t==="opacity")}const LP={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},VP=ss.length;function FP(t,e,n){let i="",r=!0;for(let s=0;s<VP;s++){const o=ss[s],a=t[o];if(a===void 0)continue;let c=!0;if(typeof a=="number"?c=a===(o.startsWith("scale")?1:0):c=parseFloat(a)===0,!c||n){const l=nb(a,lf[o]);if(!c){r=!1;const d=LP[o]||o;i+=`${d}(${l}) `}n&&(e[o]=l)}}return i=i.trim(),n?i=n(e,r?"":i):r&&(i="none"),i}function pf(t,e,n){const{style:i,vars:r,transformOrigin:s}=t;let o=!1,a=!1;for(const c in e){const l=e[c];if(os.has(c)){o=!0;continue}else if(Ju(c)){r[c]=l;continue}else{const d=nb(l,lf[c]);c.startsWith("origin")?(a=!0,s[c]=d):i[c]=d}}if(e.transform||(o||n?i.transform=FP(e,t.transform,n):i.transform&&(i.transform="none")),a){const{originX:c="50%",originY:l="50%",originZ:d=0}=s;i.transformOrigin=`${c} ${l} ${d}`}}const gf=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function hb(t,e,n){for(const i in e)!Tt(e[i])&&!fb(i,n)&&(t[i]=e[i])}function UP({transformTemplate:t},e){return R.useMemo(()=>{const n=gf();return pf(n,e,t),Object.assign({},n.vars,n.style)},[e])}function BP(t,e){const n=t.style||{},i={};return hb(i,n,t),Object.assign(i,UP(t,e)),i}function $P(t,e){const n={},i=BP(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=i,n}const HP={offset:"stroke-dashoffset",array:"stroke-dasharray"},zP={offset:"strokeDashoffset",array:"strokeDasharray"};function WP(t,e,n=1,i=0,r=!0){t.pathLength=1;const s=r?HP:zP;t[s.offset]=he.transform(-i);const o=he.transform(e),a=he.transform(n);t[s.array]=`${o} ${a}`}function mb(t,{attrX:e,attrY:n,attrScale:i,pathLength:r,pathSpacing:s=1,pathOffset:o=0,...a},c,l,d){if(pf(t,a,l),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:u,style:f}=t;u.transform&&(f.transform=u.transform,delete u.transform),(f.transform||u.transformOrigin)&&(f.transformOrigin=u.transformOrigin??"50% 50%",delete u.transformOrigin),f.transform&&(f.transformBox=(d==null?void 0:d.transformBox)??"fill-box",delete u.transformBox),e!==void 0&&(u.x=e),n!==void 0&&(u.y=n),i!==void 0&&(u.scale=i),r!==void 0&&WP(u,r,s,o,!1)}const pb=()=>({...gf(),attrs:{}}),gb=t=>typeof t=="string"&&t.toLowerCase()==="svg";function qP(t,e,n,i){const r=R.useMemo(()=>{const s=pb();return mb(s,e,gb(i),t.transformTemplate,t.style),{...s.attrs,style:{...s.style}}},[e]);if(t.style){const s={};hb(s,t.style,t),r.style={...s,...r.style}}return r}const KP=["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 vf(t){return typeof t!="string"||t.includes("-")?!1:!!(KP.indexOf(t)>-1||/[A-Z]/u.test(t))}function GP(t,e,n,{latestValues:i},r,s=!1){const a=(vf(t)?qP:$P)(e,i,r,t),c=NP(e,typeof t=="string",s),l=t!==R.Fragment?{...c,...a,ref:n}:{},{children:d}=e,u=R.useMemo(()=>Tt(d)?d.get():d,[d]);return R.createElement(t,{...l,children:u})}function qm(t){const e=[{},{}];return t==null||t.values.forEach((n,i)=>{e[0][i]=n.get(),e[1][i]=n.getVelocity()}),e}function yf(t,e,n,i){if(typeof e=="function"){const[r,s]=qm(i);e=e(n!==void 0?n:t.custom,r,s)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[r,s]=qm(i);e=e(n!==void 0?n:t.custom,r,s)}return e}function ca(t){return Tt(t)?t.get():t}function ZP({scrapeMotionValuesFromProps:t,createRenderState:e},n,i,r){return{latestValues:YP(n,i,r,t),renderState:e()}}function YP(t,e,n,i){const r={},s=i(t,{});for(const f in s)r[f]=ca(s[f]);let{initial:o,animate:a}=t;const c=ic(t),l=ub(t);e&&l&&!c&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let d=n?n.initial===!1:!1;d=d||o===!1;const u=d?a:o;if(u&&typeof u!="boolean"&&!nc(u)){const f=Array.isArray(u)?u:[u];for(let p=0;p<f.length;p++){const v=yf(t,f[p]);if(v){const{transitionEnd:h,transition:y,...b}=v;for(const w in b){let C=b[w];if(Array.isArray(C)){const S=d?C.length-1:0;C=C[S]}C!==null&&(r[w]=C)}for(const w in h)r[w]=h[w]}}}return r}const vb=t=>(e,n)=>{const i=R.useContext(tc),r=R.useContext(ec),s=()=>ZP(t,e,i,r);return n?s():$u(s)};function bf(t,e,n){var s;const{style:i}=t,r={};for(const o in i)(Tt(i[o])||e.style&&Tt(e.style[o])||fb(o,t)||((s=n==null?void 0:n.getValue(o))==null?void 0:s.liveStyle)!==void 0)&&(r[o]=i[o]);return r}const JP=vb({scrapeMotionValuesFromProps:bf,createRenderState:gf});function yb(t,e,n){const i=bf(t,e,n);for(const r in t)if(Tt(t[r])||Tt(e[r])){const s=ss.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;i[s]=t[r]}return i}const XP=vb({scrapeMotionValuesFromProps:yb,createRenderState:pb}),QP=Symbol.for("motionComponentSymbol");function Rr(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function eR(t,e,n){return R.useCallback(i=>{i&&t.onMount&&t.onMount(i),e&&(i?e.mount(i):e.unmount()),n&&(typeof n=="function"?n(i):Rr(n)&&(n.current=i))},[e])}const xf=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),tR="framerAppearId",bb="data-"+xf(tR),xb=R.createContext({});function nR(t,e,n,i,r){var h,y;const{visualElement:s}=R.useContext(tc),o=R.useContext(lb),a=R.useContext(ec),c=R.useContext(ff).reducedMotion,l=R.useRef(null);i=i||o.renderer,!l.current&&i&&(l.current=i(t,{visualState:e,parent:s,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:c}));const d=l.current,u=R.useContext(xb);d&&!d.projection&&r&&(d.type==="html"||d.type==="svg")&&iR(l.current,n,r,u);const f=R.useRef(!1);R.useInsertionEffect(()=>{d&&f.current&&d.update(n,a)});const p=n[bb],v=R.useRef(!!p&&!((h=window.MotionHandoffIsComplete)!=null&&h.call(window,p))&&((y=window.MotionHasOptimisedAnimation)==null?void 0:y.call(window,p)));return vy(()=>{d&&(f.current=!0,window.MotionIsMounted=!0,d.updateFeatures(),d.scheduleRenderMicrotask(),v.current&&d.animationState&&d.animationState.animateChanges())}),R.useEffect(()=>{d&&(!v.current&&d.animationState&&d.animationState.animateChanges(),v.current&&(queueMicrotask(()=>{var b;(b=window.MotionHandoffMarkAsComplete)==null||b.call(window,p)}),v.current=!1),d.enteringChildren=void 0)}),d}function iR(t,e,n,i){const{layoutId:r,layout:s,drag:o,dragConstraints:a,layoutScroll:c,layoutRoot:l,layoutCrossfade:d}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:Sb(t.parent)),t.projection.setOptions({layoutId:r,layout:s,alwaysMeasureLayout:!!o||a&&Rr(a),visualElement:t,animationType:typeof s=="string"?s:"both",initialPromotionConfig:i,crossfade:d,layoutScroll:c,layoutRoot:l})}function Sb(t){if(t)return t.options.allowProjection!==!1?t.projection:Sb(t.parent)}function il(t,{forwardMotionProps:e=!1}={},n,i){n&&IP(n);const r=vf(t)?XP:JP;function s(a,c){let l;const d={...R.useContext(ff),...a,layoutId:rR(a)},{isStatic:u}=d,f=DP(a),p=r(a,u);if(!u&&Hu){sR(d,n);const v=oR(d);l=v.MeasureLayout,f.visualElement=nR(t,p,d,i,v.ProjectionNode)}return m.jsxs(tc.Provider,{value:f,children:[l&&f.visualElement?m.jsx(l,{visualElement:f.visualElement,...d}):null,GP(t,a,eR(p,f.visualElement,c),p,u,e)]})}s.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const o=R.forwardRef(s);return o[QP]=t,o}function rR({layoutId:t}){const e=R.useContext(Bu).id;return e&&t!==void 0?e+"-"+t:t}function sR(t,e){const n=R.useContext(lb).strict;if(process.env.NODE_ENV!=="production"&&e&&n){const i="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";t.ignoreStrict?is(!1,i,"lazy-strict-mode"):Yn(!1,i,"lazy-strict-mode")}}function oR(t){const{drag:e,layout:n}=Gr;if(!e&&!n)return{};const i={...e,...n};return{MeasureLayout:e!=null&&e.isEnabled(t)||n!=null&&n.isEnabled(t)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}function aR(t,e){if(typeof Proxy>"u")return il;const n=new Map,i=(s,o)=>il(s,o,t,e),r=(s,o)=>(process.env.NODE_ENV!=="production"&&Gu(!1,"motion() is deprecated. Use motion.create() instead."),i(s,o));return new Proxy(r,{get:(s,o)=>o==="create"?i:(n.has(o)||n.set(o,il(o,void 0,t,e)),n.get(o))})}function wb({top:t,left:e,right:n,bottom:i}){return{x:{min:e,max:n},y:{min:t,max:i}}}function cR({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function lR(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),i=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:i.y,right:i.x}}function rl(t){return t===void 0||t===1}function jd({scale:t,scaleX:e,scaleY:n}){return!rl(t)||!rl(e)||!rl(n)}function Vi(t){return jd(t)||Cb(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Cb(t){return Km(t.x)||Km(t.y)}function Km(t){return t&&t!=="0%"}function Na(t,e,n){const i=t-n,r=e*i;return n+r}function Gm(t,e,n,i,r){return r!==void 0&&(t=Na(t,r,i)),Na(t,n,i)+e}function Ld(t,e=0,n=1,i,r){t.min=Gm(t.min,e,n,i,r),t.max=Gm(t.max,e,n,i,r)}function kb(t,{x:e,y:n}){Ld(t.x,e.translate,e.scale,e.originPoint),Ld(t.y,n.translate,n.scale,n.originPoint)}const Zm=.999999999999,Ym=1.0000000000001;function dR(t,e,n,i=!1){const r=n.length;if(!r)return;e.x=e.y=1;let s,o;for(let a=0;a<r;a++){s=n[a],o=s.projectionDelta;const{visualElement:c}=s.options;c&&c.props.style&&c.props.style.display==="contents"||(i&&s.options.layoutScroll&&s.scroll&&s!==s.root&&Ir(t,{x:-s.scroll.offset.x,y:-s.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,kb(t,o)),i&&Vi(s.latestValues)&&Ir(t,s.latestValues))}e.x<Ym&&e.x>Zm&&(e.x=1),e.y<Ym&&e.y>Zm&&(e.y=1)}function Ar(t,e){t.min=t.min+e,t.max=t.max+e}function Jm(t,e,n,i,r=.5){const s=Ge(t.min,t.max,r);Ld(t,e,n,s,i)}function Ir(t,e){Jm(t.x,e.x,e.scaleX,e.scale,e.originX),Jm(t.y,e.y,e.scaleY,e.scale,e.originY)}function Tb(t,e){return wb(lR(t.getBoundingClientRect(),e))}function uR(t,e,n){const i=Tb(t,n),{scroll:r}=e;return r&&(Ar(i.x,r.offset.x),Ar(i.y,r.offset.y)),i}const Xm=()=>({translate:0,scale:1,origin:0,originPoint:0}),Mr=()=>({x:Xm(),y:Xm()}),Qm=()=>({min:0,max:0}),nt=()=>({x:Qm(),y:Qm()}),Vd={current:null},Eb={current:!1};function fR(){if(Eb.current=!0,!!Hu)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Vd.current=t.matches;t.addEventListener("change",e),e()}else Vd.current=!1}const hR=new WeakMap;function mR(t,e,n){for(const i in e){const r=e[i],s=n[i];if(Tt(r))t.addValue(i,r);else if(Tt(s))t.addValue(i,Kr(r,{owner:t}));else if(s!==r)if(t.hasValue(i)){const o=t.getValue(i);o.liveStyle===!0?o.jump(r):o.hasAnimated||o.set(r)}else{const o=t.getStaticValue(i);t.addValue(i,Kr(o!==void 0?o:r,{owner:t}))}}for(const i in n)e[i]===void 0&&t.removeValue(i);return e}const ep=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class pR{scrapeMotionValuesFromProps(e,n,i){return{}}constructor({parent:e,props:n,presenceContext:i,reducedMotionConfig:r,blockInitialAnimation:s,visualState:o},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=af,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 f=Dt.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,We.render(this.render,!1,!0))};const{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=n,this.presenceContext=i,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.options=a,this.blockInitialAnimation=!!s,this.isControllingVariants=ic(n),this.isVariantNode=ub(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:d,...u}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in u){const p=u[f];c[f]!==void 0&&Tt(p)&&p.set(c[f])}}mount(e){var n;this.current=e,hR.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((i,r)=>this.bindToMotionValue(r,i)),Eb.current||fR(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Vd.current,process.env.NODE_ENV!=="production"&&Gu(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),(n=this.parent)==null||n.addChild(this),this.update(this.props,this.presenceContext)}unmount(){var e;this.projection&&this.projection.unmount(),gi(this.notifyUpdate),gi(this.render),this.valueSubscriptions.forEach(n=>n()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(e=this.parent)==null||e.removeChild(this);for(const n in this.events)this.events[n].clear();for(const n in this.features){const i=this.features[n];i&&(i.unmount(),i.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const i=os.has(e);i&&this.onBindTransform&&this.onBindTransform();const r=n.on("change",o=>{this.latestValues[e]=o,this.props.onUpdate&&We.preRender(this.notifyUpdate),i&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let s;window.MotionCheckAppearSync&&(s=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{r(),s&&s(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Gr){const n=Gr[e];if(!n)continue;const{isEnabled:i,Feature:r}=n;if(!this.features[e]&&r&&i(this.props)&&(this.features[e]=new r(this)),this.features[e]){const s=this.features[e];s.isMounted?s.update():(s.mount(),s.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):nt()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let i=0;i<ep.length;i++){const r=ep[i];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);const s="on"+r,o=e[s];o&&(this.propEventSubscriptions[r]=this.on(r,o))}this.prevMotionValues=mR(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const i=this.values.get(e);n!==i&&(i&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let i=this.values.get(e);return i===void 0&&n!==void 0&&(i=Kr(n===null?void 0:n,{owner:this}),this.addValue(e,i)),i}readValue(e,n){let i=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return i!=null&&(typeof i=="string"&&(yy(i)||xy(i))?i=parseFloat(i):!TP(i)&&vi.test(n)&&(i=tb(e,n)),this.setBaseTarget(e,Tt(i)?i.get():i)),Tt(i)?i.get():i}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){var s;const{initial:n}=this.props;let i;if(typeof n=="string"||typeof n=="object"){const o=yf(this.props,n,(s=this.presenceContext)==null?void 0:s.custom);o&&(i=o[e])}if(n&&i!==void 0)return i;const r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!Tt(r)?r:this.initialValues[e]!==void 0&&i===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new Ku),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){df.render(this.render)}}class Pb extends pR{constructor(){super(...arguments),this.KeyframeResolver=hP}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:i}){delete n[e],delete i[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Tt(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Rb(t,{style:e,vars:n},i,r){const s=t.style;let o;for(o in e)s[o]=e[o];r==null||r.applyProjectionStyles(s,i);for(o in n)s.setProperty(o,n[o])}function gR(t){return window.getComputedStyle(t)}class vR extends Pb{constructor(){super(...arguments),this.type="html",this.renderInstance=Rb}readValueFromInstance(e,n){var i;if(os.has(n))return(i=this.projection)!=null&&i.isProjecting?Ad(n):ME(e,n);{const r=gR(e),s=(Ju(n)?r.getPropertyValue(n):r[n])||0;return typeof s=="string"?s.trim():s}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Tb(e,n)}build(e,n,i){pf(e,n,i.transformTemplate)}scrapeMotionValuesFromProps(e,n,i){return bf(e,n,i)}}const Ab=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 yR(t,e,n,i){Rb(t,e,void 0,i);for(const r in e.attrs)t.setAttribute(Ab.has(r)?r:xf(r),e.attrs[r])}class bR extends Pb{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=nt}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(os.has(n)){const i=eb(n);return i&&i.default||0}return n=Ab.has(n)?n:xf(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,i){return yb(e,n,i)}build(e,n,i){mb(e,n,this.isSVGTag,i.transformTemplate,i.style)}renderInstance(e,n,i,r){yR(e,n,i,r)}mount(e){this.isSVGTag=gb(e.tagName),super.mount(e)}}const xR=(t,e)=>vf(t)?new bR(e):new vR(e,{allowProjection:t!==R.Fragment});function Fr(t,e,n){const i=t.getProps();return yf(i,e,n!==void 0?n:i.custom,t)}const Fd=t=>Array.isArray(t);function SR(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,Kr(n))}function wR(t){return Fd(t)?t[t.length-1]||0:t}function CR(t,e){const n=Fr(t,e);let{transitionEnd:i={},transition:r={},...s}=n||{};s={...s,...i};for(const o in s){const a=wR(s[o]);SR(t,o,a)}}function kR(t){return!!(Tt(t)&&t.add)}function Ud(t,e){const n=t.getValue("willChange");if(kR(n))return n.add(e);if(!n&&Jn.WillChange){const i=new Jn.WillChange("auto");t.addValue("willChange",i),i.add(e)}}function Ib(t){return t.props[bb]}const TR=t=>t!==null;function ER(t,{repeat:e,repeatType:n="loop"},i){const r=t.filter(TR),s=e&&n!=="loop"&&e%2===1?0:r.length-1;return r[s]}const PR={type:"spring",stiffness:500,damping:25,restSpeed:10},RR=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),AR={type:"keyframes",duration:.8},IR={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},MR=(t,{keyframes:e})=>e.length>2?AR:os.has(t)?t.startsWith("scale")?RR(e[1]):PR:IR;function _R({when:t,delay:e,delayChildren:n,staggerChildren:i,staggerDirection:r,repeat:s,repeatType:o,repeatDelay:a,from:c,elapsed:l,...d}){return!!Object.keys(d).length}const Sf=(t,e,n,i={},r,s)=>o=>{const a=cf(i,t)||{},c=a.delay||i.delay||0;let{elapsed:l=0}=i;l=l-un(c);const d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-l,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:s?void 0:r};_R(a)||Object.assign(d,MR(t,d)),d.duration&&(d.duration=un(d.duration)),d.repeatDelay&&(d.repeatDelay=un(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let u=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(Od(d),d.delay===0&&(u=!0)),(Jn.instantAnimations||Jn.skipAnimations)&&(u=!0,Od(d),d.delay=0),d.allowFlatten=!a.type&&!a.ease,u&&!s&&e.get()!==void 0){const f=ER(d.keyframes,a);if(f!==void 0){We.update(()=>{d.onUpdate(f),d.onComplete()});return}}return a.isSync?new of(d):new eP(d)};function NR({protectedKeys:t,needsAnimating:e},n){const i=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,i}function Mb(t,e,{delay:n=0,transitionOverride:i,type:r}={}){let{transition:s=t.getDefaultTransition(),transitionEnd:o,...a}=e;i&&(s=i);const c=[],l=r&&t.animationState&&t.animationState.getState()[r];for(const d in a){const u=t.getValue(d,t.latestValues[d]??null),f=a[d];if(f===void 0||l&&NR(l,d))continue;const p={delay:n,...cf(s||{},d)},v=u.get();if(v!==void 0&&!u.isAnimating&&!Array.isArray(f)&&f===v&&!p.velocity)continue;let h=!1;if(window.MotionHandoffAnimation){const b=Ib(t);if(b){const w=window.MotionHandoffAnimation(b,d,We);w!==null&&(p.startTime=w,h=!0)}}Ud(t,d),u.start(Sf(d,u,f,t.shouldReduceMotion&&Jy.has(d)?{type:!1}:p,t,h));const y=u.animation;y&&c.push(y)}return o&&Promise.all(c).then(()=>{We.update(()=>{o&&CR(t,o)})}),c}function _b(t,e,n,i=0,r=1){const s=Array.from(t).sort((l,d)=>l.sortNodePosition(d)).indexOf(e),o=t.size,a=(o-1)*i;return typeof n=="function"?n(s,o):r===1?s*i:a-s*i}function Bd(t,e,n={}){var c;const i=Fr(t,e,n.type==="exit"?(c=t.presenceContext)==null?void 0:c.custom:void 0);let{transition:r=t.getDefaultTransition()||{}}=i||{};n.transitionOverride&&(r=n.transitionOverride);const s=i?()=>Promise.all(Mb(t,i,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(l=0)=>{const{delayChildren:d=0,staggerChildren:u,staggerDirection:f}=r;return OR(t,e,l,d,u,f,n)}:()=>Promise.resolve(),{when:a}=r;if(a){const[l,d]=a==="beforeChildren"?[s,o]:[o,s];return l().then(()=>d())}else return Promise.all([s(),o(n.delay)])}function OR(t,e,n=0,i=0,r=0,s=1,o){const a=[];for(const c of t.variantChildren)c.notify("AnimationStart",e),a.push(Bd(c,e,{...o,delay:n+(typeof i=="function"?0:i)+_b(t.variantChildren,c,i,r,s)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(a)}function DR(t,e,n={}){t.notify("AnimationStart",e);let i;if(Array.isArray(e)){const r=e.map(s=>Bd(t,s,n));i=Promise.all(r)}else if(typeof e=="string")i=Bd(t,e,n);else{const r=typeof e=="function"?Fr(t,e,n.custom):e;i=Promise.all(Mb(t,r,n))}return i.then(()=>{t.notify("AnimationComplete",e)})}function Nb(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let i=0;i<n;i++)if(e[i]!==t[i])return!1;return!0}const jR=mf.length;function Ob(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Ob(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<jR;n++){const i=mf[n],r=t.props[i];(Gs(r)||r===!1)&&(e[i]=r)}return e}const LR=[...hf].reverse(),VR=hf.length;function FR(t){return e=>Promise.all(e.map(({animation:n,options:i})=>DR(t,n,i)))}function UR(t){let e=FR(t),n=tp(),i=!0;const r=c=>(l,d)=>{var f;const u=Fr(t,d,c==="exit"?(f=t.presenceContext)==null?void 0:f.custom:void 0);if(u){const{transition:p,transitionEnd:v,...h}=u;l={...l,...h,...v}}return l};function s(c){e=c(t)}function o(c){const{props:l}=t,d=Ob(t.parent)||{},u=[],f=new Set;let p={},v=1/0;for(let y=0;y<VR;y++){const b=LR[y],w=n[b],C=l[b]!==void 0?l[b]:d[b],S=Gs(C),x=b===c?w.isActive:null;x===!1&&(v=y);let T=C===d[b]&&C!==l[b]&&S;if(T&&i&&t.manuallyAnimateOnMount&&(T=!1),w.protectedKeys={...p},!w.isActive&&x===null||!C&&!w.prevProp||nc(C)||typeof C=="boolean")continue;const E=BR(w.prevProp,C);let P=E||b===c&&w.isActive&&!T&&S||y>v&&S,_=!1;const k=Array.isArray(C)?C:[C];let I=k.reduce(r(b),{});x===!1&&(I={});const{prevResolvedValues:N={}}=w,K={...N,...I},J=X=>{P=!0,f.has(X)&&(_=!0,f.delete(X)),w.needsAnimating[X]=!0;const O=t.getValue(X);O&&(O.liveStyle=!1)};for(const X in K){const O=I[X],oe=N[X];if(p.hasOwnProperty(X))continue;let L=!1;Fd(O)&&Fd(oe)?L=!Nb(O,oe):L=O!==oe,L?O!=null?J(X):f.add(X):O!==void 0&&f.has(X)?J(X):w.protectedKeys[X]=!0}w.prevProp=C,w.prevResolvedValues=I,w.isActive&&(p={...p,...I}),i&&t.blockInitialAnimation&&(P=!1);const se=T&&E;P&&(!se||_)&&u.push(...k.map(X=>{const O={type:b};if(typeof X=="string"&&i&&!se&&t.manuallyAnimateOnMount&&t.parent){const{parent:oe}=t,L=Fr(oe,X);if(oe.enteringChildren&&L){const{delayChildren:F}=L.transition||{};O.delay=_b(oe.enteringChildren,t,F)}}return{animation:X,options:O}}))}if(f.size){const y={};if(typeof l.initial!="boolean"){const b=Fr(t,Array.isArray(l.initial)?l.initial[0]:l.initial);b&&b.transition&&(y.transition=b.transition)}f.forEach(b=>{const w=t.getBaseTarget(b),C=t.getValue(b);C&&(C.liveStyle=!0),y[b]=w??null}),u.push({animation:y})}let h=!!u.length;return i&&(l.initial===!1||l.initial===l.animate)&&!t.manuallyAnimateOnMount&&(h=!1),i=!1,h?e(u):Promise.resolve()}function a(c,l){var u;if(n[c].isActive===l)return Promise.resolve();(u=t.variantChildren)==null||u.forEach(f=>{var p;return(p=f.animationState)==null?void 0:p.setActive(c,l)}),n[c].isActive=l;const d=o(c);for(const f in n)n[f].protectedKeys={};return d}return{animateChanges:o,setActive:a,setAnimateFunction:s,getState:()=>n,reset:()=>{n=tp(),i=!0}}}function BR(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!Nb(e,t):!1}function Di(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function tp(){return{animate:Di(!0),whileInView:Di(),whileHover:Di(),whileTap:Di(),whileDrag:Di(),whileFocus:Di(),exit:Di()}}class Ei{constructor(e){this.isMounted=!1,this.node=e}update(){}}class $R extends Ei{constructor(e){super(e),e.animationState||(e.animationState=UR(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();nc(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)==null||e.call(this)}}let HR=0;class zR extends Ei{constructor(){super(...arguments),this.id=HR++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:i}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===i)return;const r=this.node.animationState.setActive("exit",!e);n&&!e&&r.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const WR={animation:{Feature:$R},exit:{Feature:zR}};function Ys(t,e,n,i={passive:!0}){return t.addEventListener(e,n,i),()=>t.removeEventListener(e,n)}function uo(t){return{point:{x:t.pageX,y:t.pageY}}}const qR=t=>e=>uf(e)&&t(e,uo(e));function Fs(t,e,n,i){return Ys(t,e,qR(n),i)}const Db=1e-4,KR=1-Db,GR=1+Db,jb=.01,ZR=0-jb,YR=0+jb;function Rt(t){return t.max-t.min}function JR(t,e,n){return Math.abs(t-e)<=n}function np(t,e,n,i=.5){t.origin=i,t.originPoint=Ge(e.min,e.max,t.origin),t.scale=Rt(n)/Rt(e),t.translate=Ge(n.min,n.max,t.origin)-t.originPoint,(t.scale>=KR&&t.scale<=GR||isNaN(t.scale))&&(t.scale=1),(t.translate>=ZR&&t.translate<=YR||isNaN(t.translate))&&(t.translate=0)}function Us(t,e,n,i){np(t.x,e.x,n.x,i?i.originX:void 0),np(t.y,e.y,n.y,i?i.originY:void 0)}function ip(t,e,n){t.min=n.min+e.min,t.max=t.min+Rt(e)}function XR(t,e,n){ip(t.x,e.x,n.x),ip(t.y,e.y,n.y)}function rp(t,e,n){t.min=e.min-n.min,t.max=t.min+Rt(e)}function Bs(t,e,n){rp(t.x,e.x,n.x),rp(t.y,e.y,n.y)}function Gt(t){return[t("x"),t("y")]}const Lb=({current:t})=>t?t.ownerDocument.defaultView:null,sp=(t,e)=>Math.abs(t-e);function QR(t,e){const n=sp(t.x,e.x),i=sp(t.y,e.y);return Math.sqrt(n**2+i**2)}class Vb{constructor(e,n,{transformPagePoint:i,contextWindow:r=window,dragSnapToOrigin:s=!1,distanceThreshold:o=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 f=ol(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,v=QR(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!v)return;const{point:h}=f,{timestamp:y}=vt;this.history.push({...h,timestamp:y});const{onStart:b,onMove:w}=this.handlers;p||(b&&b(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,f)},this.handlePointerMove=(f,p)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=sl(p,this.transformPagePoint),We.update(this.updatePoint,!0)},this.handlePointerUp=(f,p)=>{this.end();const{onEnd:v,onSessionEnd:h,resumeAnimation:y}=this.handlers;if(this.dragSnapToOrigin&&y&&y(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const b=ol(f.type==="pointercancel"?this.lastMoveEventInfo:sl(p,this.transformPagePoint),this.history);this.startEvent&&v&&v(f,b),h&&h(f,b)},!uf(e))return;this.dragSnapToOrigin=s,this.handlers=n,this.transformPagePoint=i,this.distanceThreshold=o,this.contextWindow=r||window;const a=uo(e),c=sl(a,this.transformPagePoint),{point:l}=c,{timestamp:d}=vt;this.history=[{...l,timestamp:d}];const{onSessionStart:u}=n;u&&u(e,ol(c,this.history)),this.removeListeners=ao(Fs(this.contextWindow,"pointermove",this.handlePointerMove),Fs(this.contextWindow,"pointerup",this.handlePointerUp),Fs(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),gi(this.updatePoint)}}function sl(t,e){return e?{point:e(t.point)}:t}function op(t,e){return{x:t.x-e.x,y:t.y-e.y}}function ol({point:t},e){return{point:t,delta:op(t,Fb(e)),offset:op(t,eA(e)),velocity:tA(e,.1)}}function eA(t){return t[0]}function Fb(t){return t[t.length-1]}function tA(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,i=null;const r=Fb(t);for(;n>=0&&(i=t[n],!(r.timestamp-i.timestamp>un(e)));)n--;if(!i)return{x:0,y:0};const s=En(r.timestamp-i.timestamp);if(s===0)return{x:0,y:0};const o={x:(r.x-i.x)/s,y:(r.y-i.y)/s};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function nA(t,{min:e,max:n},i){return e!==void 0&&t<e?t=i?Ge(e,t,i.min):Math.max(t,e):n!==void 0&&t>n&&(t=i?Ge(n,t,i.max):Math.min(t,n)),t}function ap(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function iA(t,{top:e,left:n,bottom:i,right:r}){return{x:ap(t.x,n,r),y:ap(t.y,e,i)}}function cp(t,e){let n=e.min-t.min,i=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,i]=[i,n]),{min:n,max:i}}function rA(t,e){return{x:cp(t.x,e.x),y:cp(t.y,e.y)}}function sA(t,e){let n=.5;const i=Rt(t),r=Rt(e);return r>i?n=Ws(e.min,e.max-i,t.min):i>r&&(n=Ws(t.min,t.max-r,e.min)),Zn(0,1,n)}function oA(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const $d=.35;function aA(t=$d){return t===!1?t=0:t===!0&&(t=$d),{x:lp(t,"left","right"),y:lp(t,"top","bottom")}}function lp(t,e,n){return{min:dp(t,e),max:dp(t,n)}}function dp(t,e){return typeof t=="number"?t:t[e]||0}const cA=new WeakMap;class lA{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=nt(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:i}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const s=u=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(uo(u).point)},o=(u,f)=>{const{drag:p,dragPropagation:v,onDragStart:h}=this.getProps();if(p&&!v&&(this.openDragLock&&this.openDragLock(),this.openDragLock=vP(p),!this.openDragLock))return;this.latestPointerEvent=u,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Gt(b=>{let w=this.getAxisMotionValue(b).get()||0;if(Pn.test(w)){const{projection:C}=this.visualElement;if(C&&C.layout){const S=C.layout.layoutBox[b];S&&(w=Rt(S)*(parseFloat(w)/100))}}this.originPoint[b]=w}),h&&We.postRender(()=>h(u,f)),Ud(this.visualElement,"transform");const{animationState:y}=this.visualElement;y&&y.setActive("whileDrag",!0)},a=(u,f)=>{this.latestPointerEvent=u,this.latestPanInfo=f;const{dragPropagation:p,dragDirectionLock:v,onDirectionLock:h,onDrag:y}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:b}=f;if(v&&this.currentDirection===null){this.currentDirection=dA(b),this.currentDirection!==null&&h&&h(this.currentDirection);return}this.updateAxis("x",f.point,b),this.updateAxis("y",f.point,b),this.visualElement.render(),y&&y(u,f)},c=(u,f)=>{this.latestPointerEvent=u,this.latestPanInfo=f,this.stop(u,f),this.latestPointerEvent=null,this.latestPanInfo=null},l=()=>Gt(u=>{var f;return this.getAnimationState(u)==="paused"&&((f=this.getAxisMotionValue(u).animation)==null?void 0:f.play())}),{dragSnapToOrigin:d}=this.getProps();this.panSession=new Vb(e,{onSessionStart:s,onStart:o,onMove:a,onSessionEnd:c,resumeAnimation:l},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:i,contextWindow:Lb(this.visualElement)})}stop(e,n){const i=e||this.latestPointerEvent,r=n||this.latestPanInfo,s=this.isDragging;if(this.cancel(),!s||!r||!i)return;const{velocity:o}=r;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&We.postRender(()=>a(i,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(e,n,i){const{drag:r}=this.getProps();if(!i||!Po(e,r,this.currentDirection))return;const s=this.getAxisMotionValue(e);let o=this.originPoint[e]+i[e];this.constraints&&this.constraints[e]&&(o=nA(o,this.constraints[e],this.elastic[e])),s.set(o)}resolveConstraints(){var s;const{dragConstraints:e,dragElastic:n}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(s=this.visualElement.projection)==null?void 0:s.layout,r=this.constraints;e&&Rr(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&i?this.constraints=iA(i.layoutBox,e):this.constraints=!1,this.elastic=aA(n),r!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&Gt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=oA(i.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Rr(e))return!1;const i=e.current;Yn(i!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const s=uR(i,r.root,this.visualElement.getTransformPagePoint());let o=rA(r.layout.layoutBox,s);if(n){const a=n(cR(o));this.hasMutatedConstraints=!!a,a&&(o=wb(a))}return o}startAnimation(e){const{drag:n,dragMomentum:i,dragElastic:r,dragTransition:s,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},l=Gt(d=>{if(!Po(d,n,this.currentDirection))return;let u=c&&c[d]||{};o&&(u={min:0,max:0});const f=r?200:1e6,p=r?40:1e7,v={type:"inertia",velocity:i?e[d]:0,bounceStiffness:f,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...s,...u};return this.startAxisValueAnimation(d,v)});return Promise.all(l).then(a)}startAxisValueAnimation(e,n){const i=this.getAxisMotionValue(e);return Ud(this.visualElement,e),i.start(Sf(e,i,0,n,this.visualElement,!1))}stopAnimation(){Gt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){Gt(e=>{var n;return(n=this.getAxisMotionValue(e).animation)==null?void 0:n.pause()})}getAnimationState(e){var n;return(n=this.getAxisMotionValue(e).animation)==null?void 0:n.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,i=this.visualElement.getProps(),r=i[n];return r||this.visualElement.getValue(e,(i.initial?i.initial[e]:void 0)||0)}snapToCursor(e){Gt(n=>{const{drag:i}=this.getProps();if(!Po(n,i,this.currentDirection))return;const{projection:r}=this.visualElement,s=this.getAxisMotionValue(n);if(r&&r.layout){const{min:o,max:a}=r.layout.layoutBox[n];s.set(e[n]-Ge(o,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:i}=this.visualElement;if(!Rr(n)||!i||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};Gt(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const c=a.get();r[o]=sA({min:c,max:c},this.constraints[o])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.resolveConstraints(),Gt(o=>{if(!Po(o,e,null))return;const a=this.getAxisMotionValue(o),{min:c,max:l}=this.constraints[o];a.set(Ge(c,l,r[o]))})}addListeners(){if(!this.visualElement.current)return;cA.set(this.visualElement,this);const e=this.visualElement.current,n=Fs(e,"pointerdown",c=>{const{drag:l,dragListener:d=!0}=this.getProps();l&&d&&this.start(c)}),i=()=>{const{dragConstraints:c}=this.getProps();Rr(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,s=r.addEventListener("measure",i);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),We.read(i);const o=Ys(window,"resize",()=>this.scalePositionWithinConstraints()),a=r.addEventListener("didUpdate",({delta:c,hasLayoutChanged:l})=>{this.isDragging&&l&&(Gt(d=>{const u=this.getAxisMotionValue(d);u&&(this.originPoint[d]+=c[d].translate,u.set(u.get()+c[d].translate))}),this.visualElement.render())});return()=>{o(),n(),s(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:i=!1,dragPropagation:r=!1,dragConstraints:s=!1,dragElastic:o=$d,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:i,dragPropagation:r,dragConstraints:s,dragElastic:o,dragMomentum:a}}}function Po(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function dA(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class uA extends Ei{constructor(e){super(e),this.removeGroupControls=Xt,this.removeListeners=Xt,this.controls=new lA(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Xt}unmount(){this.removeGroupControls(),this.removeListeners()}}const up=t=>(e,n)=>{t&&We.postRender(()=>t(e,n))};class fA extends Ei{constructor(){super(...arguments),this.removePointerDownListener=Xt}onPointerDown(e){this.session=new Vb(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Lb(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:i,onPanEnd:r}=this.node.getProps();return{onSessionStart:up(e),onStart:up(n),onMove:i,onEnd:(s,o)=>{delete this.session,r&&We.postRender(()=>r(s,o))}}}mount(){this.removePointerDownListener=Fs(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const la={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function fp(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Ts={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(he.test(t))t=parseFloat(t);else return t;const n=fp(t,e.target.x),i=fp(t,e.target.y);return`${n}% ${i}%`}},hA={correct:(t,{treeScale:e,projectionDelta:n})=>{const i=t,r=vi.parse(t);if(r.length>5)return i;const s=vi.createTransformer(t),o=typeof r[0]!="number"?1:0,a=n.x.scale*e.x,c=n.y.scale*e.y;r[0+o]/=a,r[1+o]/=c;const l=Ge(a,c,.5);return typeof r[2+o]=="number"&&(r[2+o]/=l),typeof r[3+o]=="number"&&(r[3+o]/=l),s(r)}};let al=!1;class mA extends R.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:i,layoutId:r}=this.props,{projection:s}=e;jP(pA),s&&(n.group&&n.group.add(s),i&&i.register&&r&&i.register(s),al&&s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,onExitComplete:()=>this.safeToRemove()})),la.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:i,drag:r,isPresent:s}=this.props,{projection:o}=i;return o&&(o.isPresent=s,al=!0,r||e.layoutDependency!==n||n===void 0||e.isPresent!==s?o.willUpdate():this.safeToRemove(),e.isPresent!==s&&(s?o.promote():o.relegate()||We.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),df.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:i}=this.props,{projection:r}=e;al=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),i&&i.deregister&&i.deregister(r))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function Ub(t){const[e,n]=cb(),i=R.useContext(Bu);return m.jsx(mA,{...t,layoutGroup:i,switchLayoutGroup:R.useContext(xb),isPresent:e,safeToRemove:n})}const pA={borderRadius:{...Ts,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Ts,borderTopRightRadius:Ts,borderBottomLeftRadius:Ts,borderBottomRightRadius:Ts,boxShadow:hA};function gA(t,e,n){const i=Tt(t)?t:Kr(t);return i.start(Sf("",i,e,n)),i.animation}const vA=(t,e)=>t.depth-e.depth;class yA{constructor(){this.children=[],this.isDirty=!1}add(e){zu(this.children,e),this.isDirty=!0}remove(e){Wu(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(vA),this.isDirty=!1,this.children.forEach(e)}}function bA(t,e){const n=Dt.now(),i=({timestamp:r})=>{const s=r-n;s>=e&&(gi(i),t(s-e))};return We.setup(i,!0),()=>gi(i)}const Bb=["TopLeft","TopRight","BottomLeft","BottomRight"],xA=Bb.length,hp=t=>typeof t=="string"?parseFloat(t):t,mp=t=>typeof t=="number"||he.test(t);function SA(t,e,n,i,r,s){r?(t.opacity=Ge(0,n.opacity??1,wA(i)),t.opacityExit=Ge(e.opacity??1,0,CA(i))):s&&(t.opacity=Ge(e.opacity??1,n.opacity??1,i));for(let o=0;o<xA;o++){const a=`border${Bb[o]}Radius`;let c=pp(e,a),l=pp(n,a);if(c===void 0&&l===void 0)continue;c||(c=0),l||(l=0),c===0||l===0||mp(c)===mp(l)?(t[a]=Math.max(Ge(hp(c),hp(l),i),0),(Pn.test(l)||Pn.test(c))&&(t[a]+="%")):t[a]=l}(e.rotate||n.rotate)&&(t.rotate=Ge(e.rotate||0,n.rotate||0,i))}function pp(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const wA=$b(0,.5,Ry),CA=$b(.5,.95,Xt);function $b(t,e,n){return i=>i<t?0:i>e?1:n(Ws(t,e,i))}function gp(t,e){t.min=e.min,t.max=e.max}function Kt(t,e){gp(t.x,e.x),gp(t.y,e.y)}function vp(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function yp(t,e,n,i,r){return t-=e,t=Na(t,1/n,i),r!==void 0&&(t=Na(t,1/r,i)),t}function kA(t,e=0,n=1,i=.5,r,s=t,o=t){if(Pn.test(e)&&(e=parseFloat(e),e=Ge(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=Ge(s.min,s.max,i);t===s&&(a-=e),t.min=yp(t.min,e,n,a,r),t.max=yp(t.max,e,n,a,r)}function bp(t,e,[n,i,r],s,o){kA(t,e[n],e[i],e[r],e.scale,s,o)}const TA=["x","scaleX","originX"],EA=["y","scaleY","originY"];function xp(t,e,n,i){bp(t.x,e,TA,n?n.x:void 0,i?i.x:void 0),bp(t.y,e,EA,n?n.y:void 0,i?i.y:void 0)}function Sp(t){return t.translate===0&&t.scale===1}function Hb(t){return Sp(t.x)&&Sp(t.y)}function wp(t,e){return t.min===e.min&&t.max===e.max}function PA(t,e){return wp(t.x,e.x)&&wp(t.y,e.y)}function Cp(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function zb(t,e){return Cp(t.x,e.x)&&Cp(t.y,e.y)}function kp(t){return Rt(t.x)/Rt(t.y)}function Tp(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class RA{constructor(){this.members=[]}add(e){zu(this.members,e),e.scheduleRender()}remove(e){if(Wu(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(r=>e===r);if(n===0)return!1;let i;for(let r=n;r>=0;r--){const s=this.members[r];if(s.isPresent!==!1){i=s;break}}return i?(this.promote(i),!0):!1}promote(e,n){const i=this.lead;if(e!==i&&(this.prevLead=i,this.lead=e,e.show(),i)){i.instance&&i.scheduleRender(),e.scheduleRender(),e.resumeFrom=i,n&&(e.resumeFrom.preserveOpacity=!0),i.snapshot&&(e.snapshot=i.snapshot,e.snapshot.latestValues=i.animationValues||i.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:r}=e.options;r===!1&&i.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:i}=e;n.onExitComplete&&n.onExitComplete(),i&&i.options.onExitComplete&&i.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function AA(t,e,n){let i="";const r=t.x.translate/e.x,s=t.y.translate/e.y,o=(n==null?void 0:n.z)||0;if((r||s||o)&&(i=`translate3d(${r}px, ${s}px, ${o}px) `),(e.x!==1||e.y!==1)&&(i+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:l,rotate:d,rotateX:u,rotateY:f,skewX:p,skewY:v}=n;l&&(i=`perspective(${l}px) ${i}`),d&&(i+=`rotate(${d}deg) `),u&&(i+=`rotateX(${u}deg) `),f&&(i+=`rotateY(${f}deg) `),p&&(i+=`skewX(${p}deg) `),v&&(i+=`skewY(${v}deg) `)}const a=t.x.scale*e.x,c=t.y.scale*e.y;return(a!==1||c!==1)&&(i+=`scale(${a}, ${c})`),i||"none"}const cl=["","X","Y","Z"],IA=1e3;let MA=0;function ll(t,e,n,i){const{latestValues:r}=e;r[t]&&(n[t]=r[t],e.setStaticValue(t,0),i&&(i[t]=0))}function Wb(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Ib(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:s}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",We,!(r||s))}const{parent:i}=t;i&&!i.hasCheckedOptimisedAppear&&Wb(i)}function qb({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:i,resetTransform:r}){return class{constructor(o={},a=e==null?void 0:e()){this.id=MA++,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(OA),this.nodes.forEach(VA),this.nodes.forEach(FA),this.nodes.forEach(DA)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new yA)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new Ku),this.eventHandlers.get(o).add(a)}notifyListeners(o,...a){const c=this.eventHandlers.get(o);c&&c.notify(...a)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=ab(o)&&!CP(o),this.instance=o;const{layoutId:a,layout:c,visualElement:l}=this.options;if(l&&!l.current&&l.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||a)&&(this.isLayoutDirty=!0),t){let d,u=0;const f=()=>this.root.updateBlockedByResize=!1;We.read(()=>{u=window.innerWidth}),t(o,()=>{const p=window.innerWidth;p!==u&&(u=p,this.root.updateBlockedByResize=!0,d&&d(),d=bA(f,250),la.hasAnimatedSinceResize&&(la.hasAnimatedSinceResize=!1,this.nodes.forEach(Rp)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&l&&(a||c)&&this.addEventListener("didUpdate",({delta:d,hasLayoutChanged:u,hasRelativeLayoutChanged:f,layout:p})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const v=this.options.transition||l.getDefaultTransition()||zA,{onLayoutAnimationStart:h,onLayoutAnimationComplete:y}=l.getProps(),b=!this.targetLayout||!zb(this.targetLayout,p),w=!u&&f;if(this.options.layoutRoot||this.resumeFrom||w||u&&(b||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const C={...cf(v,"layout"),onPlay:h,onComplete:y};(l.shouldReduceMotion||this.options.layoutRoot)&&(C.delay=0,C.type=!1),this.startAnimation(C),this.setAnimationOrigin(d,w)}else u||Rp(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=p})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),gi(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(UA),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Wb(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let d=0;d<this.path.length;d++){const u=this.path[d];u.shouldResetTransform=!0,u.updateScroll("snapshot"),u.options.layoutRoot&&u.willUpdate(!1)}const{layoutId:a,layout:c}=this.options;if(a===void 0&&!c)return;const l=this.getTransformTemplate();this.prevTransformTemplateValue=l?l(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Ep);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Pp);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(LA),this.nodes.forEach(_A),this.nodes.forEach(NA)):this.nodes.forEach(Pp),this.clearAllSnapshots();const a=Dt.now();vt.delta=Zn(0,1e3/60,a-vt.timestamp),vt.timestamp=a,vt.isProcessing=!0,Jc.update.process(vt),Jc.preRender.process(vt),Jc.render.process(vt),vt.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,df.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(jA),this.sharedNodes.forEach(BA)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,We.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){We.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Rt(this.snapshot.measuredBox.x)&&!Rt(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=nt(),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,o?o.layoutBox:void 0)}updateScroll(o="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(a=!1),a&&this.instance){const c=i(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!r)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!Hb(this.projectionDelta),c=this.getTransformTemplate(),l=c?c(this.latestValues,""):void 0,d=l!==this.prevTransformTemplateValue;o&&this.instance&&(a||Vi(this.latestValues)||d)&&(r(this.instance,l),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let c=this.removeElementScroll(a);return o&&(c=this.removeTransform(c)),WA(c),{animationId:this.root.animationId,measuredBox:a,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){var l;const{visualElement:o}=this.options;if(!o)return nt();const a=o.measureViewportBox();if(!(((l=this.scroll)==null?void 0:l.wasRoot)||this.path.some(qA))){const{scroll:d}=this.root;d&&(Ar(a.x,d.offset.x),Ar(a.y,d.offset.y))}return a}removeElementScroll(o){var c;const a=nt();if(Kt(a,o),(c=this.scroll)!=null&&c.wasRoot)return a;for(let l=0;l<this.path.length;l++){const d=this.path[l],{scroll:u,options:f}=d;d!==this.root&&u&&f.layoutScroll&&(u.wasRoot&&Kt(a,o),Ar(a.x,u.offset.x),Ar(a.y,u.offset.y))}return a}applyTransform(o,a=!1){const c=nt();Kt(c,o);for(let l=0;l<this.path.length;l++){const d=this.path[l];!a&&d.options.layoutScroll&&d.scroll&&d!==d.root&&Ir(c,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),Vi(d.latestValues)&&Ir(c,d.latestValues)}return Vi(this.latestValues)&&Ir(c,this.latestValues),c}removeTransform(o){const a=nt();Kt(a,o);for(let c=0;c<this.path.length;c++){const l=this.path[c];if(!l.instance||!Vi(l.latestValues))continue;jd(l.latestValues)&&l.updateSnapshot();const d=nt(),u=l.measurePageBox();Kt(d,u),xp(a,l.latestValues,l.snapshot?l.snapshot.layoutBox:void 0,d)}return Vi(this.latestValues)&&xp(a,this.latestValues),a}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.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!==vt.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){var f;const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==a;if(!(o||c&&this.isSharedProjectionDirty||this.isProjectionDirty||(f=this.parent)!=null&&f.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:d,layoutId:u}=this.options;if(!(!this.layout||!(d||u))){if(this.resolvedRelativeTargetAt=vt.timestamp,!this.targetDelta&&!this.relativeTarget){const p=this.getClosestProjectingParent();p&&p.layout&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=nt(),this.relativeTargetOrigin=nt(),Bs(this.relativeTargetOrigin,this.layout.layoutBox,p.layout.layoutBox),Kt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=nt(),this.targetWithTransforms=nt()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),XR(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Kt(this.target,this.layout.layoutBox),kb(this.target,this.targetDelta)):Kt(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const p=this.getClosestProjectingParent();p&&!!p.resumingFrom==!!this.resumingFrom&&!p.options.layoutScroll&&p.target&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=nt(),this.relativeTargetOrigin=nt(),Bs(this.relativeTargetOrigin,this.target,p.target),Kt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||jd(this.parent.latestValues)||Cb(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 v;const o=this.getLead(),a=!!this.resumingFrom||this!==o;let c=!0;if((this.isProjectionDirty||(v=this.parent)!=null&&v.isProjectionDirty)&&(c=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===vt.timestamp&&(c=!1),c)return;const{layout:l,layoutId:d}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(l||d))return;Kt(this.layoutCorrected,this.layout.layoutBox);const u=this.treeScale.x,f=this.treeScale.y;dR(this.layoutCorrected,this.treeScale,this.path,a),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=nt());const{target:p}=o;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(vp(this.prevProjectionDelta.x,this.projectionDelta.x),vp(this.prevProjectionDelta.y,this.projectionDelta.y)),Us(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==u||this.treeScale.y!==f||!Tp(this.projectionDelta.x,this.prevProjectionDelta.x)||!Tp(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",p))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){var a;if((a=this.options.visualElement)==null||a.scheduleRender(),o){const c=this.getStack();c&&c.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Mr(),this.projectionDelta=Mr(),this.projectionDeltaWithTransform=Mr()}setAnimationOrigin(o,a=!1){const c=this.snapshot,l=c?c.latestValues:{},d={...this.latestValues},u=Mr();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=nt(),p=c?c.source:void 0,v=this.layout?this.layout.source:void 0,h=p!==v,y=this.getStack(),b=!y||y.members.length<=1,w=!!(h&&!b&&this.options.crossfade===!0&&!this.path.some(HA));this.animationProgress=0;let C;this.mixTargetDelta=S=>{const x=S/1e3;Ap(u.x,o.x,x),Ap(u.y,o.y,x),this.setTargetDelta(u),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Bs(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),$A(this.relativeTarget,this.relativeTargetOrigin,f,x),C&&PA(this.relativeTarget,C)&&(this.isProjectionDirty=!1),C||(C=nt()),Kt(C,this.relativeTarget)),h&&(this.animationValues=d,SA(d,l,this.latestValues,x,w,b)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=x},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){var a,c,l;this.notifyListeners("animationStart"),(a=this.currentAnimation)==null||a.stop(),(l=(c=this.resumingFrom)==null?void 0:c.currentAnimation)==null||l.stop(),this.pendingAnimation&&(gi(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=We.update(()=>{la.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Kr(0)),this.currentAnimation=gA(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:d=>{this.mixTargetDelta(d),o.onUpdate&&o.onUpdate(d)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.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 o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(IA),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:c,layout:l,latestValues:d}=o;if(!(!a||!c||!l)){if(this!==o&&this.layout&&l&&Kb(this.options.animationType,this.layout.layoutBox,l.layoutBox)){c=this.target||nt();const u=Rt(this.layout.layoutBox.x);c.x.min=o.target.x.min,c.x.max=c.x.min+u;const f=Rt(this.layout.layoutBox.y);c.y.min=o.target.y.min,c.y.max=c.y.min+f}Kt(a,c),Ir(a,d),Us(this.projectionDeltaWithTransform,this.layoutCorrected,a,d)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new RA),this.sharedNodes.get(o).add(a);const l=a.options.initialPromotionConfig;a.promote({transition:l?l.transition:void 0,preserveFollowOpacity:l&&l.shouldPreserveFollowOpacity?l.shouldPreserveFollowOpacity(a):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var a;const{layoutId:o}=this.options;return o?((a=this.getStack())==null?void 0:a.lead)||this:this}getPrevLead(){var a;const{layoutId:o}=this.options;return o?(a=this.getStack())==null?void 0:a.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:c}={}){const l=this.getStack();l&&l.promote(this,c),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:c}=o;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(a=!0),!a)return;const l={};c.z&&ll("z",o,l,this.animationValues);for(let d=0;d<cl.length;d++)ll(`rotate${cl[d]}`,o,l,this.animationValues),ll(`skew${cl[d]}`,o,l,this.animationValues);o.render();for(const d in l)o.setStaticValue(d,l[d]),this.animationValues&&(this.animationValues[d]=l[d]);o.scheduleRender()}applyProjectionStyles(o,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=ca(a==null?void 0:a.pointerEvents)||"",o.transform=c?c(this.latestValues,""):"none";return}const l=this.getLead();if(!this.projectionDelta||!this.layout||!l.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=ca(a==null?void 0:a.pointerEvents)||""),this.hasProjected&&!Vi(this.latestValues)&&(o.transform=c?c({},""):"none",this.hasProjected=!1);return}o.visibility="";const d=l.animationValues||l.latestValues;this.applyTransformsToTarget();let u=AA(this.projectionDeltaWithTransform,this.treeScale,d);c&&(u=c(d,u)),o.transform=u;const{x:f,y:p}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${p.origin*100}% 0`,l.animationValues?o.opacity=l===this?d.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:d.opacityExit:o.opacity=l===this?d.opacity!==void 0?d.opacity:"":d.opacityExit!==void 0?d.opacityExit:0;for(const v in Zs){if(d[v]===void 0)continue;const{correct:h,applyTo:y,isCSSVariable:b}=Zs[v],w=u==="none"?d[v]:h(d[v],l);if(y){const C=y.length;for(let S=0;S<C;S++)o[y[S]]=w}else b?this.options.visualElement.renderState.vars[v]=w:o[v]=w}this.options.layoutId&&(o.pointerEvents=l===this?ca(a==null?void 0:a.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>{var a;return(a=o.currentAnimation)==null?void 0:a.stop()}),this.root.nodes.forEach(Ep),this.root.sharedNodes.clear()}}}function _A(t){t.updateLayout()}function NA(t){var n;const e=((n=t.resumeFrom)==null?void 0:n.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:i,measuredBox:r}=t.layout,{animationType:s}=t.options,o=e.source!==t.layout.source;s==="size"?Gt(u=>{const f=o?e.measuredBox[u]:e.layoutBox[u],p=Rt(f);f.min=i[u].min,f.max=f.min+p}):Kb(s,e.layoutBox,i)&&Gt(u=>{const f=o?e.measuredBox[u]:e.layoutBox[u],p=Rt(i[u]);f.max=f.min+p,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[u].max=t.relativeTarget[u].min+p)});const a=Mr();Us(a,i,e.layoutBox);const c=Mr();o?Us(c,t.applyTransform(r,!0),e.measuredBox):Us(c,i,e.layoutBox);const l=!Hb(a);let d=!1;if(!t.resumeFrom){const u=t.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:f,layout:p}=u;if(f&&p){const v=nt();Bs(v,e.layoutBox,f.layoutBox);const h=nt();Bs(h,i,p.layoutBox),zb(v,h)||(d=!0),u.options.layoutRoot&&(t.relativeTarget=h,t.relativeTargetOrigin=v,t.relativeParent=u)}}}t.notifyListeners("didUpdate",{layout:i,snapshot:e,delta:c,layoutDelta:a,hasLayoutChanged:l,hasRelativeLayoutChanged:d})}else if(t.isLead()){const{onExitComplete:i}=t.options;i&&i()}t.options.transition=void 0}function OA(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function DA(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function jA(t){t.clearSnapshot()}function Ep(t){t.clearMeasurements()}function Pp(t){t.isLayoutDirty=!1}function LA(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Rp(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function VA(t){t.resolveTargetDelta()}function FA(t){t.calcProjection()}function UA(t){t.resetSkewAndRotation()}function BA(t){t.removeLeadSnapshot()}function Ap(t,e,n){t.translate=Ge(e.translate,0,n),t.scale=Ge(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function Ip(t,e,n,i){t.min=Ge(e.min,n.min,i),t.max=Ge(e.max,n.max,i)}function $A(t,e,n,i){Ip(t.x,e.x,n.x,i),Ip(t.y,e.y,n.y,i)}function HA(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const zA={duration:.45,ease:[.4,0,.1,1]},Mp=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),_p=Mp("applewebkit/")&&!Mp("chrome/")?Math.round:Xt;function Np(t){t.min=_p(t.min),t.max=_p(t.max)}function WA(t){Np(t.x),Np(t.y)}function Kb(t,e,n){return t==="position"||t==="preserve-aspect"&&!JR(kp(e),kp(n),.2)}function qA(t){var e;return t!==t.root&&((e=t.scroll)==null?void 0:e.wasRoot)}const KA=qb({attachResizeListener:(t,e)=>Ys(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),dl={current:void 0},Gb=qb({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!dl.current){const t=new KA({});t.mount(window),t.setOptions({layoutScroll:!0}),dl.current=t}return dl.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),GA={pan:{Feature:fA},drag:{Feature:uA,ProjectionNode:Gb,MeasureLayout:Ub}};function Op(t,e,n){const{props:i}=t;t.animationState&&i.whileHover&&t.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,s=i[r];s&&We.postRender(()=>s(e,uo(e)))}class ZA extends Ei{mount(){const{current:e}=this.node;e&&(this.unmount=yP(e,(n,i)=>(Op(this.node,i,"Start"),r=>Op(this.node,r,"End"))))}unmount(){}}class YA extends Ei{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=ao(Ys(this.node.current,"focus",()=>this.onFocus()),Ys(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Dp(t,e,n){const{props:i}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&i.whileTap&&t.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),s=i[r];s&&We.postRender(()=>s(e,uo(e)))}class JA extends Ei{mount(){const{current:e}=this.node;e&&(this.unmount=wP(e,(n,i)=>(Dp(this.node,i,"Start"),(r,{success:s})=>Dp(this.node,r,s?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Hd=new WeakMap,ul=new WeakMap,XA=t=>{const e=Hd.get(t.target);e&&e(t)},QA=t=>{t.forEach(XA)};function eI({root:t,...e}){const n=t||document;ul.has(n)||ul.set(n,{});const i=ul.get(n),r=JSON.stringify(e);return i[r]||(i[r]=new IntersectionObserver(QA,{root:t,...e})),i[r]}function tI(t,e,n){const i=eI(e);return Hd.set(t,n),i.observe(t),()=>{Hd.delete(t),i.unobserve(t)}}const nI={some:0,all:1};class iI extends Ei{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:i,amount:r="some",once:s}=e,o={root:n?n.current:void 0,rootMargin:i,threshold:typeof r=="number"?r:nI[r]},a=c=>{const{isIntersecting:l}=c;if(this.isInView===l||(this.isInView=l,s&&!l&&this.hasEnteredView))return;l&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",l);const{onViewportEnter:d,onViewportLeave:u}=this.node.getProps(),f=l?d:u;f&&f(c)};return tI(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(rI(e,n))&&this.startObserver()}unmount(){}}function rI({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const sI={inView:{Feature:iI},tap:{Feature:JA},focus:{Feature:YA},hover:{Feature:ZA}},oI={layout:{ProjectionNode:Gb,MeasureLayout:Ub}},aI={...WR,...sI,...GA,...oI},xe=aR(aI,xR);var Ro=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Zb(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var zd={exports:{}},cI=zd.exports,jp;function lI(){return jp||(jp=1,function(t){(function(e,n){t.exports?t.exports=n():e.log=n()})(cI,function(){var e=function(){},n="undefined",i=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"],s={},o=null;function a(h,y){var b=h[y];if(typeof b.bind=="function")return b.bind(h);try{return Function.prototype.bind.call(b,h)}catch{return function(){return Function.prototype.apply.apply(b,[h,arguments])}}}function c(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(h){return h==="debug"&&(h="log"),typeof console===n?!1:h==="trace"&&i?c:console[h]!==void 0?a(console,h):console.log!==void 0?a(console,"log"):e}function d(){for(var h=this.getLevel(),y=0;y<r.length;y++){var b=r[y];this[b]=y<h?e:this.methodFactory(b,h,this.name)}if(this.log=this.debug,typeof console===n&&h<this.levels.SILENT)return"No console available for logging"}function u(h){return function(){typeof console!==n&&(d.call(this),this[h].apply(this,arguments))}}function f(h,y,b){return l(h)||u.apply(this,arguments)}function p(h,y){var b=this,w,C,S,x="loglevel";typeof h=="string"?x+=":"+h:typeof h=="symbol"&&(x=void 0);function T(I){var N=(r[I]||"silent").toUpperCase();if(!(typeof window===n||!x)){try{window.localStorage[x]=N;return}catch{}try{window.document.cookie=encodeURIComponent(x)+"="+N+";"}catch{}}}function E(){var I;if(!(typeof window===n||!x)){try{I=window.localStorage[x]}catch{}if(typeof I===n)try{var N=window.document.cookie,K=encodeURIComponent(x),J=N.indexOf(K+"=");J!==-1&&(I=/^([^;]+)/.exec(N.slice(J+K.length+1))[1])}catch{}return b.levels[I]===void 0&&(I=void 0),I}}function P(){if(!(typeof window===n||!x)){try{window.localStorage.removeItem(x)}catch{}try{window.document.cookie=encodeURIComponent(x)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function _(I){var N=I;if(typeof N=="string"&&b.levels[N.toUpperCase()]!==void 0&&(N=b.levels[N.toUpperCase()]),typeof N=="number"&&N>=0&&N<=b.levels.SILENT)return N;throw new TypeError("log.setLevel() called with invalid level: "+I)}b.name=h,b.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},b.methodFactory=y||f,b.getLevel=function(){return S??C??w},b.setLevel=function(I,N){return S=_(I),N!==!1&&T(S),d.call(b)},b.setDefaultLevel=function(I){C=_(I),E()||b.setLevel(I,!1)},b.resetLevel=function(){S=null,P(),d.call(b)},b.enableAll=function(I){b.setLevel(b.levels.TRACE,I)},b.disableAll=function(I){b.setLevel(b.levels.SILENT,I)},b.rebuild=function(){if(o!==b&&(w=_(o.getLevel())),d.call(b),o===b)for(var I in s)s[I].rebuild()},w=_(o?o.getLevel():"WARN");var k=E();k!=null&&(S=_(k)),d.call(b)}o=new p,o.getLogger=function(h){if(typeof h!="symbol"&&typeof h!="string"||h==="")throw new TypeError("You must supply a name when creating a logger.");var y=s[h];return y||(y=s[h]=new p(h,o.methodFactory)),y};var v=typeof window!==n?window.log:void 0;return o.noConflict=function(){return typeof window!==n&&window.log===o&&(window.log=v),o},o.getLoggers=function(){return s},o.default=o,o})}(zd)),zd.exports}var dI=lI();const uI=Zb(dI);var Wd=function(t,e){return Wd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(n[r]=i[r])},Wd(t,e)};function ti(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Wd(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function fI(t,e,n,i){function r(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(d){try{l(i.next(d))}catch(u){o(u)}}function c(d){try{l(i.throw(d))}catch(u){o(u)}}function l(d){d.done?s(d.value):r(d.value).then(a,c)}l((i=i.apply(t,[])).next())})}function Yb(t,e){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(d){return c([l,d])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(n=0)),n;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return n.label++,{value:l[1],done:!1};case 5:n.label++,r=l[1],l=[0];continue;case 7:l=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){n=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){n.label=l[1];break}if(l[0]===6&&n.label<s[1]){n.label=s[1],s=l;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(l);break}s[2]&&n.ops.pop(),n.trys.pop();continue}l=e.call(t,n)}catch(d){l=[6,d],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Zr(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Js(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var i=n.call(t),r,s=[],o;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function Xs(t,e,n){if(arguments.length===2)for(var i=0,r=e.length,s;i<r;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return t.concat(s||Array.prototype.slice.call(e))}function Ur(t){return this instanceof Ur?(this.v=t,this):new Ur(t)}function hI(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=n.apply(t,e||[]),r,s=[];return r=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),r[Symbol.asyncIterator]=function(){return this},r;function o(p){return function(v){return Promise.resolve(v).then(p,u)}}function a(p,v){i[p]&&(r[p]=function(h){return new Promise(function(y,b){s.push([p,h,y,b])>1||c(p,h)})},v&&(r[p]=v(r[p])))}function c(p,v){try{l(i[p](v))}catch(h){f(s[0][3],h)}}function l(p){p.value instanceof Ur?Promise.resolve(p.value.v).then(d,u):f(s[0][2],p)}function d(p){c("next",p)}function u(p){c("throw",p)}function f(p,v){p(v),s.shift(),s.length&&c(s[0][0],s[0][1])}}function mI(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof Zr=="function"?Zr(t):t[Symbol.iterator](),n={},i("next"),i("throw"),i("return"),n[Symbol.asyncIterator]=function(){return this},n);function i(s){n[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),r(a,c,o.done,o.value)})}}function r(s,o,a,c){Promise.resolve(c).then(function(l){s({value:l,done:a})},o)}}function ut(t){return typeof t=="function"}function wf(t){var e=function(i){Error.call(i),i.stack=new Error().stack},n=t(e);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var fl=wf(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
76
|
-
`+e.map(function(n,i){return i+1+") "+n.toString()}).join(`
|
|
77
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function Oa(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var fo=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,n,i,r,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=Zr(o),c=a.next();!c.done;c=a.next()){var l=c.value;l.remove(this)}}catch(h){e={error:h}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}else o.remove(this);var d=this.initialTeardown;if(ut(d))try{d()}catch(h){s=h instanceof fl?h.errors:[h]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var f=Zr(u),p=f.next();!p.done;p=f.next()){var v=p.value;try{Lp(v)}catch(h){s=s??[],h instanceof fl?s=Xs(Xs([],Js(s)),Js(h.errors)):s.push(h)}}}catch(h){i={error:h}}finally{try{p&&!p.done&&(r=f.return)&&r.call(f)}finally{if(i)throw i.error}}}if(s)throw new fl(s)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)Lp(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(e)}},t.prototype._hasParent=function(e){var n=this._parentage;return n===e||Array.isArray(n)&&n.includes(e)},t.prototype._addParent=function(e){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(e),n):n?[n,e]:e},t.prototype._removeParent=function(e){var n=this._parentage;n===e?this._parentage=null:Array.isArray(n)&&Oa(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&Oa(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),Jb=fo.EMPTY;function Xb(t){return t instanceof fo||t&&"closed"in t&&ut(t.remove)&&ut(t.add)&&ut(t.unsubscribe)}function Lp(t){ut(t)?t():t.unsubscribe()}var pI={Promise:void 0},gI={setTimeout:function(t,e){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];return setTimeout.apply(void 0,Xs([t,e],Js(n)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function Qb(t){gI.setTimeout(function(){throw t})}function qd(){}function da(t){t()}var Cf=function(t){ti(e,t);function e(n){var i=t.call(this)||this;return i.isStopped=!1,n?(i.destination=n,Xb(n)&&n.add(i)):i.destination=bI,i}return e.create=function(n,i,r){return new Qs(n,i,r)},e.prototype.next=function(n){this.isStopped||this._next(n)},e.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(n){this.destination.next(n)},e.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(fo),vI=function(){function t(e){this.partialObserver=e}return t.prototype.next=function(e){var n=this.partialObserver;if(n.next)try{n.next(e)}catch(i){Ao(i)}},t.prototype.error=function(e){var n=this.partialObserver;if(n.error)try{n.error(e)}catch(i){Ao(i)}else Ao(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(n){Ao(n)}},t}(),Qs=function(t){ti(e,t);function e(n,i,r){var s=t.call(this)||this,o;return ut(n)||!n?o={next:n??void 0,error:i??void 0,complete:r??void 0}:o=n,s.destination=new vI(o),s}return e}(Cf);function Ao(t){Qb(t)}function yI(t){throw t}var bI={closed:!0,next:qd,error:yI,complete:qd},kf=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Tf(t){return t}function xI(t){return t.length===0?Tf:t.length===1?t[0]:function(e){return t.reduce(function(n,i){return i(n)},e)}}var mt=function(){function t(e){e&&(this._subscribe=e)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(e,n,i){var r=this,s=wI(e)?e:new Qs(e,n,i);return da(function(){var o=r,a=o.operator,c=o.source;s.add(a?a.call(s,c):c?r._subscribe(s):r._trySubscribe(s))}),s},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(n){e.error(n)}},t.prototype.forEach=function(e,n){var i=this;return n=Vp(n),new n(function(r,s){var o=new Qs({next:function(a){try{e(a)}catch(c){s(c),o.unsubscribe()}},error:s,complete:r});i.subscribe(o)})},t.prototype._subscribe=function(e){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(e)},t.prototype[kf]=function(){return this},t.prototype.pipe=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return xI(e)(this)},t.prototype.toPromise=function(e){var n=this;return e=Vp(e),new e(function(i,r){var s;n.subscribe(function(o){return s=o},function(o){return r(o)},function(){return i(s)})})},t.create=function(e){return new t(e)},t}();function Vp(t){var e;return(e=t??pI.Promise)!==null&&e!==void 0?e:Promise}function SI(t){return t&&ut(t.next)&&ut(t.error)&&ut(t.complete)}function wI(t){return t&&t instanceof Cf||SI(t)&&Xb(t)}function CI(t){return ut(t==null?void 0:t.lift)}function On(t){return function(e){if(CI(e))return e.lift(function(n){try{return t(n,this)}catch(i){this.error(i)}});throw new TypeError("Unable to lift unknown Observable type")}}function yi(t,e,n,i,r){return new kI(t,e,n,i,r)}var kI=function(t){ti(e,t);function e(n,i,r,s,o,a){var c=t.call(this,n)||this;return c.onFinalize=o,c.shouldUnsubscribe=a,c._next=i?function(l){try{i(l)}catch(d){n.error(d)}}:t.prototype._next,c._error=s?function(l){try{s(l)}catch(d){n.error(d)}finally{this.unsubscribe()}}:t.prototype._error,c._complete=r?function(){try{r()}catch(l){n.error(l)}finally{this.unsubscribe()}}:t.prototype._complete,c}return e.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var i=this.closed;t.prototype.unsubscribe.call(this),!i&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},e}(Cf),TI=wf(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Yr=function(t){ti(e,t);function e(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return e.prototype.lift=function(n){var i=new Fp(this,this);return i.operator=n,i},e.prototype._throwIfClosed=function(){if(this.closed)throw new TI},e.prototype.next=function(n){var i=this;da(function(){var r,s;if(i._throwIfClosed(),!i.isStopped){i.currentObservers||(i.currentObservers=Array.from(i.observers));try{for(var o=Zr(i.currentObservers),a=o.next();!a.done;a=o.next()){var c=a.value;c.next(n)}}catch(l){r={error:l}}finally{try{a&&!a.done&&(s=o.return)&&s.call(o)}finally{if(r)throw r.error}}}})},e.prototype.error=function(n){var i=this;da(function(){if(i._throwIfClosed(),!i.isStopped){i.hasError=i.isStopped=!0,i.thrownError=n;for(var r=i.observers;r.length;)r.shift().error(n)}})},e.prototype.complete=function(){var n=this;da(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var i=n.observers;i.length;)i.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},e.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},e.prototype._innerSubscribe=function(n){var i=this,r=this,s=r.hasError,o=r.isStopped,a=r.observers;return s||o?Jb:(this.currentObservers=null,a.push(n),new fo(function(){i.currentObservers=null,Oa(a,n)}))},e.prototype._checkFinalizedStatuses=function(n){var i=this,r=i.hasError,s=i.thrownError,o=i.isStopped;r?n.error(s):o&&n.complete()},e.prototype.asObservable=function(){var n=new mt;return n.source=this,n},e.create=function(n,i){return new Fp(n,i)},e}(mt),Fp=function(t){ti(e,t);function e(n,i){var r=t.call(this)||this;return r.destination=n,r.source=i,r}return e.prototype.next=function(n){var i,r;(r=(i=this.destination)===null||i===void 0?void 0:i.next)===null||r===void 0||r.call(i,n)},e.prototype.error=function(n){var i,r;(r=(i=this.destination)===null||i===void 0?void 0:i.error)===null||r===void 0||r.call(i,n)},e.prototype.complete=function(){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||i===void 0||i.call(n)},e.prototype._subscribe=function(n){var i,r;return(r=(i=this.source)===null||i===void 0?void 0:i.subscribe(n))!==null&&r!==void 0?r:Jb},e}(Yr),EI=function(t){ti(e,t);function e(n){var i=t.call(this)||this;return i._value=n,i}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(n){var i=t.prototype._subscribe.call(this,n);return!i.closed&&n.next(this._value),i},e.prototype.getValue=function(){var n=this,i=n.hasError,r=n.thrownError,s=n._value;if(i)throw r;return this._throwIfClosed(),s},e.prototype.next=function(n){t.prototype.next.call(this,this._value=n)},e}(Yr),PI={now:function(){return Date.now()}},RI=function(t){ti(e,t);function e(n,i){return t.call(this)||this}return e.prototype.schedule=function(n,i){return this},e}(fo),Up={setInterval:function(t,e){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];return setInterval.apply(void 0,Xs([t,e],Js(n)))},clearInterval:function(t){return clearInterval(t)},delegate:void 0},AI=function(t){ti(e,t);function e(n,i){var r=t.call(this,n,i)||this;return r.scheduler=n,r.work=i,r.pending=!1,r}return e.prototype.schedule=function(n,i){var r;if(i===void 0&&(i=0),this.closed)return this;this.state=n;var s=this.id,o=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(o,s,i)),this.pending=!0,this.delay=i,this.id=(r=this.id)!==null&&r!==void 0?r:this.requestAsyncId(o,this.id,i),this},e.prototype.requestAsyncId=function(n,i,r){return r===void 0&&(r=0),Up.setInterval(n.flush.bind(n,this),r)},e.prototype.recycleAsyncId=function(n,i,r){if(r===void 0&&(r=0),r!=null&&this.delay===r&&this.pending===!1)return i;i!=null&&Up.clearInterval(i)},e.prototype.execute=function(n,i){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(n,i);if(r)return r;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(n,i){var r=!1,s;try{this.work(n)}catch(o){r=!0,s=o||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),s},e.prototype.unsubscribe=function(){if(!this.closed){var n=this,i=n.id,r=n.scheduler,s=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Oa(s,this),i!=null&&(this.id=this.recycleAsyncId(r,i,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}(RI),Bp=function(){function t(e,n){n===void 0&&(n=t.now),this.schedulerActionCtor=e,this.now=n}return t.prototype.schedule=function(e,n,i){return n===void 0&&(n=0),new this.schedulerActionCtor(this,e).schedule(i,n)},t.now=PI.now,t}(),II=function(t){ti(e,t);function e(n,i){i===void 0&&(i=Bp.now);var r=t.call(this,n,i)||this;return r.actions=[],r._active=!1,r}return e.prototype.flush=function(n){var i=this.actions;if(this._active){i.push(n);return}var r;this._active=!0;do if(r=n.execute(n.state,n.delay))break;while(n=i.shift());if(this._active=!1,r){for(;n=i.shift();)n.unsubscribe();throw r}},e}(Bp);new II(AI);function MI(t){return t&&ut(t.schedule)}function _I(t){return t[t.length-1]}function e1(t){return MI(_I(t))?t.pop():void 0}var t1=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function n1(t){return ut(t==null?void 0:t.then)}function i1(t){return ut(t[kf])}function r1(t){return Symbol.asyncIterator&&ut(t==null?void 0:t[Symbol.asyncIterator])}function s1(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function NI(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var o1=NI();function a1(t){return ut(t==null?void 0:t[o1])}function c1(t){return hI(this,arguments,function(){var e,n,i,r;return Yb(this,function(s){switch(s.label){case 0:e=t.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,Ur(e.read())];case 3:return n=s.sent(),i=n.value,r=n.done,r?[4,Ur(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,Ur(i)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function l1(t){return ut(t==null?void 0:t.getReader)}function Pi(t){if(t instanceof mt)return t;if(t!=null){if(i1(t))return OI(t);if(t1(t))return DI(t);if(n1(t))return jI(t);if(r1(t))return d1(t);if(a1(t))return LI(t);if(l1(t))return VI(t)}throw s1(t)}function OI(t){return new mt(function(e){var n=t[kf]();if(ut(n.subscribe))return n.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function DI(t){return new mt(function(e){for(var n=0;n<t.length&&!e.closed;n++)e.next(t[n]);e.complete()})}function jI(t){return new mt(function(e){t.then(function(n){e.closed||(e.next(n),e.complete())},function(n){return e.error(n)}).then(null,Qb)})}function LI(t){return new mt(function(e){var n,i;try{for(var r=Zr(t),s=r.next();!s.done;s=r.next()){var o=s.value;if(e.next(o),e.closed)return}}catch(a){n={error:a}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}e.complete()})}function d1(t){return new mt(function(e){FI(t,e).catch(function(n){return e.error(n)})})}function VI(t){return d1(c1(t))}function FI(t,e){var n,i,r,s;return fI(this,void 0,void 0,function(){var o,a;return Yb(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),n=mI(t),c.label=1;case 1:return[4,n.next()];case 2:if(i=c.sent(),!!i.done)return[3,4];if(o=i.value,e.next(o),e.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),r={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),i&&!i.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(r)throw r.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function qi(t,e,n,i,r){i===void 0&&(i=0),r===void 0&&(r=!1);var s=e.schedule(function(){n(),r?t.add(this.schedule(null,i)):this.unsubscribe()},i);if(t.add(s),!r)return s}function u1(t,e){return e===void 0&&(e=0),On(function(n,i){n.subscribe(yi(i,function(r){return qi(i,t,function(){return i.next(r)},e)},function(){return qi(i,t,function(){return i.complete()},e)},function(r){return qi(i,t,function(){return i.error(r)},e)}))})}function f1(t,e){return e===void 0&&(e=0),On(function(n,i){i.add(t.schedule(function(){return n.subscribe(i)},e))})}function UI(t,e){return Pi(t).pipe(f1(e),u1(e))}function BI(t,e){return Pi(t).pipe(f1(e),u1(e))}function $I(t,e){return new mt(function(n){var i=0;return e.schedule(function(){i===t.length?n.complete():(n.next(t[i++]),n.closed||this.schedule())})})}function HI(t,e){return new mt(function(n){var i;return qi(n,e,function(){i=t[o1](),qi(n,e,function(){var r,s,o;try{r=i.next(),s=r.value,o=r.done}catch(a){n.error(a);return}o?n.complete():n.next(s)},0,!0)}),function(){return ut(i==null?void 0:i.return)&&i.return()}})}function h1(t,e){if(!t)throw new Error("Iterable cannot be null");return new mt(function(n){qi(n,e,function(){var i=t[Symbol.asyncIterator]();qi(n,e,function(){i.next().then(function(r){r.done?n.complete():n.next(r.value)})},0,!0)})})}function zI(t,e){return h1(c1(t),e)}function WI(t,e){if(t!=null){if(i1(t))return UI(t,e);if(t1(t))return $I(t,e);if(n1(t))return BI(t,e);if(r1(t))return h1(t,e);if(a1(t))return HI(t,e);if(l1(t))return zI(t,e)}throw s1(t)}function Ef(t,e){return e?WI(t,e):Pi(t)}wf(function(t){return function(e){e===void 0&&(e=null),t(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=e}});function Qt(t,e){return On(function(n,i){var r=0;n.subscribe(yi(i,function(s){i.next(t.call(e,s,r++))}))})}function qI(t,e,n,i,r,s,o,a){var c=[],l=0,d=0,u=!1,f=function(){u&&!c.length&&!l&&e.complete()},p=function(h){return l<i?v(h):c.push(h)},v=function(h){l++;var y=!1;Pi(n(h,d++)).subscribe(yi(e,function(b){e.next(b)},function(){y=!0},void 0,function(){if(y)try{l--;for(var b=function(){var w=c.shift();o||v(w)};c.length&&l<i;)b();f()}catch(w){e.error(w)}}))};return t.subscribe(yi(e,p,function(){u=!0,f()})),function(){}}function m1(t,e,n){return n===void 0&&(n=1/0),ut(e)?m1(function(i,r){return Qt(function(s,o){return e(i,s,r,o)})(Pi(t(i,r)))},n):(typeof e=="number"&&(n=e),On(function(i,r){return qI(i,r,t,n)}))}function KI(t){return m1(Tf,t)}function GI(){return KI(1)}function $p(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return GI()(Ef(t,e1(t)))}function p1(t,e){return On(function(n,i){var r=0;n.subscribe(yi(i,function(s){return t.call(e,s,r++)&&i.next(s)}))})}function ZI(t,e,n,i,r){return function(s,o){var a=n,c=e,l=0;s.subscribe(yi(o,function(d){var u=l++;c=a?t(c,d,u):(a=!0,d),o.next(c)},r))}}function Kd(t,e){return On(ZI(t,e,arguments.length>=2,!0))}function YI(t){t===void 0&&(t={});var e=t.connector,n=e===void 0?function(){return new Yr}:e,i=t.resetOnError,r=i===void 0?!0:i,s=t.resetOnComplete,o=s===void 0?!0:s,a=t.resetOnRefCountZero,c=a===void 0?!0:a;return function(l){var d,u,f,p=0,v=!1,h=!1,y=function(){u==null||u.unsubscribe(),u=void 0},b=function(){y(),d=f=void 0,v=h=!1},w=function(){var C=d;b(),C==null||C.unsubscribe()};return On(function(C,S){p++,!h&&!v&&y();var x=f=f??n();S.add(function(){p--,p===0&&!h&&!v&&(u=hl(w,c))}),x.subscribe(S),!d&&p>0&&(d=new Qs({next:function(T){return x.next(T)},error:function(T){h=!0,y(),u=hl(b,r,T),x.error(T)},complete:function(){v=!0,y(),u=hl(b,o),x.complete()}}),Pi(C).subscribe(d))})(l)}}function hl(t,e){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];if(e===!0){t();return}if(e!==!1){var r=new Qs({next:function(){r.unsubscribe(),t()}});return Pi(e.apply(void 0,Xs([],Js(n)))).subscribe(r)}}function Ri(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=e1(t);return On(function(i,r){(n?$p(t,i,n):$p(t,i)).subscribe(r)})}function Hp(t){return On(function(e,n){Pi(t).subscribe(yi(n,function(){return n.complete()},qd)),!n.closed&&e.subscribe(n)})}function JI(t,e,n){var i=ut(t)||e||n?{next:t,error:e,complete:n}:t;return i?On(function(r,s){var o;(o=i.subscribe)===null||o===void 0||o.call(i);var a=!0;r.subscribe(yi(s,function(c){var l;(l=i.next)===null||l===void 0||l.call(i,c),s.next(c)},function(){var c;a=!1,(c=i.complete)===null||c===void 0||c.call(i),s.complete()},function(c){var l;a=!1,(l=i.error)===null||l===void 0||l.call(i,c),s.error(c)},function(){var c,l;a&&((c=i.unsubscribe)===null||c===void 0||c.call(i)),(l=i.finalize)===null||l===void 0||l.call(i)}))}):Tf}var XI=Object.defineProperty,QI=Object.defineProperties,eM=Object.getOwnPropertyDescriptors,zp=Object.getOwnPropertySymbols,tM=Object.prototype.hasOwnProperty,nM=Object.prototype.propertyIsEnumerable,Wp=(t,e,n)=>e in t?XI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,li=(t,e)=>{for(var n in e||(e={}))tM.call(e,n)&&Wp(t,n,e[n]);if(zp)for(var n of zp(e))nM.call(e,n)&&Wp(t,n,e[n]);return t},Fi=(t,e)=>QI(t,eM(e)),Jr=(t,e,n)=>new Promise((i,r)=>{var s=c=>{try{a(n.next(c))}catch(l){r(l)}},o=c=>{try{a(n.throw(c))}catch(l){r(l)}},a=c=>c.done?i(c.value):Promise.resolve(c.value).then(s,o);a((n=n.apply(t,e)).next())}),iM="lk";function Pf(t){return typeof t>"u"?!1:rM(t)||sM(t)}function rM(t){var e;return t?t.hasOwnProperty("participant")&&t.hasOwnProperty("source")&&t.hasOwnProperty("track")&&typeof((e=t.publication)==null?void 0:e.track)<"u":!1}function sM(t){return t?t.hasOwnProperty("participant")&&t.hasOwnProperty("source")&&t.hasOwnProperty("publication")&&typeof t.publication<"u":!1}function oM(t){return t?t.hasOwnProperty("participant")&&t.hasOwnProperty("source")&&typeof t.publication>"u":!1}function g1(t){if(typeof t=="string"||typeof t=="number")return`${t}`;if(oM(t))return`${t.participant.identity}_${t.source}_placeholder`;if(Pf(t))return`${t.participant.identity}_${t.publication.source}_${t.publication.trackSid}`;throw new Error(`Can't generate a id for the given track reference: ${t}`)}var aM=[U.ConnectionStateChanged,U.RoomMetadataChanged,U.ActiveSpeakersChanged,U.ConnectionQualityChanged,U.ParticipantConnected,U.ParticipantDisconnected,U.ParticipantPermissionsChanged,U.ParticipantMetadataChanged,U.ParticipantNameChanged,U.ParticipantAttributesChanged,U.TrackMuted,U.TrackUnmuted,U.TrackPublished,U.TrackUnpublished,U.TrackStreamStateChanged,U.TrackSubscriptionFailed,U.TrackSubscriptionPermissionChanged,U.TrackSubscriptionStatusChanged],v1=[...aM,U.LocalTrackPublished,U.LocalTrackUnpublished],cM=[Z.TrackPublished,Z.TrackUnpublished,Z.TrackMuted,Z.TrackUnmuted,Z.TrackStreamStateChanged,Z.TrackSubscribed,Z.TrackUnsubscribed,Z.TrackSubscriptionPermissionChanged,Z.TrackSubscriptionFailed,Z.LocalTrackPublished,Z.LocalTrackUnpublished],lM=[Z.ConnectionQualityChanged,Z.IsSpeakingChanged,Z.ParticipantMetadataChanged,Z.ParticipantPermissionsChanged,Z.TrackMuted,Z.TrackUnmuted,Z.TrackPublished,Z.TrackUnpublished,Z.TrackStreamStateChanged,Z.TrackSubscriptionFailed,Z.TrackSubscriptionPermissionChanged,Z.TrackSubscriptionStatusChanged];[...lM,Z.LocalTrackPublished,Z.LocalTrackUnpublished];var Mn=uI.getLogger("lk-components-js");Mn.setDefaultLevel("WARN");function dM(t,e){var n;return Fi(li({},t),{receivedAtMediaTimestamp:(n=e.rtpTimestamp)!=null?n:0,receivedAt:e.timestamp})}function uM(t,e,n){return[...t,...e].reduceRight((i,r)=>(i.find(s=>s.id===r.id)||i.unshift(r),i),[]).slice(0-n)}function y1(t){return typeof t=="object"}function b1(t){return Array.isArray(t)&&t.filter(y1).length>0}function x1(t){return`${iM}-${t}`}function fM(t){const e=Gd(t),n=C1(t.participant).pipe(Qt(()=>Gd(t)),Ri(e));return{className:x1(t.source===V.Source.Camera||t.source===V.Source.ScreenShare?"participant-media-video":"participant-media-audio"),trackObserver:n}}function Gd(t){if(Pf(t))return t.publication;{const{source:e,name:n,participant:i}=t;if(e&&n)return i.getTrackPublications().find(r=>r.source===e&&r.trackName===n);if(n)return i.getTrackPublicationByName(n);if(e)return i.getTrackPublication(e);throw new Error("At least one of source and name needs to be defined")}}function Rf(t,...e){return new mt(n=>{const i=()=>{n.next(t)};return e.forEach(r=>{t.on(r,i)}),()=>{e.forEach(r=>{t.off(r,i)})}}).pipe(Ri(t))}function S1(t,e){return new mt(n=>{const i=(...r)=>{n.next(r)};return t.on(e,i),()=>{t.off(e,i)}})}function hM(t){return S1(t,U.ConnectionStateChanged).pipe(Qt(([e])=>e),Ri(t.state))}function mM(t){return S1(t,U.DataReceived)}function pM(t){return Rf(t,U.AudioPlaybackStatusChanged).pipe(Qt(e=>({canPlayAudio:e.canPlaybackAudio})))}function w1(t,...e){return new mt(n=>{const i=()=>{n.next(t)};return e.forEach(r=>{t.on(r,i)}),()=>{e.forEach(r=>{t.off(r,i)})}}).pipe(Ri(t))}function C1(t){return w1(t,Z.TrackMuted,Z.TrackUnmuted,Z.ParticipantPermissionsChanged,Z.TrackPublished,Z.TrackUnpublished,Z.LocalTrackPublished,Z.LocalTrackUnpublished,Z.MediaDevicesError,Z.TrackSubscriptionStatusChanged).pipe(Qt(e=>{const{isMicrophoneEnabled:n,isCameraEnabled:i,isScreenShareEnabled:r}=e,s=e.getTrackPublication(V.Source.Microphone),o=e.getTrackPublication(V.Source.Camera);return{isCameraEnabled:i,isMicrophoneEnabled:n,isScreenShareEnabled:r,cameraTrack:o,microphoneTrack:s,participant:e}}))}function gM(t,e){return new mt(n=>{const i=(...r)=>{n.next(r)};return t.on(e,i),()=>{t.off(e,i)}})}function vM(t,e={}){var n;let i;const r=new mt(c=>(i=c,()=>a.unsubscribe())).pipe(Ri(Array.from(t.remoteParticipants.values()))),s=(n=e.additionalRoomEvents)!=null?n:v1,o=Array.from(new Set([U.ParticipantConnected,U.ParticipantDisconnected,U.ConnectionStateChanged,...s])),a=Rf(t,...o).subscribe(c=>i==null?void 0:i.next(Array.from(c.remoteParticipants.values())));return t.remoteParticipants.size>0&&(i==null||i.next(Array.from(t.remoteParticipants.values()))),r}function qp(t){return typeof t>"u"?new mt:gM(t,Z.AttributesChanged).pipe(Qt(([e])=>({changed:e,attributes:t.attributes})),Ri({changed:t.attributes,attributes:t.attributes}))}var k1={CHAT:"lk.chat",TRANSCRIPTION:"lk.transcription"},yM={CHAT:"lk-chat-topic"};function T1(t,e){return Jr(this,arguments,function*(n,i,r={}){const{reliable:s,destinationIdentities:o,topic:a}=r;yield n.publishData(i,{destinationIdentities:o,topic:a,reliable:s})})}function bM(t,e,n){const i=Array.isArray(e)?e:[e],r=mM(t).pipe(p1(([,,,a])=>e===void 0||a!==void 0&&i.includes(a)),Qt(([a,c,,l])=>({payload:a,topic:l,from:c})));let s;const o=new mt(a=>{s=a});return{messageObservable:r,isSendingObservable:o,send:(a,...c)=>Jr(this,[a,...c],function*(l,d={}){s.next(!0);try{yield T1(t.localParticipant,l,li({topic:i[0]},d))}finally{s.next(!1)}})}}var Io=new WeakMap;function xM(t){return t.ignoreLegacy==!0}var SM=t=>JSON.parse(new TextDecoder().decode(t)),wM=t=>new TextEncoder().encode(JSON.stringify(t));function CM(t,e){var n,i,r,s,o,a;const c=()=>{var x,T,E;return((x=t.serverInfo)==null?void 0:x.edition)===1||!!((T=t.serverInfo)!=null&&T.version)&&mi((E=t.serverInfo)==null?void 0:E.version,"1.8.2")>0},l=new Yr,d=(n=void 0)!=null?n:k1.CHAT,u=(i=void 0)!=null?i:yM.CHAT;let f=!1;Io.has(t)||(f=!0);const p=(r=Io.get(t))!=null?r:new Map,v=(s=p.get(d))!=null?s:new Yr;p.set(d,v),Io.set(t,p);const h=(o=void 0)!=null?o:SM;if(f){t.registerTextStreamHandler(d,(T,E)=>Jr(this,null,function*(){const{id:P,timestamp:_}=T.info;Ef(T).pipe(Kd((k,I)=>k+I),Qt(k=>({id:P,timestamp:_,message:k,from:t.getParticipantByIdentity(E.identity)}))).subscribe({next:k=>v.next(k)})}));const{messageObservable:x}=bM(t,[u]);x.pipe(Qt(T=>{const E=h(T.payload);return xM(E)?void 0:Fi(li({},E),{from:T.from})}),p1(T=>!!T),Hp(l)).subscribe(v)}const y=v.pipe(Kd((x,T)=>{if("id"in T&&x.find(E=>{var P,_;return((P=E.from)==null?void 0:P.identity)===((_=T.from)==null?void 0:_.identity)&&E.id===T.id})){const E=x.findIndex(P=>P.id===T.id);if(E>-1){const P=x[E];x[E]=Fi(li({},T),{timestamp:P.timestamp,editTimestamp:T.timestamp})}return[...x]}return[...x,T]},[]),Hp(l)),b=new EI(!1),w=(a=void 0)!=null?a:wM,C=(x,T)=>Jr(this,null,function*(){T||(T={}),T.topic!=null||(T.topic=d),b.next(!0);try{const E={id:(yield t.localParticipant.sendText(x,T)).id,timestamp:Date.now(),message:x},P=Fi(li({},E),{attachedFiles:T.attachments}),_=Fi(li({},P),{from:t.localParticipant,attributes:T.attributes});v.next(_);const k=w(Fi(li({},E),{ignoreLegacy:c()}));try{yield T1(t.localParticipant,k,{reliable:!0,topic:u})}catch(I){Mn.info("could not send message in legacy chat format",I)}return _}finally{b.next(!1)}});function S(){l.next(),l.complete(),v.complete(),Io.delete(t),t.unregisterTextStreamHandler(d)}return t.once(U.Disconnected,S),{messageObservable:y,isSendingObservable:b,send:C}}function kM(){const t=e=>Jr(this,null,function*(){Mn.info("Start Audio for room: ",e),yield e.startAudio()});return{className:x1("start-audio-button"),roomAudioPlaybackAllowedObservable:pM,handleStartAudioPlayback:t}}function Kp(t,e,n=!0){const i=[t.localParticipant,...Array.from(t.remoteParticipants.values())],r=[];return i.forEach(s=>{e.forEach(o=>{const a=Array.from(s.trackPublications.values()).filter(c=>c.source===o&&(!n||c.track)).map(c=>({participant:s,publication:c,source:c.source}));r.push(...a)})}),{trackReferences:r,participants:i}}function Gp(t,e,n=!1){const{sources:i,kind:r,name:s}=e;return Array.from(t.trackPublications.values()).filter(o=>(!i||i.includes(o.source))&&(!r||o.kind===r)&&(!s||o.trackName===s)&&(!n||o.track)).map(o=>({participant:t,publication:o,source:o.source}))}function TM(t,e,n){var i,r;const s=(i=n.additionalRoomEvents)!=null?i:v1,o=(r=n.onlySubscribed)!=null?r:!0,a=Array.from(new Set([U.ParticipantConnected,U.ParticipantDisconnected,U.ConnectionStateChanged,U.LocalTrackPublished,U.LocalTrackUnpublished,U.TrackPublished,U.TrackUnpublished,U.TrackSubscriptionStatusChanged,...s]).values());return Rf(t,...a).pipe(Qt(c=>{const l=Kp(c,e,o);return Mn.debug(`TrackReference[] was updated. (length ${l.trackReferences.length})`,l),l}),Ri(Kp(t,e,o)))}function EM(t,e){return w1(t,...cM).pipe(Qt(n=>{const i=Gp(n,e);return Mn.debug(`TrackReference[] was updated. (length ${i.length})`,i),i}),Ri(Gp(t,e)))}function E1(t,e){return new mt(n=>{const i=(...r)=>{n.next(r)};return t.on(e,i),()=>{t.off(e,i)}})}function PM(t){return E1(t,re.TranscriptionReceived)}function RM(t){return E1(t,re.TimeSyncUpdate).pipe(Qt(([e])=>e))}var ml=null,pl=null,AM=0;function Zp(){return ml||(ml=new Map),ml}function IM(){return pl||(pl=new WeakMap),pl}function MM(t,e){const n=IM();let i=n.get(t);return i||(i=`room_${AM++}`,n.set(t,i)),`${i}:${e}`}function _M(t,e){const n=MM(t,e),i=Zp(),r=i.get(n);if(r)return r;const s=new Yr;let o=[];const a="lk.segment_id",c=s.pipe(JI({subscribe:()=>{t.registerTextStreamHandler(e,(l,d)=>Jr(this,null,function*(){var u;const f=Ef(l).pipe(Kd((v,h)=>v+h,"")),p=!!((u=l.info.attributes)!=null&&u[a]);f.subscribe(v=>{const h=o.findIndex(y=>{var b,w;return y.streamInfo.id===l.info.id||p&&((b=y.streamInfo.attributes)==null?void 0:b[a])===((w=l.info.attributes)==null?void 0:w[a])});h!==-1?(o[h]=Fi(li({},o[h]),{text:v}),s.next([...o])):(o.push({text:v,participantInfo:d,streamInfo:l.info}),s.next([...o]))})}))},finalize:()=>{t.unregisterTextStreamHandler(e)}}),YI());return i.set(n,c),t.on(U.Disconnected,()=>{Zp().delete(n),o=[],s.next([])}),c}g.createContext(void 0);const NM=g.createContext(void 0);function P1(){return g.useContext(NM)}function R1(t){const e=P1(),n=t??e;if(!n)throw new Error("No TrackRef, make sure you are inside a TrackRefContext or pass the TrackRef explicitly");return n}const OM=g.createContext(void 0);function A1(){return g.useContext(OM)}const Da=g.createContext(void 0);function ho(){const t=g.useContext(Da);if(!t)throw Error("tried to access room context outside of livekit room component");return t}function I1(){return g.useContext(Da)}function mo(t){const e=I1(),n=t??e;if(!n)throw new Error("No room provided, make sure you are inside a Room context or pass the room explicitly");return n}g.createContext(void 0);function M1(t){var e,n,i="";if(typeof t=="string"||typeof t=="number")i+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(e=0;e<r;e++)t[e]&&(n=M1(t[e]))&&(i&&(i+=" "),i+=n)}else for(n in t)t[n]&&(i&&(i+=" "),i+=n);return i}function _1(){for(var t,e,n=0,i="",r=arguments.length;n<r;n++)(t=arguments[n])&&(e=M1(t))&&(i&&(i+=" "),i+=e);return i}function DM(...t){return(...e)=>{for(const n of t)if(typeof n=="function")try{n(...e)}catch(i){console.error(i)}}}function N1(...t){const e={...t[0]};for(let n=1;n<t.length;n++){const i=t[n];for(const r in i){const s=e[r],o=i[r];typeof s=="function"&&typeof o=="function"&&r[0]==="o"&&r[1]==="n"&&r.charCodeAt(2)>=65&&r.charCodeAt(2)<=90?e[r]=DM(s,o):(r==="className"||r==="UNSAFE_className")&&typeof s=="string"&&typeof o=="string"?e[r]=_1(s,o):e[r]=o!==void 0?o:s}}return e}function jM(t){return t!==void 0}function O1(...t){return N1(...t.filter(jM))}function LM(t,e,n){return g.Children.map(t,i=>g.isValidElement(i)&&g.Children.only(t)?(i.props.className&&(e??(e={}),e.className=_1(i.props.className,e.className),e.style={...i.props.style,...e.style}),g.cloneElement(i,{...e,key:n})):i)}function bi(t,e,n=!0){const[i,r]=g.useState(e);return g.useEffect(()=>{if(n&&r(e),typeof window>"u"||!t)return;const s=t.subscribe(r);return()=>s.unsubscribe()},[t,n]),i}function Af(t){const e=mo(t),n=g.useMemo(()=>hM(e),[e]);return bi(n,e.state)}function VM(t={}){const e=mo(t.room),[n,i]=g.useState(e.localParticipant),[r,s]=g.useState(n.isMicrophoneEnabled),[o,a]=g.useState(n.isCameraEnabled),[c,l]=g.useState(n.isScreenShareEnabled),[d,u]=g.useState(n.lastMicrophoneError),[f,p]=g.useState(n.lastCameraError),[v,h]=g.useState(void 0),[y,b]=g.useState(void 0),w=C=>{a(C.isCameraEnabled),s(C.isMicrophoneEnabled),l(C.isScreenShareEnabled),b(C.cameraTrack),h(C.microphoneTrack),u(C.participant.lastMicrophoneError),p(C.participant.lastCameraError),i(C.participant)};return g.useEffect(()=>{const C=C1(e.localParticipant).subscribe(w);return()=>C.unsubscribe()},[e]),{isMicrophoneEnabled:r,isScreenShareEnabled:c,isCameraEnabled:o,microphoneTrack:v,cameraTrack:y,lastMicrophoneError:d,lastCameraError:f,localParticipant:n}}function D1(t={}){const e=mo(t.room),[n,i]=g.useState([]);return g.useEffect(()=>{const r=vM(e,{additionalRoomEvents:t.updateOnlyOn}).subscribe(i);return()=>r.unsubscribe()},[e,JSON.stringify(t.updateOnlyOn)]),n}function FM({room:t,props:e}){const n=mo(t),{className:i,roomAudioPlaybackAllowedObservable:r,handleStartAudioPlayback:s}=g.useMemo(()=>kM(),[]),o=g.useMemo(()=>r(n),[n,r]),{canPlayAudio:a}=bi(o,{canPlayAudio:n.canPlaybackAudio});return{mergedProps:g.useMemo(()=>N1(e,{className:i,onClick:()=>{s(n)},style:{display:a?"none":"block"}}),[e,i,a,s,n]),canPlayAudio:a}}function If(t=[V.Source.Camera,V.Source.Microphone,V.Source.ScreenShare,V.Source.ScreenShareAudio,V.Source.Unknown],e={}){const n=mo(e.room),[i,r]=g.useState([]),[s,o]=g.useState([]),a=g.useMemo(()=>t.map(c=>y1(c)?c.source:c),[JSON.stringify(t)]);return g.useEffect(()=>{const c=TM(n,a,{additionalRoomEvents:e.updateOnlyOn,onlySubscribed:e.onlySubscribed}).subscribe(({trackReferences:l,participants:d})=>{Mn.debug("setting track bundles",l,d),r(l),o(d)});return()=>c.unsubscribe()},[n,JSON.stringify(e.onlySubscribed),JSON.stringify(e.updateOnlyOn),JSON.stringify(t)]),g.useMemo(()=>{if(b1(t)){const c=BM(t,s),l=Array.from(i);return s.forEach(d=>{c.has(d.identity)&&(c.get(d.identity)??[]).forEach(u=>{if(i.find(({participant:p,publication:v})=>d.identity===p.identity&&v.source===u))return;Mn.debug(`Add ${u} placeholder for participant ${d.identity}.`);const f={participant:d,source:u};l.push(f)})}),l}else return i},[i,s,t])}function UM(t,e){const n=new Set(t);for(const i of e)n.delete(i);return n}function BM(t,e){const n=new Map;if(b1(t)){const i=t.filter(r=>r.withPlaceholder).map(r=>r.source);e.forEach(r=>{const s=r.getTrackPublications().map(a=>{var c;return(c=a.track)==null?void 0:c.source}).filter(a=>a!==void 0),o=Array.from(UM(new Set(i),new Set(s)));o.length>0&&n.set(r.identity,o)})}return n}function $M(t){const e=ho(),n=Af(e),i=g.useMemo(()=>n===ge.Disconnected,[n]),r=g.useMemo(()=>CM(e),[e,t,i]),s=bi(r.isSendingObservable,!1),o=bi(r.messageObservable,[]);return{send:r.send,chatMessages:o,isSending:s}}const HM=t=>{const e=n=>{let i=1-Math.max(-100,Math.min(-10,n))*-1/100;return i=Math.sqrt(i),i};return t.map(n=>n===-1/0?0:e(n))},zM={bands:5,loPass:100,hiPass:600,updateInterval:32,analyserOptions:{fftSize:2048}};function WM(t,e={}){var n;const i=t instanceof V?t:(n=t==null?void 0:t.publication)==null?void 0:n.track,r={...zM,...e},[s,o]=g.useState(new Array(r.bands).fill(0));return g.useEffect(()=>{if(!i||!(i!=null&&i.mediaStream))return;const{analyser:a,cleanup:c}=aT(i,r.analyserOptions),l=a.frequencyBinCount,d=new Float32Array(l),u=setInterval(()=>{a.getFloatFrequencyData(d);let f=new Float32Array(d.length);for(let y=0;y<d.length;y++)f[y]=d[y];f=f.slice(e.loPass,e.hiPass);const p=HM(f),v=Math.ceil(p.length/r.bands),h=[];for(let y=0;y<r.bands;y++){const b=p.slice(y*v,(y+1)*v).reduce((w,C)=>w+=C,0);h.push(b/v)}o(h)},r.updateInterval);return()=>{c(),clearInterval(u)}},[i,i==null?void 0:i.mediaStream,JSON.stringify(e)]),s}function Yp(t,e){const n=A1(),i=D1({updateOnlyOn:[]}),r=g.useMemo(()=>e?i.find(o=>o.identity===e):n,[e,i,n]),s=g.useMemo(()=>{if(r)return EM(r,{sources:t})},[r,JSON.stringify(t)]);return bi(s,[])}function qM(t){var e,n,i;const r=g.useMemo(()=>{var s;return(s=t==null?void 0:t.publication)!=null&&s.track?RM(t==null?void 0:t.publication.track):void 0},[(e=t==null?void 0:t.publication)==null?void 0:e.track]);return bi(r,{timestamp:Date.now(),rtpTimestamp:(i=(n=t==null?void 0:t.publication)==null?void 0:n.track)==null?void 0:i.rtpTimestamp})}const KM={bufferSize:100};function GM(t,e){const n={...KM,...e},[i,r]=g.useState([]),s=qM(t),o=a=>{var c;(c=n.onTranscription)==null||c.call(n,a),r(l=>uM(l,a.map(d=>dM(d,s)),n.bufferSize))};return g.useEffect(()=>{if(!(t!=null&&t.publication))return;const a=PM(t.publication).subscribe(c=>{o(...c)});return()=>{a.unsubscribe()}},[t&&g1(t),o]),{segments:i}}function ZM(t={}){const e=A1(),n=t.participant??e,i=g.useMemo(()=>qp(n),[n]);return bi(i,{attributes:n==null?void 0:n.attributes})}const Jp="lk.agent.state";function j1(){const t=D1(),e=t.find(u=>u.kind===Yi.AGENT&&!("lk.publish_on_behalf"in u.attributes)),n=t.find(u=>u.kind===Yi.AGENT&&u.attributes["lk.publish_on_behalf"]===(e==null?void 0:e.identity)),i=Yp([V.Source.Microphone,V.Source.Camera],e==null?void 0:e.identity),r=Yp([V.Source.Microphone,V.Source.Camera],n==null?void 0:n.identity),s=i.find(u=>u.source===V.Source.Microphone)??r.find(u=>u.source===V.Source.Microphone),o=i.find(u=>u.source===V.Source.Camera)??r.find(u=>u.source===V.Source.Camera),{segments:a}=GM(s),c=Af(),{attributes:l}=ZM({participant:e}),d=g.useMemo(()=>c===ge.Disconnected?"disconnected":c===ge.Connecting||!e||!(l!=null&&l[Jp])?"connecting":l[Jp],[l,e,c]);return{agent:e,state:d,audioTrack:s,videoTrack:o,agentTranscriptions:a,agentAttributes:l}}function YM(t){const e=ho(),n=Af(e)===ge.Disconnected,i=g.useMemo(()=>_M(e,t),[e,t]);return{textStreams:bi(n?void 0:i,[])}}function JM(t){const{participantIdentities:e,trackSids:n}={},{textStreams:i}=YM(k1.TRANSCRIPTION);return g.useMemo(()=>i.filter(r=>e?e.includes(r.participantInfo.identity):!0).filter(r=>{var s;return n?n.includes(((s=r.streamInfo.attributes)==null?void 0:s["lk.transcribed_track_id"])??""):!0}),[i,e,n])}const Xp=g.forwardRef(function({label:t="Allow Audio",...e},n){const i=ho(),{mergedProps:r}=FM({room:i,props:e});return g.createElement("button",{ref:n,...r},t)});function L1(t,e={}){const[n,i]=g.useState(Gd(t)),[r,s]=g.useState(n==null?void 0:n.isMuted),[o,a]=g.useState(n==null?void 0:n.isSubscribed),[c,l]=g.useState(n==null?void 0:n.track),[d,u]=g.useState("landscape"),f=g.useRef(),{className:p,trackObserver:v}=g.useMemo(()=>fM(t),[t.participant.sid??t.participant.identity,t.source,Pf(t)&&t.publication.trackSid]);return g.useEffect(()=>{const h=v.subscribe(y=>{Mn.debug("update track",y),i(y),s(y==null?void 0:y.isMuted),a(y==null?void 0:y.isSubscribed),l(y==null?void 0:y.track)});return()=>h==null?void 0:h.unsubscribe()},[v]),g.useEffect(()=>{var h,y;return c&&(f.current&&c.detach(f.current),(h=e.element)!=null&&h.current&&!(t.participant.isLocal&&(c==null?void 0:c.kind)==="audio")&&c.attach(e.element.current)),f.current=(y=e.element)==null?void 0:y.current,()=>{f.current&&(c==null||c.detach(f.current))}},[c,e.element]),g.useEffect(()=>{var h,y;if(typeof((h=n==null?void 0:n.dimensions)==null?void 0:h.width)=="number"&&typeof((y=n==null?void 0:n.dimensions)==null?void 0:y.height)=="number"){const b=n.dimensions.width>n.dimensions.height?"landscape":"portrait";u(b)}},[n]),{publication:n,isMuted:r,isSubscribed:o,track:c,elementProps:O1(e.props,{className:p,"data-lk-local-participant":t.participant.isLocal,"data-lk-source":n==null?void 0:n.source,...(n==null?void 0:n.kind)==="video"&&{"data-lk-orientation":d}})}}var gl,Qp;function XM(){if(Qp)return gl;Qp=1;var t="Expected a function",e=NaN,n="[object Symbol]",i=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt,c=typeof Ro=="object"&&Ro&&Ro.Object===Object&&Ro,l=typeof self=="object"&&self&&self.Object===Object&&self,d=c||l||Function("return this")(),u=Object.prototype,f=u.toString,p=Math.max,v=Math.min,h=function(){return d.Date.now()};function y(x,T,E){var P,_,k,I,N,K,J=0,se=!1,ie=!1,X=!0;if(typeof x!="function")throw new TypeError(t);T=S(T)||0,b(E)&&(se=!!E.leading,ie="maxWait"in E,k=ie?p(S(E.maxWait)||0,T):k,X="trailing"in E?!!E.trailing:X);function O(D){var $=P,Q=_;return P=_=void 0,J=D,I=x.apply(Q,$),I}function oe(D){return J=D,N=setTimeout(te,T),se?O(D):I}function L(D){var $=D-K,Q=D-J,W=T-$;return ie?v(W,k-Q):W}function F(D){var $=D-K,Q=D-J;return K===void 0||$>=T||$<0||ie&&Q>=k}function te(){var D=h();if(F(D))return j(D);N=setTimeout(te,L(D))}function j(D){return N=void 0,X&&P?O(D):(P=_=void 0,I)}function q(){N!==void 0&&clearTimeout(N),J=0,P=K=_=N=void 0}function ee(){return N===void 0?I:j(h())}function G(){var D=h(),$=F(D);if(P=arguments,_=this,K=D,$){if(N===void 0)return oe(K);if(ie)return N=setTimeout(te,T),O(K)}return N===void 0&&(N=setTimeout(te,T)),I}return G.cancel=q,G.flush=ee,G}function b(x){var T=typeof x;return!!x&&(T=="object"||T=="function")}function w(x){return!!x&&typeof x=="object"}function C(x){return typeof x=="symbol"||w(x)&&f.call(x)==n}function S(x){if(typeof x=="number")return x;if(C(x))return e;if(b(x)){var T=typeof x.valueOf=="function"?x.valueOf():x;x=b(T)?T+"":T}if(typeof x!="string")return x===0?x:+x;x=x.replace(i,"");var E=s.test(x);return E||o.test(x)?a(x.slice(2),E?2:8):r.test(x)?e:+x}return gl=y,gl}var QM=XM();const eg=Zb(QM);function e4(t){const e=R.useRef(t);e.current=t,R.useEffect(()=>()=>{e.current()},[])}function t4(t,e=500,n){const i=R.useRef();e4(()=>{i.current&&i.current.cancel()});const r=R.useMemo(()=>{const s=eg(t,e,n),o=(...a)=>s(...a);return o.cancel=()=>{s.cancel()},o.isPending=()=>!!i.current,o.flush=()=>s.flush(),o},[t,e,n]);return R.useEffect(()=>{i.current=eg(t,e,n)},[t,e,n]),r}function n4(t,e,n){const i=(l,d)=>l===d,r=t instanceof Function?t():t,[s,o]=R.useState(r),a=R.useRef(r),c=t4(o,e,n);return i(a.current,r)||(c(r),a.current=r),[s,c]}function i4({threshold:t=0,root:e=null,rootMargin:n="0%",freezeOnceVisible:i=!1,initialIsIntersecting:r=!1,onChange:s}={}){var o;const[a,c]=R.useState(null),[l,d]=R.useState(()=>({isIntersecting:r,entry:void 0})),u=R.useRef();u.current=s;const f=((o=l.entry)==null?void 0:o.isIntersecting)&&i;R.useEffect(()=>{if(!a||!("IntersectionObserver"in window)||f)return;const h=new IntersectionObserver(y=>{const b=Array.isArray(h.thresholds)?h.thresholds:[h.thresholds];y.forEach(w=>{const C=w.isIntersecting&&b.some(S=>w.intersectionRatio>=S);d({isIntersecting:C,entry:w}),u.current&&u.current(C,w)})},{threshold:t,root:e,rootMargin:n});return h.observe(a),()=>{h.disconnect()}},[a,JSON.stringify(t),e,n,f,i]);const p=R.useRef(null);R.useEffect(()=>{var h;!a&&(h=l.entry)!=null&&h.target&&!i&&!f&&p.current!==l.entry.target&&(p.current=l.entry.target,d({isIntersecting:r,entry:void 0}))},[a,l.entry,i,f,r]);const v=[c,!!l.isIntersecting,l.entry];return v.ref=v[0],v.isIntersecting=v[1],v.entry=v[2],v}const Mf=g.forwardRef(function({onTrackClick:t,onClick:e,onSubscriptionStatusChanged:n,trackRef:i,manageSubscription:r,...s},o){const a=R1(i),c=g.useRef(null);g.useImperativeHandle(o,()=>c.current);const l=i4({root:c.current}),[d]=n4(l,3e3);g.useEffect(()=>{r&&a.publication instanceof Pa&&(d==null?void 0:d.isIntersecting)===!1&&(l==null?void 0:l.isIntersecting)===!1&&a.publication.setSubscribed(!1)},[d,a,r]),g.useEffect(()=>{r&&a.publication instanceof Pa&&(l==null?void 0:l.isIntersecting)===!0&&a.publication.setSubscribed(!0)},[l,a,r]);const{elementProps:u,publication:f,isSubscribed:p}=L1(a,{element:c,props:s});g.useEffect(()=>{n==null||n(!!p)},[p,n]);const v=h=>{e==null||e(h),t==null||t({participant:a==null?void 0:a.participant,track:f})};return g.createElement("video",{ref:c,...u,muted:!0,onClick:v})}),r4=g.forwardRef(function({trackRef:t,onSubscriptionStatusChanged:e,volume:n,...i},r){const s=R1(t),o=g.useRef(null);g.useImperativeHandle(r,()=>o.current);const{elementProps:a,isSubscribed:c,track:l,publication:d}=L1(s,{element:o,props:i});return g.useEffect(()=>{e==null||e(!!c)},[c,e]),g.useEffect(()=>{l===void 0||n===void 0||(l instanceof my?l.setVolume(n):Mn.warn("Volume can only be set on remote audio tracks."))},[n,l]),g.useEffect(()=>{d===void 0||i.muted===void 0||(d instanceof Pa?d.setEnabled(!i.muted):Mn.warn("Can only call setEnabled on remote track publications."))},[i.muted,d,l]),g.createElement("audio",{ref:o,...a})});function tg({volume:t,muted:e}){const n=If([V.Source.Microphone,V.Source.ScreenShareAudio,V.Source.Unknown],{updateOnlyOn:[],onlySubscribed:!0}).filter(i=>!i.participant.isLocal&&i.publication.kind===V.Kind.Audio);return g.createElement("div",{style:{display:"none"}},n.map(i=>g.createElement(r4,{key:g1(i),trackRef:i,volume:t,muted:e})))}const s4=t=>{const e=[];for(let n=0;n<t;n++)e.push([n,t-1-n]);return e},ng=t=>[[Math.floor(t/2)],[-1]],o4=(t,e,n)=>{const[i,r]=R.useState(0),[s,o]=R.useState([[]]);R.useEffect(()=>{if(t==="thinking")o(ng(e));else if(t==="connecting"||t==="initializing"){const c=[...s4(e)];o(c)}else o(t==="listening"?ng(e):t===void 0||t==="speaking"?[new Array(e).fill(0).map((c,l)=>l)]:[[]]);r(0)},[t,e]);const a=R.useRef(null);return R.useEffect(()=>{let c=performance.now();const l=d=>{d-c>=n&&(r(u=>u+1),c=d),a.current=requestAnimationFrame(l)};return a.current=requestAnimationFrame(l),()=>{a.current!==null&&cancelAnimationFrame(a.current)}},[n,e,t,s.length]),s[i%s.length]},a4=new Map([["connecting",2e3],["initializing",2e3],["listening",500],["thinking",150]]),c4=(t,e)=>{if(t===void 0)return 1e3;let n=a4.get(t);if(n)switch(t){case"connecting":n/=e;break}return n},V1=g.forwardRef(function({state:t,options:e,barCount:n=15,trackRef:i,children:r,...s},o){const a=O1(s,{className:"lk-audio-bar-visualizer"});let c=P1();i&&(c=i);const l=WM(c,{bands:n,loPass:100,hiPass:200}),d=(e==null?void 0:e.minHeight)??20,u=(e==null?void 0:e.maxHeight)??100,f=o4(t,n,c4(t,n)??100);return g.createElement("div",{ref:o,...a,"data-lk-va-state":t},l.map((p,v)=>r?LM(r,{"data-lk-highlighted":f.includes(v),"data-lk-bar-index":v,className:"lk-audio-bar",style:{height:`${Math.min(u,Math.max(d,p*100+5))}%`}}):g.createElement("span",{key:v,"data-lk-highlighted":f.includes(v),"data-lk-bar-index":v,className:`lk-audio-bar ${f.includes(v)&&"lk-highlighted"}`,style:{height:`${Math.min(u,Math.max(d,p*100+5))}%`}})))});function l4(t){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}Array(12).fill(0);let Zd=1;class d4{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const n=this.subscribers.indexOf(e);this.subscribers.splice(n,1)}),this.publish=e=>{this.subscribers.forEach(n=>n(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var n;const{message:i,...r}=e,s=typeof(e==null?void 0:e.id)=="number"||((n=e.id)==null?void 0:n.length)>0?e.id:Zd++,o=this.toasts.find(c=>c.id===s),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),o?this.toasts=this.toasts.map(c=>c.id===s?(this.publish({...c,...e,id:s,title:i}),{...c,...e,id:s,dismissible:a,title:i}):c):this.addToast({title:i,...r,dismissible:a,id:s}),s},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:e,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(i=>i({id:n.id,dismiss:!0}))}),e),this.message=(e,n)=>this.create({...n,message:e}),this.error=(e,n)=>this.create({...n,message:e,type:"error"}),this.success=(e,n)=>this.create({...n,type:"success",message:e}),this.info=(e,n)=>this.create({...n,type:"info",message:e}),this.warning=(e,n)=>this.create({...n,type:"warning",message:e}),this.loading=(e,n)=>this.create({...n,type:"loading",message:e}),this.promise=(e,n)=>{if(!n)return;let i;n.loading!==void 0&&(i=this.create({...n,promise:e,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const r=Promise.resolve(e instanceof Function?e():e);let s=i!==void 0,o;const a=r.then(async l=>{if(o=["resolve",l],R.isValidElement(l))s=!1,this.create({id:i,type:"default",message:l});else if(f4(l)&&!l.ok){s=!1;const u=typeof n.error=="function"?await n.error(`HTTP error! status: ${l.status}`):n.error,f=typeof n.description=="function"?await n.description(`HTTP error! status: ${l.status}`):n.description,v=typeof u=="object"&&!R.isValidElement(u)?u:{message:u};this.create({id:i,type:"error",description:f,...v})}else if(l instanceof Error){s=!1;const u=typeof n.error=="function"?await n.error(l):n.error,f=typeof n.description=="function"?await n.description(l):n.description,v=typeof u=="object"&&!R.isValidElement(u)?u:{message:u};this.create({id:i,type:"error",description:f,...v})}else if(n.success!==void 0){s=!1;const u=typeof n.success=="function"?await n.success(l):n.success,f=typeof n.description=="function"?await n.description(l):n.description,v=typeof u=="object"&&!R.isValidElement(u)?u:{message:u};this.create({id:i,type:"success",description:f,...v})}}).catch(async l=>{if(o=["reject",l],n.error!==void 0){s=!1;const d=typeof n.error=="function"?await n.error(l):n.error,u=typeof n.description=="function"?await n.description(l):n.description,p=typeof d=="object"&&!R.isValidElement(d)?d:{message:d};this.create({id:i,type:"error",description:u,...p})}}).finally(()=>{s&&(this.dismiss(i),i=void 0),n.finally==null||n.finally.call(n)}),c=()=>new Promise((l,d)=>a.then(()=>o[0]==="reject"?d(o[1]):l(o[1])).catch(d));return typeof i!="string"&&typeof i!="number"?{unwrap:c}:Object.assign(i,{unwrap:c})},this.custom=(e,n)=>{const i=(n==null?void 0:n.id)||Zd++;return this.create({jsx:e(i),id:i,...n}),i},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Zt=new d4,u4=(t,e)=>{const n=(e==null?void 0:e.id)||Zd++;return Zt.addToast({title:t,...e,id:n}),n},f4=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",h4=u4,m4=()=>Zt.toasts,p4=()=>Zt.getActiveToasts(),F1=Object.assign(h4,{success:Zt.success,info:Zt.info,warning:Zt.warning,error:Zt.error,custom:Zt.custom,message:Zt.message,promise:Zt.promise,dismiss:Zt.dismiss,loading:Zt.loading},{getHistory:m4,getToasts:p4});l4("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");const pn=g.forwardRef((t,e)=>{const{alt:n,color:i="currentColor",size:r="1em",weight:s="regular",mirrored:o=!1,children:a,weights:c,...l}=t;return g.createElement("svg",{ref:e,xmlns:"http://www.w3.org/2000/svg",width:r,height:r,fill:i,viewBox:"0 0 256 256",transform:o?"scale(-1, 1)":void 0,...l},!!n&&g.createElement("title",null,n),a,c.get(s))});pn.displayName="SSRBase";const g4=new Map([["bold",g.createElement(g.Fragment,null,g.createElement("path",{d:"M216.49,104.49l-80,80a12,12,0,0,1-17,0l-80-80a12,12,0,0,1,17-17L128,159l71.51-71.52a12,12,0,0,1,17,17Z"}))],["duotone",g.createElement(g.Fragment,null,g.createElement("path",{d:"M208,96l-80,80L48,96Z",opacity:"0.2"}),g.createElement("path",{d:"M215.39,92.94A8,8,0,0,0,208,88H48a8,8,0,0,0-5.66,13.66l80,80a8,8,0,0,0,11.32,0l80-80A8,8,0,0,0,215.39,92.94ZM128,164.69,67.31,104H188.69Z"}))],["fill",g.createElement(g.Fragment,null,g.createElement("path",{d:"M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,48,88H208a8,8,0,0,1,5.66,13.66Z"}))],["light",g.createElement(g.Fragment,null,g.createElement("path",{d:"M212.24,100.24l-80,80a6,6,0,0,1-8.48,0l-80-80a6,6,0,0,1,8.48-8.48L128,167.51l75.76-75.75a6,6,0,0,1,8.48,8.48Z"}))],["regular",g.createElement(g.Fragment,null,g.createElement("path",{d:"M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"}))],["thin",g.createElement(g.Fragment,null,g.createElement("path",{d:"M210.83,98.83l-80,80a4,4,0,0,1-5.66,0l-80-80a4,4,0,0,1,5.66-5.66L128,170.34l77.17-77.17a4,4,0,1,1,5.66,5.66Z"}))]]),_f=g.forwardRef((t,e)=>g.createElement(pn,{ref:e,...t,weights:g4}));_f.displayName="CaretDownIcon";const v4=new Map([["bold",g.createElement(g.Fragment,null,g.createElement("path",{d:"M216.49,168.49a12,12,0,0,1-17,0L128,97,56.49,168.49a12,12,0,0,1-17-17l80-80a12,12,0,0,1,17,0l80,80A12,12,0,0,1,216.49,168.49Z"}))],["duotone",g.createElement(g.Fragment,null,g.createElement("path",{d:"M208,160H48l80-80Z",opacity:"0.2"}),g.createElement("path",{d:"M213.66,154.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,48,168H208a8,8,0,0,0,5.66-13.66ZM67.31,152,128,91.31,188.69,152Z"}))],["fill",g.createElement(g.Fragment,null,g.createElement("path",{d:"M215.39,163.06A8,8,0,0,1,208,168H48a8,8,0,0,1-5.66-13.66l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,215.39,163.06Z"}))],["light",g.createElement(g.Fragment,null,g.createElement("path",{d:"M212.24,164.24a6,6,0,0,1-8.48,0L128,88.49,52.24,164.24a6,6,0,0,1-8.48-8.48l80-80a6,6,0,0,1,8.48,0l80,80A6,6,0,0,1,212.24,164.24Z"}))],["regular",g.createElement(g.Fragment,null,g.createElement("path",{d:"M213.66,165.66a8,8,0,0,1-11.32,0L128,91.31,53.66,165.66a8,8,0,0,1-11.32-11.32l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,213.66,165.66Z"}))],["thin",g.createElement(g.Fragment,null,g.createElement("path",{d:"M210.83,162.83a4,4,0,0,1-5.66,0L128,85.66,50.83,162.83a4,4,0,0,1-5.66-5.66l80-80a4,4,0,0,1,5.66,0l80,80A4,4,0,0,1,210.83,162.83Z"}))]]),U1=g.forwardRef((t,e)=>g.createElement(pn,{ref:e,...t,weights:v4}));U1.displayName="CaretUpIcon";const y4=new Map([["bold",g.createElement(g.Fragment,null,g.createElement("path",{d:"M216,44H40A20,20,0,0,0,20,64V224A19.82,19.82,0,0,0,31.56,242.1a20.14,20.14,0,0,0,8.49,1.9,19.91,19.91,0,0,0,12.82-4.72l.12-.11L84.47,212H216a20,20,0,0,0,20-20V64A20,20,0,0,0,216,44Zm-4,144H80a11.93,11.93,0,0,0-7.84,2.92L44,215.23V68H212ZM84,108A12,12,0,0,1,96,96h64a12,12,0,1,1,0,24H96A12,12,0,0,1,84,108Zm0,40a12,12,0,0,1,12-12h64a12,12,0,0,1,0,24H96A12,12,0,0,1,84,148Z"}))],["duotone",g.createElement(g.Fragment,null,g.createElement("path",{d:"M224,64V192a8,8,0,0,1-8,8H80L45.15,230.11A8,8,0,0,1,32,224V64a8,8,0,0,1,8-8H216A8,8,0,0,1,224,64Z",opacity:"0.2"}),g.createElement("path",{d:"M216,48H40A16,16,0,0,0,24,64V224a15.85,15.85,0,0,0,9.24,14.5A16.13,16.13,0,0,0,40,240a15.89,15.89,0,0,0,10.25-3.78l.09-.07L83,208H216a16,16,0,0,0,16-16V64A16,16,0,0,0,216,48ZM40,224h0ZM216,192H80a8,8,0,0,0-5.23,1.95L40,224V64H216ZM88,112a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H96A8,8,0,0,1,88,112Zm0,32a8,8,0,0,1,8-8h64a8,8,0,1,1,0,16H96A8,8,0,0,1,88,144Z"}))],["fill",g.createElement(g.Fragment,null,g.createElement("path",{d:"M216,48H40A16,16,0,0,0,24,64V224a15.84,15.84,0,0,0,9.25,14.5A16.05,16.05,0,0,0,40,240a15.89,15.89,0,0,0,10.25-3.78l.09-.07L83,208H216a16,16,0,0,0,16-16V64A16,16,0,0,0,216,48ZM160,152H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm0-32H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Z"}))],["light",g.createElement(g.Fragment,null,g.createElement("path",{d:"M216,50H40A14,14,0,0,0,26,64V224a13.88,13.88,0,0,0,8.09,12.69A14.11,14.11,0,0,0,40,238a13.87,13.87,0,0,0,9-3.31l.06-.05L82.23,206H216a14,14,0,0,0,14-14V64A14,14,0,0,0,216,50Zm2,142a2,2,0,0,1-2,2H80a6,6,0,0,0-3.92,1.46L41.26,225.53A2,2,0,0,1,38,224V64a2,2,0,0,1,2-2H216a2,2,0,0,1,2,2Zm-52-80a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,112Zm0,32a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,144Z"}))],["regular",g.createElement(g.Fragment,null,g.createElement("path",{d:"M216,48H40A16,16,0,0,0,24,64V224a15.85,15.85,0,0,0,9.24,14.5A16.13,16.13,0,0,0,40,240a15.89,15.89,0,0,0,10.25-3.78l.09-.07L83,208H216a16,16,0,0,0,16-16V64A16,16,0,0,0,216,48ZM40,224h0ZM216,192H80a8,8,0,0,0-5.23,1.95L40,224V64H216ZM88,112a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H96A8,8,0,0,1,88,112Zm0,32a8,8,0,0,1,8-8h64a8,8,0,1,1,0,16H96A8,8,0,0,1,88,144Z"}))],["thin",g.createElement(g.Fragment,null,g.createElement("path",{d:"M216,52H40A12,12,0,0,0,28,64V224a11.89,11.89,0,0,0,6.93,10.88A12.17,12.17,0,0,0,40,236a11.89,11.89,0,0,0,7.69-2.83l0,0L81.49,204H216a12,12,0,0,0,12-12V64A12,12,0,0,0,216,52Zm4,140a4,4,0,0,1-4,4H80a4,4,0,0,0-2.62,1L42.56,227.06A4,4,0,0,1,36,224V64a4,4,0,0,1,4-4H216a4,4,0,0,1,4,4Zm-56-80a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,112Zm0,32a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,144Z"}))]]),B1=g.forwardRef((t,e)=>g.createElement(pn,{ref:e,...t,weights:y4}));B1.displayName="ChatTextIcon";const b4=new Map([["bold",g.createElement(g.Fragment,null,g.createElement("path",{d:"M232.49,80.49l-128,128a12,12,0,0,1-17,0l-56-56a12,12,0,1,1,17-17L96,183,215.51,63.51a12,12,0,0,1,17,17Z"}))],["duotone",g.createElement(g.Fragment,null,g.createElement("path",{d:"M232,56V200a16,16,0,0,1-16,16H40a16,16,0,0,1-16-16V56A16,16,0,0,1,40,40H216A16,16,0,0,1,232,56Z",opacity:"0.2"}),g.createElement("path",{d:"M205.66,85.66l-96,96a8,8,0,0,1-11.32,0l-40-40a8,8,0,0,1,11.32-11.32L104,164.69l90.34-90.35a8,8,0,0,1,11.32,11.32Z"}))],["fill",g.createElement(g.Fragment,null,g.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM205.66,85.66l-96,96a8,8,0,0,1-11.32,0l-40-40a8,8,0,0,1,11.32-11.32L104,164.69l90.34-90.35a8,8,0,0,1,11.32,11.32Z"}))],["light",g.createElement(g.Fragment,null,g.createElement("path",{d:"M228.24,76.24l-128,128a6,6,0,0,1-8.48,0l-56-56a6,6,0,0,1,8.48-8.48L96,191.51,219.76,67.76a6,6,0,0,1,8.48,8.48Z"}))],["regular",g.createElement(g.Fragment,null,g.createElement("path",{d:"M229.66,77.66l-128,128a8,8,0,0,1-11.32,0l-56-56a8,8,0,0,1,11.32-11.32L96,188.69,218.34,66.34a8,8,0,0,1,11.32,11.32Z"}))],["thin",g.createElement(g.Fragment,null,g.createElement("path",{d:"M226.83,74.83l-128,128a4,4,0,0,1-5.66,0l-56-56a4,4,0,0,1,5.66-5.66L96,194.34,221.17,69.17a4,4,0,1,1,5.66,5.66Z"}))]]),$1=g.forwardRef((t,e)=>g.createElement(pn,{ref:e,...t,weights:b4}));$1.displayName="CheckIcon";const x4=new Map([["bold",g.createElement(g.Fragment,null,g.createElement("path",{d:"M128,180a52.06,52.06,0,0,0,52-52V64A52,52,0,0,0,76,64v64A52.06,52.06,0,0,0,128,180ZM100,64a28,28,0,0,1,56,0v64a28,28,0,0,1-56,0Zm40,155.22V240a12,12,0,0,1-24,0V219.22A92.14,92.14,0,0,1,36,128a12,12,0,0,1,24,0,68,68,0,0,0,136,0,12,12,0,0,1,24,0A92.14,92.14,0,0,1,140,219.22Z"}))],["duotone",g.createElement(g.Fragment,null,g.createElement("path",{d:"M168,64v64a40,40,0,0,1-40,40h0a40,40,0,0,1-40-40V64a40,40,0,0,1,40-40h0A40,40,0,0,1,168,64Z",opacity:"0.2"}),g.createElement("path",{d:"M128,176a48.05,48.05,0,0,0,48-48V64a48,48,0,0,0-96,0v64A48.05,48.05,0,0,0,128,176ZM96,64a32,32,0,0,1,64,0v64a32,32,0,0,1-64,0Zm40,143.6V240a8,8,0,0,1-16,0V207.6A80.11,80.11,0,0,1,48,128a8,8,0,0,1,16,0,64,64,0,0,0,128,0,8,8,0,0,1,16,0A80.11,80.11,0,0,1,136,207.6Z"}))],["fill",g.createElement(g.Fragment,null,g.createElement("path",{d:"M80,128V64a48,48,0,0,1,96,0v64a48,48,0,0,1-96,0Zm128,0a8,8,0,0,0-16,0,64,64,0,0,1-128,0,8,8,0,0,0-16,0,80.11,80.11,0,0,0,72,79.6V240a8,8,0,0,0,16,0V207.6A80.11,80.11,0,0,0,208,128Z"}))],["light",g.createElement(g.Fragment,null,g.createElement("path",{d:"M128,174a46.06,46.06,0,0,0,46-46V64a46,46,0,0,0-92,0v64A46.06,46.06,0,0,0,128,174ZM94,64a34,34,0,0,1,68,0v64a34,34,0,0,1-68,0Zm40,141.75V240a6,6,0,0,1-12,0V205.75A78.09,78.09,0,0,1,50,128a6,6,0,0,1,12,0,66,66,0,0,0,132,0,6,6,0,0,1,12,0A78.09,78.09,0,0,1,134,205.75Z"}))],["regular",g.createElement(g.Fragment,null,g.createElement("path",{d:"M128,176a48.05,48.05,0,0,0,48-48V64a48,48,0,0,0-96,0v64A48.05,48.05,0,0,0,128,176ZM96,64a32,32,0,0,1,64,0v64a32,32,0,0,1-64,0Zm40,143.6V240a8,8,0,0,1-16,0V207.6A80.11,80.11,0,0,1,48,128a8,8,0,0,1,16,0,64,64,0,0,0,128,0,8,8,0,0,1,16,0A80.11,80.11,0,0,1,136,207.6Z"}))],["thin",g.createElement(g.Fragment,null,g.createElement("path",{d:"M128,172a44.05,44.05,0,0,0,44-44V64a44,44,0,0,0-88,0v64A44.05,44.05,0,0,0,128,172ZM92,64a36,36,0,0,1,72,0v64a36,36,0,0,1-72,0Zm40,139.89V240a4,4,0,0,1-8,0V203.89A76.09,76.09,0,0,1,52,128a4,4,0,0,1,8,0,68,68,0,0,0,136,0,4,4,0,0,1,8,0A76.09,76.09,0,0,1,132,203.89Z"}))]]),H1=g.forwardRef((t,e)=>g.createElement(pn,{ref:e,...t,weights:x4}));H1.displayName="MicrophoneIcon";const S4=new Map([["bold",g.createElement(g.Fragment,null,g.createElement("path",{d:"M56.88,39.93A12,12,0,1,0,39.12,56.07L76,96.64V128a52,52,0,0,0,72.11,48l11.26,12.39A67.34,67.34,0,0,1,128,196a68.07,68.07,0,0,1-68-68,12,12,0,0,0-24,0,92.14,92.14,0,0,0,80,91.22V240a12,12,0,0,0,24,0V219.23a90.39,90.39,0,0,0,35.92-12.68l23.2,25.52a12,12,0,0,0,17.76-16.14ZM128,156a28,28,0,0,1-28-28v-5l29.9,32.89C129.27,156,128.64,156,128,156Zm63-2.42A67.63,67.63,0,0,0,196,128a12,12,0,0,1,24,0,91.48,91.48,0,0,1-6.74,34.61,12,12,0,0,1-22.23-9ZM85.7,33.75A52,52,0,0,1,180,64v56.54a12,12,0,0,1-24,0V64a28,28,0,0,0-50.79-16.28,12,12,0,0,1-19.51-14Z"}))],["duotone",g.createElement(g.Fragment,null,g.createElement("path",{d:"M168,64v64a40,40,0,0,1-40,40h0a40,40,0,0,1-40-40V64a40,40,0,0,1,40-40h0A40,40,0,0,1,168,64Z",opacity:"0.2"}),g.createElement("path",{d:"M213.92,218.62l-160-176A8,8,0,0,0,42.08,53.38L80,95.09V128a48,48,0,0,0,69.11,43.12l11.1,12.2A63.41,63.41,0,0,1,128,192a64.07,64.07,0,0,1-64-64,8,8,0,0,0-16,0,80.11,80.11,0,0,0,72,79.6V240a8,8,0,0,0,16,0V207.59a78.83,78.83,0,0,0,35.16-12.22l30.92,34a8,8,0,1,0,11.84-10.76ZM128,160a32,32,0,0,1-32-32V112.69l41.66,45.82A32,32,0,0,1,128,160Zm57.52-3.91A63.32,63.32,0,0,0,192,128a8,8,0,0,1,16,0,79.16,79.16,0,0,1-8.11,35.12,8,8,0,0,1-7.19,4.49,7.88,7.88,0,0,1-3.51-.82A8,8,0,0,1,185.52,156.09ZM84,44.87A48,48,0,0,1,176,64v64a49.19,49.19,0,0,1-.26,5,8,8,0,0,1-8,7.17,8.13,8.13,0,0,1-.84,0,8,8,0,0,1-7.12-8.79c.11-1.1.17-2.24.17-3.36V64A32,32,0,0,0,98.64,51.25,8,8,0,1,1,84,44.87Z"}))],["fill",g.createElement(g.Fragment,null,g.createElement("path",{d:"M213.38,229.92a8,8,0,0,1-11.3-.54l-30.92-34A78.83,78.83,0,0,1,136,207.59V240a8,8,0,0,1-16,0V207.6A80.11,80.11,0,0,1,48,128a8,8,0,0,1,16,0,64.07,64.07,0,0,0,64,64,63.41,63.41,0,0,0,32.21-8.68l-11.1-12.2A48,48,0,0,1,80,128V95.09L42.08,53.38A8,8,0,0,1,53.92,42.62l160,176A8,8,0,0,1,213.38,229.92Zm-24.19-63.13a7.88,7.88,0,0,0,3.51.82,8,8,0,0,0,7.19-4.49A79.16,79.16,0,0,0,208,128a8,8,0,0,0-16,0,63.32,63.32,0,0,1-6.48,28.09A8,8,0,0,0,189.19,166.79Zm-27.33-29.22A8,8,0,0,0,175.74,133a49.49,49.49,0,0,0,.26-5V64A48,48,0,0,0,84,44.87a8,8,0,0,0,1.41,8.57Z"}))],["light",g.createElement(g.Fragment,null,g.createElement("path",{d:"M212.44,220,52.44,44A6,6,0,0,0,43.56,52L82,94.32V128a46,46,0,0,0,67.56,40.64l13.75,15.12A65.26,65.26,0,0,1,128,194a66.08,66.08,0,0,1-66-66,6,6,0,0,0-12,0,78.09,78.09,0,0,0,72,77.75V240a6,6,0,0,0,12,0V205.77a76.93,76.93,0,0,0,37.48-13L203.56,228a6,6,0,0,0,8.88-8.08ZM128,162a34,34,0,0,1-34-34V107.52l47.12,51.84A33.82,33.82,0,0,1,128,162Zm59.32-5A65.38,65.38,0,0,0,194,128a6,6,0,0,1,12,0,77.33,77.33,0,0,1-7.9,34.25A6,6,0,1,1,187.32,157ZM85.8,45.67A46,46,0,0,1,174,64v64a45.17,45.17,0,0,1-.25,4.81,6,6,0,0,1-6,5.38q-.31,0-.63,0a6,6,0,0,1-5.34-6.59A35.41,35.41,0,0,0,162,128V64A34,34,0,0,0,96.8,50.45a6,6,0,0,1-11-4.78Z"}))],["regular",g.createElement(g.Fragment,null,g.createElement("path",{d:"M213.92,218.62l-160-176A8,8,0,0,0,42.08,53.38L80,95.09V128a48,48,0,0,0,69.11,43.12l11.1,12.2A63.41,63.41,0,0,1,128,192a64.07,64.07,0,0,1-64-64,8,8,0,0,0-16,0,80.11,80.11,0,0,0,72,79.6V240a8,8,0,0,0,16,0V207.59a78.83,78.83,0,0,0,35.16-12.22l30.92,34a8,8,0,1,0,11.84-10.76ZM128,160a32,32,0,0,1-32-32V112.69l41.66,45.82A32,32,0,0,1,128,160Zm57.52-3.91A63.32,63.32,0,0,0,192,128a8,8,0,0,1,16,0,79.16,79.16,0,0,1-8.11,35.12,8,8,0,0,1-7.19,4.49,7.88,7.88,0,0,1-3.51-.82A8,8,0,0,1,185.52,156.09ZM84,44.87A48,48,0,0,1,176,64v64a49.19,49.19,0,0,1-.26,5,8,8,0,0,1-8,7.17,8.13,8.13,0,0,1-.84,0,8,8,0,0,1-7.12-8.79c.11-1.1.17-2.24.17-3.36V64A32,32,0,0,0,98.64,51.25,8,8,0,1,1,84,44.87Z"}))],["thin",g.createElement(g.Fragment,null,g.createElement("path",{d:"M211,221.31,51,45.31A4,4,0,0,0,45,50.69L84,93.55V128a44,44,0,0,0,66,38.12l16.38,18A67.21,67.21,0,0,1,128,196a68.07,68.07,0,0,1-68-68,4,4,0,0,0-8,0,76.09,76.09,0,0,0,72,75.89V240a4,4,0,0,0,8,0V203.89a75.1,75.1,0,0,0,39.79-13.77L205,226.69a4,4,0,1,0,5.92-5.38ZM128,164a36,36,0,0,1-36-36V102.35L144.43,160A35.83,35.83,0,0,1,128,164Zm61.12-6.15A67.44,67.44,0,0,0,196,128a4,4,0,0,1,8,0,75.28,75.28,0,0,1-7.7,33.37,4,4,0,0,1-7.18-3.52ZM87.63,46.46A44,44,0,0,1,172,64v64a44.2,44.2,0,0,1-.24,4.61,4,4,0,0,1-4,3.58l-.42,0a4,4,0,0,1-3.57-4.39A36.67,36.67,0,0,0,164,128V64A36,36,0,0,0,95,49.66a4,4,0,0,1-7.34-3.2Z"}))]]),z1=g.forwardRef((t,e)=>g.createElement(pn,{ref:e,...t,weights:S4}));z1.displayName="MicrophoneSlashIcon";const w4=new Map([["bold",g.createElement(g.Fragment,null,g.createElement("path",{d:"M208,36H48A28,28,0,0,0,20,64V176a28,28,0,0,0,28,28H208a28,28,0,0,0,28-28V64A28,28,0,0,0,208,36Zm4,140a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V64a4,4,0,0,1,4-4H208a4,4,0,0,1,4,4Zm-40,52a12,12,0,0,1-12,12H96a12,12,0,0,1,0-24h64A12,12,0,0,1,172,228ZM160.49,103.51a12,12,0,0,1-17,17L140,117v35a12,12,0,0,1-24,0V117l-3.51,3.52a12,12,0,0,1-17-17l24-24a12,12,0,0,1,17,0Z"}))],["duotone",g.createElement(g.Fragment,null,g.createElement("path",{d:"M224,64V176a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V64A16,16,0,0,1,48,48H208A16,16,0,0,1,224,64Z",opacity:"0.2"}),g.createElement("path",{d:"M208,40H48A24,24,0,0,0,24,64V176a24,24,0,0,0,24,24H208a24,24,0,0,0,24-24V64A24,24,0,0,0,208,40Zm8,136a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V64a8,8,0,0,1,8-8H208a8,8,0,0,1,8,8Zm-48,48a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,224ZM157.66,106.34a8,8,0,0,1-11.32,11.32L136,107.31V152a8,8,0,0,1-16,0V107.31l-10.34,10.35a8,8,0,0,1-11.32-11.32l24-24a8,8,0,0,1,11.32,0Z"}))],["fill",g.createElement(g.Fragment,null,g.createElement("path",{d:"M168,224a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,224ZM232,64V176a24,24,0,0,1-24,24H48a24,24,0,0,1-24-24V64A24,24,0,0,1,48,40H208A24,24,0,0,1,232,64Zm-74.34,42.34-24-24a8,8,0,0,0-11.32,0l-24,24a8,8,0,0,0,11.32,11.32L120,107.31V152a8,8,0,0,0,16,0V107.31l10.34,10.35a8,8,0,0,0,11.32-11.32Z"}))],["light",g.createElement(g.Fragment,null,g.createElement("path",{d:"M208,42H48A22,22,0,0,0,26,64V176a22,22,0,0,0,22,22H208a22,22,0,0,0,22-22V64A22,22,0,0,0,208,42Zm10,134a10,10,0,0,1-10,10H48a10,10,0,0,1-10-10V64A10,10,0,0,1,48,54H208a10,10,0,0,1,10,10Zm-52,48a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,224Zm-9.76-116.24a6,6,0,1,1-8.48,8.48L134,102.49V152a6,6,0,0,1-12,0V102.49l-13.76,13.75a6,6,0,0,1-8.48-8.48l24-24a6,6,0,0,1,8.48,0Z"}))],["regular",g.createElement(g.Fragment,null,g.createElement("path",{d:"M208,40H48A24,24,0,0,0,24,64V176a24,24,0,0,0,24,24H208a24,24,0,0,0,24-24V64A24,24,0,0,0,208,40Zm8,136a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V64a8,8,0,0,1,8-8H208a8,8,0,0,1,8,8Zm-48,48a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,224ZM157.66,106.34a8,8,0,0,1-11.32,11.32L136,107.31V152a8,8,0,0,1-16,0V107.31l-10.34,10.35a8,8,0,0,1-11.32-11.32l24-24a8,8,0,0,1,11.32,0Z"}))],["thin",g.createElement(g.Fragment,null,g.createElement("path",{d:"M208,44H48A20,20,0,0,0,28,64V176a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V64A20,20,0,0,0,208,44Zm12,132a12,12,0,0,1-12,12H48a12,12,0,0,1-12-12V64A12,12,0,0,1,48,52H208a12,12,0,0,1,12,12Zm-56,48a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,224Zm-9.17-114.83a4,4,0,0,1-5.66,5.66L132,97.66V152a4,4,0,0,1-8,0V97.66l-17.17,17.17a4,4,0,0,1-5.66-5.66l24-24a4,4,0,0,1,5.66,0Z"}))]]),W1=g.forwardRef((t,e)=>g.createElement(pn,{ref:e,...t,weights:w4}));W1.displayName="MonitorArrowUpIcon";const C4=new Map([["bold",g.createElement(g.Fragment,null,g.createElement("path",{d:"M140,32V64a12,12,0,0,1-24,0V32a12,12,0,0,1,24,0Zm33.25,62.75a12,12,0,0,0,8.49-3.52L204.37,68.6a12,12,0,0,0-17-17L164.77,74.26a12,12,0,0,0,8.48,20.49ZM224,116H192a12,12,0,0,0,0,24h32a12,12,0,0,0,0-24Zm-42.26,48.77a12,12,0,1,0-17,17l22.63,22.63a12,12,0,0,0,17-17ZM128,180a12,12,0,0,0-12,12v32a12,12,0,0,0,24,0V192A12,12,0,0,0,128,180ZM74.26,164.77,51.63,187.4a12,12,0,0,0,17,17l22.63-22.63a12,12,0,1,0-17-17ZM76,128a12,12,0,0,0-12-12H32a12,12,0,0,0,0,24H64A12,12,0,0,0,76,128ZM68.6,51.63a12,12,0,1,0-17,17L74.26,91.23a12,12,0,0,0,17-17Z"}))],["duotone",g.createElement(g.Fragment,null,g.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),g.createElement("path",{d:"M136,32V64a8,8,0,0,1-16,0V32a8,8,0,0,1,16,0Zm37.25,58.75a8,8,0,0,0,5.66-2.35l22.63-22.62a8,8,0,0,0-11.32-11.32L167.6,77.09a8,8,0,0,0,5.65,13.66ZM224,120H192a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16Zm-45.09,47.6a8,8,0,0,0-11.31,11.31l22.62,22.63a8,8,0,0,0,11.32-11.32ZM128,184a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V192A8,8,0,0,0,128,184ZM77.09,167.6,54.46,190.22a8,8,0,0,0,11.32,11.32L88.4,178.91A8,8,0,0,0,77.09,167.6ZM72,128a8,8,0,0,0-8-8H32a8,8,0,0,0,0,16H64A8,8,0,0,0,72,128ZM65.78,54.46A8,8,0,0,0,54.46,65.78L77.09,88.4A8,8,0,0,0,88.4,77.09Z"}))],["fill",g.createElement(g.Fragment,null,g.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm33.94,58.75,17-17a8,8,0,0,1,11.32,11.32l-17,17a8,8,0,0,1-11.31-11.31ZM48,136a8,8,0,0,1,0-16H72a8,8,0,0,1,0,16Zm46.06,37.25-17,17a8,8,0,0,1-11.32-11.32l17-17a8,8,0,0,1,11.31,11.31Zm0-79.19a8,8,0,0,1-11.31,0l-17-17A8,8,0,0,1,77.09,65.77l17,17A8,8,0,0,1,94.06,94.06ZM136,208a8,8,0,0,1-16,0V184a8,8,0,0,1,16,0Zm0-136a8,8,0,0,1-16,0V48a8,8,0,0,1,16,0Zm54.23,118.23a8,8,0,0,1-11.32,0l-17-17a8,8,0,0,1,11.31-11.31l17,17A8,8,0,0,1,190.23,190.23ZM208,136H184a8,8,0,0,1,0-16h24a8,8,0,0,1,0,16Z"}))],["light",g.createElement(g.Fragment,null,g.createElement("path",{d:"M134,32V64a6,6,0,0,1-12,0V32a6,6,0,0,1,12,0Zm39.25,56.75A6,6,0,0,0,177.5,87l22.62-22.63a6,6,0,0,0-8.48-8.48L169,78.5a6,6,0,0,0,4.24,10.25ZM224,122H192a6,6,0,0,0,0,12h32a6,6,0,0,0,0-12Zm-46.5,47A6,6,0,0,0,169,177.5l22.63,22.62a6,6,0,0,0,8.48-8.48ZM128,186a6,6,0,0,0-6,6v32a6,6,0,0,0,12,0V192A6,6,0,0,0,128,186ZM78.5,169,55.88,191.64a6,6,0,1,0,8.48,8.48L87,177.5A6,6,0,1,0,78.5,169ZM70,128a6,6,0,0,0-6-6H32a6,6,0,0,0,0,12H64A6,6,0,0,0,70,128ZM64.36,55.88a6,6,0,0,0-8.48,8.48L78.5,87A6,6,0,1,0,87,78.5Z"}))],["regular",g.createElement(g.Fragment,null,g.createElement("path",{d:"M136,32V64a8,8,0,0,1-16,0V32a8,8,0,0,1,16,0Zm37.25,58.75a8,8,0,0,0,5.66-2.35l22.63-22.62a8,8,0,0,0-11.32-11.32L167.6,77.09a8,8,0,0,0,5.65,13.66ZM224,120H192a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16Zm-45.09,47.6a8,8,0,0,0-11.31,11.31l22.62,22.63a8,8,0,0,0,11.32-11.32ZM128,184a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V192A8,8,0,0,0,128,184ZM77.09,167.6,54.46,190.22a8,8,0,0,0,11.32,11.32L88.4,178.91A8,8,0,0,0,77.09,167.6ZM72,128a8,8,0,0,0-8-8H32a8,8,0,0,0,0,16H64A8,8,0,0,0,72,128ZM65.78,54.46A8,8,0,0,0,54.46,65.78L77.09,88.4A8,8,0,0,0,88.4,77.09Z"}))],["thin",g.createElement(g.Fragment,null,g.createElement("path",{d:"M132,32V64a4,4,0,0,1-8,0V32a4,4,0,0,1,8,0Zm41.25,54.75a4,4,0,0,0,2.83-1.18L198.71,63a4,4,0,0,0-5.66-5.66L170.43,79.92a4,4,0,0,0,2.82,6.83ZM224,124H192a4,4,0,0,0,0,8h32a4,4,0,0,0,0-8Zm-47.92,46.43a4,4,0,1,0-5.65,5.65l22.62,22.63a4,4,0,0,0,5.66-5.66ZM128,188a4,4,0,0,0-4,4v32a4,4,0,0,0,8,0V192A4,4,0,0,0,128,188ZM79.92,170.43,57.29,193.05A4,4,0,0,0,63,198.71l22.62-22.63a4,4,0,1,0-5.65-5.65ZM68,128a4,4,0,0,0-4-4H32a4,4,0,0,0,0,8H64A4,4,0,0,0,68,128ZM63,57.29A4,4,0,0,0,57.29,63L79.92,85.57a4,4,0,1,0,5.65-5.65Z"}))]]),Nf=g.forwardRef((t,e)=>g.createElement(pn,{ref:e,...t,weights:C4}));Nf.displayName="SpinnerIcon";const k4=new Map([["bold",g.createElement(g.Fragment,null,g.createElement("path",{d:"M249.45,69.31a12,12,0,0,0-12.51,1L212,88.43V72a20,20,0,0,0-20-20H32A20,20,0,0,0,12,72V184a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V167.57l24.94,18.14A12,12,0,0,0,256,176V80A12,12,0,0,0,249.45,69.31ZM188,180H36V76H188Zm44-27.57-20-14.54V118.11l20-14.54Z"}))],["duotone",g.createElement(g.Fragment,null,g.createElement("path",{d:"M200,72V184a8,8,0,0,1-8,8H32a8,8,0,0,1-8-8V72a8,8,0,0,1,8-8H192A8,8,0,0,1,200,72Z",opacity:"0.2"}),g.createElement("path",{d:"M251.77,73a8,8,0,0,0-8.21.39L208,97.05V72a16,16,0,0,0-16-16H32A16,16,0,0,0,16,72V184a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V159l35.56,23.71A8,8,0,0,0,248,184a8,8,0,0,0,8-8V80A8,8,0,0,0,251.77,73ZM192,184H32V72H192V184Zm48-22.95-32-21.33V116.28L240,95Z"}))],["fill",g.createElement(g.Fragment,null,g.createElement("path",{d:"M192,72V184a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V72A16,16,0,0,1,32,56H176A16,16,0,0,1,192,72Zm58,.25a8.23,8.23,0,0,0-6.63,1.22L209.78,95.86A4,4,0,0,0,208,99.19v57.62a4,4,0,0,0,1.78,3.33l33.78,22.52a8,8,0,0,0,8.58.19,8.33,8.33,0,0,0,3.86-7.17V80A8,8,0,0,0,250,72.25Z"}))],["light",g.createElement(g.Fragment,null,g.createElement("path",{d:"M250.83,74.71a6,6,0,0,0-6.16.3L206,100.79V72a14,14,0,0,0-14-14H32A14,14,0,0,0,18,72V184a14,14,0,0,0,14,14H192a14,14,0,0,0,14-14V155.21L244.67,181a6,6,0,0,0,9.33-5V80A6,6,0,0,0,250.83,74.71ZM194,184a2,2,0,0,1-2,2H32a2,2,0,0,1-2-2V72a2,2,0,0,1,2-2H192a2,2,0,0,1,2,2Zm48-19.21-36-24V115.21l36-24Z"}))],["regular",g.createElement(g.Fragment,null,g.createElement("path",{d:"M251.77,73a8,8,0,0,0-8.21.39L208,97.05V72a16,16,0,0,0-16-16H32A16,16,0,0,0,16,72V184a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V159l35.56,23.71A8,8,0,0,0,248,184a8,8,0,0,0,8-8V80A8,8,0,0,0,251.77,73ZM192,184H32V72H192V184Zm48-22.95-32-21.33V116.28L240,95Z"}))],["thin",g.createElement(g.Fragment,null,g.createElement("path",{d:"M249.89,76.47a4,4,0,0,0-4.11.2L204,104.53V72a12,12,0,0,0-12-12H32A12,12,0,0,0,20,72V184a12,12,0,0,0,12,12H192a12,12,0,0,0,12-12V151.47l41.78,27.86A4,4,0,0,0,252,176V80A4,4,0,0,0,249.89,76.47ZM196,184a4,4,0,0,1-4,4H32a4,4,0,0,1-4-4V72a4,4,0,0,1,4-4H192a4,4,0,0,1,4,4Zm48-15.47-40-26.67V114.14l40-26.67Z"}))]]),q1=g.forwardRef((t,e)=>g.createElement(pn,{ref:e,...t,weights:k4}));q1.displayName="VideoCameraIcon";const T4=new Map([["bold",g.createElement(g.Fragment,null,g.createElement("path",{d:"M249.45,69.31a12,12,0,0,0-12.51,1L212,88.43V72a20,20,0,0,0-20-20H123.88a12,12,0,0,0,0,24H188v68a12,12,0,0,0,4.46,9.33c.15.13.31.25.48.38l44,32A12,12,0,0,0,256,176V80A12,12,0,0,0,249.45,69.31ZM232,152.43l-20-14.54V118.11l20-14.54ZM56.88,31.93A12,12,0,1,0,39.12,48.07L42.69,52H32A20,20,0,0,0,12,72V184a20,20,0,0,0,20,20H180.87l18.25,20.07a12,12,0,0,0,17.76-16.14ZM36,180V76H64.51l94.55,104Z"}))],["duotone",g.createElement(g.Fragment,null,g.createElement("path",{d:"M200,72V184a8,8,0,0,1-8,8H32a8,8,0,0,1-8-8V72a8,8,0,0,1,8-8H192A8,8,0,0,1,200,72Z",opacity:"0.2"}),g.createElement("path",{d:"M251.77,73a8,8,0,0,0-8.21.39L208,97.05V72a16,16,0,0,0-16-16H113.06a8,8,0,0,0,0,16H192v87.63a8,8,0,0,0,16,0V159l35.56,23.71A8,8,0,0,0,248,184a8,8,0,0,0,8-8V80A8,8,0,0,0,251.77,73ZM240,161.05l-32-21.33V116.28L240,95ZM53.92,34.62A8,8,0,1,0,42.08,45.38L51.73,56H32A16,16,0,0,0,16,72V184a16,16,0,0,0,16,16H182.64l19.44,21.38a8,8,0,1,0,11.84-10.76ZM32,184V72H66.28L168.1,184Z"}))],["fill",g.createElement(g.Fragment,null,g.createElement("path",{d:"M256,80.23v95.45a8.33,8.33,0,0,1-3.86,7.17,8,8,0,0,1-8.58-.19l-33.78-22.52a4,4,0,0,1-1.78-3.33V99.19a4,4,0,0,1,1.78-3.32l33.78-22.53a8,8,0,0,1,9.73.66A8.23,8.23,0,0,1,256,80.23ZM53.92,34.62A8,8,0,1,0,42.08,45.38L51.73,56H32A16,16,0,0,0,16,72V184a16,16,0,0,0,16,16H182.64l19.44,21.38a8,8,0,1,0,11.84-10.76ZM185,155.07a4,4,0,0,0,7-2.7V72a16,16,0,0,0-16-16H104a4,4,0,0,0-3,6.69Z"}))],["light",g.createElement(g.Fragment,null,g.createElement("path",{d:"M250.83,74.71a6,6,0,0,0-6.16.3L206,100.79V72a14,14,0,0,0-14-14H113.06a6,6,0,0,0,0,12H192a2,2,0,0,1,2,2v87.63a6,6,0,0,0,12,0v-4.42L244.67,181a6,6,0,0,0,9.33-5V80A6,6,0,0,0,250.83,74.71ZM242,164.79l-36-24V115.21l36-24ZM52.44,36A6,6,0,0,0,43.56,44L56.25,58H32A14,14,0,0,0,18,72V184a14,14,0,0,0,14,14H183.53l20,22a6,6,0,0,0,8.88-8.08ZM32,186a2,2,0,0,1-2-2V72a2,2,0,0,1,2-2H67.16L172.62,186Z"}))],["regular",g.createElement(g.Fragment,null,g.createElement("path",{d:"M251.77,73a8,8,0,0,0-8.21.39L208,97.05V72a16,16,0,0,0-16-16H113.06a8,8,0,0,0,0,16H192v87.63a8,8,0,0,0,16,0V159l35.56,23.71A8,8,0,0,0,248,184a8,8,0,0,0,8-8V80A8,8,0,0,0,251.77,73ZM240,161.05l-32-21.33V116.28L240,95ZM53.92,34.62A8,8,0,1,0,42.08,45.38L51.73,56H32A16,16,0,0,0,16,72V184a16,16,0,0,0,16,16H182.64l19.44,21.38a8,8,0,1,0,11.84-10.76ZM32,184V72H66.28L168.1,184Z"}))],["thin",g.createElement(g.Fragment,null,g.createElement("path",{d:"M249.89,76.47a4,4,0,0,0-4.11.2L204,104.53V72a12,12,0,0,0-12-12H113.06a4,4,0,0,0,0,8H192a4,4,0,0,1,4,4v87.63a4,4,0,0,0,8,0v-8.16l41.78,27.86A4,4,0,0,0,252,176V80A4,4,0,0,0,249.89,76.47ZM244,168.53l-40-26.67V114.14l40-26.67ZM51,37.31A4,4,0,0,0,45,42.69L60.78,60H32A12,12,0,0,0,20,72V184a12,12,0,0,0,12,12H184.41L205,218.69a4,4,0,1,0,5.92-5.38ZM32,188a4,4,0,0,1-4-4V72a4,4,0,0,1,4-4H68.05L177.14,188Z"}))]]),K1=g.forwardRef((t,e)=>g.createElement(pn,{ref:e,...t,weights:T4}));K1.displayName="VideoCameraSlashIcon";const E4=new Map([["bold",g.createElement(g.Fragment,null,g.createElement("path",{d:"M240.26,186.1,152.81,34.23h0a28.74,28.74,0,0,0-49.62,0L15.74,186.1a27.45,27.45,0,0,0,0,27.71A28.31,28.31,0,0,0,40.55,228h174.9a28.31,28.31,0,0,0,24.79-14.19A27.45,27.45,0,0,0,240.26,186.1Zm-20.8,15.7a4.46,4.46,0,0,1-4,2.2H40.55a4.46,4.46,0,0,1-4-2.2,3.56,3.56,0,0,1,0-3.73L124,46.2a4.77,4.77,0,0,1,8,0l87.44,151.87A3.56,3.56,0,0,1,219.46,201.8ZM116,136V104a12,12,0,0,1,24,0v32a12,12,0,0,1-24,0Zm28,40a16,16,0,1,1-16-16A16,16,0,0,1,144,176Z"}))],["duotone",g.createElement(g.Fragment,null,g.createElement("path",{d:"M215.46,216H40.54C27.92,216,20,202.79,26.13,192.09L113.59,40.22c6.3-11,22.52-11,28.82,0l87.46,151.87C236,202.79,228.08,216,215.46,216Z",opacity:"0.2"}),g.createElement("path",{d:"M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z"}))],["fill",g.createElement(g.Fragment,null,g.createElement("path",{d:"M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM120,104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm8,88a12,12,0,1,1,12-12A12,12,0,0,1,128,192Z"}))],["light",g.createElement(g.Fragment,null,g.createElement("path",{d:"M235.07,189.09,147.61,37.22h0a22.75,22.75,0,0,0-39.22,0L20.93,189.09a21.53,21.53,0,0,0,0,21.72A22.35,22.35,0,0,0,40.55,222h174.9a22.35,22.35,0,0,0,19.6-11.19A21.53,21.53,0,0,0,235.07,189.09ZM224.66,204.8a10.46,10.46,0,0,1-9.21,5.2H40.55a10.46,10.46,0,0,1-9.21-5.2,9.51,9.51,0,0,1,0-9.72L118.79,43.21a10.75,10.75,0,0,1,18.42,0l87.46,151.87A9.51,9.51,0,0,1,224.66,204.8ZM122,144V104a6,6,0,0,1,12,0v40a6,6,0,0,1-12,0Zm16,36a10,10,0,1,1-10-10A10,10,0,0,1,138,180Z"}))],["regular",g.createElement(g.Fragment,null,g.createElement("path",{d:"M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z"}))],["thin",g.createElement(g.Fragment,null,g.createElement("path",{d:"M233.34,190.09,145.88,38.22h0a20.75,20.75,0,0,0-35.76,0L22.66,190.09a19.52,19.52,0,0,0,0,19.71A20.36,20.36,0,0,0,40.54,220H215.46a20.36,20.36,0,0,0,17.86-10.2A19.52,19.52,0,0,0,233.34,190.09ZM226.4,205.8a12.47,12.47,0,0,1-10.94,6.2H40.54a12.47,12.47,0,0,1-10.94-6.2,11.45,11.45,0,0,1,0-11.72L117.05,42.21a12.76,12.76,0,0,1,21.9,0L226.4,194.08A11.45,11.45,0,0,1,226.4,205.8ZM124,144V104a4,4,0,0,1,8,0v40a4,4,0,0,1-8,0Zm12,36a8,8,0,1,1-8-8A8,8,0,0,1,136,180Z"}))]]),P4=R.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),G1=g.forwardRef((t,e)=>{const{alt:n,color:i,size:r,weight:s,mirrored:o,children:a,weights:c,...l}=t,{color:d="currentColor",size:u,weight:f="regular",mirrored:p=!1,...v}=g.useContext(P4);return g.createElement("svg",{ref:e,xmlns:"http://www.w3.org/2000/svg",width:r??u,height:r??u,fill:i??d,viewBox:"0 0 256 256",transform:o||p?"scale(-1, 1)":void 0,...v,...l},!!n&&g.createElement("title",null,n),a,c.get(s??f))});G1.displayName="IconBase";const Z1=g.forwardRef((t,e)=>g.createElement(G1,{ref:e,...t,weights:E4}));Z1.displayName="WarningIcon";const Of="-",R4=t=>{const e=I4(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:i}=t;return{getClassGroupId:o=>{const a=o.split(Of);return a[0]===""&&a.length!==1&&a.shift(),Y1(a,e)||A4(o)},getConflictingClassGroupIds:(o,a)=>{const c=n[o]||[];return a&&i[o]?[...c,...i[o]]:c}}},Y1=(t,e)=>{var o;if(t.length===0)return e.classGroupId;const n=t[0],i=e.nextPart.get(n),r=i?Y1(t.slice(1),i):void 0;if(r)return r;if(e.validators.length===0)return;const s=t.join(Of);return(o=e.validators.find(({validator:a})=>a(s)))==null?void 0:o.classGroupId},ig=/^\[(.+)\]$/,A4=t=>{if(ig.test(t)){const e=ig.exec(t)[1],n=e==null?void 0:e.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},I4=t=>{const{theme:e,classGroups:n}=t,i={nextPart:new Map,validators:[]};for(const r in n)Yd(n[r],i,r,e);return i},Yd=(t,e,n,i)=>{t.forEach(r=>{if(typeof r=="string"){const s=r===""?e:rg(e,r);s.classGroupId=n;return}if(typeof r=="function"){if(M4(r)){Yd(r(i),e,n,i);return}e.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([s,o])=>{Yd(o,rg(e,s),n,i)})})},rg=(t,e)=>{let n=t;return e.split(Of).forEach(i=>{n.nextPart.has(i)||n.nextPart.set(i,{nextPart:new Map,validators:[]}),n=n.nextPart.get(i)}),n},M4=t=>t.isThemeGetter,_4=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,i=new Map;const r=(s,o)=>{n.set(s,o),e++,e>t&&(e=0,i=n,n=new Map)};return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=i.get(s))!==void 0)return r(s,o),o},set(s,o){n.has(s)?n.set(s,o):r(s,o)}}},Jd="!",Xd=":",N4=Xd.length,O4=t=>{const{prefix:e,experimentalParseClassName:n}=t;let i=r=>{const s=[];let o=0,a=0,c=0,l;for(let v=0;v<r.length;v++){let h=r[v];if(o===0&&a===0){if(h===Xd){s.push(r.slice(c,v)),c=v+N4;continue}if(h==="/"){l=v;continue}}h==="["?o++:h==="]"?o--:h==="("?a++:h===")"&&a--}const d=s.length===0?r:r.substring(c),u=D4(d),f=u!==d,p=l&&l>c?l-c:void 0;return{modifiers:s,hasImportantModifier:f,baseClassName:u,maybePostfixModifierPosition:p}};if(e){const r=e+Xd,s=i;i=o=>o.startsWith(r)?s(o.substring(r.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(n){const r=i;i=s=>n({className:s,parseClassName:r})}return i},D4=t=>t.endsWith(Jd)?t.substring(0,t.length-1):t.startsWith(Jd)?t.substring(1):t,j4=t=>{const e=Object.fromEntries(t.orderSensitiveModifiers.map(i=>[i,!0]));return i=>{if(i.length<=1)return i;const r=[];let s=[];return i.forEach(o=>{o[0]==="["||e[o]?(r.push(...s.sort(),o),s=[]):s.push(o)}),r.push(...s.sort()),r}},L4=t=>({cache:_4(t.cacheSize),parseClassName:O4(t),sortModifiers:j4(t),...R4(t)}),V4=/\s+/,F4=(t,e)=>{const{parseClassName:n,getClassGroupId:i,getConflictingClassGroupIds:r,sortModifiers:s}=e,o=[],a=t.trim().split(V4);let c="";for(let l=a.length-1;l>=0;l-=1){const d=a[l],{isExternal:u,modifiers:f,hasImportantModifier:p,baseClassName:v,maybePostfixModifierPosition:h}=n(d);if(u){c=d+(c.length>0?" "+c:c);continue}let y=!!h,b=i(y?v.substring(0,h):v);if(!b){if(!y){c=d+(c.length>0?" "+c:c);continue}if(b=i(v),!b){c=d+(c.length>0?" "+c:c);continue}y=!1}const w=s(f).join(":"),C=p?w+Jd:w,S=C+b;if(o.includes(S))continue;o.push(S);const x=r(b,y);for(let T=0;T<x.length;++T){const E=x[T];o.push(C+E)}c=d+(c.length>0?" "+c:c)}return c};function U4(){let t=0,e,n,i="";for(;t<arguments.length;)(e=arguments[t++])&&(n=J1(e))&&(i&&(i+=" "),i+=n);return i}const J1=t=>{if(typeof t=="string")return t;let e,n="";for(let i=0;i<t.length;i++)t[i]&&(e=J1(t[i]))&&(n&&(n+=" "),n+=e);return n};function B4(t,...e){let n,i,r,s=o;function o(c){const l=e.reduce((d,u)=>u(d),t());return n=L4(l),i=n.cache.get,r=n.cache.set,s=a,a(c)}function a(c){const l=i(c);if(l)return l;const d=F4(c,n);return r(c,d),d}return function(){return s(U4.apply(null,arguments))}}const ft=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},X1=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Q1=/^\((?:(\w[\w-]*):)?(.+)\)$/i,$4=/^\d+\/\d+$/,H4=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,z4=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,W4=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,q4=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,K4=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,fr=t=>$4.test(t),ye=t=>!!t&&!Number.isNaN(Number(t)),ri=t=>!!t&&Number.isInteger(Number(t)),vl=t=>t.endsWith("%")&&ye(t.slice(0,-1)),Ln=t=>H4.test(t),G4=()=>!0,Z4=t=>z4.test(t)&&!W4.test(t),ex=()=>!1,Y4=t=>q4.test(t),J4=t=>K4.test(t),X4=t=>!de(t)&&!ue(t),Q4=t=>as(t,ix,ex),de=t=>X1.test(t),ji=t=>as(t,rx,Z4),yl=t=>as(t,r_,ye),sg=t=>as(t,tx,ex),e_=t=>as(t,nx,J4),Mo=t=>as(t,sx,Y4),ue=t=>Q1.test(t),Es=t=>cs(t,rx),t_=t=>cs(t,s_),og=t=>cs(t,tx),n_=t=>cs(t,ix),i_=t=>cs(t,nx),_o=t=>cs(t,sx,!0),as=(t,e,n)=>{const i=X1.exec(t);return i?i[1]?e(i[1]):n(i[2]):!1},cs=(t,e,n=!1)=>{const i=Q1.exec(t);return i?i[1]?e(i[1]):n:!1},tx=t=>t==="position"||t==="percentage",nx=t=>t==="image"||t==="url",ix=t=>t==="length"||t==="size"||t==="bg-size",rx=t=>t==="length",r_=t=>t==="number",s_=t=>t==="family-name",sx=t=>t==="shadow",o_=()=>{const t=ft("color"),e=ft("font"),n=ft("text"),i=ft("font-weight"),r=ft("tracking"),s=ft("leading"),o=ft("breakpoint"),a=ft("container"),c=ft("spacing"),l=ft("radius"),d=ft("shadow"),u=ft("inset-shadow"),f=ft("text-shadow"),p=ft("drop-shadow"),v=ft("blur"),h=ft("perspective"),y=ft("aspect"),b=ft("ease"),w=ft("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],x=()=>[...S(),ue,de],T=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto","contain","none"],P=()=>[ue,de,c],_=()=>[fr,"full","auto",...P()],k=()=>[ri,"none","subgrid",ue,de],I=()=>["auto",{span:["full",ri,ue,de]},ri,ue,de],N=()=>[ri,"auto",ue,de],K=()=>["auto","min","max","fr",ue,de],J=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],se=()=>["start","end","center","stretch","center-safe","end-safe"],ie=()=>["auto",...P()],X=()=>[fr,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...P()],O=()=>[t,ue,de],oe=()=>[...S(),og,sg,{position:[ue,de]}],L=()=>["no-repeat",{repeat:["","x","y","space","round"]}],F=()=>["auto","cover","contain",n_,Q4,{size:[ue,de]}],te=()=>[vl,Es,ji],j=()=>["","none","full",l,ue,de],q=()=>["",ye,Es,ji],ee=()=>["solid","dashed","dotted","double"],G=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],D=()=>[ye,vl,og,sg],$=()=>["","none",v,ue,de],Q=()=>["none",ye,ue,de],W=()=>["none",ye,ue,de],ce=()=>[ye,ue,de],z=()=>[fr,"full",...P()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ln],breakpoint:[Ln],color:[G4],container:[Ln],"drop-shadow":[Ln],ease:["in","out","in-out"],font:[X4],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ln],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ln],shadow:[Ln],spacing:["px",ye],text:[Ln],"text-shadow":[Ln],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",fr,de,ue,y]}],container:["container"],columns:[{columns:[ye,de,ue,a]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:x()}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:_()}],"inset-x":[{"inset-x":_()}],"inset-y":[{"inset-y":_()}],start:[{start:_()}],end:[{end:_()}],top:[{top:_()}],right:[{right:_()}],bottom:[{bottom:_()}],left:[{left:_()}],visibility:["visible","invisible","collapse"],z:[{z:[ri,"auto",ue,de]}],basis:[{basis:[fr,"full","auto",a,...P()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ye,fr,"auto","initial","none",de]}],grow:[{grow:["",ye,ue,de]}],shrink:[{shrink:["",ye,ue,de]}],order:[{order:[ri,"first","last","none",ue,de]}],"grid-cols":[{"grid-cols":k()}],"col-start-end":[{col:I()}],"col-start":[{"col-start":N()}],"col-end":[{"col-end":N()}],"grid-rows":[{"grid-rows":k()}],"row-start-end":[{row:I()}],"row-start":[{"row-start":N()}],"row-end":[{"row-end":N()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":K()}],"auto-rows":[{"auto-rows":K()}],gap:[{gap:P()}],"gap-x":[{"gap-x":P()}],"gap-y":[{"gap-y":P()}],"justify-content":[{justify:[...J(),"normal"]}],"justify-items":[{"justify-items":[...se(),"normal"]}],"justify-self":[{"justify-self":["auto",...se()]}],"align-content":[{content:["normal",...J()]}],"align-items":[{items:[...se(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...se(),{baseline:["","last"]}]}],"place-content":[{"place-content":J()}],"place-items":[{"place-items":[...se(),"baseline"]}],"place-self":[{"place-self":["auto",...se()]}],p:[{p:P()}],px:[{px:P()}],py:[{py:P()}],ps:[{ps:P()}],pe:[{pe:P()}],pt:[{pt:P()}],pr:[{pr:P()}],pb:[{pb:P()}],pl:[{pl:P()}],m:[{m:ie()}],mx:[{mx:ie()}],my:[{my:ie()}],ms:[{ms:ie()}],me:[{me:ie()}],mt:[{mt:ie()}],mr:[{mr:ie()}],mb:[{mb:ie()}],ml:[{ml:ie()}],"space-x":[{"space-x":P()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":P()}],"space-y-reverse":["space-y-reverse"],size:[{size:X()}],w:[{w:[a,"screen",...X()]}],"min-w":[{"min-w":[a,"screen","none",...X()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...X()]}],h:[{h:["screen","lh",...X()]}],"min-h":[{"min-h":["screen","lh","none",...X()]}],"max-h":[{"max-h":["screen","lh",...X()]}],"font-size":[{text:["base",n,Es,ji]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,ue,yl]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",vl,de]}],"font-family":[{font:[t_,de,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[r,ue,de]}],"line-clamp":[{"line-clamp":[ye,"none",ue,yl]}],leading:[{leading:[s,...P()]}],"list-image":[{"list-image":["none",ue,de]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ue,de]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:O()}],"text-color":[{text:O()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ee(),"wavy"]}],"text-decoration-thickness":[{decoration:[ye,"from-font","auto",ue,ji]}],"text-decoration-color":[{decoration:O()}],"underline-offset":[{"underline-offset":[ye,"auto",ue,de]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ue,de]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ue,de]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:oe()}],"bg-repeat":[{bg:L()}],"bg-size":[{bg:F()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ri,ue,de],radial:["",ue,de],conic:[ri,ue,de]},i_,e_]}],"bg-color":[{bg:O()}],"gradient-from-pos":[{from:te()}],"gradient-via-pos":[{via:te()}],"gradient-to-pos":[{to:te()}],"gradient-from":[{from:O()}],"gradient-via":[{via:O()}],"gradient-to":[{to:O()}],rounded:[{rounded:j()}],"rounded-s":[{"rounded-s":j()}],"rounded-e":[{"rounded-e":j()}],"rounded-t":[{"rounded-t":j()}],"rounded-r":[{"rounded-r":j()}],"rounded-b":[{"rounded-b":j()}],"rounded-l":[{"rounded-l":j()}],"rounded-ss":[{"rounded-ss":j()}],"rounded-se":[{"rounded-se":j()}],"rounded-ee":[{"rounded-ee":j()}],"rounded-es":[{"rounded-es":j()}],"rounded-tl":[{"rounded-tl":j()}],"rounded-tr":[{"rounded-tr":j()}],"rounded-br":[{"rounded-br":j()}],"rounded-bl":[{"rounded-bl":j()}],"border-w":[{border:q()}],"border-w-x":[{"border-x":q()}],"border-w-y":[{"border-y":q()}],"border-w-s":[{"border-s":q()}],"border-w-e":[{"border-e":q()}],"border-w-t":[{"border-t":q()}],"border-w-r":[{"border-r":q()}],"border-w-b":[{"border-b":q()}],"border-w-l":[{"border-l":q()}],"divide-x":[{"divide-x":q()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":q()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ee(),"hidden","none"]}],"divide-style":[{divide:[...ee(),"hidden","none"]}],"border-color":[{border:O()}],"border-color-x":[{"border-x":O()}],"border-color-y":[{"border-y":O()}],"border-color-s":[{"border-s":O()}],"border-color-e":[{"border-e":O()}],"border-color-t":[{"border-t":O()}],"border-color-r":[{"border-r":O()}],"border-color-b":[{"border-b":O()}],"border-color-l":[{"border-l":O()}],"divide-color":[{divide:O()}],"outline-style":[{outline:[...ee(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ye,ue,de]}],"outline-w":[{outline:["",ye,Es,ji]}],"outline-color":[{outline:O()}],shadow:[{shadow:["","none",d,_o,Mo]}],"shadow-color":[{shadow:O()}],"inset-shadow":[{"inset-shadow":["none",u,_o,Mo]}],"inset-shadow-color":[{"inset-shadow":O()}],"ring-w":[{ring:q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:O()}],"ring-offset-w":[{"ring-offset":[ye,ji]}],"ring-offset-color":[{"ring-offset":O()}],"inset-ring-w":[{"inset-ring":q()}],"inset-ring-color":[{"inset-ring":O()}],"text-shadow":[{"text-shadow":["none",f,_o,Mo]}],"text-shadow-color":[{"text-shadow":O()}],opacity:[{opacity:[ye,ue,de]}],"mix-blend":[{"mix-blend":[...G(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":G()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[ye]}],"mask-image-linear-from-pos":[{"mask-linear-from":D()}],"mask-image-linear-to-pos":[{"mask-linear-to":D()}],"mask-image-linear-from-color":[{"mask-linear-from":O()}],"mask-image-linear-to-color":[{"mask-linear-to":O()}],"mask-image-t-from-pos":[{"mask-t-from":D()}],"mask-image-t-to-pos":[{"mask-t-to":D()}],"mask-image-t-from-color":[{"mask-t-from":O()}],"mask-image-t-to-color":[{"mask-t-to":O()}],"mask-image-r-from-pos":[{"mask-r-from":D()}],"mask-image-r-to-pos":[{"mask-r-to":D()}],"mask-image-r-from-color":[{"mask-r-from":O()}],"mask-image-r-to-color":[{"mask-r-to":O()}],"mask-image-b-from-pos":[{"mask-b-from":D()}],"mask-image-b-to-pos":[{"mask-b-to":D()}],"mask-image-b-from-color":[{"mask-b-from":O()}],"mask-image-b-to-color":[{"mask-b-to":O()}],"mask-image-l-from-pos":[{"mask-l-from":D()}],"mask-image-l-to-pos":[{"mask-l-to":D()}],"mask-image-l-from-color":[{"mask-l-from":O()}],"mask-image-l-to-color":[{"mask-l-to":O()}],"mask-image-x-from-pos":[{"mask-x-from":D()}],"mask-image-x-to-pos":[{"mask-x-to":D()}],"mask-image-x-from-color":[{"mask-x-from":O()}],"mask-image-x-to-color":[{"mask-x-to":O()}],"mask-image-y-from-pos":[{"mask-y-from":D()}],"mask-image-y-to-pos":[{"mask-y-to":D()}],"mask-image-y-from-color":[{"mask-y-from":O()}],"mask-image-y-to-color":[{"mask-y-to":O()}],"mask-image-radial":[{"mask-radial":[ue,de]}],"mask-image-radial-from-pos":[{"mask-radial-from":D()}],"mask-image-radial-to-pos":[{"mask-radial-to":D()}],"mask-image-radial-from-color":[{"mask-radial-from":O()}],"mask-image-radial-to-color":[{"mask-radial-to":O()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":S()}],"mask-image-conic-pos":[{"mask-conic":[ye]}],"mask-image-conic-from-pos":[{"mask-conic-from":D()}],"mask-image-conic-to-pos":[{"mask-conic-to":D()}],"mask-image-conic-from-color":[{"mask-conic-from":O()}],"mask-image-conic-to-color":[{"mask-conic-to":O()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:oe()}],"mask-repeat":[{mask:L()}],"mask-size":[{mask:F()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ue,de]}],filter:[{filter:["","none",ue,de]}],blur:[{blur:$()}],brightness:[{brightness:[ye,ue,de]}],contrast:[{contrast:[ye,ue,de]}],"drop-shadow":[{"drop-shadow":["","none",p,_o,Mo]}],"drop-shadow-color":[{"drop-shadow":O()}],grayscale:[{grayscale:["",ye,ue,de]}],"hue-rotate":[{"hue-rotate":[ye,ue,de]}],invert:[{invert:["",ye,ue,de]}],saturate:[{saturate:[ye,ue,de]}],sepia:[{sepia:["",ye,ue,de]}],"backdrop-filter":[{"backdrop-filter":["","none",ue,de]}],"backdrop-blur":[{"backdrop-blur":$()}],"backdrop-brightness":[{"backdrop-brightness":[ye,ue,de]}],"backdrop-contrast":[{"backdrop-contrast":[ye,ue,de]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ye,ue,de]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ye,ue,de]}],"backdrop-invert":[{"backdrop-invert":["",ye,ue,de]}],"backdrop-opacity":[{"backdrop-opacity":[ye,ue,de]}],"backdrop-saturate":[{"backdrop-saturate":[ye,ue,de]}],"backdrop-sepia":[{"backdrop-sepia":["",ye,ue,de]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":P()}],"border-spacing-x":[{"border-spacing-x":P()}],"border-spacing-y":[{"border-spacing-y":P()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ue,de]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ye,"initial",ue,de]}],ease:[{ease:["linear","initial",b,ue,de]}],delay:[{delay:[ye,ue,de]}],animate:[{animate:["none",w,ue,de]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,ue,de]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:Q()}],"rotate-x":[{"rotate-x":Q()}],"rotate-y":[{"rotate-y":Q()}],"rotate-z":[{"rotate-z":Q()}],scale:[{scale:W()}],"scale-x":[{"scale-x":W()}],"scale-y":[{"scale-y":W()}],"scale-z":[{"scale-z":W()}],"scale-3d":["scale-3d"],skew:[{skew:ce()}],"skew-x":[{"skew-x":ce()}],"skew-y":[{"skew-y":ce()}],transform:[{transform:[ue,de,"","none","gpu","cpu"]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:z()}],"translate-x":[{"translate-x":z()}],"translate-y":[{"translate-y":z()}],"translate-z":[{"translate-z":z()}],"translate-none":["translate-none"],accent:[{accent:O()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:O()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ue,de]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ue,de]}],fill:[{fill:["none",...O()]}],"stroke-w":[{stroke:[ye,Es,ji,yl]}],stroke:[{stroke:["none",...O()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},a_=B4(o_);function fe(...t){return a_(xu.clsx(t))}function c_(t,e){return{id:t.streamInfo.id,timestamp:t.streamInfo.timestamp,message:t.text,from:t.participantInfo.identity===e.localParticipant.identity?e.localParticipant:Array.from(e.remoteParticipants.values()).find(n=>n.identity===t.participantInfo.identity)}}const l_=Wa.cva(["relative w-full rounded-lg border px-4 py-3 text-sm grid grid-cols-[0_1fr] gap-y-0.5 items-start","has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current"],{variants:{variant:{default:"bg-card text-card-foreground",destructive:["text-destructive-foreground bg-destructive border-destructive-border","[&>svg]:text-current *:data-[slot=alert-description]:text-destructive-foreground/90"]}},defaultVariants:{variant:"default"}});function d_({className:t,variant:e,...n}){return m.jsx("div",{"data-slot":"alert",role:"alert",className:fe(l_({variant:e}),t),...n})}function u_({className:t,...e}){return m.jsx("div",{"data-slot":"alert-title",className:fe("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...e})}function f_({className:t,...e}){return m.jsx("div",{"data-slot":"alert-description",className:fe("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...e})}function No(t){return F1.custom(e=>m.jsx(h_,{id:e,title:t.title,description:t.description}),{duration:1e4})}function h_(t){const{title:e,id:n,description:i}=t;return m.jsxs(d_,{onClick:()=>F1.dismiss(n),className:"bg-gradient-to-br from-[#181825] to-[#232336] border border-[#232336] shadow-lg shadow-black/40 rounded-xl px-4 py-3 flex items-start gap-3 hover:shadow-xl transition-all duration-200",style:{color:"#F3F4F6"},children:[m.jsx(Z1,{weight:"bold",className:"text-yellow-400 mt-1 flex-shrink-0",size:24}),m.jsxs("div",{className:"flex flex-col",children:[m.jsx(u_,{className:"text-base font-semibold text-white mb-1",children:e}),m.jsx(f_,{className:"text-sm text-gray-300 leading-snug",children:i})]})]})}function ag(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function ox(...t){return e=>{let n=!1;const i=t.map(r=>{const s=ag(r,e);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let r=0;r<i.length;r++){const s=i[r];typeof s=="function"?s():ag(t[r],null)}}}}function xt(...t){return g.useCallback(ox(...t),t)}function eo(t){const e=p_(t),n=g.forwardRef((i,r)=>{const{children:s,...o}=i,a=g.Children.toArray(s),c=a.find(v_);if(c){const l=c.props.children,d=a.map(u=>u===c?g.Children.count(l)>1?g.Children.only(null):g.isValidElement(l)?l.props.children:null:u);return m.jsx(e,{...o,ref:r,children:g.isValidElement(l)?g.cloneElement(l,void 0,d):null})}return m.jsx(e,{...o,ref:r,children:s})});return n.displayName=`${t}.Slot`,n}var m_=eo("Slot");function p_(t){const e=g.forwardRef((n,i)=>{const{children:r,...s}=n;if(g.isValidElement(r)){const o=b_(r),a=y_(s,r.props);return r.type!==g.Fragment&&(a.ref=i?ox(i,o):o),g.cloneElement(r,a)}return g.Children.count(r)>1?g.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var g_=Symbol("radix.slottable");function v_(t){return g.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===g_}function y_(t,e){const n={...e};for(const i in e){const r=t[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?n[i]=(...a)=>{const c=s(...a);return r(...a),c}:r&&(n[i]=r):i==="style"?n[i]={...r,...s}:i==="className"&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...t,...n}}function b_(t){var i,r;let e=(i=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:i.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(r=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}const x_=Wa.cva(["text-xs font-bold tracking-wider uppercase whitespace-nowrap","inline-flex items-center justify-center gap-2 shrink-0 rounded-full cursor-pointer outline-none transition-colors duration-300","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","disabled:pointer-events-none disabled:opacity-50","aria-invalid:ring-destructive/20 aria-invalid:border-destructive dark:aria-invalid:ring-destructive/40 ","[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0"],{variants:{variant:{default:"bg-button text-button-foreground hover:bg-muted focus:bg-muted",destructive:["bg-destructive text-destructive-foreground","hover:bg-destructive-hover focus:bg-destructive-hover focus-visible:ring-destructive-foreground/20","dark:focus-visible:ring-destructive-foreground/40"],outline:["border bg-background","hover:bg-accent hover:text-accent-foreground","dark:bg-input/30 dark:border-input dark:hover:bg-input/50"],primary:"",secondary:"bg-secondary text-secondary-foregroun hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function S_({className:t,variant:e,size:n,asChild:i=!1,...r}){const s=i?m_:"button";return m.jsx(s,{"data-slot":"button",className:fe(x_({variant:e,size:n,className:t})),...r})}function w_({onSend:t,className:e,disabled:n,...i}){const r=R.useRef(null),[s,o]=R.useState(""),a=l=>{var d,u;l.preventDefault(),(d=i.onSubmit)==null||d.call(i,l),t==null||t(s),o(""),(u=r.current)==null||u.focus({preventScroll:!0})},c=n||s.trim().length===0;return m.jsxs("form",{...i,onSubmit:a,className:fe("flex items-center rounded-md pl-1 text-sm",e),children:[m.jsx("input",{ref:r,type:"text",className:"flex-1 focus:outline-none",placeholder:"Type something...",value:s,onChange:l=>o(l.target.value),disabled:n}),m.jsx(S_,{size:"sm",type:"submit",variant:c?"secondary":"primary",disabled:c,className:"font-mono",children:"SEND"})]})}function it(t,e,{checkForDefaultPrevented:n=!0}={}){return function(r){if(t==null||t(r),n===!1||!r.defaultPrevented)return e==null?void 0:e(r)}}var Lt=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},C_=g[" useInsertionEffect ".trim().toString()]||Lt;function Qd({prop:t,defaultProp:e,onChange:n=()=>{},caller:i}){const[r,s,o]=k_({defaultProp:e,onChange:n}),a=t!==void 0,c=a?t:r;{const d=g.useRef(t!==void 0);g.useEffect(()=>{const u=d.current;u!==a&&console.warn(`${i} is changing from ${u?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,i])}const l=g.useCallback(d=>{var u;if(a){const f=T_(d)?d(t):d;f!==t&&((u=o.current)==null||u.call(o,f))}else s(d)},[a,t,s,o]);return[c,l]}function k_({defaultProp:t,onChange:e}){const[n,i]=g.useState(t),r=g.useRef(n),s=g.useRef(e);return C_(()=>{s.current=e},[e]),g.useEffect(()=>{var o;r.current!==n&&((o=s.current)==null||o.call(s,n),r.current=n)},[n,r]),[n,i,s]}function T_(t){return typeof t=="function"}var E_=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],et=E_.reduce((t,e)=>{const n=eo(`Primitive.${e}`),i=g.forwardRef((r,s)=>{const{asChild:o,...a}=r,c=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(c,{...a,ref:s})});return i.displayName=`Primitive.${e}`,{...t,[e]:i}},{});function P_(t,e){t&&qa.flushSync(()=>t.dispatchEvent(e))}var ax="Toggle",cx=g.forwardRef((t,e)=>{const{pressed:n,defaultPressed:i,onPressedChange:r,...s}=t,[o,a]=Qd({prop:n,onChange:r,defaultProp:i??!1,caller:ax});return m.jsx(et.button,{type:"button","aria-pressed":o,"data-state":o?"on":"off","data-disabled":t.disabled?"":void 0,...s,ref:e,onClick:it(t.onClick,()=>{t.disabled||a(!o)})})});cx.displayName=ax;var R_=cx;const A_=Wa.cva(["inline-flex items-center justify-center gap-2 rounded-full","text-sm font-medium whitespace-nowrap","cursor-pointer outline-none transition-[color,border,background-color]","!focus:ring-0 !focus-visible:ring-0 !focus:border-none !focus-visible:border-none !ring-0 !border-none !outline-none","aria-invalid:ring-0 dark:aria-invalid:ring-0 aria-invalid:border-0","disabled:pointer-events-none disabled:opacity-50 disabled:not-allowed","data-[state=on]:bg-button-selected data-[state=on]:border-button-border-selected","[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0"],{variants:{variant:{default:"bg-button hover:bg-muted focus:bg-muted hover:text-muted-foreground focus:text-muted-foreground",primary:"text-fg1 bg-button hover:bg-button-hover focus:bg-button-hover data-[state=off]:bg-button-primary hover:data-[state=off]:bg-button-hover data-[state=off]:text-button-primary-foreground",secondary:"text-fg1 bg-button hover:bg-button-hover focus:bg-button-hover data-[state=on]:bg-button-secondary hover:data-[state=on]:bg-button-secondary data-[state=on]:text-button-secondary-foreground",outline:["border border-button-border bg-button text-button-foreground","hover:bg-background focus:bg-background"]},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-1.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}});function lx({className:t,variant:e,size:n,...i}){return m.jsx(R_,{"data-slot":"toggle",className:fe(A_({variant:e,size:n,className:t})),...i})}function I_(t){const[e,n]=R.useState(()=>t.getPublishPermissions());return R.useEffect(()=>{const i=()=>{n(t.getPublishPermissions())},r=()=>{i()};return t.on("connection.connected",r),t.on("connection.disconnected",r),()=>{t.off("connection.connected",r),t.off("connection.disconnected",r)}},[t]),e}function M_(t){const[e,n]=R.useState(()=>t.getLocalParticipant()),[i,r]=R.useState(()=>t.getMicrophoneTrack());return R.useEffect(()=>{const s=()=>{const a=t.getLocalParticipant(),c=t.getMicrophoneTrack();console.log("🎤 useVoxketLocalParticipant: Updating state:",{hasParticipant:!!a,hasMicTrack:!!c,isMicEnabled:t.isMicrophoneEnabled,trackPublications:a?a.trackPublications.size:0}),n(a),r(c)};s(),t.on("connection.connected",s),t.on("connection.disconnected",s),t.on("track.muted",s),t.on("track.unmuted",s);const o=t.getRoom();if(o){const a=()=>{console.log("🎤 Track published, updating participant state"),s()},c=()=>{console.log("🎤 Track unpublished, updating participant state"),s()};return o.on("localTrackPublished",a),o.on("localTrackUnpublished",c),()=>{t.off("connection.connected",s),t.off("connection.disconnected",s),t.off("track.muted",s),t.off("track.unmuted",s),o.off("localTrackPublished",a),o.off("localTrackUnpublished",c)}}else return()=>{t.off("connection.connected",s),t.off("connection.disconnected",s),t.off("track.muted",s),t.off("track.unmuted",s)}},[t]),{localParticipant:e,microphoneTrack:i}}function bl(t,e,n){const[i,r]=R.useState(!1),[s,o]=R.useState(!1);return R.useEffect(()=>{const c=()=>{let l=!1;switch(e){case"microphone":l=t.isMicrophoneEnabled;break;case"camera":l=t.isCameraEnabled;break;case"screenShare":l=t.isScreenShareEnabled;break}console.log(`useVoxketTrackToggle: ${e} enabled state updated to:`,l),r(l)};return c(),t.on("track.muted",c),t.on("track.unmuted",c),t.on("connection.connected",c),()=>{t.off("track.muted",c),t.off("track.unmuted",c),t.off("connection.connected",c)}},[t,e]),{enabled:i,pending:s,toggle:async c=>{var l;try{o(!0);const d=c!==void 0?c:!i;switch(e){case"microphone":await t.toggleMicrophone(d);break;case"camera":await t.toggleCamera(d);break;case"screenShare":d?await t.startScreenShare():await t.stopScreenShare();break}}catch(d){(l=n==null?void 0:n.onDeviceError)==null||l.call(n,d)}finally{o(!1)}}}}function __(t){const[e,n]=R.useState(()=>t.getRoom()),[i,r]=R.useState(()=>t.getConnectionState());return R.useEffect(()=>{const s=()=>{n(t.getRoom()),r(t.getConnectionState())};return t.on("connection.connected",s),t.on("connection.disconnected",s),t.on("connection.connecting",s),()=>{t.off("connection.connected",s),t.off("connection.disconnected",s),t.off("connection.connecting",s)}},[t]),e}function N_(t,e){const[n,i]=R.useState([]),[r,s]=R.useState("");return R.useEffect(()=>{var l;const a=async()=>{try{const d=e==="audioinput"?await t.getAudioInputDevices():await t.getVideoInputDevices();i(d)}catch(d){console.error("Failed to load devices:",d)}};a();const c=()=>{a()};return(l=navigator.mediaDevices)==null||l.addEventListener("devicechange",c),()=>{var d;(d=navigator.mediaDevices)==null||d.removeEventListener("devicechange",c)}},[t,e]),{devices:n,activeDeviceId:r,setActiveMediaDevice:async a=>{try{e==="audioinput"?await t.setAudioInputDevice(a):await t.setVideoInputDevice(a),s(a)}catch(c){console.error("Failed to set device:",c)}}}}function O_(t){const{preventSave:e=!1}=t||{};return{saveAudioInputEnabled:o=>{e||localStorage.setItem("voxket-audio-input-enabled",o.toString())},saveAudioInputDeviceId:o=>{e||localStorage.setItem("voxket-audio-input-device-id",o)},saveVideoInputEnabled:o=>{e||localStorage.setItem("voxket-video-input-enabled",o.toString())},saveVideoInputDeviceId:o=>{e||localStorage.setItem("voxket-video-input-device-id",o)}}}function cg(t,[e,n]){return Math.min(n,Math.max(e,t))}function Df(t,e=[]){let n=[];function i(s,o){const a=g.createContext(o),c=n.length;n=[...n,o];const l=u=>{var b;const{scope:f,children:p,...v}=u,h=((b=f==null?void 0:f[t])==null?void 0:b[c])||a,y=g.useMemo(()=>v,Object.values(v));return m.jsx(h.Provider,{value:y,children:p})};l.displayName=s+"Provider";function d(u,f){var h;const p=((h=f==null?void 0:f[t])==null?void 0:h[c])||a,v=g.useContext(p);if(v)return v;if(o!==void 0)return o;throw new Error(`\`${u}\` must be used within \`${s}\``)}return[l,d]}const r=()=>{const s=n.map(o=>g.createContext(o));return function(a){const c=(a==null?void 0:a[t])||s;return g.useMemo(()=>({[`__scope${t}`]:{...a,[t]:c}}),[a,c])}};return r.scopeName=t,[i,D_(r,...e)]}function D_(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const i=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(s){const o=i.reduce((a,{useScope:c,scopeName:l})=>{const u=c(s)[`__scope${l}`];return{...a,...u}},{});return g.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}function j_(t){const e=t+"CollectionProvider",[n,i]=Df(e),[r,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=h=>{const{scope:y,children:b}=h,w=R.useRef(null),C=R.useRef(new Map).current;return m.jsx(r,{scope:y,itemMap:C,collectionRef:w,children:b})};o.displayName=e;const a=t+"CollectionSlot",c=eo(a),l=R.forwardRef((h,y)=>{const{scope:b,children:w}=h,C=s(a,b),S=xt(y,C.collectionRef);return m.jsx(c,{ref:S,children:w})});l.displayName=a;const d=t+"CollectionItemSlot",u="data-radix-collection-item",f=eo(d),p=R.forwardRef((h,y)=>{const{scope:b,children:w,...C}=h,S=R.useRef(null),x=xt(y,S),T=s(d,b);return R.useEffect(()=>(T.itemMap.set(S,{ref:S,...C}),()=>void T.itemMap.delete(S))),m.jsx(f,{[u]:"",ref:x,children:w})});p.displayName=d;function v(h){const y=s(t+"CollectionConsumer",h);return R.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const C=Array.from(w.querySelectorAll(`[${u}]`));return Array.from(y.itemMap.values()).sort((T,E)=>C.indexOf(T.ref.current)-C.indexOf(E.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},v,i]}var L_=g.createContext(void 0);function V_(t){const e=g.useContext(L_);return t||e||"ltr"}function Qi(t){const e=g.useRef(t);return g.useEffect(()=>{e.current=t}),g.useMemo(()=>(...n)=>{var i;return(i=e.current)==null?void 0:i.call(e,...n)},[])}function F_(t,e=globalThis==null?void 0:globalThis.document){const n=Qi(t);g.useEffect(()=>{const i=r=>{r.key==="Escape"&&n(r)};return e.addEventListener("keydown",i,{capture:!0}),()=>e.removeEventListener("keydown",i,{capture:!0})},[n,e])}var U_="DismissableLayer",eu="dismissableLayer.update",B_="dismissableLayer.pointerDownOutside",$_="dismissableLayer.focusOutside",lg,dx=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ux=g.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:i,onPointerDownOutside:r,onFocusOutside:s,onInteractOutside:o,onDismiss:a,...c}=t,l=g.useContext(dx),[d,u]=g.useState(null),f=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=g.useState({}),v=xt(e,E=>u(E)),h=Array.from(l.layers),[y]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),b=h.indexOf(y),w=d?h.indexOf(d):-1,C=l.layersWithOutsidePointerEventsDisabled.size>0,S=w>=b,x=W_(E=>{const P=E.target,_=[...l.branches].some(k=>k.contains(P));!S||_||(r==null||r(E),o==null||o(E),E.defaultPrevented||a==null||a())},f),T=q_(E=>{const P=E.target;[...l.branches].some(k=>k.contains(P))||(s==null||s(E),o==null||o(E),E.defaultPrevented||a==null||a())},f);return F_(E=>{w===l.layers.size-1&&(i==null||i(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},f),g.useEffect(()=>{if(d)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(lg=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(d)),l.layers.add(d),dg(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=lg)}},[d,f,n,l]),g.useEffect(()=>()=>{d&&(l.layers.delete(d),l.layersWithOutsidePointerEventsDisabled.delete(d),dg())},[d,l]),g.useEffect(()=>{const E=()=>p({});return document.addEventListener(eu,E),()=>document.removeEventListener(eu,E)},[]),m.jsx(et.div,{...c,ref:v,style:{pointerEvents:C?S?"auto":"none":void 0,...t.style},onFocusCapture:it(t.onFocusCapture,T.onFocusCapture),onBlurCapture:it(t.onBlurCapture,T.onBlurCapture),onPointerDownCapture:it(t.onPointerDownCapture,x.onPointerDownCapture)})});ux.displayName=U_;var H_="DismissableLayerBranch",z_=g.forwardRef((t,e)=>{const n=g.useContext(dx),i=g.useRef(null),r=xt(e,i);return g.useEffect(()=>{const s=i.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),m.jsx(et.div,{...t,ref:r})});z_.displayName=H_;function W_(t,e=globalThis==null?void 0:globalThis.document){const n=Qi(t),i=g.useRef(!1),r=g.useRef(()=>{});return g.useEffect(()=>{const s=a=>{if(a.target&&!i.current){let c=function(){fx(B_,n,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",r.current),r.current=c,e.addEventListener("click",r.current,{once:!0})):c()}else e.removeEventListener("click",r.current);i.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",s),e.removeEventListener("click",r.current)}},[e,n]),{onPointerDownCapture:()=>i.current=!0}}function q_(t,e=globalThis==null?void 0:globalThis.document){const n=Qi(t),i=g.useRef(!1);return g.useEffect(()=>{const r=s=>{s.target&&!i.current&&fx($_,n,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",r),()=>e.removeEventListener("focusin",r)},[e,n]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function dg(){const t=new CustomEvent(eu);document.dispatchEvent(t)}function fx(t,e,n,{discrete:i}){const r=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&r.addEventListener(t,e,{once:!0}),i?P_(r,s):r.dispatchEvent(s)}var xl=0;function K_(){g.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??ug()),document.body.insertAdjacentElement("beforeend",t[1]??ug()),xl++,()=>{xl===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),xl--}},[])}function ug(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Sl="focusScope.autoFocusOnMount",wl="focusScope.autoFocusOnUnmount",fg={bubbles:!1,cancelable:!0},G_="FocusScope",hx=g.forwardRef((t,e)=>{const{loop:n=!1,trapped:i=!1,onMountAutoFocus:r,onUnmountAutoFocus:s,...o}=t,[a,c]=g.useState(null),l=Qi(r),d=Qi(s),u=g.useRef(null),f=xt(e,h=>c(h)),p=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(i){let h=function(C){if(p.paused||!a)return;const S=C.target;a.contains(S)?u.current=S:ai(u.current,{select:!0})},y=function(C){if(p.paused||!a)return;const S=C.relatedTarget;S!==null&&(a.contains(S)||ai(u.current,{select:!0}))},b=function(C){if(document.activeElement===document.body)for(const x of C)x.removedNodes.length>0&&ai(a)};document.addEventListener("focusin",h),document.addEventListener("focusout",y);const w=new MutationObserver(b);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",y),w.disconnect()}}},[i,a,p.paused]),g.useEffect(()=>{if(a){mg.add(p);const h=document.activeElement;if(!a.contains(h)){const b=new CustomEvent(Sl,fg);a.addEventListener(Sl,l),a.dispatchEvent(b),b.defaultPrevented||(Z_(eN(mx(a)),{select:!0}),document.activeElement===h&&ai(a))}return()=>{a.removeEventListener(Sl,l),setTimeout(()=>{const b=new CustomEvent(wl,fg);a.addEventListener(wl,d),a.dispatchEvent(b),b.defaultPrevented||ai(h??document.body,{select:!0}),a.removeEventListener(wl,d),mg.remove(p)},0)}}},[a,l,d,p]);const v=g.useCallback(h=>{if(!n&&!i||p.paused)return;const y=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,b=document.activeElement;if(y&&b){const w=h.currentTarget,[C,S]=Y_(w);C&&S?!h.shiftKey&&b===S?(h.preventDefault(),n&&ai(C,{select:!0})):h.shiftKey&&b===C&&(h.preventDefault(),n&&ai(S,{select:!0})):b===w&&h.preventDefault()}},[n,i,p.paused]);return m.jsx(et.div,{tabIndex:-1,...o,ref:f,onKeyDown:v})});hx.displayName=G_;function Z_(t,{select:e=!1}={}){const n=document.activeElement;for(const i of t)if(ai(i,{select:e}),document.activeElement!==n)return}function Y_(t){const e=mx(t),n=hg(e,t),i=hg(e.reverse(),t);return[n,i]}function mx(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const r=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||r?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function hg(t,e){for(const n of t)if(!J_(n,{upTo:e}))return n}function J_(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function X_(t){return t instanceof HTMLInputElement&&"select"in t}function ai(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&X_(t)&&e&&t.select()}}var mg=Q_();function Q_(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=pg(t,e),t.unshift(e)},remove(e){var n;t=pg(t,e),(n=t[0])==null||n.resume()}}}function pg(t,e){const n=[...t],i=n.indexOf(e);return i!==-1&&n.splice(i,1),n}function eN(t){return t.filter(e=>e.tagName!=="A")}var tN=g[" useId ".trim().toString()]||(()=>{}),nN=0;function jf(t){const[e,n]=g.useState(tN());return Lt(()=>{n(i=>i??String(nN++))},[t]),t||(e?`radix-${e}`:"")}const iN=["top","right","bottom","left"],xi=Math.min,Ut=Math.max,ja=Math.round,Oo=Math.floor,Rn=t=>({x:t,y:t}),rN={left:"right",right:"left",bottom:"top",top:"bottom"},sN={start:"end",end:"start"};function tu(t,e,n){return Ut(t,xi(e,n))}function Xn(t,e){return typeof t=="function"?t(e):t}function Qn(t){return t.split("-")[0]}function ls(t){return t.split("-")[1]}function Lf(t){return t==="x"?"y":"x"}function Vf(t){return t==="y"?"height":"width"}const oN=new Set(["top","bottom"]);function kn(t){return oN.has(Qn(t))?"y":"x"}function Ff(t){return Lf(kn(t))}function aN(t,e,n){n===void 0&&(n=!1);const i=ls(t),r=Ff(t),s=Vf(r);let o=r==="x"?i===(n?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=La(o)),[o,La(o)]}function cN(t){const e=La(t);return[nu(t),e,nu(e)]}function nu(t){return t.replace(/start|end/g,e=>sN[e])}const gg=["left","right"],vg=["right","left"],lN=["top","bottom"],dN=["bottom","top"];function uN(t,e,n){switch(t){case"top":case"bottom":return n?e?vg:gg:e?gg:vg;case"left":case"right":return e?lN:dN;default:return[]}}function fN(t,e,n,i){const r=ls(t);let s=uN(Qn(t),n==="start",i);return r&&(s=s.map(o=>o+"-"+r),e&&(s=s.concat(s.map(nu)))),s}function La(t){return t.replace(/left|right|bottom|top/g,e=>rN[e])}function hN(t){return{top:0,right:0,bottom:0,left:0,...t}}function px(t){return typeof t!="number"?hN(t):{top:t,right:t,bottom:t,left:t}}function Va(t){const{x:e,y:n,width:i,height:r}=t;return{width:i,height:r,top:n,left:e,right:e+i,bottom:n+r,x:e,y:n}}function yg(t,e,n){let{reference:i,floating:r}=t;const s=kn(e),o=Ff(e),a=Vf(o),c=Qn(e),l=s==="y",d=i.x+i.width/2-r.width/2,u=i.y+i.height/2-r.height/2,f=i[a]/2-r[a]/2;let p;switch(c){case"top":p={x:d,y:i.y-r.height};break;case"bottom":p={x:d,y:i.y+i.height};break;case"right":p={x:i.x+i.width,y:u};break;case"left":p={x:i.x-r.width,y:u};break;default:p={x:i.x,y:i.y}}switch(ls(e)){case"start":p[o]-=f*(n&&l?-1:1);break;case"end":p[o]+=f*(n&&l?-1:1);break}return p}const mN=async(t,e,n)=>{const{placement:i="bottom",strategy:r="absolute",middleware:s=[],platform:o}=n,a=s.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(e));let l=await o.getElementRects({reference:t,floating:e,strategy:r}),{x:d,y:u}=yg(l,i,c),f=i,p={},v=0;for(let h=0;h<a.length;h++){const{name:y,fn:b}=a[h],{x:w,y:C,data:S,reset:x}=await b({x:d,y:u,initialPlacement:i,placement:f,strategy:r,middlewareData:p,rects:l,platform:o,elements:{reference:t,floating:e}});d=w??d,u=C??u,p={...p,[y]:{...p[y],...S}},x&&v<=50&&(v++,typeof x=="object"&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:r}):x.rects),{x:d,y:u}=yg(l,f,c)),h=-1)}return{x:d,y:u,placement:f,strategy:r,middlewareData:p}};async function to(t,e){var n;e===void 0&&(e={});const{x:i,y:r,platform:s,rects:o,elements:a,strategy:c}=t,{boundary:l="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:f=!1,padding:p=0}=Xn(e,t),v=px(p),y=a[f?u==="floating"?"reference":"floating":u],b=Va(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:l,rootBoundary:d,strategy:c})),w=u==="floating"?{x:i,y:r,width:o.floating.width,height:o.floating.height}:o.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),S=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},x=Va(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:C,strategy:c}):w);return{top:(b.top-x.top+v.top)/S.y,bottom:(x.bottom-b.bottom+v.bottom)/S.y,left:(b.left-x.left+v.left)/S.x,right:(x.right-b.right+v.right)/S.x}}const pN=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:r,rects:s,platform:o,elements:a,middlewareData:c}=e,{element:l,padding:d=0}=Xn(t,e)||{};if(l==null)return{};const u=px(d),f={x:n,y:i},p=Ff(r),v=Vf(p),h=await o.getDimensions(l),y=p==="y",b=y?"top":"left",w=y?"bottom":"right",C=y?"clientHeight":"clientWidth",S=s.reference[v]+s.reference[p]-f[p]-s.floating[v],x=f[p]-s.reference[p],T=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l));let E=T?T[C]:0;(!E||!await(o.isElement==null?void 0:o.isElement(T)))&&(E=a.floating[C]||s.floating[v]);const P=S/2-x/2,_=E/2-h[v]/2-1,k=xi(u[b],_),I=xi(u[w],_),N=k,K=E-h[v]-I,J=E/2-h[v]/2+P,se=tu(N,J,K),ie=!c.arrow&&ls(r)!=null&&J!==se&&s.reference[v]/2-(J<N?k:I)-h[v]/2<0,X=ie?J<N?J-N:J-K:0;return{[p]:f[p]+X,data:{[p]:se,centerOffset:J-se-X,...ie&&{alignmentOffset:X}},reset:ie}}}),gN=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,i;const{placement:r,middlewareData:s,rects:o,initialPlacement:a,platform:c,elements:l}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:h=!0,...y}=Xn(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const b=Qn(r),w=kn(a),C=Qn(a)===a,S=await(c.isRTL==null?void 0:c.isRTL(l.floating)),x=f||(C||!h?[La(a)]:cN(a)),T=v!=="none";!f&&T&&x.push(...fN(a,h,v,S));const E=[a,...x],P=await to(e,y),_=[];let k=((i=s.flip)==null?void 0:i.overflows)||[];if(d&&_.push(P[b]),u){const J=aN(r,o,S);_.push(P[J[0]],P[J[1]])}if(k=[...k,{placement:r,overflows:_}],!_.every(J=>J<=0)){var I,N;const J=(((I=s.flip)==null?void 0:I.index)||0)+1,se=E[J];if(se&&(!(u==="alignment"?w!==kn(se):!1)||k.every(O=>O.overflows[0]>0&&kn(O.placement)===w)))return{data:{index:J,overflows:k},reset:{placement:se}};let ie=(N=k.filter(X=>X.overflows[0]<=0).sort((X,O)=>X.overflows[1]-O.overflows[1])[0])==null?void 0:N.placement;if(!ie)switch(p){case"bestFit":{var K;const X=(K=k.filter(O=>{if(T){const oe=kn(O.placement);return oe===w||oe==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(oe=>oe>0).reduce((oe,L)=>oe+L,0)]).sort((O,oe)=>O[1]-oe[1])[0])==null?void 0:K[0];X&&(ie=X);break}case"initialPlacement":ie=a;break}if(r!==ie)return{reset:{placement:ie}}}return{}}}};function bg(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function xg(t){return iN.some(e=>t[e]>=0)}const vN=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:i="referenceHidden",...r}=Xn(t,e);switch(i){case"referenceHidden":{const s=await to(e,{...r,elementContext:"reference"}),o=bg(s,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:xg(o)}}}case"escaped":{const s=await to(e,{...r,altBoundary:!0}),o=bg(s,n.floating);return{data:{escapedOffsets:o,escaped:xg(o)}}}default:return{}}}}},gx=new Set(["left","top"]);async function yN(t,e){const{placement:n,platform:i,elements:r}=t,s=await(i.isRTL==null?void 0:i.isRTL(r.floating)),o=Qn(n),a=ls(n),c=kn(n)==="y",l=gx.has(o)?-1:1,d=s&&c?-1:1,u=Xn(e,t);let{mainAxis:f,crossAxis:p,alignmentAxis:v}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),c?{x:p*d,y:f*l}:{x:f*l,y:p*d}}const bN=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,i;const{x:r,y:s,placement:o,middlewareData:a}=e,c=await yN(e,t);return o===((n=a.offset)==null?void 0:n.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:r+c.x,y:s+c.y,data:{...c,placement:o}}}}},xN=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:i,placement:r}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:a={fn:y=>{let{x:b,y:w}=y;return{x:b,y:w}}},...c}=Xn(t,e),l={x:n,y:i},d=await to(e,c),u=kn(Qn(r)),f=Lf(u);let p=l[f],v=l[u];if(s){const y=f==="y"?"top":"left",b=f==="y"?"bottom":"right",w=p+d[y],C=p-d[b];p=tu(w,p,C)}if(o){const y=u==="y"?"top":"left",b=u==="y"?"bottom":"right",w=v+d[y],C=v-d[b];v=tu(w,v,C)}const h=a.fn({...e,[f]:p,[u]:v});return{...h,data:{x:h.x-n,y:h.y-i,enabled:{[f]:s,[u]:o}}}}}},SN=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:i,placement:r,rects:s,middlewareData:o}=e,{offset:a=0,mainAxis:c=!0,crossAxis:l=!0}=Xn(t,e),d={x:n,y:i},u=kn(r),f=Lf(u);let p=d[f],v=d[u];const h=Xn(a,e),y=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){const C=f==="y"?"height":"width",S=s.reference[f]-s.floating[C]+y.mainAxis,x=s.reference[f]+s.reference[C]-y.mainAxis;p<S?p=S:p>x&&(p=x)}if(l){var b,w;const C=f==="y"?"width":"height",S=gx.has(Qn(r)),x=s.reference[u]-s.floating[C]+(S&&((b=o.offset)==null?void 0:b[u])||0)+(S?0:y.crossAxis),T=s.reference[u]+s.reference[C]+(S?0:((w=o.offset)==null?void 0:w[u])||0)-(S?y.crossAxis:0);v<x?v=x:v>T&&(v=T)}return{[f]:p,[u]:v}}}},wN=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,i;const{placement:r,rects:s,platform:o,elements:a}=e,{apply:c=()=>{},...l}=Xn(t,e),d=await to(e,l),u=Qn(r),f=ls(r),p=kn(r)==="y",{width:v,height:h}=s.floating;let y,b;u==="top"||u==="bottom"?(y=u,b=f===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(b=u,y=f==="end"?"top":"bottom");const w=h-d.top-d.bottom,C=v-d.left-d.right,S=xi(h-d[y],w),x=xi(v-d[b],C),T=!e.middlewareData.shift;let E=S,P=x;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(P=C),(i=e.middlewareData.shift)!=null&&i.enabled.y&&(E=w),T&&!f){const k=Ut(d.left,0),I=Ut(d.right,0),N=Ut(d.top,0),K=Ut(d.bottom,0);p?P=v-2*(k!==0||I!==0?k+I:Ut(d.left,d.right)):E=h-2*(N!==0||K!==0?N+K:Ut(d.top,d.bottom))}await c({...e,availableWidth:P,availableHeight:E});const _=await o.getDimensions(a.floating);return v!==_.width||h!==_.height?{reset:{rects:!0}}:{}}}};function rc(){return typeof window<"u"}function ds(t){return vx(t)?(t.nodeName||"").toLowerCase():"#document"}function Ht(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Dn(t){var e;return(e=(vx(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function vx(t){return rc()?t instanceof Node||t instanceof Ht(t).Node:!1}function hn(t){return rc()?t instanceof Element||t instanceof Ht(t).Element:!1}function _n(t){return rc()?t instanceof HTMLElement||t instanceof Ht(t).HTMLElement:!1}function Sg(t){return!rc()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Ht(t).ShadowRoot}const CN=new Set(["inline","contents"]);function po(t){const{overflow:e,overflowX:n,overflowY:i,display:r}=mn(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&!CN.has(r)}const kN=new Set(["table","td","th"]);function TN(t){return kN.has(ds(t))}const EN=[":popover-open",":modal"];function sc(t){return EN.some(e=>{try{return t.matches(e)}catch{return!1}})}const PN=["transform","translate","scale","rotate","perspective"],RN=["transform","translate","scale","rotate","perspective","filter"],AN=["paint","layout","strict","content"];function Uf(t){const e=Bf(),n=hn(t)?mn(t):t;return PN.some(i=>n[i]?n[i]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||RN.some(i=>(n.willChange||"").includes(i))||AN.some(i=>(n.contain||"").includes(i))}function IN(t){let e=Si(t);for(;_n(e)&&!Xr(e);){if(Uf(e))return e;if(sc(e))return null;e=Si(e)}return null}function Bf(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const MN=new Set(["html","body","#document"]);function Xr(t){return MN.has(ds(t))}function mn(t){return Ht(t).getComputedStyle(t)}function oc(t){return hn(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Si(t){if(ds(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Sg(t)&&t.host||Dn(t);return Sg(e)?e.host:e}function yx(t){const e=Si(t);return Xr(e)?t.ownerDocument?t.ownerDocument.body:t.body:_n(e)&&po(e)?e:yx(e)}function no(t,e,n){var i;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=yx(t),s=r===((i=t.ownerDocument)==null?void 0:i.body),o=Ht(r);if(s){const a=iu(o);return e.concat(o,o.visualViewport||[],po(r)?r:[],a&&n?no(a):[])}return e.concat(r,no(r,[],n))}function iu(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function bx(t){const e=mn(t);let n=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=_n(t),s=r?t.offsetWidth:n,o=r?t.offsetHeight:i,a=ja(n)!==s||ja(i)!==o;return a&&(n=s,i=o),{width:n,height:i,$:a}}function $f(t){return hn(t)?t:t.contextElement}function Br(t){const e=$f(t);if(!_n(e))return Rn(1);const n=e.getBoundingClientRect(),{width:i,height:r,$:s}=bx(e);let o=(s?ja(n.width):n.width)/i,a=(s?ja(n.height):n.height)/r;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const _N=Rn(0);function xx(t){const e=Ht(t);return!Bf()||!e.visualViewport?_N:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function NN(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Ht(t)?!1:e}function er(t,e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1);const r=t.getBoundingClientRect(),s=$f(t);let o=Rn(1);e&&(i?hn(i)&&(o=Br(i)):o=Br(t));const a=NN(s,n,i)?xx(s):Rn(0);let c=(r.left+a.x)/o.x,l=(r.top+a.y)/o.y,d=r.width/o.x,u=r.height/o.y;if(s){const f=Ht(s),p=i&&hn(i)?Ht(i):i;let v=f,h=iu(v);for(;h&&i&&p!==v;){const y=Br(h),b=h.getBoundingClientRect(),w=mn(h),C=b.left+(h.clientLeft+parseFloat(w.paddingLeft))*y.x,S=b.top+(h.clientTop+parseFloat(w.paddingTop))*y.y;c*=y.x,l*=y.y,d*=y.x,u*=y.y,c+=C,l+=S,v=Ht(h),h=iu(v)}}return Va({width:d,height:u,x:c,y:l})}function Hf(t,e){const n=oc(t).scrollLeft;return e?e.left+n:er(Dn(t)).left+n}function Sx(t,e,n){n===void 0&&(n=!1);const i=t.getBoundingClientRect(),r=i.left+e.scrollLeft-(n?0:Hf(t,i)),s=i.top+e.scrollTop;return{x:r,y:s}}function ON(t){let{elements:e,rect:n,offsetParent:i,strategy:r}=t;const s=r==="fixed",o=Dn(i),a=e?sc(e.floating):!1;if(i===o||a&&s)return n;let c={scrollLeft:0,scrollTop:0},l=Rn(1);const d=Rn(0),u=_n(i);if((u||!u&&!s)&&((ds(i)!=="body"||po(o))&&(c=oc(i)),_n(i))){const p=er(i);l=Br(i),d.x=p.x+i.clientLeft,d.y=p.y+i.clientTop}const f=o&&!u&&!s?Sx(o,c,!0):Rn(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+d.x+f.x,y:n.y*l.y-c.scrollTop*l.y+d.y+f.y}}function DN(t){return Array.from(t.getClientRects())}function jN(t){const e=Dn(t),n=oc(t),i=t.ownerDocument.body,r=Ut(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),s=Ut(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let o=-n.scrollLeft+Hf(t);const a=-n.scrollTop;return mn(i).direction==="rtl"&&(o+=Ut(e.clientWidth,i.clientWidth)-r),{width:r,height:s,x:o,y:a}}function LN(t,e){const n=Ht(t),i=Dn(t),r=n.visualViewport;let s=i.clientWidth,o=i.clientHeight,a=0,c=0;if(r){s=r.width,o=r.height;const l=Bf();(!l||l&&e==="fixed")&&(a=r.offsetLeft,c=r.offsetTop)}return{width:s,height:o,x:a,y:c}}const VN=new Set(["absolute","fixed"]);function FN(t,e){const n=er(t,!0,e==="fixed"),i=n.top+t.clientTop,r=n.left+t.clientLeft,s=_n(t)?Br(t):Rn(1),o=t.clientWidth*s.x,a=t.clientHeight*s.y,c=r*s.x,l=i*s.y;return{width:o,height:a,x:c,y:l}}function wg(t,e,n){let i;if(e==="viewport")i=LN(t,n);else if(e==="document")i=jN(Dn(t));else if(hn(e))i=FN(e,n);else{const r=xx(t);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return Va(i)}function wx(t,e){const n=Si(t);return n===e||!hn(n)||Xr(n)?!1:mn(n).position==="fixed"||wx(n,e)}function UN(t,e){const n=e.get(t);if(n)return n;let i=no(t,[],!1).filter(a=>hn(a)&&ds(a)!=="body"),r=null;const s=mn(t).position==="fixed";let o=s?Si(t):t;for(;hn(o)&&!Xr(o);){const a=mn(o),c=Uf(o);!c&&a.position==="fixed"&&(r=null),(s?!c&&!r:!c&&a.position==="static"&&!!r&&VN.has(r.position)||po(o)&&!c&&wx(t,o))?i=i.filter(d=>d!==o):r=a,o=Si(o)}return e.set(t,i),i}function BN(t){let{element:e,boundary:n,rootBoundary:i,strategy:r}=t;const o=[...n==="clippingAncestors"?sc(e)?[]:UN(e,this._c):[].concat(n),i],a=o[0],c=o.reduce((l,d)=>{const u=wg(e,d,r);return l.top=Ut(u.top,l.top),l.right=xi(u.right,l.right),l.bottom=xi(u.bottom,l.bottom),l.left=Ut(u.left,l.left),l},wg(e,a,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function $N(t){const{width:e,height:n}=bx(t);return{width:e,height:n}}function HN(t,e,n){const i=_n(e),r=Dn(e),s=n==="fixed",o=er(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const c=Rn(0);function l(){c.x=Hf(r)}if(i||!i&&!s)if((ds(e)!=="body"||po(r))&&(a=oc(e)),i){const p=er(e,!0,s,e);c.x=p.x+e.clientLeft,c.y=p.y+e.clientTop}else r&&l();s&&!i&&r&&l();const d=r&&!i&&!s?Sx(r,a):Rn(0),u=o.left+a.scrollLeft-c.x-d.x,f=o.top+a.scrollTop-c.y-d.y;return{x:u,y:f,width:o.width,height:o.height}}function Cl(t){return mn(t).position==="static"}function Cg(t,e){if(!_n(t)||mn(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Dn(t)===n&&(n=n.ownerDocument.body),n}function Cx(t,e){const n=Ht(t);if(sc(t))return n;if(!_n(t)){let r=Si(t);for(;r&&!Xr(r);){if(hn(r)&&!Cl(r))return r;r=Si(r)}return n}let i=Cg(t,e);for(;i&&TN(i)&&Cl(i);)i=Cg(i,e);return i&&Xr(i)&&Cl(i)&&!Uf(i)?n:i||IN(t)||n}const zN=async function(t){const e=this.getOffsetParent||Cx,n=this.getDimensions,i=await n(t.floating);return{reference:HN(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function WN(t){return mn(t).direction==="rtl"}const qN={convertOffsetParentRelativeRectToViewportRelativeRect:ON,getDocumentElement:Dn,getClippingRect:BN,getOffsetParent:Cx,getElementRects:zN,getClientRects:DN,getDimensions:$N,getScale:Br,isElement:hn,isRTL:WN};function kx(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function KN(t,e){let n=null,i;const r=Dn(t);function s(){var a;clearTimeout(i),(a=n)==null||a.disconnect(),n=null}function o(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const l=t.getBoundingClientRect(),{left:d,top:u,width:f,height:p}=l;if(a||e(),!f||!p)return;const v=Oo(u),h=Oo(r.clientWidth-(d+f)),y=Oo(r.clientHeight-(u+p)),b=Oo(d),C={rootMargin:-v+"px "+-h+"px "+-y+"px "+-b+"px",threshold:Ut(0,xi(1,c))||1};let S=!0;function x(T){const E=T[0].intersectionRatio;if(E!==c){if(!S)return o();E?o(!1,E):i=setTimeout(()=>{o(!1,1e-7)},1e3)}E===1&&!kx(l,t.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(x,{...C,root:r.ownerDocument})}catch{n=new IntersectionObserver(x,C)}n.observe(t)}return o(!0),s}function GN(t,e,n,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=i,l=$f(t),d=r||s?[...l?no(l):[],...no(e)]:[];d.forEach(b=>{r&&b.addEventListener("scroll",n,{passive:!0}),s&&b.addEventListener("resize",n)});const u=l&&a?KN(l,n):null;let f=-1,p=null;o&&(p=new ResizeObserver(b=>{let[w]=b;w&&w.target===l&&p&&(p.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var C;(C=p)==null||C.observe(e)})),n()}),l&&!c&&p.observe(l),p.observe(e));let v,h=c?er(t):null;c&&y();function y(){const b=er(t);h&&!kx(h,b)&&n(),h=b,v=requestAnimationFrame(y)}return n(),()=>{var b;d.forEach(w=>{r&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),u==null||u(),(b=p)==null||b.disconnect(),p=null,c&&cancelAnimationFrame(v)}}const ZN=bN,YN=xN,JN=gN,XN=wN,QN=vN,kg=pN,eO=SN,tO=(t,e,n)=>{const i=new Map,r={platform:qN,...n},s={...r.platform,_c:i};return mN(t,e,{...r,platform:s})};var nO=typeof document<"u",iO=function(){},ua=nO?R.useLayoutEffect:iO;function Fa(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,i,r;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(i=n;i--!==0;)if(!Fa(t[i],e[i]))return!1;return!0}if(r=Object.keys(t),n=r.length,n!==Object.keys(e).length)return!1;for(i=n;i--!==0;)if(!{}.hasOwnProperty.call(e,r[i]))return!1;for(i=n;i--!==0;){const s=r[i];if(!(s==="_owner"&&t.$$typeof)&&!Fa(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function Tx(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Tg(t,e){const n=Tx(t);return Math.round(e*n)/n}function kl(t){const e=g.useRef(t);return ua(()=>{e.current=t}),e}function rO(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:i=[],platform:r,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:c,open:l}=t,[d,u]=g.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[f,p]=g.useState(i);Fa(f,i)||p(i);const[v,h]=g.useState(null),[y,b]=g.useState(null),w=g.useCallback(O=>{O!==T.current&&(T.current=O,h(O))},[]),C=g.useCallback(O=>{O!==E.current&&(E.current=O,b(O))},[]),S=s||v,x=o||y,T=g.useRef(null),E=g.useRef(null),P=g.useRef(d),_=c!=null,k=kl(c),I=kl(r),N=kl(l),K=g.useCallback(()=>{if(!T.current||!E.current)return;const O={placement:e,strategy:n,middleware:f};I.current&&(O.platform=I.current),tO(T.current,E.current,O).then(oe=>{const L={...oe,isPositioned:N.current!==!1};J.current&&!Fa(P.current,L)&&(P.current=L,qa.flushSync(()=>{u(L)}))})},[f,e,n,I,N]);ua(()=>{l===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,u(O=>({...O,isPositioned:!1})))},[l]);const J=g.useRef(!1);ua(()=>(J.current=!0,()=>{J.current=!1}),[]),ua(()=>{if(S&&(T.current=S),x&&(E.current=x),S&&x){if(k.current)return k.current(S,x,K);K()}},[S,x,K,k,_]);const se=g.useMemo(()=>({reference:T,floating:E,setReference:w,setFloating:C}),[w,C]),ie=g.useMemo(()=>({reference:S,floating:x}),[S,x]),X=g.useMemo(()=>{const O={position:n,left:0,top:0};if(!ie.floating)return O;const oe=Tg(ie.floating,d.x),L=Tg(ie.floating,d.y);return a?{...O,transform:"translate("+oe+"px, "+L+"px)",...Tx(ie.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:oe,top:L}},[n,a,ie.floating,d.x,d.y]);return g.useMemo(()=>({...d,update:K,refs:se,elements:ie,floatingStyles:X}),[d,K,se,ie,X])}const sO=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:i,padding:r}=typeof t=="function"?t(n):t;return i&&e(i)?i.current!=null?kg({element:i.current,padding:r}).fn(n):{}:i?kg({element:i,padding:r}).fn(n):{}}}},oO=(t,e)=>({...ZN(t),options:[t,e]}),aO=(t,e)=>({...YN(t),options:[t,e]}),cO=(t,e)=>({...eO(t),options:[t,e]}),lO=(t,e)=>({...JN(t),options:[t,e]}),dO=(t,e)=>({...XN(t),options:[t,e]}),uO=(t,e)=>({...QN(t),options:[t,e]}),fO=(t,e)=>({...sO(t),options:[t,e]});var hO="Arrow",Ex=g.forwardRef((t,e)=>{const{children:n,width:i=10,height:r=5,...s}=t;return m.jsx(et.svg,{...s,ref:e,width:i,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ex.displayName=hO;var mO=Ex;function pO(t){const[e,n]=g.useState(void 0);return Lt(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const i=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const s=r[0];let o,a;if("borderBoxSize"in s){const c=s.borderBoxSize,l=Array.isArray(c)?c[0]:c;o=l.inlineSize,a=l.blockSize}else o=t.offsetWidth,a=t.offsetHeight;n({width:o,height:a})});return i.observe(t,{box:"border-box"}),()=>i.unobserve(t)}else n(void 0)},[t]),e}var zf="Popper",[Px,Rx]=Df(zf),[gO,Ax]=Px(zf),Ix=t=>{const{__scopePopper:e,children:n}=t,[i,r]=g.useState(null);return m.jsx(gO,{scope:e,anchor:i,onAnchorChange:r,children:n})};Ix.displayName=zf;var Mx="PopperAnchor",_x=g.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:i,...r}=t,s=Ax(Mx,n),o=g.useRef(null),a=xt(e,o);return g.useEffect(()=>{s.onAnchorChange((i==null?void 0:i.current)||o.current)}),i?null:m.jsx(et.div,{...r,ref:a})});_x.displayName=Mx;var Wf="PopperContent",[vO,yO]=Px(Wf),Nx=g.forwardRef((t,e)=>{var D,$,Q,W,ce,z;const{__scopePopper:n,side:i="bottom",sideOffset:r=0,align:s="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:d=0,sticky:u="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:v,...h}=t,y=Ax(Wf,n),[b,w]=g.useState(null),C=xt(e,me=>w(me)),[S,x]=g.useState(null),T=pO(S),E=(T==null?void 0:T.width)??0,P=(T==null?void 0:T.height)??0,_=i+(s!=="center"?"-"+s:""),k=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},I=Array.isArray(l)?l:[l],N=I.length>0,K={padding:k,boundary:I.filter(xO),altBoundary:N},{refs:J,floatingStyles:se,placement:ie,isPositioned:X,middlewareData:O}=rO({strategy:"fixed",placement:_,whileElementsMounted:(...me)=>GN(...me,{animationFrame:p==="always"}),elements:{reference:y.anchor},middleware:[oO({mainAxis:r+P,alignmentAxis:o}),c&&aO({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?cO():void 0,...K}),c&&lO({...K}),dO({...K,apply:({elements:me,rects:Ee,availableWidth:qe,availableHeight:Ct})=>{const{width:gn,height:vn}=Ee.reference,Et=me.floating.style;Et.setProperty("--radix-popper-available-width",`${qe}px`),Et.setProperty("--radix-popper-available-height",`${Ct}px`),Et.setProperty("--radix-popper-anchor-width",`${gn}px`),Et.setProperty("--radix-popper-anchor-height",`${vn}px`)}}),S&&fO({element:S,padding:a}),SO({arrowWidth:E,arrowHeight:P}),f&&uO({strategy:"referenceHidden",...K})]}),[oe,L]=jx(ie),F=Qi(v);Lt(()=>{X&&(F==null||F())},[X,F]);const te=(D=O.arrow)==null?void 0:D.x,j=($=O.arrow)==null?void 0:$.y,q=((Q=O.arrow)==null?void 0:Q.centerOffset)!==0,[ee,G]=g.useState();return Lt(()=>{b&&G(window.getComputedStyle(b).zIndex)},[b]),m.jsx("div",{ref:J.setFloating,"data-radix-popper-content-wrapper":"",style:{...se,transform:X?se.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ee,"--radix-popper-transform-origin":[(W=O.transformOrigin)==null?void 0:W.x,(ce=O.transformOrigin)==null?void 0:ce.y].join(" "),...((z=O.hide)==null?void 0:z.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:m.jsx(vO,{scope:n,placedSide:oe,onArrowChange:x,arrowX:te,arrowY:j,shouldHideArrow:q,children:m.jsx(et.div,{"data-side":oe,"data-align":L,...h,ref:C,style:{...h.style,animation:X?void 0:"none"}})})})});Nx.displayName=Wf;var Ox="PopperArrow",bO={top:"bottom",right:"left",bottom:"top",left:"right"},Dx=g.forwardRef(function(e,n){const{__scopePopper:i,...r}=e,s=yO(Ox,i),o=bO[s.placedSide];return m.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:m.jsx(mO,{...r,ref:n,style:{...r.style,display:"block"}})})});Dx.displayName=Ox;function xO(t){return t!==null}var SO=t=>({name:"transformOrigin",options:t,fn(e){var y,b,w;const{placement:n,rects:i,middlewareData:r}=e,o=((y=r.arrow)==null?void 0:y.centerOffset)!==0,a=o?0:t.arrowWidth,c=o?0:t.arrowHeight,[l,d]=jx(n),u={start:"0%",center:"50%",end:"100%"}[d],f=(((b=r.arrow)==null?void 0:b.x)??0)+a/2,p=(((w=r.arrow)==null?void 0:w.y)??0)+c/2;let v="",h="";return l==="bottom"?(v=o?u:`${f}px`,h=`${-c}px`):l==="top"?(v=o?u:`${f}px`,h=`${i.floating.height+c}px`):l==="right"?(v=`${-c}px`,h=o?u:`${p}px`):l==="left"&&(v=`${i.floating.width+c}px`,h=o?u:`${p}px`),{data:{x:v,y:h}}}});function jx(t){const[e,n="center"]=t.split("-");return[e,n]}var wO=Ix,CO=_x,kO=Nx,TO=Dx,EO="Portal",Lx=g.forwardRef((t,e)=>{var a;const{container:n,...i}=t,[r,s]=g.useState(!1);Lt(()=>s(!0),[]);const o=n||r&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return o?bu.createPortal(m.jsx(et.div,{...i,ref:e}),o):null});Lx.displayName=EO;function PO(t){const e=g.useRef({value:t,previous:t});return g.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var Vx=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),RO="VisuallyHidden",AO=g.forwardRef((t,e)=>m.jsx(et.span,{...t,ref:e,style:{...Vx,...t.style}}));AO.displayName=RO;var IO=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},hr=new WeakMap,Do=new WeakMap,jo={},Tl=0,Fx=function(t){return t&&(t.host||Fx(t.parentNode))},MO=function(t,e){return e.map(function(n){if(t.contains(n))return n;var i=Fx(n);return i&&t.contains(i)?i:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},_O=function(t,e,n,i){var r=MO(e,Array.isArray(t)?t:[t]);jo[n]||(jo[n]=new WeakMap);var s=jo[n],o=[],a=new Set,c=new Set(r),l=function(u){!u||a.has(u)||(a.add(u),l(u.parentNode))};r.forEach(l);var d=function(u){!u||c.has(u)||Array.prototype.forEach.call(u.children,function(f){if(a.has(f))d(f);else try{var p=f.getAttribute(i),v=p!==null&&p!=="false",h=(hr.get(f)||0)+1,y=(s.get(f)||0)+1;hr.set(f,h),s.set(f,y),o.push(f),h===1&&v&&Do.set(f,!0),y===1&&f.setAttribute(n,"true"),v||f.setAttribute(i,"true")}catch(b){console.error("aria-hidden: cannot operate on ",f,b)}})};return d(e),a.clear(),Tl++,function(){o.forEach(function(u){var f=hr.get(u)-1,p=s.get(u)-1;hr.set(u,f),s.set(u,p),f||(Do.has(u)||u.removeAttribute(i),Do.delete(u)),p||u.removeAttribute(n)}),Tl--,Tl||(hr=new WeakMap,hr=new WeakMap,Do=new WeakMap,jo={})}},NO=function(t,e,n){n===void 0&&(n="data-aria-hidden");var i=Array.from(Array.isArray(t)?t:[t]),r=IO(t);return r?(i.push.apply(i,Array.from(r.querySelectorAll("[aria-live], script"))),_O(i,r,n,"aria-hidden")):function(){return null}},Cn=function(){return Cn=Object.assign||function(e){for(var n,i=1,r=arguments.length;i<r;i++){n=arguments[i];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Cn.apply(this,arguments)};function Ux(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]]);return n}function OO(t,e,n){if(n||arguments.length===2)for(var i=0,r=e.length,s;i<r;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return t.concat(s||Array.prototype.slice.call(e))}var fa="right-scroll-bar-position",ha="width-before-scroll-bar",DO="with-scroll-bars-hidden",jO="--removed-body-scroll-bar-size";function El(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function LO(t,e){var n=R.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(i){var r=n.value;r!==i&&(n.value=i,n.callback(i,r))}}}})[0];return n.callback=e,n.facade}var VO=typeof window<"u"?g.useLayoutEffect:g.useEffect,Eg=new WeakMap;function FO(t,e){var n=LO(null,function(i){return t.forEach(function(r){return El(r,i)})});return VO(function(){var i=Eg.get(n);if(i){var r=new Set(i),s=new Set(t),o=n.current;r.forEach(function(a){s.has(a)||El(a,null)}),s.forEach(function(a){r.has(a)||El(a,o)})}Eg.set(n,t)},[t]),n}function UO(t){return t}function BO(t,e){e===void 0&&(e=UO);var n=[],i=!1,r={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(s){var o=e(s,i);return n.push(o),function(){n=n.filter(function(a){return a!==o})}},assignSyncMedium:function(s){for(i=!0;n.length;){var o=n;n=[],o.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){i=!0;var o=[];if(n.length){var a=n;n=[],a.forEach(s),o=n}var c=function(){var d=o;o=[],d.forEach(s)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(d){o.push(d),l()},filter:function(d){return o=o.filter(d),n}}}};return r}function $O(t){t===void 0&&(t={});var e=BO(null);return e.options=Cn({async:!0,ssr:!1},t),e}var Bx=function(t){var e=t.sideCar,n=Ux(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=e.read();if(!i)throw new Error("Sidecar medium not found");return g.createElement(i,Cn({},n))};Bx.isSideCarExport=!0;function HO(t,e){return t.useMedium(e),Bx}var $x=$O(),Pl=function(){},ac=g.forwardRef(function(t,e){var n=g.useRef(null),i=g.useState({onScrollCapture:Pl,onWheelCapture:Pl,onTouchMoveCapture:Pl}),r=i[0],s=i[1],o=t.forwardProps,a=t.children,c=t.className,l=t.removeScrollBar,d=t.enabled,u=t.shards,f=t.sideCar,p=t.noRelative,v=t.noIsolation,h=t.inert,y=t.allowPinchZoom,b=t.as,w=b===void 0?"div":b,C=t.gapMode,S=Ux(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),x=f,T=FO([n,e]),E=Cn(Cn({},S),r);return g.createElement(g.Fragment,null,d&&g.createElement(x,{sideCar:$x,removeScrollBar:l,shards:u,noRelative:p,noIsolation:v,inert:h,setCallbacks:s,allowPinchZoom:!!y,lockRef:n,gapMode:C}),o?g.cloneElement(g.Children.only(a),Cn(Cn({},E),{ref:T})):g.createElement(w,Cn({},E,{className:c,ref:T}),a))});ac.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ac.classNames={fullWidth:ha,zeroRight:fa};var zO=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function WO(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=zO();return e&&t.setAttribute("nonce",e),t}function qO(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function KO(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var GO=function(){var t=0,e=null;return{add:function(n){t==0&&(e=WO())&&(qO(e,n),KO(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},ZO=function(){var t=GO();return function(e,n){g.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},Hx=function(){var t=ZO(),e=function(n){var i=n.styles,r=n.dynamic;return t(i,r),null};return e},YO={left:0,top:0,right:0,gap:0},Rl=function(t){return parseInt(t||"",10)||0},JO=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],i=e[t==="padding"?"paddingTop":"marginTop"],r=e[t==="padding"?"paddingRight":"marginRight"];return[Rl(n),Rl(i),Rl(r)]},XO=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return YO;var e=JO(t),n=document.documentElement.clientWidth,i=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,i-n+e[2]-e[0])}},QO=Hx(),$r="data-scroll-locked",e8=function(t,e,n,i){var r=t.left,s=t.top,o=t.right,a=t.gap;return n===void 0&&(n="margin"),`
|
|
78
|
-
.`.concat(DO,` {
|
|
79
|
-
overflow: hidden `).concat(i,`;
|
|
80
|
-
padding-right: `).concat(a,"px ").concat(i,`;
|
|
81
|
-
}
|
|
82
|
-
body[`).concat($r,`] {
|
|
83
|
-
overflow: hidden `).concat(i,`;
|
|
84
|
-
overscroll-behavior: contain;
|
|
85
|
-
`).concat([e&&"position: relative ".concat(i,";"),n==="margin"&&`
|
|
86
|
-
padding-left: `.concat(r,`px;
|
|
87
|
-
padding-top: `).concat(s,`px;
|
|
88
|
-
padding-right: `).concat(o,`px;
|
|
89
|
-
margin-left:0;
|
|
90
|
-
margin-top:0;
|
|
91
|
-
margin-right: `).concat(a,"px ").concat(i,`;
|
|
92
|
-
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(i,";")].filter(Boolean).join(""),`
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.`).concat(fa,` {
|
|
96
|
-
right: `).concat(a,"px ").concat(i,`;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.`).concat(ha,` {
|
|
100
|
-
margin-right: `).concat(a,"px ").concat(i,`;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.`).concat(fa," .").concat(fa,` {
|
|
104
|
-
right: 0 `).concat(i,`;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.`).concat(ha," .").concat(ha,` {
|
|
108
|
-
margin-right: 0 `).concat(i,`;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
body[`).concat($r,`] {
|
|
112
|
-
`).concat(jO,": ").concat(a,`px;
|
|
113
|
-
}
|
|
114
|
-
`)},Pg=function(){var t=parseInt(document.body.getAttribute($r)||"0",10);return isFinite(t)?t:0},t8=function(){g.useEffect(function(){return document.body.setAttribute($r,(Pg()+1).toString()),function(){var t=Pg()-1;t<=0?document.body.removeAttribute($r):document.body.setAttribute($r,t.toString())}},[])},n8=function(t){var e=t.noRelative,n=t.noImportant,i=t.gapMode,r=i===void 0?"margin":i;t8();var s=g.useMemo(function(){return XO(r)},[r]);return g.createElement(QO,{styles:e8(s,!e,r,n?"":"!important")})},ru=!1;if(typeof window<"u")try{var Lo=Object.defineProperty({},"passive",{get:function(){return ru=!0,!0}});window.addEventListener("test",Lo,Lo),window.removeEventListener("test",Lo,Lo)}catch{ru=!1}var mr=ru?{passive:!1}:!1,i8=function(t){return t.tagName==="TEXTAREA"},zx=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!i8(t)&&n[e]==="visible")},r8=function(t){return zx(t,"overflowY")},s8=function(t){return zx(t,"overflowX")},Rg=function(t,e){var n=e.ownerDocument,i=e;do{typeof ShadowRoot<"u"&&i instanceof ShadowRoot&&(i=i.host);var r=Wx(t,i);if(r){var s=qx(t,i),o=s[1],a=s[2];if(o>a)return!0}i=i.parentNode}while(i&&i!==n.body);return!1},o8=function(t){var e=t.scrollTop,n=t.scrollHeight,i=t.clientHeight;return[e,n,i]},a8=function(t){var e=t.scrollLeft,n=t.scrollWidth,i=t.clientWidth;return[e,n,i]},Wx=function(t,e){return t==="v"?r8(e):s8(e)},qx=function(t,e){return t==="v"?o8(e):a8(e)},c8=function(t,e){return t==="h"&&e==="rtl"?-1:1},l8=function(t,e,n,i,r){var s=c8(t,window.getComputedStyle(e).direction),o=s*i,a=n.target,c=e.contains(a),l=!1,d=o>0,u=0,f=0;do{if(!a)break;var p=qx(t,a),v=p[0],h=p[1],y=p[2],b=h-y-s*v;(v||b)&&Wx(t,a)&&(u+=b,f+=v);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!c&&a!==document.body||c&&(e.contains(a)||e===a));return(d&&Math.abs(u)<1||!d&&Math.abs(f)<1)&&(l=!0),l},Vo=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},Ag=function(t){return[t.deltaX,t.deltaY]},Ig=function(t){return t&&"current"in t?t.current:t},d8=function(t,e){return t[0]===e[0]&&t[1]===e[1]},u8=function(t){return`
|
|
115
|
-
.block-interactivity-`.concat(t,` {pointer-events: none;}
|
|
116
|
-
.allow-interactivity-`).concat(t,` {pointer-events: all;}
|
|
117
|
-
`)},f8=0,pr=[];function h8(t){var e=g.useRef([]),n=g.useRef([0,0]),i=g.useRef(),r=g.useState(f8++)[0],s=g.useState(Hx)[0],o=g.useRef(t);g.useEffect(function(){o.current=t},[t]),g.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(r));var h=OO([t.lockRef.current],(t.shards||[]).map(Ig),!0).filter(Boolean);return h.forEach(function(y){return y.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),h.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(r))})}}},[t.inert,t.lockRef.current,t.shards]);var a=g.useCallback(function(h,y){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!o.current.allowPinchZoom;var b=Vo(h),w=n.current,C="deltaX"in h?h.deltaX:w[0]-b[0],S="deltaY"in h?h.deltaY:w[1]-b[1],x,T=h.target,E=Math.abs(C)>Math.abs(S)?"h":"v";if("touches"in h&&E==="h"&&T.type==="range")return!1;var P=Rg(E,T);if(!P)return!0;if(P?x=E:(x=E==="v"?"h":"v",P=Rg(E,T)),!P)return!1;if(!i.current&&"changedTouches"in h&&(C||S)&&(i.current=x),!x)return!0;var _=i.current||x;return l8(_,y,h,_==="h"?C:S)},[]),c=g.useCallback(function(h){var y=h;if(!(!pr.length||pr[pr.length-1]!==s)){var b="deltaY"in y?Ag(y):Vo(y),w=e.current.filter(function(x){return x.name===y.type&&(x.target===y.target||y.target===x.shadowParent)&&d8(x.delta,b)})[0];if(w&&w.should){y.cancelable&&y.preventDefault();return}if(!w){var C=(o.current.shards||[]).map(Ig).filter(Boolean).filter(function(x){return x.contains(y.target)}),S=C.length>0?a(y,C[0]):!o.current.noIsolation;S&&y.cancelable&&y.preventDefault()}}},[]),l=g.useCallback(function(h,y,b,w){var C={name:h,delta:y,target:b,should:w,shadowParent:m8(b)};e.current.push(C),setTimeout(function(){e.current=e.current.filter(function(S){return S!==C})},1)},[]),d=g.useCallback(function(h){n.current=Vo(h),i.current=void 0},[]),u=g.useCallback(function(h){l(h.type,Ag(h),h.target,a(h,t.lockRef.current))},[]),f=g.useCallback(function(h){l(h.type,Vo(h),h.target,a(h,t.lockRef.current))},[]);g.useEffect(function(){return pr.push(s),t.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:f}),document.addEventListener("wheel",c,mr),document.addEventListener("touchmove",c,mr),document.addEventListener("touchstart",d,mr),function(){pr=pr.filter(function(h){return h!==s}),document.removeEventListener("wheel",c,mr),document.removeEventListener("touchmove",c,mr),document.removeEventListener("touchstart",d,mr)}},[]);var p=t.removeScrollBar,v=t.inert;return g.createElement(g.Fragment,null,v?g.createElement(s,{styles:u8(r)}):null,p?g.createElement(n8,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function m8(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const p8=HO($x,h8);var Kx=g.forwardRef(function(t,e){return g.createElement(ac,Cn({},t,{ref:e,sideCar:p8}))});Kx.classNames=ac.classNames;var g8=[" ","Enter","ArrowUp","ArrowDown"],v8=[" ","Enter"],tr="Select",[cc,lc,y8]=j_(tr),[us,jL]=Df(tr,[y8,Rx]),dc=Rx(),[b8,Ai]=us(tr),[x8,S8]=us(tr),Gx=t=>{const{__scopeSelect:e,children:n,open:i,defaultOpen:r,onOpenChange:s,value:o,defaultValue:a,onValueChange:c,dir:l,name:d,autoComplete:u,disabled:f,required:p,form:v}=t,h=dc(e),[y,b]=g.useState(null),[w,C]=g.useState(null),[S,x]=g.useState(!1),T=V_(l),[E,P]=Qd({prop:i,defaultProp:r??!1,onChange:s,caller:tr}),[_,k]=Qd({prop:o,defaultProp:a,onChange:c,caller:tr}),I=g.useRef(null),N=y?v||!!y.closest("form"):!0,[K,J]=g.useState(new Set),se=Array.from(K).map(ie=>ie.props.value).join(";");return m.jsx(wO,{...h,children:m.jsxs(b8,{required:p,scope:e,trigger:y,onTriggerChange:b,valueNode:w,onValueNodeChange:C,valueNodeHasChildren:S,onValueNodeHasChildrenChange:x,contentId:jf(),value:_,onValueChange:k,open:E,onOpenChange:P,dir:T,triggerPointerDownPosRef:I,disabled:f,children:[m.jsx(cc.Provider,{scope:e,children:m.jsx(x8,{scope:t.__scopeSelect,onNativeOptionAdd:g.useCallback(ie=>{J(X=>new Set(X).add(ie))},[]),onNativeOptionRemove:g.useCallback(ie=>{J(X=>{const O=new Set(X);return O.delete(ie),O})},[]),children:n})}),N?m.jsxs(gS,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:u,value:_,onChange:ie=>k(ie.target.value),disabled:f,form:v,children:[_===void 0?m.jsx("option",{value:""}):null,Array.from(K)]},se):null]})})};Gx.displayName=tr;var Zx="SelectTrigger",Yx=g.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:i=!1,...r}=t,s=dc(n),o=Ai(Zx,n),a=o.disabled||i,c=xt(e,o.onTriggerChange),l=lc(n),d=g.useRef("touch"),[u,f,p]=yS(h=>{const y=l().filter(C=>!C.disabled),b=y.find(C=>C.value===o.value),w=bS(y,h,b);w!==void 0&&o.onValueChange(w.value)}),v=h=>{a||(o.onOpenChange(!0),p()),h&&(o.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return m.jsx(CO,{asChild:!0,...s,children:m.jsx(et.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":vS(o.value)?"":void 0,...r,ref:c,onClick:it(r.onClick,h=>{h.currentTarget.focus(),d.current!=="mouse"&&v(h)}),onPointerDown:it(r.onPointerDown,h=>{d.current=h.pointerType;const y=h.target;y.hasPointerCapture(h.pointerId)&&y.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(v(h),h.preventDefault())}),onKeyDown:it(r.onKeyDown,h=>{const y=u.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&f(h.key),!(y&&h.key===" ")&&g8.includes(h.key)&&(v(),h.preventDefault())})})})});Yx.displayName=Zx;var Jx="SelectValue",Xx=g.forwardRef((t,e)=>{const{__scopeSelect:n,className:i,style:r,children:s,placeholder:o="",...a}=t,c=Ai(Jx,n),{onValueNodeHasChildrenChange:l}=c,d=s!==void 0,u=xt(e,c.onValueNodeChange);return Lt(()=>{l(d)},[l,d]),m.jsx(et.span,{...a,ref:u,style:{pointerEvents:"none"},children:vS(c.value)?m.jsx(m.Fragment,{children:o}):s})});Xx.displayName=Jx;var w8="SelectIcon",Qx=g.forwardRef((t,e)=>{const{__scopeSelect:n,children:i,...r}=t;return m.jsx(et.span,{"aria-hidden":!0,...r,ref:e,children:i||"▼"})});Qx.displayName=w8;var C8="SelectPortal",eS=t=>m.jsx(Lx,{asChild:!0,...t});eS.displayName=C8;var nr="SelectContent",tS=g.forwardRef((t,e)=>{const n=Ai(nr,t.__scopeSelect),[i,r]=g.useState();if(Lt(()=>{r(new DocumentFragment)},[]),!n.open){const s=i;return s?qa.createPortal(m.jsx(nS,{scope:t.__scopeSelect,children:m.jsx(cc.Slot,{scope:t.__scopeSelect,children:m.jsx("div",{children:t.children})})}),s):null}return m.jsx(iS,{...t,ref:e})});tS.displayName=nr;var on=10,[nS,Ii]=us(nr),k8="SelectContentImpl",T8=eo("SelectContent.RemoveScroll"),iS=g.forwardRef((t,e)=>{const{__scopeSelect:n,position:i="item-aligned",onCloseAutoFocus:r,onEscapeKeyDown:s,onPointerDownOutside:o,side:a,sideOffset:c,align:l,alignOffset:d,arrowPadding:u,collisionBoundary:f,collisionPadding:p,sticky:v,hideWhenDetached:h,avoidCollisions:y,...b}=t,w=Ai(nr,n),[C,S]=g.useState(null),[x,T]=g.useState(null),E=xt(e,D=>S(D)),[P,_]=g.useState(null),[k,I]=g.useState(null),N=lc(n),[K,J]=g.useState(!1),se=g.useRef(!1);g.useEffect(()=>{if(C)return NO(C)},[C]),K_();const ie=g.useCallback(D=>{const[$,...Q]=N().map(z=>z.ref.current),[W]=Q.slice(-1),ce=document.activeElement;for(const z of D)if(z===ce||(z==null||z.scrollIntoView({block:"nearest"}),z===$&&x&&(x.scrollTop=0),z===W&&x&&(x.scrollTop=x.scrollHeight),z==null||z.focus(),document.activeElement!==ce))return},[N,x]),X=g.useCallback(()=>ie([P,C]),[ie,P,C]);g.useEffect(()=>{K&&X()},[K,X]);const{onOpenChange:O,triggerPointerDownPosRef:oe}=w;g.useEffect(()=>{if(C){let D={x:0,y:0};const $=W=>{var ce,z;D={x:Math.abs(Math.round(W.pageX)-(((ce=oe.current)==null?void 0:ce.x)??0)),y:Math.abs(Math.round(W.pageY)-(((z=oe.current)==null?void 0:z.y)??0))}},Q=W=>{D.x<=10&&D.y<=10?W.preventDefault():C.contains(W.target)||O(!1),document.removeEventListener("pointermove",$),oe.current=null};return oe.current!==null&&(document.addEventListener("pointermove",$),document.addEventListener("pointerup",Q,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",Q,{capture:!0})}}},[C,O,oe]),g.useEffect(()=>{const D=()=>O(!1);return window.addEventListener("blur",D),window.addEventListener("resize",D),()=>{window.removeEventListener("blur",D),window.removeEventListener("resize",D)}},[O]);const[L,F]=yS(D=>{const $=N().filter(ce=>!ce.disabled),Q=$.find(ce=>ce.ref.current===document.activeElement),W=bS($,D,Q);W&&setTimeout(()=>W.ref.current.focus())}),te=g.useCallback((D,$,Q)=>{const W=!se.current&&!Q;(w.value!==void 0&&w.value===$||W)&&(_(D),W&&(se.current=!0))},[w.value]),j=g.useCallback(()=>C==null?void 0:C.focus(),[C]),q=g.useCallback((D,$,Q)=>{const W=!se.current&&!Q;(w.value!==void 0&&w.value===$||W)&&I(D)},[w.value]),ee=i==="popper"?su:rS,G=ee===su?{side:a,sideOffset:c,align:l,alignOffset:d,arrowPadding:u,collisionBoundary:f,collisionPadding:p,sticky:v,hideWhenDetached:h,avoidCollisions:y}:{};return m.jsx(nS,{scope:n,content:C,viewport:x,onViewportChange:T,itemRefCallback:te,selectedItem:P,onItemLeave:j,itemTextRefCallback:q,focusSelectedItem:X,selectedItemText:k,position:i,isPositioned:K,searchRef:L,children:m.jsx(Kx,{as:T8,allowPinchZoom:!0,children:m.jsx(hx,{asChild:!0,trapped:w.open,onMountAutoFocus:D=>{D.preventDefault()},onUnmountAutoFocus:it(r,D=>{var $;($=w.trigger)==null||$.focus({preventScroll:!0}),D.preventDefault()}),children:m.jsx(ux,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:D=>D.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:m.jsx(ee,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:D=>D.preventDefault(),...b,...G,onPlaced:()=>J(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:it(b.onKeyDown,D=>{const $=D.ctrlKey||D.altKey||D.metaKey;if(D.key==="Tab"&&D.preventDefault(),!$&&D.key.length===1&&F(D.key),["ArrowUp","ArrowDown","Home","End"].includes(D.key)){let W=N().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);if(["ArrowUp","End"].includes(D.key)&&(W=W.slice().reverse()),["ArrowUp","ArrowDown"].includes(D.key)){const ce=D.target,z=W.indexOf(ce);W=W.slice(z+1)}setTimeout(()=>ie(W)),D.preventDefault()}})})})})})})});iS.displayName=k8;var E8="SelectItemAlignedPosition",rS=g.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:i,...r}=t,s=Ai(nr,n),o=Ii(nr,n),[a,c]=g.useState(null),[l,d]=g.useState(null),u=xt(e,E=>d(E)),f=lc(n),p=g.useRef(!1),v=g.useRef(!0),{viewport:h,selectedItem:y,selectedItemText:b,focusSelectedItem:w}=o,C=g.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&l&&h&&y&&b){const E=s.trigger.getBoundingClientRect(),P=l.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),k=b.getBoundingClientRect();if(s.dir!=="rtl"){const ce=k.left-P.left,z=_.left-ce,me=E.left-z,Ee=E.width+me,qe=Math.max(Ee,P.width),Ct=window.innerWidth-on,gn=cg(z,[on,Math.max(on,Ct-qe)]);a.style.minWidth=Ee+"px",a.style.left=gn+"px"}else{const ce=P.right-k.right,z=window.innerWidth-_.right-ce,me=window.innerWidth-E.right-z,Ee=E.width+me,qe=Math.max(Ee,P.width),Ct=window.innerWidth-on,gn=cg(z,[on,Math.max(on,Ct-qe)]);a.style.minWidth=Ee+"px",a.style.right=gn+"px"}const I=f(),N=window.innerHeight-on*2,K=h.scrollHeight,J=window.getComputedStyle(l),se=parseInt(J.borderTopWidth,10),ie=parseInt(J.paddingTop,10),X=parseInt(J.borderBottomWidth,10),O=parseInt(J.paddingBottom,10),oe=se+ie+K+O+X,L=Math.min(y.offsetHeight*5,oe),F=window.getComputedStyle(h),te=parseInt(F.paddingTop,10),j=parseInt(F.paddingBottom,10),q=E.top+E.height/2-on,ee=N-q,G=y.offsetHeight/2,D=y.offsetTop+G,$=se+ie+D,Q=oe-$;if($<=q){const ce=I.length>0&&y===I[I.length-1].ref.current;a.style.bottom="0px";const z=l.clientHeight-h.offsetTop-h.offsetHeight,me=Math.max(ee,G+(ce?j:0)+z+X),Ee=$+me;a.style.height=Ee+"px"}else{const ce=I.length>0&&y===I[0].ref.current;a.style.top="0px";const me=Math.max(q,se+h.offsetTop+(ce?te:0)+G)+Q;a.style.height=me+"px",h.scrollTop=$-q+h.offsetTop}a.style.margin=`${on}px 0`,a.style.minHeight=L+"px",a.style.maxHeight=N+"px",i==null||i(),requestAnimationFrame(()=>p.current=!0)}},[f,s.trigger,s.valueNode,a,l,h,y,b,s.dir,i]);Lt(()=>C(),[C]);const[S,x]=g.useState();Lt(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]);const T=g.useCallback(E=>{E&&v.current===!0&&(C(),w==null||w(),v.current=!1)},[C,w]);return m.jsx(R8,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:m.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:m.jsx(et.div,{...r,ref:u,style:{boxSizing:"border-box",maxHeight:"100%",...r.style}})})})});rS.displayName=E8;var P8="SelectPopperPosition",su=g.forwardRef((t,e)=>{const{__scopeSelect:n,align:i="start",collisionPadding:r=on,...s}=t,o=dc(n);return m.jsx(kO,{...o,...s,ref:e,align:i,collisionPadding:r,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});su.displayName=P8;var[R8,qf]=us(nr,{}),ou="SelectViewport",sS=g.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:i,...r}=t,s=Ii(ou,n),o=qf(ou,n),a=xt(e,s.onViewportChange),c=g.useRef(0);return m.jsxs(m.Fragment,{children:[m.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),m.jsx(cc.Slot,{scope:n,children:m.jsx(et.div,{"data-radix-select-viewport":"",role:"presentation",...r,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...r.style},onScroll:it(r.onScroll,l=>{const d=l.currentTarget,{contentWrapper:u,shouldExpandOnScrollRef:f}=o;if(f!=null&&f.current&&u){const p=Math.abs(c.current-d.scrollTop);if(p>0){const v=window.innerHeight-on*2,h=parseFloat(u.style.minHeight),y=parseFloat(u.style.height),b=Math.max(h,y);if(b<v){const w=b+p,C=Math.min(v,w),S=w-C;u.style.height=C+"px",u.style.bottom==="0px"&&(d.scrollTop=S>0?S:0,u.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});sS.displayName=ou;var oS="SelectGroup",[A8,I8]=us(oS),M8=g.forwardRef((t,e)=>{const{__scopeSelect:n,...i}=t,r=jf();return m.jsx(A8,{scope:n,id:r,children:m.jsx(et.div,{role:"group","aria-labelledby":r,...i,ref:e})})});M8.displayName=oS;var aS="SelectLabel",_8=g.forwardRef((t,e)=>{const{__scopeSelect:n,...i}=t,r=I8(aS,n);return m.jsx(et.div,{id:r.id,...i,ref:e})});_8.displayName=aS;var Ua="SelectItem",[N8,cS]=us(Ua),lS=g.forwardRef((t,e)=>{const{__scopeSelect:n,value:i,disabled:r=!1,textValue:s,...o}=t,a=Ai(Ua,n),c=Ii(Ua,n),l=a.value===i,[d,u]=g.useState(s??""),[f,p]=g.useState(!1),v=xt(e,w=>{var C;return(C=c.itemRefCallback)==null?void 0:C.call(c,w,i,r)}),h=jf(),y=g.useRef("touch"),b=()=>{r||(a.onValueChange(i),a.onOpenChange(!1))};if(i==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return m.jsx(N8,{scope:n,value:i,disabled:r,textId:h,isSelected:l,onItemTextChange:g.useCallback(w=>{u(C=>C||((w==null?void 0:w.textContent)??"").trim())},[]),children:m.jsx(cc.ItemSlot,{scope:n,value:i,disabled:r,textValue:d,children:m.jsx(et.div,{role:"option","aria-labelledby":h,"data-highlighted":f?"":void 0,"aria-selected":l&&f,"data-state":l?"checked":"unchecked","aria-disabled":r||void 0,"data-disabled":r?"":void 0,tabIndex:r?void 0:-1,...o,ref:v,onFocus:it(o.onFocus,()=>p(!0)),onBlur:it(o.onBlur,()=>p(!1)),onClick:it(o.onClick,()=>{y.current!=="mouse"&&b()}),onPointerUp:it(o.onPointerUp,()=>{y.current==="mouse"&&b()}),onPointerDown:it(o.onPointerDown,w=>{y.current=w.pointerType}),onPointerMove:it(o.onPointerMove,w=>{var C;y.current=w.pointerType,r?(C=c.onItemLeave)==null||C.call(c):y.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:it(o.onPointerLeave,w=>{var C;w.currentTarget===document.activeElement&&((C=c.onItemLeave)==null||C.call(c))}),onKeyDown:it(o.onKeyDown,w=>{var S;((S=c.searchRef)==null?void 0:S.current)!==""&&w.key===" "||(v8.includes(w.key)&&b(),w.key===" "&&w.preventDefault())})})})})});lS.displayName=Ua;var _s="SelectItemText",dS=g.forwardRef((t,e)=>{const{__scopeSelect:n,className:i,style:r,...s}=t,o=Ai(_s,n),a=Ii(_s,n),c=cS(_s,n),l=S8(_s,n),[d,u]=g.useState(null),f=xt(e,b=>u(b),c.onItemTextChange,b=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,b,c.value,c.disabled)}),p=d==null?void 0:d.textContent,v=g.useMemo(()=>m.jsx("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:y}=l;return Lt(()=>(h(v),()=>y(v)),[h,y,v]),m.jsxs(m.Fragment,{children:[m.jsx(et.span,{id:c.textId,...s,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?qa.createPortal(s.children,o.valueNode):null]})});dS.displayName=_s;var uS="SelectItemIndicator",fS=g.forwardRef((t,e)=>{const{__scopeSelect:n,...i}=t;return cS(uS,n).isSelected?m.jsx(et.span,{"aria-hidden":!0,...i,ref:e}):null});fS.displayName=uS;var au="SelectScrollUpButton",hS=g.forwardRef((t,e)=>{const n=Ii(au,t.__scopeSelect),i=qf(au,t.__scopeSelect),[r,s]=g.useState(!1),o=xt(e,i.onScrollButtonChange);return Lt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const l=c.scrollTop>0;s(l)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),r?m.jsx(pS,{...t,ref:o,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});hS.displayName=au;var cu="SelectScrollDownButton",mS=g.forwardRef((t,e)=>{const n=Ii(cu,t.__scopeSelect),i=qf(cu,t.__scopeSelect),[r,s]=g.useState(!1),o=xt(e,i.onScrollButtonChange);return Lt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const l=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<l;s(d)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),r?m.jsx(pS,{...t,ref:o,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});mS.displayName=cu;var pS=g.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:i,...r}=t,s=Ii("SelectScrollButton",n),o=g.useRef(null),a=lc(n),c=g.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return g.useEffect(()=>()=>c(),[c]),Lt(()=>{var d;const l=a().find(u=>u.ref.current===document.activeElement);(d=l==null?void 0:l.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),m.jsx(et.div,{"aria-hidden":!0,...r,ref:e,style:{flexShrink:0,...r.style},onPointerDown:it(r.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(i,50))}),onPointerMove:it(r.onPointerMove,()=>{var l;(l=s.onItemLeave)==null||l.call(s),o.current===null&&(o.current=window.setInterval(i,50))}),onPointerLeave:it(r.onPointerLeave,()=>{c()})})}),O8="SelectSeparator",D8=g.forwardRef((t,e)=>{const{__scopeSelect:n,...i}=t;return m.jsx(et.div,{"aria-hidden":!0,...i,ref:e})});D8.displayName=O8;var lu="SelectArrow",j8=g.forwardRef((t,e)=>{const{__scopeSelect:n,...i}=t,r=dc(n),s=Ai(lu,n),o=Ii(lu,n);return s.open&&o.position==="popper"?m.jsx(TO,{...r,...i,ref:e}):null});j8.displayName=lu;var L8="SelectBubbleInput",gS=g.forwardRef(({__scopeSelect:t,value:e,...n},i)=>{const r=g.useRef(null),s=xt(i,r),o=PO(e);return g.useEffect(()=>{const a=r.current;if(!a)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(o!==e&&d){const u=new Event("change",{bubbles:!0});d.call(a,e),a.dispatchEvent(u)}},[o,e]),m.jsx(et.select,{...n,style:{...Vx,...n.style},ref:s,defaultValue:e})});gS.displayName=L8;function vS(t){return t===""||t===void 0}function yS(t){const e=Qi(t),n=g.useRef(""),i=g.useRef(0),r=g.useCallback(o=>{const a=n.current+o;e(a),function c(l){n.current=l,window.clearTimeout(i.current),l!==""&&(i.current=window.setTimeout(()=>c(""),1e3))}(a)},[e]),s=g.useCallback(()=>{n.current="",window.clearTimeout(i.current)},[]);return g.useEffect(()=>()=>window.clearTimeout(i.current),[]),[n,r,s]}function bS(t,e,n){const r=e.length>1&&Array.from(e).every(l=>l===e[0])?e[0]:e,s=n?t.indexOf(n):-1;let o=V8(t,Math.max(s,0));r.length===1&&(o=o.filter(l=>l!==n));const c=o.find(l=>l.textValue.toLowerCase().startsWith(r.toLowerCase()));return c!==n?c:void 0}function V8(t,e){return t.map((n,i)=>t[(e+i)%t.length])}var F8=Gx,U8=Yx,B8=Xx,$8=Qx,H8=eS,z8=tS,W8=sS,q8=lS,K8=dS,G8=fS,Z8=hS,Y8=mS;function Mg({...t}){return m.jsx(F8,{"data-slot":"select",...t})}function _g({...t}){return m.jsx(B8,{"data-slot":"select-value",...t})}function Ng({className:t,size:e="default",children:n,...i}){return m.jsxs(U8,{"data-slot":"select-trigger","data-size":e,className:fe(["flex w-fit cursor-pointer items-center justify-between gap-2","rounded-full px-3 py-2 text-sm whitespace-nowrap","bg-button transition-[color,border,background-color]","disabled:cursor-not-allowed disabled:opacity-50","hover:bg-muted hover:text-muted-foreground","!focus:ring-0 !focus-visible:ring-0 !focus:border-none !focus-visible:border-none !ring-0 !border-none !outline-none","aria-invalid:ring-0 dark:aria-invalid:ring-0","data-[placeholder]:text-muted-foreground","data-[size=default]:h-9 data-[size=sm]:h-8","*:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2","[&:not([class*='text-'])_svg:not([class*='text-'])]:text-muted-foreground","[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"],t),...i,children:[n,m.jsx($8,{asChild:!0,children:m.jsx(_f,{weight:"bold",className:"size-4 transition-colors"})})]})}function Og({className:t,children:e,position:n="popper",...i}){return m.jsx(H8,{children:m.jsxs(z8,{"data-slot":"select-content",className:fe(["bg-[#18182a]/90 backdrop-blur-md text-white border border-[#23233a] shadow-2xl","relative z-50 overflow-x-hidden overflow-y-auto rounded-xl","max-h-(--radix-select-content-available-height) min-w-[8rem]","origin-(--radix-select-content-transform-origin)","data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95","data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95","data-[side=top]:slide-in-from-bottom-2","data-[side=right]:slide-in-from-left-2","data-[side=bottom]:slide-in-from-top-2","data-[side=left]:slide-in-from-right-2"],n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,...i,children:[m.jsx(J8,{}),m.jsx(W8,{className:fe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:e}),m.jsx(X8,{})]})})}function Dg({className:t,children:e,...n}){return m.jsxs(q8,{"data-slot":"select-item",className:fe(["relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none","cursor-pointer disabled:cursor-not-allowed","focus:bg-accent focus:text-accent-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50","*:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2","[&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"],t),...n,children:[m.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:m.jsx(G8,{children:m.jsx($1,{className:"size-4",weight:"bold"})})}),m.jsx(K8,{children:e})]})}function J8({className:t,...e}){return m.jsx(Z8,{"data-slot":"select-scroll-up-button",className:fe("flex cursor-default items-center justify-center py-1",t),...e,children:m.jsx(U1,{className:"size-4",weight:"bold"})})}function X8({className:t,...e}){return m.jsx(Y8,{"data-slot":"select-scroll-down-button",className:fe("flex cursor-default items-center justify-center py-1",t),...e,children:m.jsx(_f,{className:"size-4",weight:"bold"})})}const jg=Wa.cva(["w-full rounded-full px-3 py-2 text-sm cursor-pointer","disabled:not-allowed hover:bg-button-hover focus:bg-button-hover"],{variants:{size:{default:"w-[180px]",sm:"w-auto"}},defaultVariants:{size:"default"}});function Lg({kind:t,track:e,requestPermissions:n,onError:i,client:r,...s}){const o=s.size||"default";if(!r)return m.jsxs(Mg,{disabled:!0,children:[m.jsx(Ng,{className:fe(jg({size:o}),s.className),children:m.jsx(_g,{placeholder:`Select a ${t}`})}),m.jsx(Og,{children:m.jsx(Dg,{value:"none",children:"No devices available"})})]});const{devices:a,activeDeviceId:c,setActiveMediaDevice:l}=N_(r,t==="audioinput"?"audioinput":"videoinput");return m.jsxs(Mg,{value:c,onValueChange:l,children:[m.jsx(Ng,{className:fe(jg({size:o}),s.className,"hover:bg"),children:o!=="sm"&&m.jsx(_g,{className:"font-mono text-sm",placeholder:`Select a ${t}`})}),m.jsx(Og,{children:a.map(d=>m.jsx(Dg,{value:d.deviceId,className:"font-mono text-xs",children:d.label},d.deviceId))})]})}function Q8(t,e,n=!1){if(n)return Nf;switch(t){case V.Source.Microphone:return e?H1:z1;case V.Source.Camera:return e?q1:K1;case V.Source.ScreenShare:return W1;default:return g.Fragment}}function Al({source:t,pressed:e,pending:n,className:i,...r}){const s=Q8(t,e??!1,n),o=t===V.Source.Microphone&&!(e??!1)&&!n,a=t===V.Source.Camera&&!(e??!1)&&!n;return g.useEffect(()=>{console.log(`TrackToggle for ${t} changed: pressed=${e}, pending=${n}, actualState=${e?"enabled":"disabled"}`)},[t,e,n]),m.jsxs(lx,{pressed:e,"aria-label":`Toggle ${t}`,className:fe(i),...r,children:[m.jsx(s,{weight:"bold",className:fe(n&&"animate-spin",o||a?"text-red-500":void 0)}),r.children]})}function e6(t){return t?I_(t):{camera:!0,microphone:!0,screenShare:!0,data:!0}}function t6(t={}){const{controls:e,saveUserChoices:n=!0,client:i}=t,r={leave:!0,...e};if(!i)return{micTrackRef:{participant:void 0,source:V.Source.Microphone,publication:void 0},visibleControls:r,microphoneToggle:{enabled:!1,pending:!1,toggle:async()=>{}},cameraToggle:{enabled:!1,pending:!1,toggle:async()=>{}},screenShareToggle:{enabled:!1,pending:!1,toggle:async()=>{}},handleDisconnect:()=>{},handleAudioDeviceChange:()=>{},handleVideoDeviceChange:()=>{}};const{microphoneTrack:s,localParticipant:o}=M_(i),a=e6(i);__(i);const c=bl(i,"microphone",{onDeviceError:T=>{var E;return(E=t.onDeviceError)==null?void 0:E.call(t,{source:V.Source.Microphone,error:T})}}),l=bl(i,"camera",{onDeviceError:T=>{var E;return(E=t.onDeviceError)==null?void 0:E.call(t,{source:V.Source.Camera,error:T})}}),d=bl(i,"screenShare",{onDeviceError:T=>{var E;return(E=t.onDeviceError)==null?void 0:E.call(t,{source:V.Source.ScreenShare,error:T})}}),u=g.useMemo(()=>{let T;if(o){for(const[,E]of o.trackPublications)if(E.source===V.Source.Microphone){T=E;break}}return console.log("🎤 Creating micTrackRef:",{hasParticipant:!!o,hasPublication:!!T,isTrackSubscribed:T==null?void 0:T.isSubscribed,isMuted:T==null?void 0:T.isMuted,trackSid:T==null?void 0:T.trackSid}),{participant:o??void 0,source:V.Source.Microphone,publication:T}},[o,s]);r.microphone??(r.microphone=a.microphone),r.screenShare??(r.screenShare=a.screenShare),r.camera??(r.camera=a.camera),r.chat??(r.chat=a.data);const{saveAudioInputEnabled:f,saveAudioInputDeviceId:p,saveVideoInputEnabled:v,saveVideoInputDeviceId:h}=O_({preventSave:!n}),y=g.useCallback(()=>{i&&i.disconnect()},[i]),b=g.useCallback(T=>{p(T??"default"),i&&i.setAudioInputDevice(T)},[p,i]),w=g.useCallback(T=>{h(T??"default"),i&&i.setVideoInputDevice(T)},[h,i]),C=g.useCallback(async T=>{d.enabled&&await d.toggle(!1),await l.toggle(T),v(!l.enabled)},[l,v,d]),S=g.useCallback(async T=>{await c.toggle(T),f(!c.enabled)},[c,f]),x=g.useCallback(async T=>{l.enabled&&await l.toggle(!1),await d.toggle(T)},[l,d]);return{micTrackRef:u,visibleControls:r,cameraToggle:{...l,toggle:C},microphoneToggle:{...c,toggle:S},screenShareToggle:{...d,toggle:x},handleDisconnect:y,handleAudioDeviceChange:b,handleVideoDeviceChange:w}}const n6={card:" bg-gradient-to-br from-black to-gray-900 border border-gray-900 w-full h-full flex flex-col justify-between overflow-hidden mx-auto my-auto rounded-2xl shadow-lg",cardTopGradient:"pointer-events-none absolute top-0 left-0 w-full h-10 z-10 bg-gradient-to-b from-black/90 to-transparent",cardRadial:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-gray-800/20 via-transparent to-transparent",cardPurpleBlur:"absolute top-0 right-0 w-32 h-32 bg-gradient-to-br from-gray-600/10 to-transparent rounded-full blur-2xl",cardPinkBlur:"absolute bottom-0 left-0 w-24 h-24 bg-gradient-to-tr from-gray-500/8 to-transparent rounded-full blur-xl",cardPulse1:"absolute -top-2 -left-2 w-6 h-6 bg-gradient-to-br from-gray-400 to-gray-500 rounded-full blur-sm opacity-20 animate-pulse",cardPulse2:"absolute -bottom-2 -right-2 w-4 h-4 bg-gradient-to-br from-gray-500 to-gray-600 rounded-full blur-sm opacity-15 animate-pulse",main:"w-full flex flex-col items-center justify-center max-w-md mx-auto bg-gradient-to-br from-black to-gray-900 rounded-2xl shadow-xl p-0 overflow-hidden h-full",text:{primary:"text-white",secondary:"text-gray-300",muted:"text-gray-400",accent:"bg-clip-text text-transparent bg-gradient-to-r from-white via-gray-200 to-gray-300"},micButton:"absolute w-20 h-20 bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 mic-glow shadow-2xl group",chatButton:"absolute w-20 h-20 bg-gradient-to-br from-[#10B981] to-[#059669] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",videoButton:"absolute w-20 h-20 bg-gradient-to-br from-[#8B5CF6] to-[#EC4899] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",popupTrigger:"bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] text-white font-medium hover:from-[#2563EB] hover:to-[#7C3AED] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-gray-900",promptSlider:"absolute w-full py-3 px-2 bg-gray-900 rounded-xl text-center text-white text-sm transition-opacity duration-700 ease-in-out border border-gray-600",statusIndicator:"w-2 h-2 bg-gray-400 rounded-full animate-pulse",pulseRings:{ring1:"w-32 h-32 rounded-full border-2 border-gray-600/30 pulse-ring",ring2:"absolute w-28 h-28 rounded-full border-2 border-gray-500/20 pulse-ring",ring3:"absolute w-24 h-24 rounded-full border-2 border-gray-400/15 pulse-ring"},controlBar:"border border-gray-600 rounded-3xl py-4 flex flex-col justify-end h-full bg-gray-900/50 backdrop-blur-sm",chatInput:{container:"bg-gray-900 w-full border-gray-600",textarea:"bg-gray-800 border-none text-white placeholder-gray-400",sendButton:"bg-blue-600 hover:bg-blue-700 disabled:bg-gray-600 disabled:opacity-50 text-white",attachButton:"text-gray-400 hover:text-gray-300 hover:bg-gray-700",endButton:"bg-red-900/20 hover:bg-red-800/30 text-red-400 border-red-800"},chatMessage:{own:"bg-gray-600 text-white",other:"bg-gray-700 text-white"},chatHeader:{container:"bg-gray-900 border-gray-600",backButton:"text-gray-400 hover:text-white hover:bg-gray-700"},spinner:"w-10 h-10 animate-spin text-gray-400 mb-2",suggestedResponse:{container:"bg-gray-800 text-blue-300 border-gray-700 hover:bg-gray-700 hover:text-white"},video:{container:"bg-gradient-to-br from-black to-gray-900 text-white",header:"border-gray-700 bg-gray-900/50",headerButton:"bg-gray-800 hover:bg-gray-700 text-gray-300",statusDot:"bg-green-500 animate-pulse",controlsBackground:"bg-gray-900/80 backdrop-blur-sm border-t border-gray-700",controlEnabled:"bg-blue-600 hover:bg-blue-700 text-white",controlDisabled:"bg-gray-700 hover:bg-gray-600 text-gray-300",endCall:"bg-red-600 hover:bg-red-700 text-white",tile:"bg-gray-800 border border-gray-700 shadow-lg",placeholder:"bg-gray-800 text-gray-300",avatar:"bg-gray-700 text-gray-300",nameOverlay:"bg-black/70 text-white",mutedIndicator:"bg-red-600/80 text-white"}},i6={card:" bg-gradient-to-br from-white to-gray-50 border border-gray-200 w-full h-full flex flex-col justify-between overflow-hidden mx-auto my-auto shadow-lg",cardTopGradient:"pointer-events-none absolute top-0 left-0 w-full h-10 z-10 bg-gradient-to-b from-white/90 to-transparent",cardRadial:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-blue-500/5 via-transparent to-transparent",cardPurpleBlur:"absolute top-0 right-0 w-32 h-32 bg-gradient-to-br from-purple-500/10 to-transparent rounded-full blur-2xl",cardPinkBlur:"absolute bottom-0 left-0 w-24 h-24 bg-gradient-to-tr from-pink-500/8 to-transparent rounded-full blur-xl",cardPulse1:"absolute -top-2 -left-2 w-6 h-6 bg-gradient-to-br from-blue-500 to-purple-500 rounded-full blur-sm opacity-30 animate-pulse",cardPulse2:"absolute -bottom-2 -right-2 w-4 h-4 bg-gradient-to-br from-pink-500 to-purple-500 rounded-full blur-sm opacity-20 animate-pulse",main:"w-full flex flex-col items-center justify-center max-w-md mx-auto bg-gradient-to-br from-white to-gray-50 rounded-2xl shadow-xl p-0 overflow-hidden h-full",text:{primary:"text-gray-900",secondary:"text-gray-700",muted:"text-gray-500",accent:"bg-clip-text text-transparent bg-gradient-to-r from-blue-600 via-purple-600 to-pink-600"},micButton:"absolute text-white w-20 h-20 bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 mic-glow shadow-2xl group",chatButton:"absolute text-white w-20 h-20 bg-gradient-to-br from-[#10B981] to-[#059669] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",videoButton:"absolute text-white w-20 h-20 bg-gradient-to-br from-[#8B5CF6] to-[#EC4899] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",popupTrigger:"bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] text-white font-medium hover:from-[#2563EB] hover:to-[#7C3AED] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-white",promptSlider:"absolute w-full py-3 px-2 bg-gray-100 rounded-xl text-center text-gray-700 text-sm transition-opacity duration-700 ease-in-out border border-gray-200",statusIndicator:"w-2 h-2 bg-green-500 rounded-full animate-pulse",pulseRings:{ring1:"w-32 h-32 rounded-full border-2 border-blue-500/20 pulse-ring",ring2:"absolute w-28 h-28 rounded-full border-2 border-purple-500/15 pulse-ring",ring3:"absolute w-24 h-24 rounded-full border-2 border-pink-500/10 pulse-ring"},controlBar:"border border-gray-200 rounded-3xl py-4 flex flex-col justify-end h-full bg-white/80 backdrop-blur-sm",chatInput:{container:"bg-white/90 border-gray-200 shadow-sm",textarea:"bg-white border-none text-gray-900 placeholder-gray-500 ",sendButton:"bg-blue-600 hover:bg-blue-700 disabled:bg-gray-300 disabled:opacity-50 text-white",attachButton:"text-gray-500 hover:text-gray-700 hover:bg-gray-100 bg-blue-50",endButton:"bg-red-50 hover:bg-red-100 text-red-600 border-red-200"},chatMessage:{own:"bg-blue-50 text-gray-900 border border-blue-100",other:"bg-gray-50 text-gray-900 border border-gray-200"},chatHeader:{container:"bg-white border-gray-200",backButton:"text-gray-500 hover:text-gray-700 hover:bg-gray-100"},spinner:"w-10 h-10 animate-spin text-blue-500 mb-2",suggestedResponse:{container:"bg-white text-blue-700 border-blue-200 hover:bg-blue-50 hover:text-blue-900"},video:{container:"bg-gradient-to-br from-white to-gray-50 text-gray-900",header:"border-gray-200 bg-white/80",headerButton:"bg-gray-100 hover:bg-gray-200 text-gray-600",statusDot:"bg-green-500 animate-pulse",controlsBackground:"bg-white/90 backdrop-blur-sm border-t border-gray-200",controlEnabled:"bg-blue-600 hover:bg-blue-700 text-white",controlDisabled:"bg-gray-200 hover:bg-gray-300 text-gray-600",endCall:"bg-red-600 hover:bg-red-700 text-white",tile:"bg-white border border-gray-200 shadow-sm",placeholder:"bg-gray-50 text-gray-600",avatar:"bg-gray-200 text-gray-600",nameOverlay:"bg-black/70 text-white",mutedIndicator:"bg-red-600/80 text-white"}},r6={card:" text-white bg-gradient-to-br from-[#171727] to-[#12121F] border border-gray-800 w-full h-full flex flex-col justify-between overflow-hidden mx-auto my-auto",cardTopGradient:"pointer-events-none absolute top-0 left-0 w-full h-10 z-10 bg-gradient-to-b from-[#171727]/90 to-transparent",cardRadial:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-[#3B82F6]/15 via-transparent to-transparent",cardPurpleBlur:"absolute top-0 right-0 w-32 h-32 bg-gradient-to-br from-[#8B5CF6]/25 to-transparent rounded-full blur-2xl",cardPinkBlur:"absolute bottom-0 left-0 w-24 h-24 bg-gradient-to-tr from-[#EC4899]/20 to-transparent rounded-full blur-xl",cardPulse1:"absolute -top-2 -left-2 w-6 h-6 bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] rounded-full blur-sm opacity-50 animate-pulse",cardPulse2:"absolute -bottom-2 -right-2 w-4 h-4 bg-gradient-to-br from-[#EC4899] to-[#8B5CF6] rounded-full blur-sm opacity-40 animate-pulse",main:"w-full flex flex-col items-center justify-center max-w-md mx-auto bg-gradient-to-br from-[#171727] to-[#12121F] rounded-2xl shadow-xl p-0 overflow-hidden h-full",text:{primary:"text-white",secondary:"text-gray-300",muted:"text-gray-400",accent:"bg-clip-text text-transparent bg-gradient-to-r from-[#3B82F6] via-[#8B5CF6] to-[#EC4899]"},micButton:"absolute w-20 h-20 bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 mic-glow shadow-2xl group",chatButton:"absolute w-20 h-20 bg-gradient-to-br from-[#10B981] to-[#059669] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",videoButton:"absolute w-20 h-20 bg-gradient-to-br from-[#8B5CF6] to-[#EC4899] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",popupTrigger:"bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] text-white font-medium hover:from-[#2563EB] hover:to-[#7C3AED] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-gray-900 shadow-xl",promptSlider:"absolute w-full py-3 px-2 bg-[#1E1E2E] rounded-xl text-center text-gray-200 text-sm transition-opacity duration-700 ease-in-out border border-gray-700",statusIndicator:"w-2 h-2 bg-[#10B981] rounded-full animate-pulse",pulseRings:{ring1:"w-32 h-32 rounded-full border-2 border-[#3B82F6]/40 pulse-ring",ring2:"absolute w-28 h-28 rounded-full border-2 border-[#8B5CF6]/30 pulse-ring",ring3:"absolute w-24 h-24 rounded-full border-2 border-[#EC4899]/20 pulse-ring"},controlBar:"border border-border rounded-3xl py-4 flex flex-col justify-end h-full",chatInput:{container:"bg-[#1E1E2E] border-gray-700",textarea:"bg-[#1E1E2E] border-none text-white placeholder-gray-400",sendButton:"bg-[#3B82F6] hover:bg-[#2563EB] disabled:bg-gray-600 disabled:opacity-50 text-white",attachButton:"text-gray-400 hover:text-gray-300 hover:bg-gray-700",endButton:"bg-red-900/20 hover:bg-red-800/30 text-red-400 border-red-800"},chatMessage:{own:"bg-[#1E1E2E]/80 text-white",other:"bg-[#1E1E2E] text-white border border-gray-700"},chatHeader:{container:"bg-[#1E1E2E] border-gray-700",backButton:"text-gray-400 hover:text-white hover:bg-gray-700"},spinner:"w-10 h-10 animate-spin text-blue-400 mb-2",suggestedResponse:{container:"bg-[#221f3f] text-white border-none"},video:{container:"bg-gradient-to-br from-[#171727] to-[#12121F] text-white",header:"border-gray-700 bg-[#1E1E2E]/80",headerButton:"bg-[#1E1E2E] hover:bg-gray-700 text-gray-300",statusDot:"bg-[#10B981] animate-pulse",controlsBackground:"bg-[#1E1E2E]/90 backdrop-blur-sm border-t border-gray-700",controlEnabled:"bg-[#3B82F6] hover:bg-[#2563EB] text-white",controlDisabled:"bg-gray-700 hover:bg-gray-600 text-gray-300",endCall:"bg-red-600 hover:bg-red-700 text-white",tile:"bg-[#1E1E2E] border border-gray-700 shadow-xl",placeholder:"bg-[#1E1E2E] text-gray-300",avatar:"bg-gray-700 text-gray-300",nameOverlay:"bg-black/70 text-white",mutedIndicator:"bg-red-600/80 text-white"}},Vg={dark:n6,light:i6,vox:r6};function St(t){return Vg[t]||Vg.vox}function s6({controls:t,saveUserChoices:e=!0,capabilities:n,className:i,onSendMessage:r,onChatOpenChange:s,onDisconnect:o,onDeviceError:a,theme:c="vox",client:l,...d}){const[u,f]=g.useState(!1),[p,v]=g.useState(!1),h=St(c),{micTrackRef:y,visibleControls:b,cameraToggle:w,microphoneToggle:C,screenShareToggle:S,handleAudioDeviceChange:x,handleVideoDeviceChange:T,handleDisconnect:E}=t6({controls:t,saveUserChoices:e,client:l}),P=async _=>{v(!0);try{await(r==null?void 0:r(_))}finally{v(!1)}};return g.useEffect(()=>{s==null||s(u)},[u,s]),g.useEffect(()=>{var _,k,I,N;console.log("🎤 AgentControlBar: micTrackRef changed:",{hasParticipant:!!y.participant,hasPublication:!!y.publication,source:y.source,isSubscribed:(_=y.publication)==null?void 0:_.isSubscribed,isMuted:(k=y.publication)==null?void 0:k.isMuted,trackSid:(I=y.publication)==null?void 0:I.trackSid,hasTrack:!!((N=y.publication)!=null&&N.track)})},[y]),m.jsxs("div",{"aria-label":"Voice assistant controls",className:fe(h.controlBar,i),...d,children:[n.suportsChatInput&&m.jsxs("div",{inert:!u,className:fe("overflow-hidden transition-[height] relative duration-300 ease-in-out",u?"h-[64px] mb-3":"h-0"),children:[m.jsx("div",{className:"flex h-9 px-4 w-full",children:m.jsx(w_,{onSend:P,disabled:p,className:fe("w-full",h.chatInput)})}),m.jsx("hr",{className:"border-border my-2 mx-5"})]}),m.jsxs("div",{className:fe("flex flex-row items-center gap-2 rounded-2xl mx-auto border-none backdrop-blur-lg px-2 py-2",c==="light"?"bg-white/80":"bg-[#18182a]/80"),children:[m.jsxs("div",{className:"flex gap-y-2 justify-start",children:[b.microphone&&m.jsxs("div",{className:"flex gap-y-2 items-center rounded-full overflow-hidden border-none ",children:[m.jsx(Al,{variant:"primary",source:V.Source.Microphone,pressed:C.enabled,disabled:C.pending,onPressedChange:C.toggle,className:"w-auto py-2 rounded-none border-none bg-transparent text-inherit focus:bg-primary/80 hover:bg-primary/80 transition-colors"}),m.jsx(V1,{barCount:3,trackRef:y,options:{minHeight:5},className:"flex h-full w-auto items-center justify-center gap-x-0.5",children:m.jsx("span",{className:fe(["h-full w-0.5 origin-center rounded-2xl","bg-white","group-data-[state=on]/track:bg-white group-data-[state=off]/track:bg-white","data-lk-muted:bg-muted"])})}),m.jsx(Lg,{size:"sm",kind:"audioinput",client:l,onError:a?_=>_ instanceof Error?a({source:V.Source.Microphone,error:_}):void 0:void 0,onActiveDeviceChange:x,className:fe(["h-full py-2 rounded-none border-none bg-transparent text-inherit focus:bg-primary/80 hover:bg-primary/30 transition-colors","min-w-[2.5rem]"])})]}),n.suportsVideoInput&&b.camera&&m.jsxs("div",{className:"flex items-center rounded-full overflow-hidden border-none ",children:[m.jsx(Al,{variant:"primary",source:V.Source.Camera,pressed:w.enabled,pending:w.pending,disabled:w.pending,onPressedChange:w.toggle,className:"w-auto py-2 rounded-none border-none bg-transparent text-inherit focus:bg-primary/80 hover:bg-primary/80 transition-colors"}),m.jsx(Lg,{size:"sm",kind:"videoinput",client:l,onError:a?_=>_ instanceof Error?a({source:V.Source.Camera,error:_}):void 0:void 0,onActiveDeviceChange:T,className:fe(["h-full py-2 rounded-none border-none bg-transparent text-inherit focus:bg-primary/80 hover:bg-primary/80 transition-colors","min-w-[2.5rem]"])})]}),n.suportsScreenShare&&b.screenShare&&m.jsx("div",{className:"flex items-center rounded-full overflow-hidden border-none ",children:m.jsx(Al,{variant:"secondary",source:V.Source.ScreenShare,pressed:S.enabled,disabled:S.pending,onPressedChange:S.toggle,className:"w-auto py-2 disabled:opacity-70 rounded-none border-none bg-transparent text-inherit focus:bg-primary/80 hover:bg-primary/80 transition-colors"})})]}),b.chat&&m.jsx("div",{className:"flex items-center rounded-full overflow-hidden bg-secondary text-secondary-foreground border-none ",children:m.jsx(lx,{variant:"secondary","aria-label":"Toggle chat",pressed:u,onPressedChange:_=>{f(_)},className:"aspect-square h-full py-3 rounded-none border-none bg-transparent text-inherit focus:bg-secondary/80 hover:bg-secondary/80 transition-colors flex items-center",children:m.jsx(B1,{weight:"bold",className:"h-5 w-5"})})})]})]})}const o6=(t,e)=>{var a,c;const n=g.useMemo(()=>e?e(t.message):t.message,[t.message,e]),i=!!t.editTimestamp,r=new Date(t.timestamp),s=typeof navigator<"u"?navigator.language:"en-US",o=(a=t.from)!=null&&a.name&&t.from.name!==""?t.from.name:(c=t.from)==null?void 0:c.identity;return{message:n,hasBeenEdited:i,time:r,locale:s,name:o}},a6=({entry:t,messageFormatter:e,className:n,participantName:i,...r})=>{var d,u;const{message:s,time:o,locale:a}=o6(t,e),c=((d=t.from)==null?void 0:d.isLocal)??!1;fe("w-full px-3 py-2 rounded-2xl text-xs break-words whitespace-pre-line",c?" text-end border border-[#5078F2]/30":"bg-muted text-foreground border border-[#813aa7]/30","text-left");const l=fe("inline-flex items-center justify-center w-6 h-6 rounded-full text-xs font-bold flex-shrink-0",c?"bg-[#5078F2] text-white":"bg-[#813aa7] ml-1 text-white");return m.jsx("li",{title:o.toLocaleTimeString(a,{timeStyle:"full"}),className:fe("group flex mb-2",c?"justify-end":"justify-start",n),...r,children:m.jsxs("div",{className:fe("flex w-fit max-w-full rounded-2xl border",c?"flex-row-reverse items-center border-[#5078F2]/30":"flex-row items-center border-[#813aa7]/30 bg-muted text-foreground"),children:[m.jsx("span",{className:l,children:c?((u=i==null?void 0:i[0])==null?void 0:u.toUpperCase())||"U":"A"}),m.jsx("span",{className:fe("flex items-center text-xs break-words whitespace-pre-line",c?"ml-auto justify-end text-right":"justify-start text-left","px-3 py-2"),children:s})]})})};function c6(t){R.useEffect(()=>{function e(){const n=t.current;n&&(n.scrollTop=n.scrollHeight)}if(t.current){const n=new ResizeObserver(e);return n.observe(t.current),e(),()=>n.disconnect()}},[t])}const l6=({className:t,children:e,...n})=>{const i=R.useRef(null);return c6(i),m.jsx("div",{ref:i,className:fe("flex flex-col justify-end",t),...n,children:e})},d6=({state:t,audioTrack:e,className:n,ref:i})=>m.jsx("div",{ref:i,className:fe("",n),children:m.jsx(V1,{barCount:5,state:t,options:{minHeight:5},trackRef:e,className:fe("flex aspect-video w-40 items-center justify-center gap-1"),children:m.jsx("span",{className:fe(["bg-[#6721a4] min-h-2 w-2 rounded-full","origin-center transition-colors duration-250 ease-linear","data-[lk-highlighted=true]:bg-[#5c64f6]","data-[lk-muted=true]:bg-[#222222]"])})})}),u6=({videoTrack:t,className:e,ref:n})=>{var i,r;return m.jsx("div",{ref:n,className:fe(e),children:m.jsx(Mf,{trackRef:t,width:((i=t==null?void 0:t.publication.dimensions)==null?void 0:i.width)??0,height:((r=t==null?void 0:t.publication.dimensions)==null?void 0:r.height)??0,className:"rounded-md"})})},f6=xe.create(Mf),h6=({trackRef:t,className:e,ref:n})=>{var i,r;return m.jsx("div",{className:fe("bg-muted overflow-hidden rounded-md",e),children:m.jsx(f6,{ref:n,trackRef:t,width:((i=t==null?void 0:t.publication.dimensions)==null?void 0:i.width)??0,height:((r=t==null?void 0:t.publication.dimensions)==null?void 0:r.height)??0,className:fe("h-full w-auto")})})},Fg=xe.create(h6),m6=xe.create(d6),p6=xe.create(u6),Vn={initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},exit:{opacity:0,scale:0},transition:{type:"spring",stiffness:675,damping:75,mass:1}},gr={grid:["h-full w-full","grid gap-x-2 place-content-center","grid-cols-[1fr_1fr] grid-rows-[90px_1fr_90px]"],agentChatOpenWithSecondTile:["col-start-1 row-start-1","self-center justify-self-end"],agentChatOpenWithoutSecondTile:["col-start-1 row-start-1","col-span-2","place-content-center"],agentChatClosed:["col-start-1 row-start-1","col-span-2 row-span-3","place-content-center"],secondTileChatOpen:["col-start-2 row-start-1","self-center justify-self-start"],secondTileChatClosed:["col-start-2 row-start-3","place-content-end"]};function g6(t){const{localParticipant:e}=VM(),n=e.getTrackPublication(t);return R.useMemo(()=>n?{source:t,participant:e,publication:n}:void 0,[t,n,e])}function v6({chatOpen:t}){const{state:e,audioTrack:n,videoTrack:i,agent:{isActive:r=!1}={}}=j1(),[s]=If([V.Source.ScreenShare]),o=g6(V.Source.Camera),a=o&&!o.publication.isMuted,c=s&&!s.publication.isMuted,l=a||c,d={...Vn.transition,delay:t?0:.15},u={...Vn.animate,scale:t?1:3,transition:d},f={...Vn.animate,transition:d},p=d,v=d,h=i!==void 0;return m.jsx("div",{className:"relative w-full h-full z-10 flex items-center justify-center",children:m.jsx("div",{className:"relative w-full h-full max-w-2xl px-4 md:px-0",children:m.jsxs("div",{className:fe(gr.grid),children:[r&&m.jsx("div",{className:fe(["grid",!t&&gr.agentChatClosed,t&&l&&gr.agentChatOpenWithSecondTile,t&&!l&&gr.agentChatOpenWithoutSecondTile]),children:m.jsxs("div",{className:"h-full flex items-center justify-center",children:[!h&&m.jsx(m6,{layoutId:"agent",...Vn,animate:u,transition:p,state:e,audioTrack:n,className:fe(t?"h-[90px]":"h-auto w-full")},"agent"),h&&m.jsx(p6,{layoutId:"avatar",...Vn,animate:f,transition:v,videoTrack:i,className:fe(t?"h-[90px] [&>video]:h-[90px] [&>video]:w-auto":"h-auto w-full")},"avatar")]})}),m.jsx("div",{className:fe(["grid",t&&gr.secondTileChatOpen,!t&&gr.secondTileChatClosed]),children:m.jsxs("div",{className:"w-full px-10 flex items-center shadow-2xl justify-between",children:[o&&a&&m.jsx(Fg,{layout:"position",layoutId:"camera",...Vn,trackRef:o,transition:{...Vn.transition,delay:t?0:.15},className:"h-[60px] order-1"},"camera"),c&&m.jsx(Fg,{layout:"position",layoutId:"screen",...Vn,trackRef:s,transition:{...Vn.transition,delay:t?0:.15},className:"h-[70px] order-2"},"screen")]})})]})})})}/**
|
|
118
|
-
* @license lucide-react v0.522.0 - ISC
|
|
119
|
-
*
|
|
120
|
-
* This source code is licensed under the ISC license.
|
|
121
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
122
|
-
*/const y6=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),b6=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,i)=>i?i.toUpperCase():n.toLowerCase()),Ug=t=>{const e=b6(t);return e.charAt(0).toUpperCase()+e.slice(1)},xS=(...t)=>t.filter((e,n,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===n).join(" ").trim(),x6=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};/**
|
|
123
|
-
* @license lucide-react v0.522.0 - ISC
|
|
124
|
-
*
|
|
125
|
-
* This source code is licensed under the ISC license.
|
|
126
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
127
|
-
*/var S6={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
128
|
-
* @license lucide-react v0.522.0 - ISC
|
|
129
|
-
*
|
|
130
|
-
* This source code is licensed under the ISC license.
|
|
131
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
132
|
-
*/const w6=R.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:r="",children:s,iconNode:o,...a},c)=>R.createElement("svg",{ref:c,...S6,width:e,height:e,stroke:t,strokeWidth:i?Number(n)*24/Number(e):n,className:xS("lucide",r),...!s&&!x6(a)&&{"aria-hidden":"true"},...a},[...o.map(([l,d])=>R.createElement(l,d)),...Array.isArray(s)?s:[s]]));/**
|
|
133
|
-
* @license lucide-react v0.522.0 - ISC
|
|
134
|
-
*
|
|
135
|
-
* This source code is licensed under the ISC license.
|
|
136
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
137
|
-
*/const wt=(t,e)=>{const n=R.forwardRef(({className:i,...r},s)=>R.createElement(w6,{ref:s,iconNode:e,className:xS(`lucide-${y6(Ug(t))}`,`lucide-${t}`,i),...r}));return n.displayName=Ug(t),n};/**
|
|
138
|
-
* @license lucide-react v0.522.0 - ISC
|
|
139
|
-
*
|
|
140
|
-
* This source code is licensed under the ISC license.
|
|
141
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
142
|
-
*/const C6=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],k6=wt("archive",C6);/**
|
|
143
|
-
* @license lucide-react v0.522.0 - ISC
|
|
144
|
-
*
|
|
145
|
-
* This source code is licensed under the ISC license.
|
|
146
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
147
|
-
*/const T6=[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16",key:"qmtpty"}],["path",{d:"M9.5 4h5L17 7h3a2 2 0 0 1 2 2v7.5",key:"1ufyfc"}],["path",{d:"M14.121 15.121A3 3 0 1 1 9.88 10.88",key:"11zox6"}]],SS=wt("camera-off",T6);/**
|
|
148
|
-
* @license lucide-react v0.522.0 - ISC
|
|
149
|
-
*
|
|
150
|
-
* This source code is licensed under the ISC license.
|
|
151
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
152
|
-
*/const E6=[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],wS=wt("camera",E6);/**
|
|
153
|
-
* @license lucide-react v0.522.0 - ISC
|
|
154
|
-
*
|
|
155
|
-
* This source code is licensed under the ISC license.
|
|
156
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
157
|
-
*/const P6=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],R6=wt("download",P6);/**
|
|
158
|
-
* @license lucide-react v0.522.0 - ISC
|
|
159
|
-
*
|
|
160
|
-
* This source code is licensed under the ISC license.
|
|
161
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
162
|
-
*/const A6=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],I6=wt("file-text",A6);/**
|
|
163
|
-
* @license lucide-react v0.522.0 - ISC
|
|
164
|
-
*
|
|
165
|
-
* This source code is licensed under the ISC license.
|
|
166
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
167
|
-
*/const M6=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],_6=wt("image",M6);/**
|
|
168
|
-
* @license lucide-react v0.522.0 - ISC
|
|
169
|
-
*
|
|
170
|
-
* This source code is licensed under the ISC license.
|
|
171
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
172
|
-
*/const N6=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],O6=wt("layout-grid",N6);/**
|
|
173
|
-
* @license lucide-react v0.522.0 - ISC
|
|
174
|
-
*
|
|
175
|
-
* This source code is licensed under the ISC license.
|
|
176
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
177
|
-
*/const D6=[["path",{d:"M17 17H4a2 2 0 0 1-2-2V5c0-1.5 1-2 1-2",key:"k0q8oc"}],["path",{d:"M22 15V5a2 2 0 0 0-2-2H9",key:"cp1ac0"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],j6=wt("monitor-off",D6);/**
|
|
178
|
-
* @license lucide-react v0.522.0 - ISC
|
|
179
|
-
*
|
|
180
|
-
* This source code is licensed under the ISC license.
|
|
181
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
182
|
-
*/const L6=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],V6=wt("monitor",L6);/**
|
|
183
|
-
* @license lucide-react v0.522.0 - ISC
|
|
184
|
-
*
|
|
185
|
-
* This source code is licensed under the ISC license.
|
|
186
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
187
|
-
*/const F6=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],U6=wt("music",F6);/**
|
|
188
|
-
* @license lucide-react v0.522.0 - ISC
|
|
189
|
-
*
|
|
190
|
-
* This source code is licensed under the ISC license.
|
|
191
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
192
|
-
*/const B6=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],$6=wt("paperclip",B6);/**
|
|
193
|
-
* @license lucide-react v0.522.0 - ISC
|
|
194
|
-
*
|
|
195
|
-
* This source code is licensed under the ISC license.
|
|
196
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
197
|
-
*/const H6=[["path",{d:"M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272",key:"1wngk7"}],["path",{d:"M22 2 2 22",key:"y4kqgn"}],["path",{d:"M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473",key:"10hv5p"}]],CS=wt("phone-off",H6);/**
|
|
198
|
-
* @license lucide-react v0.522.0 - ISC
|
|
199
|
-
*
|
|
200
|
-
* This source code is licensed under the ISC license.
|
|
201
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
202
|
-
*/const z6=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],W6=wt("send-horizontal",z6);/**
|
|
203
|
-
* @license lucide-react v0.522.0 - ISC
|
|
204
|
-
*
|
|
205
|
-
* This source code is licensed under the ISC license.
|
|
206
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
207
|
-
*/const q6=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],K6=wt("user",q6);/**
|
|
208
|
-
* @license lucide-react v0.522.0 - ISC
|
|
209
|
-
*
|
|
210
|
-
* This source code is licensed under the ISC license.
|
|
211
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
212
|
-
*/const G6=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Z6=wt("users",G6);/**
|
|
213
|
-
* @license lucide-react v0.522.0 - ISC
|
|
214
|
-
*
|
|
215
|
-
* This source code is licensed under the ISC license.
|
|
216
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
217
|
-
*/const Y6=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],J6=wt("video",Y6);/**
|
|
218
|
-
* @license lucide-react v0.522.0 - ISC
|
|
219
|
-
*
|
|
220
|
-
* This source code is licensed under the ISC license.
|
|
221
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
222
|
-
*/const X6=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Q6=wt("x",X6);function Bg({timeout:t}){const[e,n]=R.useState(100),i=R.useRef(null),r=R.useRef(null);return R.useEffect(()=>{if(!t||t<=0)return;n(100),r.current=Date.now();const s=()=>{if(!t||r.current===null)return;const o=Date.now()-r.current,a=Math.max(0,100-o/t*100);n(a),a>0&&(i.current=requestAnimationFrame(s))};return i.current=requestAnimationFrame(s),()=>{i.current&&cancelAnimationFrame(i.current)}},[t]),!t||t<=0?null:m.jsx("div",{className:"w-full h-1 relative top-1 rounded-t-4xl bg-gray-700 overflow-hidden",children:m.jsx(xe.div,{className:"h-1 rounded-t-4xl dark:bg-white bg-blue-200 ",initial:{width:"100%"},animate:{width:`${Math.max(e,2)}%`},transition:{duration:.1,ease:"linear"},style:{minWidth:"2%"}})})}function Qr({interaction:t,theme:e,onDismiss:n,client:i,addLocalMessage:r}){var a;if(!t||!t.isVisible||!t.component)return null;const[s]=g.useState(()=>Date.now()),o=()=>t.component?g.createElement(t.component,{handler:t.handler||void 0,timeout:t.timeout,loadData:async l=>{console.log("InteractiveComponent: Loading data:",l)},presentationMode:t.presentationMode,data:t.data,client:i,addLocalMessage:r}):m.jsx("div",{className:"p-4 text-red-500",children:"Component not found"});switch(t.presentationMode){case"fullscreen":return m.jsx(Vr,{children:m.jsxs(xe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[9999] bg-black",children:[m.jsxs("div",{className:"flex flex-col",children:[m.jsx(Bg,{timeout:t.timeout}),m.jsxs("div",{className:"flex items-center justify-between p-4 bg-black/80 text-white border-b border-gray-700",children:[m.jsx("h3",{className:"text-lg font-semibold",children:t.methodName.replace(/_/g," ").replace(/\b\w/g,c=>c.toUpperCase())}),m.jsx("button",{onClick:n||((a=t.handler)==null?void 0:a.dismissView),className:"p-2 rounded-full bg-white/20 hover:bg-white/30 text-white transition-colors",children:m.jsx(Q6,{className:"w-5 h-5"})})]})]}),m.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:o()})]})});case"embedded":default:return m.jsx(Vr,{children:m.jsx(xe.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"w-fit rounded-lg ",children:m.jsxs("div",{children:[m.jsx(Bg,{timeout:t.timeout}),o()]})})})}}function eD(){const t=JM(),e=$M(),n=ho();return{messages:R.useMemo(()=>[...t.map(s=>c_(s,n)),...e.chatMessages].sort((s,o)=>s.timestamp-o.timestamp),[t,e.chatMessages,n]),send:e.send}}const tD=({logLevel:t}={})=>{const e=ho();g.useEffect(()=>(xk(t??"debug"),window.__lk_room=e,()=>{window.__lk_room=void 0}),[e,t])},$g=t=>t,nD=()=>{let t=$g;return{configure(e){t=e},generate(e){return t(e)},reset(){t=$g}}},iD=nD();function wi(t,...e){const n=new URL(`https://mui.com/production-error/?code=${t}`);return e.forEach(i=>n.searchParams.append("args[]",i)),`Minified MUI error #${t}; visit ${n} for the full message.`}function ir(t){if(typeof t!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":wi(7));return t.charAt(0).toUpperCase()+t.slice(1)}var Fo={exports:{}},Uo={exports:{}},Me={};/** @license React v16.13.1
|
|
223
|
-
* react-is.production.min.js
|
|
224
|
-
*
|
|
225
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
226
|
-
*
|
|
227
|
-
* This source code is licensed under the MIT license found in the
|
|
228
|
-
* LICENSE file in the root directory of this source tree.
|
|
229
|
-
*/var Hg;function rD(){if(Hg)return Me;Hg=1;var t=typeof Symbol=="function"&&Symbol.for,e=t?Symbol.for("react.element"):60103,n=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,r=t?Symbol.for("react.strict_mode"):60108,s=t?Symbol.for("react.profiler"):60114,o=t?Symbol.for("react.provider"):60109,a=t?Symbol.for("react.context"):60110,c=t?Symbol.for("react.async_mode"):60111,l=t?Symbol.for("react.concurrent_mode"):60111,d=t?Symbol.for("react.forward_ref"):60112,u=t?Symbol.for("react.suspense"):60113,f=t?Symbol.for("react.suspense_list"):60120,p=t?Symbol.for("react.memo"):60115,v=t?Symbol.for("react.lazy"):60116,h=t?Symbol.for("react.block"):60121,y=t?Symbol.for("react.fundamental"):60117,b=t?Symbol.for("react.responder"):60118,w=t?Symbol.for("react.scope"):60119;function C(x){if(typeof x=="object"&&x!==null){var T=x.$$typeof;switch(T){case e:switch(x=x.type,x){case c:case l:case i:case s:case r:case u:return x;default:switch(x=x&&x.$$typeof,x){case a:case d:case v:case p:case o:return x;default:return T}}case n:return T}}}function S(x){return C(x)===l}return Me.AsyncMode=c,Me.ConcurrentMode=l,Me.ContextConsumer=a,Me.ContextProvider=o,Me.Element=e,Me.ForwardRef=d,Me.Fragment=i,Me.Lazy=v,Me.Memo=p,Me.Portal=n,Me.Profiler=s,Me.StrictMode=r,Me.Suspense=u,Me.isAsyncMode=function(x){return S(x)||C(x)===c},Me.isConcurrentMode=S,Me.isContextConsumer=function(x){return C(x)===a},Me.isContextProvider=function(x){return C(x)===o},Me.isElement=function(x){return typeof x=="object"&&x!==null&&x.$$typeof===e},Me.isForwardRef=function(x){return C(x)===d},Me.isFragment=function(x){return C(x)===i},Me.isLazy=function(x){return C(x)===v},Me.isMemo=function(x){return C(x)===p},Me.isPortal=function(x){return C(x)===n},Me.isProfiler=function(x){return C(x)===s},Me.isStrictMode=function(x){return C(x)===r},Me.isSuspense=function(x){return C(x)===u},Me.isValidElementType=function(x){return typeof x=="string"||typeof x=="function"||x===i||x===l||x===s||x===r||x===u||x===f||typeof x=="object"&&x!==null&&(x.$$typeof===v||x.$$typeof===p||x.$$typeof===o||x.$$typeof===a||x.$$typeof===d||x.$$typeof===y||x.$$typeof===b||x.$$typeof===w||x.$$typeof===h)},Me.typeOf=C,Me}var _e={};/** @license React v16.13.1
|
|
230
|
-
* react-is.development.js
|
|
231
|
-
*
|
|
232
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
233
|
-
*
|
|
234
|
-
* This source code is licensed under the MIT license found in the
|
|
235
|
-
* LICENSE file in the root directory of this source tree.
|
|
236
|
-
*/var zg;function sD(){return zg||(zg=1,process.env.NODE_ENV!=="production"&&function(){var t=typeof Symbol=="function"&&Symbol.for,e=t?Symbol.for("react.element"):60103,n=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,r=t?Symbol.for("react.strict_mode"):60108,s=t?Symbol.for("react.profiler"):60114,o=t?Symbol.for("react.provider"):60109,a=t?Symbol.for("react.context"):60110,c=t?Symbol.for("react.async_mode"):60111,l=t?Symbol.for("react.concurrent_mode"):60111,d=t?Symbol.for("react.forward_ref"):60112,u=t?Symbol.for("react.suspense"):60113,f=t?Symbol.for("react.suspense_list"):60120,p=t?Symbol.for("react.memo"):60115,v=t?Symbol.for("react.lazy"):60116,h=t?Symbol.for("react.block"):60121,y=t?Symbol.for("react.fundamental"):60117,b=t?Symbol.for("react.responder"):60118,w=t?Symbol.for("react.scope"):60119;function C(z){return typeof z=="string"||typeof z=="function"||z===i||z===l||z===s||z===r||z===u||z===f||typeof z=="object"&&z!==null&&(z.$$typeof===v||z.$$typeof===p||z.$$typeof===o||z.$$typeof===a||z.$$typeof===d||z.$$typeof===y||z.$$typeof===b||z.$$typeof===w||z.$$typeof===h)}function S(z){if(typeof z=="object"&&z!==null){var me=z.$$typeof;switch(me){case e:var Ee=z.type;switch(Ee){case c:case l:case i:case s:case r:case u:return Ee;default:var qe=Ee&&Ee.$$typeof;switch(qe){case a:case d:case v:case p:case o:return qe;default:return me}}case n:return me}}}var x=c,T=l,E=a,P=o,_=e,k=d,I=i,N=v,K=p,J=n,se=s,ie=r,X=u,O=!1;function oe(z){return O||(O=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),L(z)||S(z)===c}function L(z){return S(z)===l}function F(z){return S(z)===a}function te(z){return S(z)===o}function j(z){return typeof z=="object"&&z!==null&&z.$$typeof===e}function q(z){return S(z)===d}function ee(z){return S(z)===i}function G(z){return S(z)===v}function D(z){return S(z)===p}function $(z){return S(z)===n}function Q(z){return S(z)===s}function W(z){return S(z)===r}function ce(z){return S(z)===u}_e.AsyncMode=x,_e.ConcurrentMode=T,_e.ContextConsumer=E,_e.ContextProvider=P,_e.Element=_,_e.ForwardRef=k,_e.Fragment=I,_e.Lazy=N,_e.Memo=K,_e.Portal=J,_e.Profiler=se,_e.StrictMode=ie,_e.Suspense=X,_e.isAsyncMode=oe,_e.isConcurrentMode=L,_e.isContextConsumer=F,_e.isContextProvider=te,_e.isElement=j,_e.isForwardRef=q,_e.isFragment=ee,_e.isLazy=G,_e.isMemo=D,_e.isPortal=$,_e.isProfiler=Q,_e.isStrictMode=W,_e.isSuspense=ce,_e.isValidElementType=C,_e.typeOf=S}()),_e}var Wg;function kS(){return Wg||(Wg=1,process.env.NODE_ENV==="production"?Uo.exports=rD():Uo.exports=sD()),Uo.exports}/*
|
|
237
|
-
object-assign
|
|
238
|
-
(c) Sindre Sorhus
|
|
239
|
-
@license MIT
|
|
240
|
-
*/var Il,qg;function oD(){if(qg)return Il;qg=1;var t=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(s){if(s==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(s)}function r(){try{if(!Object.assign)return!1;var s=new String("abc");if(s[5]="de",Object.getOwnPropertyNames(s)[0]==="5")return!1;for(var o={},a=0;a<10;a++)o["_"+String.fromCharCode(a)]=a;var c=Object.getOwnPropertyNames(o).map(function(d){return o[d]});if(c.join("")!=="0123456789")return!1;var l={};return"abcdefghijklmnopqrst".split("").forEach(function(d){l[d]=d}),Object.keys(Object.assign({},l)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Il=r()?Object.assign:function(s,o){for(var a,c=i(s),l,d=1;d<arguments.length;d++){a=Object(arguments[d]);for(var u in a)e.call(a,u)&&(c[u]=a[u]);if(t){l=t(a);for(var f=0;f<l.length;f++)n.call(a,l[f])&&(c[l[f]]=a[l[f]])}}return c},Il}var Ml,Kg;function Kf(){if(Kg)return Ml;Kg=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Ml=t,Ml}var _l,Gg;function TS(){return Gg||(Gg=1,_l=Function.call.bind(Object.prototype.hasOwnProperty)),_l}var Nl,Zg;function aD(){if(Zg)return Nl;Zg=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var e=Kf(),n={},i=TS();t=function(s){var o="Warning: "+s;typeof console<"u"&&console.error(o);try{throw new Error(o)}catch{}}}function r(s,o,a,c,l){if(process.env.NODE_ENV!=="production"){for(var d in s)if(i(s,d)){var u;try{if(typeof s[d]!="function"){var f=Error((c||"React class")+": "+a+" type `"+d+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof s[d]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw f.name="Invariant Violation",f}u=s[d](o,d,c,a,null,e)}catch(v){u=v}if(u&&!(u instanceof Error)&&t((c||"React class")+": type specification of "+a+" `"+d+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof u+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),u instanceof Error&&!(u.message in n)){n[u.message]=!0;var p=l?l():"";t("Failed "+a+" type: "+u.message+(p??""))}}}}return r.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},Nl=r,Nl}var Ol,Yg;function cD(){if(Yg)return Ol;Yg=1;var t=kS(),e=oD(),n=Kf(),i=TS(),r=aD(),s=function(){};process.env.NODE_ENV!=="production"&&(s=function(a){var c="Warning: "+a;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}});function o(){return null}return Ol=function(a,c){var l=typeof Symbol=="function"&&Symbol.iterator,d="@@iterator";function u(L){var F=L&&(l&&L[l]||L[d]);if(typeof F=="function")return F}var f="<<anonymous>>",p={array:b("array"),bigint:b("bigint"),bool:b("boolean"),func:b("function"),number:b("number"),object:b("object"),string:b("string"),symbol:b("symbol"),any:w(),arrayOf:C,element:S(),elementType:x(),instanceOf:T,node:k(),objectOf:P,oneOf:E,oneOfType:_,shape:N,exact:K};function v(L,F){return L===F?L!==0||1/L===1/F:L!==L&&F!==F}function h(L,F){this.message=L,this.data=F&&typeof F=="object"?F:{},this.stack=""}h.prototype=Error.prototype;function y(L){if(process.env.NODE_ENV!=="production")var F={},te=0;function j(ee,G,D,$,Q,W,ce){if($=$||f,W=W||D,ce!==n){if(c){var z=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw z.name="Invariant Violation",z}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var me=$+":"+D;!F[me]&&te<3&&(s("You are manually calling a React.PropTypes validation function for the `"+W+"` prop on `"+$+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),F[me]=!0,te++)}}return G[D]==null?ee?G[D]===null?new h("The "+Q+" `"+W+"` is marked as required "+("in `"+$+"`, but its value is `null`.")):new h("The "+Q+" `"+W+"` is marked as required in "+("`"+$+"`, but its value is `undefined`.")):null:L(G,D,$,Q,W)}var q=j.bind(null,!1);return q.isRequired=j.bind(null,!0),q}function b(L){function F(te,j,q,ee,G,D){var $=te[j],Q=ie($);if(Q!==L){var W=X($);return new h("Invalid "+ee+" `"+G+"` of type "+("`"+W+"` supplied to `"+q+"`, expected ")+("`"+L+"`."),{expectedType:L})}return null}return y(F)}function w(){return y(o)}function C(L){function F(te,j,q,ee,G){if(typeof L!="function")return new h("Property `"+G+"` of component `"+q+"` has invalid PropType notation inside arrayOf.");var D=te[j];if(!Array.isArray(D)){var $=ie(D);return new h("Invalid "+ee+" `"+G+"` of type "+("`"+$+"` supplied to `"+q+"`, expected an array."))}for(var Q=0;Q<D.length;Q++){var W=L(D,Q,q,ee,G+"["+Q+"]",n);if(W instanceof Error)return W}return null}return y(F)}function S(){function L(F,te,j,q,ee){var G=F[te];if(!a(G)){var D=ie(G);return new h("Invalid "+q+" `"+ee+"` of type "+("`"+D+"` supplied to `"+j+"`, expected a single ReactElement."))}return null}return y(L)}function x(){function L(F,te,j,q,ee){var G=F[te];if(!t.isValidElementType(G)){var D=ie(G);return new h("Invalid "+q+" `"+ee+"` of type "+("`"+D+"` supplied to `"+j+"`, expected a single ReactElement type."))}return null}return y(L)}function T(L){function F(te,j,q,ee,G){if(!(te[j]instanceof L)){var D=L.name||f,$=oe(te[j]);return new h("Invalid "+ee+" `"+G+"` of type "+("`"+$+"` supplied to `"+q+"`, expected ")+("instance of `"+D+"`."))}return null}return y(F)}function E(L){if(!Array.isArray(L))return process.env.NODE_ENV!=="production"&&(arguments.length>1?s("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):s("Invalid argument supplied to oneOf, expected an array.")),o;function F(te,j,q,ee,G){for(var D=te[j],$=0;$<L.length;$++)if(v(D,L[$]))return null;var Q=JSON.stringify(L,function(ce,z){var me=X(z);return me==="symbol"?String(z):z});return new h("Invalid "+ee+" `"+G+"` of value `"+String(D)+"` "+("supplied to `"+q+"`, expected one of "+Q+"."))}return y(F)}function P(L){function F(te,j,q,ee,G){if(typeof L!="function")return new h("Property `"+G+"` of component `"+q+"` has invalid PropType notation inside objectOf.");var D=te[j],$=ie(D);if($!=="object")return new h("Invalid "+ee+" `"+G+"` of type "+("`"+$+"` supplied to `"+q+"`, expected an object."));for(var Q in D)if(i(D,Q)){var W=L(D,Q,q,ee,G+"."+Q,n);if(W instanceof Error)return W}return null}return y(F)}function _(L){if(!Array.isArray(L))return process.env.NODE_ENV!=="production"&&s("Invalid argument supplied to oneOfType, expected an instance of array."),o;for(var F=0;F<L.length;F++){var te=L[F];if(typeof te!="function")return s("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+O(te)+" at index "+F+"."),o}function j(q,ee,G,D,$){for(var Q=[],W=0;W<L.length;W++){var ce=L[W],z=ce(q,ee,G,D,$,n);if(z==null)return null;z.data&&i(z.data,"expectedType")&&Q.push(z.data.expectedType)}var me=Q.length>0?", expected one of type ["+Q.join(", ")+"]":"";return new h("Invalid "+D+" `"+$+"` supplied to "+("`"+G+"`"+me+"."))}return y(j)}function k(){function L(F,te,j,q,ee){return J(F[te])?null:new h("Invalid "+q+" `"+ee+"` supplied to "+("`"+j+"`, expected a ReactNode."))}return y(L)}function I(L,F,te,j,q){return new h((L||"React class")+": "+F+" type `"+te+"."+j+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+q+"`.")}function N(L){function F(te,j,q,ee,G){var D=te[j],$=ie(D);if($!=="object")return new h("Invalid "+ee+" `"+G+"` of type `"+$+"` "+("supplied to `"+q+"`, expected `object`."));for(var Q in L){var W=L[Q];if(typeof W!="function")return I(q,ee,G,Q,X(W));var ce=W(D,Q,q,ee,G+"."+Q,n);if(ce)return ce}return null}return y(F)}function K(L){function F(te,j,q,ee,G){var D=te[j],$=ie(D);if($!=="object")return new h("Invalid "+ee+" `"+G+"` of type `"+$+"` "+("supplied to `"+q+"`, expected `object`."));var Q=e({},te[j],L);for(var W in Q){var ce=L[W];if(i(L,W)&&typeof ce!="function")return I(q,ee,G,W,X(ce));if(!ce)return new h("Invalid "+ee+" `"+G+"` key `"+W+"` supplied to `"+q+"`.\nBad object: "+JSON.stringify(te[j],null," ")+`
|
|
241
|
-
Valid keys: `+JSON.stringify(Object.keys(L),null," "));var z=ce(D,W,q,ee,G+"."+W,n);if(z)return z}return null}return y(F)}function J(L){switch(typeof L){case"number":case"string":case"undefined":return!0;case"boolean":return!L;case"object":if(Array.isArray(L))return L.every(J);if(L===null||a(L))return!0;var F=u(L);if(F){var te=F.call(L),j;if(F!==L.entries){for(;!(j=te.next()).done;)if(!J(j.value))return!1}else for(;!(j=te.next()).done;){var q=j.value;if(q&&!J(q[1]))return!1}}else return!1;return!0;default:return!1}}function se(L,F){return L==="symbol"?!0:F?F["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&F instanceof Symbol:!1}function ie(L){var F=typeof L;return Array.isArray(L)?"array":L instanceof RegExp?"object":se(F,L)?"symbol":F}function X(L){if(typeof L>"u"||L===null)return""+L;var F=ie(L);if(F==="object"){if(L instanceof Date)return"date";if(L instanceof RegExp)return"regexp"}return F}function O(L){var F=X(L);switch(F){case"array":case"object":return"an "+F;case"boolean":case"date":case"regexp":return"a "+F;default:return F}}function oe(L){return!L.constructor||!L.constructor.name?f:L.constructor.name}return p.checkPropTypes=r,p.resetWarningCache=r.resetWarningCache,p.PropTypes=p,p},Ol}var Dl,Jg;function lD(){if(Jg)return Dl;Jg=1;var t=Kf();function e(){}function n(){}return n.resetWarningCache=e,Dl=function(){function i(o,a,c,l,d,u){if(u!==t){var f=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw f.name="Invariant Violation",f}}i.isRequired=i;function r(){return i}var s={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:r,element:i,elementType:i,instanceOf:r,node:i,objectOf:r,oneOf:r,oneOfType:r,shape:r,exact:r,checkPropTypes:n,resetWarningCache:e};return s.PropTypes=s,s},Dl}var Xg;function dD(){if(Xg)return Fo.exports;if(Xg=1,process.env.NODE_ENV!=="production"){var t=kS(),e=!0;Fo.exports=cD()(t.isElement,e)}else Fo.exports=lD()();return Fo.exports}var uD=dD();const Pe=Vw(uD);function fD(t,e,n=void 0){const i={};for(const r in t){const s=t[r];let o="",a=!0;for(let c=0;c<s.length;c+=1){const l=s[c];l&&(o+=(a===!0?"":" ")+e(l),a=!1,n&&n[l]&&(o+=" "+n[l]))}i[r]=o}return i}var Bo={exports:{}},Ne={};/**
|
|
242
|
-
* @license React
|
|
243
|
-
* react-is.production.js
|
|
244
|
-
*
|
|
245
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
246
|
-
*
|
|
247
|
-
* This source code is licensed under the MIT license found in the
|
|
248
|
-
* LICENSE file in the root directory of this source tree.
|
|
249
|
-
*/var Qg;function hD(){if(Qg)return Ne;Qg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),l=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),f=Symbol.for("react.view_transition"),p=Symbol.for("react.client.reference");function v(h){if(typeof h=="object"&&h!==null){var y=h.$$typeof;switch(y){case t:switch(h=h.type,h){case n:case r:case i:case c:case l:case f:return h;default:switch(h=h&&h.$$typeof,h){case o:case a:case u:case d:return h;case s:return h;default:return y}}case e:return y}}}return Ne.ContextConsumer=s,Ne.ContextProvider=o,Ne.Element=t,Ne.ForwardRef=a,Ne.Fragment=n,Ne.Lazy=u,Ne.Memo=d,Ne.Portal=e,Ne.Profiler=r,Ne.StrictMode=i,Ne.Suspense=c,Ne.SuspenseList=l,Ne.isContextConsumer=function(h){return v(h)===s},Ne.isContextProvider=function(h){return v(h)===o},Ne.isElement=function(h){return typeof h=="object"&&h!==null&&h.$$typeof===t},Ne.isForwardRef=function(h){return v(h)===a},Ne.isFragment=function(h){return v(h)===n},Ne.isLazy=function(h){return v(h)===u},Ne.isMemo=function(h){return v(h)===d},Ne.isPortal=function(h){return v(h)===e},Ne.isProfiler=function(h){return v(h)===r},Ne.isStrictMode=function(h){return v(h)===i},Ne.isSuspense=function(h){return v(h)===c},Ne.isSuspenseList=function(h){return v(h)===l},Ne.isValidElementType=function(h){return typeof h=="string"||typeof h=="function"||h===n||h===r||h===i||h===c||h===l||typeof h=="object"&&h!==null&&(h.$$typeof===u||h.$$typeof===d||h.$$typeof===o||h.$$typeof===s||h.$$typeof===a||h.$$typeof===p||h.getModuleId!==void 0)},Ne.typeOf=v,Ne}var Oe={};/**
|
|
250
|
-
* @license React
|
|
251
|
-
* react-is.development.js
|
|
252
|
-
*
|
|
253
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
254
|
-
*
|
|
255
|
-
* This source code is licensed under the MIT license found in the
|
|
256
|
-
* LICENSE file in the root directory of this source tree.
|
|
257
|
-
*/var e0;function mD(){return e0||(e0=1,process.env.NODE_ENV!=="production"&&function(){function t(h){if(typeof h=="object"&&h!==null){var y=h.$$typeof;switch(y){case e:switch(h=h.type,h){case i:case s:case r:case l:case d:case p:return h;default:switch(h=h&&h.$$typeof,h){case a:case c:case f:case u:return h;case o:return h;default:return y}}case n:return y}}}var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),a=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.view_transition"),v=Symbol.for("react.client.reference");Oe.ContextConsumer=o,Oe.ContextProvider=a,Oe.Element=e,Oe.ForwardRef=c,Oe.Fragment=i,Oe.Lazy=f,Oe.Memo=u,Oe.Portal=n,Oe.Profiler=s,Oe.StrictMode=r,Oe.Suspense=l,Oe.SuspenseList=d,Oe.isContextConsumer=function(h){return t(h)===o},Oe.isContextProvider=function(h){return t(h)===a},Oe.isElement=function(h){return typeof h=="object"&&h!==null&&h.$$typeof===e},Oe.isForwardRef=function(h){return t(h)===c},Oe.isFragment=function(h){return t(h)===i},Oe.isLazy=function(h){return t(h)===f},Oe.isMemo=function(h){return t(h)===u},Oe.isPortal=function(h){return t(h)===n},Oe.isProfiler=function(h){return t(h)===s},Oe.isStrictMode=function(h){return t(h)===r},Oe.isSuspense=function(h){return t(h)===l},Oe.isSuspenseList=function(h){return t(h)===d},Oe.isValidElementType=function(h){return typeof h=="string"||typeof h=="function"||h===i||h===s||h===r||h===l||h===d||typeof h=="object"&&h!==null&&(h.$$typeof===f||h.$$typeof===u||h.$$typeof===a||h.$$typeof===o||h.$$typeof===c||h.$$typeof===v||h.getModuleId!==void 0)},Oe.typeOf=t}()),Oe}var t0;function pD(){return t0||(t0=1,process.env.NODE_ENV==="production"?Bo.exports=hD():Bo.exports=mD()),Bo.exports}var Ba=pD();function qn(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function ES(t){if(g.isValidElement(t)||Ba.isValidElementType(t)||!qn(t))return t;const e={};return Object.keys(t).forEach(n=>{e[n]=ES(t[n])}),e}function zt(t,e,n={clone:!0}){const i=n.clone?{...t}:t;return qn(t)&&qn(e)&&Object.keys(e).forEach(r=>{g.isValidElement(e[r])||Ba.isValidElementType(e[r])?i[r]=e[r]:qn(e[r])&&Object.prototype.hasOwnProperty.call(t,r)&&qn(t[r])?i[r]=zt(t[r],e[r],n):n.clone?i[r]=qn(e[r])?ES(e[r]):e[r]:i[r]=e[r]}),i}function $s(t,e){return e?zt(t,e,{clone:!1}):t}const Mi=process.env.NODE_ENV!=="production"?Pe.oneOfType([Pe.number,Pe.string,Pe.object,Pe.array]):{};function n0(t,e){if(!t.containerQueries)return e;const n=Object.keys(e).filter(i=>i.startsWith("@container")).sort((i,r)=>{var o,a;const s=/min-width:\s*([0-9.]+)/;return+(((o=i.match(s))==null?void 0:o[1])||0)-+(((a=r.match(s))==null?void 0:a[1])||0)});return n.length?n.reduce((i,r)=>{const s=e[r];return delete i[r],i[r]=s,i},{...e}):e}function gD(t,e){return e==="@"||e.startsWith("@")&&(t.some(n=>e.startsWith(`@${n}`))||!!e.match(/^@\d/))}function vD(t,e){const n=e.match(/^@([^/]+)?\/?(.+)?$/);if(!n){if(process.env.NODE_ENV!=="production")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The provided shorthand ${`(${e})`} is invalid. The format should be \`@<breakpoint | number>\` or \`@<breakpoint | number>/<container>\`.
|
|
258
|
-
For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`:wi(18,`(${e})`));return null}const[,i,r]=n,s=Number.isNaN(+i)?i||0:+i;return t.containerQueries(r).up(s)}function yD(t){const e=(s,o)=>s.replace("@media",o?`@container ${o}`:"@container");function n(s,o){s.up=(...a)=>e(t.breakpoints.up(...a),o),s.down=(...a)=>e(t.breakpoints.down(...a),o),s.between=(...a)=>e(t.breakpoints.between(...a),o),s.only=(...a)=>e(t.breakpoints.only(...a),o),s.not=(...a)=>{const c=e(t.breakpoints.not(...a),o);return c.includes("not all and")?c.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):c}}const i={},r=s=>(n(i,s),i);return n(r),{...t,containerQueries:r}}const uc={xs:0,sm:600,md:900,lg:1200,xl:1536},i0={keys:["xs","sm","md","lg","xl"],up:t=>`@media (min-width:${uc[t]}px)`},bD={containerQueries:t=>({up:e=>{let n=typeof e=="number"?e:uc[e]||e;return typeof n=="number"&&(n=`${n}px`),t?`@container ${t} (min-width:${n})`:`@container (min-width:${n})`}})};function ei(t,e,n){const i=t.theme||{};if(Array.isArray(e)){const s=i.breakpoints||i0;return e.reduce((o,a,c)=>(o[s.up(s.keys[c])]=n(e[c]),o),{})}if(typeof e=="object"){const s=i.breakpoints||i0;return Object.keys(e).reduce((o,a)=>{if(gD(s.keys,a)){const c=vD(i.containerQueries?i:bD,a);c&&(o[c]=n(e[a],a))}else if(Object.keys(s.values||uc).includes(a)){const c=s.up(a);o[c]=n(e[a],a)}else{const c=a;o[c]=e[c]}return o},{})}return n(e)}function xD(t={}){var n;return((n=t.keys)==null?void 0:n.reduce((i,r)=>{const s=t.up(r);return i[s]={},i},{}))||{}}function r0(t,e){return t.reduce((n,i)=>{const r=n[i];return(!r||Object.keys(r).length===0)&&delete n[i],n},e)}function fc(t,e,n=!0){if(!e||typeof e!="string")return null;if(t&&t.vars&&n){const i=`vars.${e}`.split(".").reduce((r,s)=>r&&r[s]?r[s]:null,t);if(i!=null)return i}return e.split(".").reduce((i,r)=>i&&i[r]!=null?i[r]:null,t)}function $a(t,e,n,i=n){let r;return typeof t=="function"?r=t(n):Array.isArray(t)?r=t[n]||i:r=fc(t,n)||i,e&&(r=e(r,i,t)),r}function st(t){const{prop:e,cssProperty:n=t.prop,themeKey:i,transform:r}=t,s=o=>{if(o[e]==null)return null;const a=o[e],c=o.theme,l=fc(c,i)||{};return ei(o,a,u=>{let f=$a(l,r,u);return u===f&&typeof u=="string"&&(f=$a(l,r,`${e}${u==="default"?"":ir(u)}`,u)),n===!1?f:{[n]:f}})};return s.propTypes=process.env.NODE_ENV!=="production"?{[e]:Mi}:{},s.filterProps=[e],s}function SD(t){const e={};return n=>(e[n]===void 0&&(e[n]=t(n)),e[n])}const wD={m:"margin",p:"padding"},CD={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},s0={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},kD=SD(t=>{if(t.length>2)if(s0[t])t=s0[t];else return[t];const[e,n]=t.split(""),i=wD[e],r=CD[n]||"";return Array.isArray(r)?r.map(s=>i+s):[i+r]}),hc=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],mc=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],TD=[...hc,...mc];function go(t,e,n,i){const r=fc(t,e,!0)??n;return typeof r=="number"||typeof r=="string"?s=>typeof s=="string"?s:(process.env.NODE_ENV!=="production"&&typeof s!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${s}.`),typeof r=="string"?r.startsWith("var(")&&s===0?0:r.startsWith("var(")&&s===1?r:`calc(${s} * ${r})`:r*s):Array.isArray(r)?s=>{if(typeof s=="string")return s;const o=Math.abs(s);process.env.NODE_ENV!=="production"&&(Number.isInteger(o)?o>r.length-1&&console.error([`MUI: The value provided (${o}) overflows.`,`The supported values are: ${JSON.stringify(r)}.`,`${o} > ${r.length-1}, you need to add the missing values.`].join(`
|
|
259
|
-
`)):console.error([`MUI: The \`theme.${e}\` array type cannot be combined with non integer values.You should either use an integer value that can be used as index, or define the \`theme.${e}\` as a number.`].join(`
|
|
260
|
-
`)));const a=r[o];return s>=0?a:typeof a=="number"?-a:typeof a=="string"&&a.startsWith("var(")?`calc(-1 * ${a})`:`-${a}`}:typeof r=="function"?r:(process.env.NODE_ENV!=="production"&&console.error([`MUI: The \`theme.${e}\` value (${r}) is invalid.`,"It should be a number, an array or a function."].join(`
|
|
261
|
-
`)),()=>{})}function Gf(t){return go(t,"spacing",8,"spacing")}function vo(t,e){return typeof e=="string"||e==null?e:t(e)}function ED(t,e){return n=>t.reduce((i,r)=>(i[r]=vo(e,n),i),{})}function PD(t,e,n,i){if(!e.includes(n))return null;const r=kD(n),s=ED(r,i),o=t[n];return ei(t,o,s)}function PS(t,e){const n=Gf(t.theme);return Object.keys(t).map(i=>PD(t,e,i,n)).reduce($s,{})}function Ze(t){return PS(t,hc)}Ze.propTypes=process.env.NODE_ENV!=="production"?hc.reduce((t,e)=>(t[e]=Mi,t),{}):{};Ze.filterProps=hc;function Ye(t){return PS(t,mc)}Ye.propTypes=process.env.NODE_ENV!=="production"?mc.reduce((t,e)=>(t[e]=Mi,t),{}):{};Ye.filterProps=mc;process.env.NODE_ENV!=="production"&&TD.reduce((t,e)=>(t[e]=Mi,t),{});function pc(...t){const e=t.reduce((i,r)=>(r.filterProps.forEach(s=>{i[s]=r}),i),{}),n=i=>Object.keys(i).reduce((r,s)=>e[s]?$s(r,e[s](i)):r,{});return n.propTypes=process.env.NODE_ENV!=="production"?t.reduce((i,r)=>Object.assign(i,r.propTypes),{}):{},n.filterProps=t.reduce((i,r)=>i.concat(r.filterProps),[]),n}function Yt(t){return typeof t!="number"?t:`${t}px solid`}function en(t,e){return st({prop:t,themeKey:"borders",transform:e})}const RD=en("border",Yt),AD=en("borderTop",Yt),ID=en("borderRight",Yt),MD=en("borderBottom",Yt),_D=en("borderLeft",Yt),ND=en("borderColor"),OD=en("borderTopColor"),DD=en("borderRightColor"),jD=en("borderBottomColor"),LD=en("borderLeftColor"),VD=en("outline",Yt),FD=en("outlineColor"),gc=t=>{if(t.borderRadius!==void 0&&t.borderRadius!==null){const e=go(t.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:vo(e,i)});return ei(t,t.borderRadius,n)}return null};gc.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:Mi}:{};gc.filterProps=["borderRadius"];pc(RD,AD,ID,MD,_D,ND,OD,DD,jD,LD,gc,VD,FD);const vc=t=>{if(t.gap!==void 0&&t.gap!==null){const e=go(t.theme,"spacing",8,"gap"),n=i=>({gap:vo(e,i)});return ei(t,t.gap,n)}return null};vc.propTypes=process.env.NODE_ENV!=="production"?{gap:Mi}:{};vc.filterProps=["gap"];const yc=t=>{if(t.columnGap!==void 0&&t.columnGap!==null){const e=go(t.theme,"spacing",8,"columnGap"),n=i=>({columnGap:vo(e,i)});return ei(t,t.columnGap,n)}return null};yc.propTypes=process.env.NODE_ENV!=="production"?{columnGap:Mi}:{};yc.filterProps=["columnGap"];const bc=t=>{if(t.rowGap!==void 0&&t.rowGap!==null){const e=go(t.theme,"spacing",8,"rowGap"),n=i=>({rowGap:vo(e,i)});return ei(t,t.rowGap,n)}return null};bc.propTypes=process.env.NODE_ENV!=="production"?{rowGap:Mi}:{};bc.filterProps=["rowGap"];const UD=st({prop:"gridColumn"}),BD=st({prop:"gridRow"}),$D=st({prop:"gridAutoFlow"}),HD=st({prop:"gridAutoColumns"}),zD=st({prop:"gridAutoRows"}),WD=st({prop:"gridTemplateColumns"}),qD=st({prop:"gridTemplateRows"}),KD=st({prop:"gridTemplateAreas"}),GD=st({prop:"gridArea"});pc(vc,yc,bc,UD,BD,$D,HD,zD,WD,qD,KD,GD);function Hr(t,e){return e==="grey"?e:t}const ZD=st({prop:"color",themeKey:"palette",transform:Hr}),YD=st({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:Hr}),JD=st({prop:"backgroundColor",themeKey:"palette",transform:Hr});pc(ZD,YD,JD);function Bt(t){return t<=1&&t!==0?`${t*100}%`:t}const XD=st({prop:"width",transform:Bt}),Zf=t=>{if(t.maxWidth!==void 0&&t.maxWidth!==null){const e=n=>{var r,s,o,a,c;const i=((o=(s=(r=t.theme)==null?void 0:r.breakpoints)==null?void 0:s.values)==null?void 0:o[n])||uc[n];return i?((c=(a=t.theme)==null?void 0:a.breakpoints)==null?void 0:c.unit)!=="px"?{maxWidth:`${i}${t.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:Bt(n)}};return ei(t,t.maxWidth,e)}return null};Zf.filterProps=["maxWidth"];const QD=st({prop:"minWidth",transform:Bt}),e3=st({prop:"height",transform:Bt}),t3=st({prop:"maxHeight",transform:Bt}),n3=st({prop:"minHeight",transform:Bt});st({prop:"size",cssProperty:"width",transform:Bt});st({prop:"size",cssProperty:"height",transform:Bt});const i3=st({prop:"boxSizing"});pc(XD,Zf,QD,e3,t3,n3,i3);const xc={border:{themeKey:"borders",transform:Yt},borderTop:{themeKey:"borders",transform:Yt},borderRight:{themeKey:"borders",transform:Yt},borderBottom:{themeKey:"borders",transform:Yt},borderLeft:{themeKey:"borders",transform:Yt},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:Yt},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:gc},color:{themeKey:"palette",transform:Hr},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:Hr},backgroundColor:{themeKey:"palette",transform:Hr},p:{style:Ye},pt:{style:Ye},pr:{style:Ye},pb:{style:Ye},pl:{style:Ye},px:{style:Ye},py:{style:Ye},padding:{style:Ye},paddingTop:{style:Ye},paddingRight:{style:Ye},paddingBottom:{style:Ye},paddingLeft:{style:Ye},paddingX:{style:Ye},paddingY:{style:Ye},paddingInline:{style:Ye},paddingInlineStart:{style:Ye},paddingInlineEnd:{style:Ye},paddingBlock:{style:Ye},paddingBlockStart:{style:Ye},paddingBlockEnd:{style:Ye},m:{style:Ze},mt:{style:Ze},mr:{style:Ze},mb:{style:Ze},ml:{style:Ze},mx:{style:Ze},my:{style:Ze},margin:{style:Ze},marginTop:{style:Ze},marginRight:{style:Ze},marginBottom:{style:Ze},marginLeft:{style:Ze},marginX:{style:Ze},marginY:{style:Ze},marginInline:{style:Ze},marginInlineStart:{style:Ze},marginInlineEnd:{style:Ze},marginBlock:{style:Ze},marginBlockStart:{style:Ze},marginBlockEnd:{style:Ze},displayPrint:{cssProperty:!1,transform:t=>({"@media print":{display:t}})},display:{},overflow:{},textOverflow:{},visibility:{},whiteSpace:{},flexBasis:{},flexDirection:{},flexWrap:{},justifyContent:{},alignItems:{},alignContent:{},order:{},flex:{},flexGrow:{},flexShrink:{},alignSelf:{},justifyItems:{},justifySelf:{},gap:{style:vc},rowGap:{style:bc},columnGap:{style:yc},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:Bt},maxWidth:{style:Zf},minWidth:{transform:Bt},height:{transform:Bt},maxHeight:{transform:Bt},minHeight:{transform:Bt},boxSizing:{},font:{themeKey:"font"},fontFamily:{themeKey:"typography"},fontSize:{themeKey:"typography"},fontStyle:{themeKey:"typography"},fontWeight:{themeKey:"typography"},letterSpacing:{},textTransform:{},lineHeight:{},textAlign:{},typography:{cssProperty:!1,themeKey:"typography"}};function r3(...t){const e=t.reduce((i,r)=>i.concat(Object.keys(r)),[]),n=new Set(e);return t.every(i=>n.size===Object.keys(i).length)}function s3(t,e){return typeof t=="function"?t(e):t}function o3(){function t(n,i,r,s){const o={[n]:i,theme:r},a=s[n];if(!a)return{[n]:i};const{cssProperty:c=n,themeKey:l,transform:d,style:u}=a;if(i==null)return null;if(l==="typography"&&i==="inherit")return{[n]:i};const f=fc(r,l)||{};return u?u(o):ei(o,i,v=>{let h=$a(f,d,v);return v===h&&typeof v=="string"&&(h=$a(f,d,`${n}${v==="default"?"":ir(v)}`,v)),c===!1?h:{[c]:h}})}function e(n){const{sx:i,theme:r={},nested:s}=n||{};if(!i)return null;const o=r.unstable_sxConfig??xc;function a(c){let l=c;if(typeof c=="function")l=c(r);else if(typeof c!="object")return c;if(!l)return null;const d=xD(r.breakpoints),u=Object.keys(d);let f=d;return Object.keys(l).forEach(p=>{const v=s3(l[p],r);if(v!=null)if(typeof v=="object")if(o[p])f=$s(f,t(p,v,r,o));else{const h=ei({theme:r},v,y=>({[p]:y}));r3(h,v)?f[p]=e({sx:v,theme:r,nested:!0}):f=$s(f,h)}else f=$s(f,t(p,v,r,o))}),!s&&r.modularCssLayers?{"@layer sx":n0(r,r0(u,f))}:n0(r,r0(u,f))}return Array.isArray(i)?i.map(a):a(i)}return e}const es=o3();es.filterProps=["sx"];function du(){return du=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},du.apply(null,arguments)}function a3(t){if(t.sheet)return t.sheet;for(var e=0;e<document.styleSheets.length;e++)if(document.styleSheets[e].ownerNode===t)return document.styleSheets[e]}function c3(t){var e=document.createElement("style");return e.setAttribute("data-emotion",t.key),t.nonce!==void 0&&e.setAttribute("nonce",t.nonce),e.appendChild(document.createTextNode("")),e.setAttribute("data-s",""),e}var l3=function(){function t(n){var i=this;this._insertTag=function(r){var s;i.tags.length===0?i.insertionPoint?s=i.insertionPoint.nextSibling:i.prepend?s=i.container.firstChild:s=i.before:s=i.tags[i.tags.length-1].nextSibling,i.container.insertBefore(r,s),i.tags.push(r)},this.isSpeedy=n.speedy===void 0?!0:n.speedy,this.tags=[],this.ctr=0,this.nonce=n.nonce,this.key=n.key,this.container=n.container,this.prepend=n.prepend,this.insertionPoint=n.insertionPoint,this.before=null}var e=t.prototype;return e.hydrate=function(i){i.forEach(this._insertTag)},e.insert=function(i){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(c3(this));var r=this.tags[this.tags.length-1];if(this.isSpeedy){var s=a3(r);try{s.insertRule(i,s.cssRules.length)}catch{}}else r.appendChild(document.createTextNode(i));this.ctr++},e.flush=function(){this.tags.forEach(function(i){var r;return(r=i.parentNode)==null?void 0:r.removeChild(i)}),this.tags=[],this.ctr=0},t}(),kt="-ms-",Ha="-moz-",Re="-webkit-",RS="comm",Yf="rule",Jf="decl",d3="@import",AS="@keyframes",u3="@layer",f3=Math.abs,Sc=String.fromCharCode,h3=Object.assign;function m3(t,e){return yt(t,0)^45?(((e<<2^yt(t,0))<<2^yt(t,1))<<2^yt(t,2))<<2^yt(t,3):0}function IS(t){return t.trim()}function p3(t,e){return(t=e.exec(t))?t[0]:t}function Ae(t,e,n){return t.replace(e,n)}function uu(t,e){return t.indexOf(e)}function yt(t,e){return t.charCodeAt(e)|0}function io(t,e,n){return t.slice(e,n)}function Sn(t){return t.length}function Xf(t){return t.length}function $o(t,e){return e.push(t),t}function g3(t,e){return t.map(e).join("")}var wc=1,ts=1,MS=0,Vt=0,dt=0,fs="";function Cc(t,e,n,i,r,s,o){return{value:t,root:e,parent:n,type:i,props:r,children:s,line:wc,column:ts,length:o,return:""}}function Ps(t,e){return h3(Cc("",null,null,"",null,null,0),t,{length:-t.length},e)}function v3(){return dt}function y3(){return dt=Vt>0?yt(fs,--Vt):0,ts--,dt===10&&(ts=1,wc--),dt}function Wt(){return dt=Vt<MS?yt(fs,Vt++):0,ts++,dt===10&&(ts=1,wc++),dt}function An(){return yt(fs,Vt)}function ma(){return Vt}function yo(t,e){return io(fs,t,e)}function ro(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function _S(t){return wc=ts=1,MS=Sn(fs=t),Vt=0,[]}function NS(t){return fs="",t}function pa(t){return IS(yo(Vt-1,fu(t===91?t+2:t===40?t+1:t)))}function b3(t){for(;(dt=An())&&dt<33;)Wt();return ro(t)>2||ro(dt)>3?"":" "}function x3(t,e){for(;--e&&Wt()&&!(dt<48||dt>102||dt>57&&dt<65||dt>70&&dt<97););return yo(t,ma()+(e<6&&An()==32&&Wt()==32))}function fu(t){for(;Wt();)switch(dt){case t:return Vt;case 34:case 39:t!==34&&t!==39&&fu(dt);break;case 40:t===41&&fu(t);break;case 92:Wt();break}return Vt}function S3(t,e){for(;Wt()&&t+dt!==57;)if(t+dt===84&&An()===47)break;return"/*"+yo(e,Vt-1)+"*"+Sc(t===47?t:Wt())}function w3(t){for(;!ro(An());)Wt();return yo(t,Vt)}function C3(t){return NS(ga("",null,null,null,[""],t=_S(t),0,[0],t))}function ga(t,e,n,i,r,s,o,a,c){for(var l=0,d=0,u=o,f=0,p=0,v=0,h=1,y=1,b=1,w=0,C="",S=r,x=s,T=i,E=C;y;)switch(v=w,w=Wt()){case 40:if(v!=108&&yt(E,u-1)==58){uu(E+=Ae(pa(w),"&","&\f"),"&\f")!=-1&&(b=-1);break}case 34:case 39:case 91:E+=pa(w);break;case 9:case 10:case 13:case 32:E+=b3(v);break;case 92:E+=x3(ma()-1,7);continue;case 47:switch(An()){case 42:case 47:$o(k3(S3(Wt(),ma()),e,n),c);break;default:E+="/"}break;case 123*h:a[l++]=Sn(E)*b;case 125*h:case 59:case 0:switch(w){case 0:case 125:y=0;case 59+d:b==-1&&(E=Ae(E,/\f/g,"")),p>0&&Sn(E)-u&&$o(p>32?a0(E+";",i,n,u-1):a0(Ae(E," ","")+";",i,n,u-2),c);break;case 59:E+=";";default:if($o(T=o0(E,e,n,l,d,r,a,C,S=[],x=[],u),s),w===123)if(d===0)ga(E,e,T,T,S,s,u,a,x);else switch(f===99&&yt(E,3)===110?100:f){case 100:case 108:case 109:case 115:ga(t,T,T,i&&$o(o0(t,T,T,0,0,r,a,C,r,S=[],u),x),r,x,u,a,i?S:x);break;default:ga(E,T,T,T,[""],x,0,a,x)}}l=d=p=0,h=b=1,C=E="",u=o;break;case 58:u=1+Sn(E),p=v;default:if(h<1){if(w==123)--h;else if(w==125&&h++==0&&y3()==125)continue}switch(E+=Sc(w),w*h){case 38:b=d>0?1:(E+="\f",-1);break;case 44:a[l++]=(Sn(E)-1)*b,b=1;break;case 64:An()===45&&(E+=pa(Wt())),f=An(),d=u=Sn(C=E+=w3(ma())),w++;break;case 45:v===45&&Sn(E)==2&&(h=0)}}return s}function o0(t,e,n,i,r,s,o,a,c,l,d){for(var u=r-1,f=r===0?s:[""],p=Xf(f),v=0,h=0,y=0;v<i;++v)for(var b=0,w=io(t,u+1,u=f3(h=o[v])),C=t;b<p;++b)(C=IS(h>0?f[b]+" "+w:Ae(w,/&\f/g,f[b])))&&(c[y++]=C);return Cc(t,e,n,r===0?Yf:a,c,l,d)}function k3(t,e,n){return Cc(t,e,n,RS,Sc(v3()),io(t,2,-2),0)}function a0(t,e,n,i){return Cc(t,e,n,Jf,io(t,0,i),io(t,i+1,-1),i)}function zr(t,e){for(var n="",i=Xf(t),r=0;r<i;r++)n+=e(t[r],r,t,e)||"";return n}function T3(t,e,n,i){switch(t.type){case u3:if(t.children.length)break;case d3:case Jf:return t.return=t.return||t.value;case RS:return"";case AS:return t.return=t.value+"{"+zr(t.children,i)+"}";case Yf:t.value=t.props.join(",")}return Sn(n=zr(t.children,i))?t.return=t.value+"{"+n+"}":""}function E3(t){var e=Xf(t);return function(n,i,r,s){for(var o="",a=0;a<e;a++)o+=t[a](n,i,r,s)||"";return o}}function P3(t){return function(e){e.root||(e=e.return)&&t(e)}}function OS(t){var e=Object.create(null);return function(n){return e[n]===void 0&&(e[n]=t(n)),e[n]}}var R3=function(e,n,i){for(var r=0,s=0;r=s,s=An(),r===38&&s===12&&(n[i]=1),!ro(s);)Wt();return yo(e,Vt)},A3=function(e,n){var i=-1,r=44;do switch(ro(r)){case 0:r===38&&An()===12&&(n[i]=1),e[i]+=R3(Vt-1,n,i);break;case 2:e[i]+=pa(r);break;case 4:if(r===44){e[++i]=An()===58?"&\f":"",n[i]=e[i].length;break}default:e[i]+=Sc(r)}while(r=Wt());return e},I3=function(e,n){return NS(A3(_S(e),n))},c0=new WeakMap,M3=function(e){if(!(e.type!=="rule"||!e.parent||e.length<1)){for(var n=e.value,i=e.parent,r=e.column===i.column&&e.line===i.line;i.type!=="rule";)if(i=i.parent,!i)return;if(!(e.props.length===1&&n.charCodeAt(0)!==58&&!c0.get(i))&&!r){c0.set(e,!0);for(var s=[],o=I3(n,s),a=i.props,c=0,l=0;c<o.length;c++)for(var d=0;d<a.length;d++,l++)e.props[l]=s[c]?o[c].replace(/&\f/g,a[d]):a[d]+" "+o[c]}}},_3=function(e){if(e.type==="decl"){var n=e.value;n.charCodeAt(0)===108&&n.charCodeAt(2)===98&&(e.return="",e.value="")}};function DS(t,e){switch(m3(t,e)){case 5103:return Re+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return Re+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return Re+t+Ha+t+kt+t+t;case 6828:case 4268:return Re+t+kt+t+t;case 6165:return Re+t+kt+"flex-"+t+t;case 5187:return Re+t+Ae(t,/(\w+).+(:[^]+)/,Re+"box-$1$2"+kt+"flex-$1$2")+t;case 5443:return Re+t+kt+"flex-item-"+Ae(t,/flex-|-self/,"")+t;case 4675:return Re+t+kt+"flex-line-pack"+Ae(t,/align-content|flex-|-self/,"")+t;case 5548:return Re+t+kt+Ae(t,"shrink","negative")+t;case 5292:return Re+t+kt+Ae(t,"basis","preferred-size")+t;case 6060:return Re+"box-"+Ae(t,"-grow","")+Re+t+kt+Ae(t,"grow","positive")+t;case 4554:return Re+Ae(t,/([^-])(transform)/g,"$1"+Re+"$2")+t;case 6187:return Ae(Ae(Ae(t,/(zoom-|grab)/,Re+"$1"),/(image-set)/,Re+"$1"),t,"")+t;case 5495:case 3959:return Ae(t,/(image-set\([^]*)/,Re+"$1$`$1");case 4968:return Ae(Ae(t,/(.+:)(flex-)?(.*)/,Re+"box-pack:$3"+kt+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Re+t+t;case 4095:case 3583:case 4068:case 2532:return Ae(t,/(.+)-inline(.+)/,Re+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(Sn(t)-1-e>6)switch(yt(t,e+1)){case 109:if(yt(t,e+4)!==45)break;case 102:return Ae(t,/(.+:)(.+)-([^]+)/,"$1"+Re+"$2-$3$1"+Ha+(yt(t,e+3)==108?"$3":"$2-$3"))+t;case 115:return~uu(t,"stretch")?DS(Ae(t,"stretch","fill-available"),e)+t:t}break;case 4949:if(yt(t,e+1)!==115)break;case 6444:switch(yt(t,Sn(t)-3-(~uu(t,"!important")&&10))){case 107:return Ae(t,":",":"+Re)+t;case 101:return Ae(t,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Re+(yt(t,14)===45?"inline-":"")+"box$3$1"+Re+"$2$3$1"+kt+"$2box$3")+t}break;case 5936:switch(yt(t,e+11)){case 114:return Re+t+kt+Ae(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return Re+t+kt+Ae(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return Re+t+kt+Ae(t,/[svh]\w+-[tblr]{2}/,"lr")+t}return Re+t+kt+t+t}return t}var N3=function(e,n,i,r){if(e.length>-1&&!e.return)switch(e.type){case Jf:e.return=DS(e.value,e.length);break;case AS:return zr([Ps(e,{value:Ae(e.value,"@","@"+Re)})],r);case Yf:if(e.length)return g3(e.props,function(s){switch(p3(s,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return zr([Ps(e,{props:[Ae(s,/:(read-\w+)/,":"+Ha+"$1")]})],r);case"::placeholder":return zr([Ps(e,{props:[Ae(s,/:(plac\w+)/,":"+Re+"input-$1")]}),Ps(e,{props:[Ae(s,/:(plac\w+)/,":"+Ha+"$1")]}),Ps(e,{props:[Ae(s,/:(plac\w+)/,kt+"input-$1")]})],r)}return""})}},O3=[N3],D3=function(e){var n=e.key;if(n==="css"){var i=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(i,function(h){var y=h.getAttribute("data-emotion");y.indexOf(" ")!==-1&&(document.head.appendChild(h),h.setAttribute("data-s",""))})}var r=e.stylisPlugins||O3,s={},o,a=[];o=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+n+' "]'),function(h){for(var y=h.getAttribute("data-emotion").split(" "),b=1;b<y.length;b++)s[y[b]]=!0;a.push(h)});var c,l=[M3,_3];{var d,u=[T3,P3(function(h){d.insert(h)})],f=E3(l.concat(r,u)),p=function(y){return zr(C3(y),f)};c=function(y,b,w,C){d=w,p(y?y+"{"+b.styles+"}":b.styles),C&&(v.inserted[b.name]=!0)}}var v={key:n,sheet:new l3({key:n,container:o,nonce:e.nonce,speedy:e.speedy,prepend:e.prepend,insertionPoint:e.insertionPoint}),nonce:e.nonce,inserted:s,registered:{},insert:c};return v.sheet.hydrate(a),v},j3=!0;function L3(t,e,n){var i="";return n.split(" ").forEach(function(r){t[r]!==void 0?e.push(t[r]+";"):r&&(i+=r+" ")}),i}var jS=function(e,n,i){var r=e.key+"-"+n.name;(i===!1||j3===!1)&&e.registered[r]===void 0&&(e.registered[r]=n.styles)},V3=function(e,n,i){jS(e,n,i);var r=e.key+"-"+n.name;if(e.inserted[n.name]===void 0){var s=n;do e.insert(n===s?"."+r:"",s,e.sheet,!0),s=s.next;while(s!==void 0)}};function F3(t){for(var e=0,n,i=0,r=t.length;r>=4;++i,r-=4)n=t.charCodeAt(i)&255|(t.charCodeAt(++i)&255)<<8|(t.charCodeAt(++i)&255)<<16|(t.charCodeAt(++i)&255)<<24,n=(n&65535)*1540483477+((n>>>16)*59797<<16),n^=n>>>24,e=(n&65535)*1540483477+((n>>>16)*59797<<16)^(e&65535)*1540483477+((e>>>16)*59797<<16);switch(r){case 3:e^=(t.charCodeAt(i+2)&255)<<16;case 2:e^=(t.charCodeAt(i+1)&255)<<8;case 1:e^=t.charCodeAt(i)&255,e=(e&65535)*1540483477+((e>>>16)*59797<<16)}return e^=e>>>13,e=(e&65535)*1540483477+((e>>>16)*59797<<16),((e^e>>>15)>>>0).toString(36)}var U3={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},B3=/[A-Z]|^ms/g,$3=/_EMO_([^_]+?)_([^]*?)_EMO_/g,LS=function(e){return e.charCodeAt(1)===45},l0=function(e){return e!=null&&typeof e!="boolean"},jl=OS(function(t){return LS(t)?t:t.replace(B3,"-$&").toLowerCase()}),d0=function(e,n){switch(e){case"animation":case"animationName":if(typeof n=="string")return n.replace($3,function(i,r,s){return wn={name:r,styles:s,next:wn},r})}return U3[e]!==1&&!LS(e)&&typeof n=="number"&&n!==0?n+"px":n};function so(t,e,n){if(n==null)return"";var i=n;if(i.__emotion_styles!==void 0)return i;switch(typeof n){case"boolean":return"";case"object":{var r=n;if(r.anim===1)return wn={name:r.name,styles:r.styles,next:wn},r.name;var s=n;if(s.styles!==void 0){var o=s.next;if(o!==void 0)for(;o!==void 0;)wn={name:o.name,styles:o.styles,next:wn},o=o.next;var a=s.styles+";";return a}return H3(t,e,n)}case"function":{if(t!==void 0){var c=wn,l=n(t);return wn=c,so(t,e,l)}break}}var d=n;if(e==null)return d;var u=e[d];return u!==void 0?u:d}function H3(t,e,n){var i="";if(Array.isArray(n))for(var r=0;r<n.length;r++)i+=so(t,e,n[r])+";";else for(var s in n){var o=n[s];if(typeof o!="object"){var a=o;e!=null&&e[a]!==void 0?i+=s+"{"+e[a]+"}":l0(a)&&(i+=jl(s)+":"+d0(s,a)+";")}else if(Array.isArray(o)&&typeof o[0]=="string"&&(e==null||e[o[0]]===void 0))for(var c=0;c<o.length;c++)l0(o[c])&&(i+=jl(s)+":"+d0(s,o[c])+";");else{var l=so(t,e,o);switch(s){case"animation":case"animationName":{i+=jl(s)+":"+l+";";break}default:i+=s+"{"+l+"}"}}}return i}var u0=/label:\s*([^\s;{]+)\s*(;|$)/g,wn;function VS(t,e,n){if(t.length===1&&typeof t[0]=="object"&&t[0]!==null&&t[0].styles!==void 0)return t[0];var i=!0,r="";wn=void 0;var s=t[0];if(s==null||s.raw===void 0)i=!1,r+=so(n,e,s);else{var o=s;r+=o[0]}for(var a=1;a<t.length;a++)if(r+=so(n,e,t[a]),i){var c=s;r+=c[a]}u0.lastIndex=0;for(var l="",d;(d=u0.exec(r))!==null;)l+="-"+d[1];var u=F3(r)+l;return{name:u,styles:r,next:wn}}var z3=function(e){return e()},W3=g.useInsertionEffect?g.useInsertionEffect:!1,q3=W3||z3,FS=g.createContext(typeof HTMLElement<"u"?D3({key:"css"}):null);FS.Provider;var K3=function(e){return R.forwardRef(function(n,i){var r=R.useContext(FS);return e(n,r,i)})},G3=g.createContext({}),Z3=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,Y3=OS(function(t){return Z3.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),J3=Y3,X3=function(e){return e!=="theme"},f0=function(e){return typeof e=="string"&&e.charCodeAt(0)>96?J3:X3},h0=function(e,n,i){var r;if(n){var s=n.shouldForwardProp;r=e.__emotion_forwardProp&&s?function(o){return e.__emotion_forwardProp(o)&&s(o)}:s}return typeof r!="function"&&i&&(r=e.__emotion_forwardProp),r},Q3=function(e){var n=e.cache,i=e.serialized,r=e.isStringTag;return jS(n,i,r),q3(function(){return V3(n,i,r)}),null},e5=function t(e,n){var i=e.__emotion_real===e,r=i&&e.__emotion_base||e,s,o;n!==void 0&&(s=n.label,o=n.target);var a=h0(e,n,i),c=a||f0(r),l=!c("as");return function(){var d=arguments,u=i&&e.__emotion_styles!==void 0?e.__emotion_styles.slice(0):[];if(s!==void 0&&u.push("label:"+s+";"),d[0]==null||d[0].raw===void 0)u.push.apply(u,d);else{var f=d[0];u.push(f[0]);for(var p=d.length,v=1;v<p;v++)u.push(d[v],f[v])}var h=K3(function(y,b,w){var C=l&&y.as||r,S="",x=[],T=y;if(y.theme==null){T={};for(var E in y)T[E]=y[E];T.theme=g.useContext(G3)}typeof y.className=="string"?S=L3(b.registered,x,y.className):y.className!=null&&(S=y.className+" ");var P=VS(u.concat(x),b.registered,T);S+=b.key+"-"+P.name,o!==void 0&&(S+=" "+o);var _=l&&a===void 0?f0(C):c,k={};for(var I in y)l&&I==="as"||_(I)&&(k[I]=y[I]);return k.className=S,w&&(k.ref=w),g.createElement(g.Fragment,null,g.createElement(Q3,{cache:b,serialized:P,isStringTag:typeof C=="string"}),g.createElement(C,k))});return h.displayName=s!==void 0?s:"Styled("+(typeof r=="string"?r:r.displayName||r.name||"Component")+")",h.defaultProps=e.defaultProps,h.__emotion_real=h,h.__emotion_base=r,h.__emotion_styles=u,h.__emotion_forwardProp=a,Object.defineProperty(h,"toString",{value:function(){return"."+o}}),h.withComponent=function(y,b){var w=t(y,du({},n,b,{shouldForwardProp:h0(h,b,!0)}));return w.apply(void 0,u)},h}},t5=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"],hu=e5.bind(null);t5.forEach(function(t){hu[t]=hu(t)});/**
|
|
262
|
-
* @mui/styled-engine v7.2.0
|
|
263
|
-
*
|
|
264
|
-
* @license MIT
|
|
265
|
-
* This source code is licensed under the MIT license found in the
|
|
266
|
-
* LICENSE file in the root directory of this source tree.
|
|
267
|
-
*/function n5(t,e){const n=hu(t,e);return process.env.NODE_ENV!=="production"?(...i)=>{const r=typeof t=="string"?`"${t}"`:"component";return i.length===0?console.error([`MUI: Seems like you called \`styled(${r})()\` without a \`style\` argument.`,'You must provide a `styles` argument: `styled("div")(styleYouForgotToPass)`.'].join(`
|
|
268
|
-
`)):i.some(s=>s===void 0)&&console.error(`MUI: the styled(${r})(...args) API requires all its args to be defined.`),n(...i)}:n}function i5(t,e){Array.isArray(t.__emotion_styles)&&(t.__emotion_styles=e(t.__emotion_styles))}const m0=[];function Ki(t){return m0[0]=t,VS(m0)}const r5=t=>{const e=Object.keys(t).map(n=>({key:n,val:t[n]}))||[];return e.sort((n,i)=>n.val-i.val),e.reduce((n,i)=>({...n,[i.key]:i.val}),{})};function s5(t){const{values:e={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...r}=t,s=r5(e),o=Object.keys(s);function a(f){return`@media (min-width:${typeof e[f]=="number"?e[f]:f}${n})`}function c(f){return`@media (max-width:${(typeof e[f]=="number"?e[f]:f)-i/100}${n})`}function l(f,p){const v=o.indexOf(p);return`@media (min-width:${typeof e[f]=="number"?e[f]:f}${n}) and (max-width:${(v!==-1&&typeof e[o[v]]=="number"?e[o[v]]:p)-i/100}${n})`}function d(f){return o.indexOf(f)+1<o.length?l(f,o[o.indexOf(f)+1]):a(f)}function u(f){const p=o.indexOf(f);return p===0?a(o[1]):p===o.length-1?c(o[p]):l(f,o[o.indexOf(f)+1]).replace("@media","@media not all and")}return{keys:o,values:s,up:a,down:c,between:l,only:d,not:u,unit:n,...r}}const o5={borderRadius:4};function US(t=8,e=Gf({spacing:t})){if(t.mui)return t;const n=(...i)=>(process.env.NODE_ENV!=="production"&&(i.length<=4||console.error(`MUI: Too many arguments provided, expected between 0 and 4, got ${i.length}`)),(i.length===0?[1]:i).map(s=>{const o=e(s);return typeof o=="number"?`${o}px`:o}).join(" "));return n.mui=!0,n}function a5(t,e){var i;const n=this;if(n.vars){if(!((i=n.colorSchemes)!=null&&i[t])||typeof n.getColorSchemeSelector!="function")return{};let r=n.getColorSchemeSelector(t);return r==="&"?e:((r.includes("data-")||r.includes("."))&&(r=`*:where(${r.replace(/\s*&$/,"")}) &`),{[r]:e})}return n.palette.mode===t?e:{}}function BS(t={},...e){const{breakpoints:n={},palette:i={},spacing:r,shape:s={},...o}=t,a=s5(n),c=US(r);let l=zt({breakpoints:a,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:c,shape:{...o5,...s}},o);return l=yD(l),l.applyStyles=a5,l=e.reduce((d,u)=>zt(d,u),l),l.unstable_sxConfig={...xc,...o==null?void 0:o.unstable_sxConfig},l.unstable_sx=function(u){return es({sx:u,theme:this})},l}const c5={active:"active",checked:"checked",completed:"completed",disabled:"disabled",error:"error",expanded:"expanded",focused:"focused",focusVisible:"focusVisible",open:"open",readOnly:"readOnly",required:"required",selected:"selected"};function Qf(t,e,n="Mui"){const i=c5[e];return i?`${n}-${i}`:`${iD.generate(t)}-${e}`}function l5(t,e,n="Mui"){const i={};return e.forEach(r=>{i[r]=Qf(t,r,n)}),i}function $S(t,e=""){return t.displayName||t.name||e}function p0(t,e,n){const i=$S(e);return t.displayName||(i!==""?`${n}(${i})`:n)}function d5(t){if(t!=null){if(typeof t=="string")return t;if(typeof t=="function")return $S(t,"Component");if(typeof t=="object")switch(t.$$typeof){case Ba.ForwardRef:return p0(t,t.render,"ForwardRef");case Ba.Memo:return p0(t,t.type,"memo");default:return}}}function HS(t){const{variants:e,...n}=t,i={variants:e,style:Ki(n),isProcessed:!0};return i.style===n||e&&e.forEach(r=>{typeof r.style!="function"&&(r.style=Ki(r.style))}),i}const u5=BS();function Ll(t){return t!=="ownerState"&&t!=="theme"&&t!=="sx"&&t!=="as"}function $i(t,e){return e&&t&&typeof t=="object"&&t.styles&&!t.styles.startsWith("@layer")&&(t.styles=`@layer ${e}{${String(t.styles)}}`),t}function f5(t){return t?(e,n)=>n[t]:null}function h5(t,e,n){t.theme=v5(t.theme)?n:t.theme[e]||t.theme}function va(t,e,n){const i=typeof e=="function"?e(t):e;if(Array.isArray(i))return i.flatMap(r=>va(t,r,n));if(Array.isArray(i==null?void 0:i.variants)){let r;if(i.isProcessed)r=n?$i(i.style,n):i.style;else{const{variants:s,...o}=i;r=n?$i(Ki(o),n):o}return zS(t,i.variants,[r],n)}return i!=null&&i.isProcessed?n?$i(Ki(i.style),n):i.style:n?$i(Ki(i),n):i}function zS(t,e,n=[],i=void 0){var s;let r;e:for(let o=0;o<e.length;o+=1){const a=e[o];if(typeof a.props=="function"){if(r??(r={...t,...t.ownerState,ownerState:t.ownerState}),!a.props(r))continue}else for(const c in a.props)if(t[c]!==a.props[c]&&((s=t.ownerState)==null?void 0:s[c])!==a.props[c])continue e;typeof a.style=="function"?(r??(r={...t,...t.ownerState,ownerState:t.ownerState}),n.push(i?$i(Ki(a.style(r)),i):a.style(r))):n.push(i?$i(Ki(a.style),i):a.style)}return n}function m5(t={}){const{themeId:e,defaultTheme:n=u5,rootShouldForwardProp:i=Ll,slotShouldForwardProp:r=Ll}=t;function s(a){h5(a,e,n)}return(a,c={})=>{i5(a,T=>T.filter(E=>E!==es));const{name:l,slot:d,skipVariantsResolver:u,skipSx:f,overridesResolver:p=f5(WS(d)),...v}=c,h=l&&l.startsWith("Mui")||d?"components":"custom",y=u!==void 0?u:d&&d!=="Root"&&d!=="root"||!1,b=f||!1;let w=Ll;d==="Root"||d==="root"?w=i:d?w=r:y5(a)&&(w=void 0);const C=n5(a,{shouldForwardProp:w,label:g5(l,d),...v}),S=T=>{if(T.__emotion_real===T)return T;if(typeof T=="function")return function(P){return va(P,T,P.theme.modularCssLayers?h:void 0)};if(qn(T)){const E=HS(T);return function(_){return E.variants?va(_,E,_.theme.modularCssLayers?h:void 0):_.theme.modularCssLayers?$i(E.style,h):E.style}}return T},x=(...T)=>{const E=[],P=T.map(S),_=[];if(E.push(s),l&&p&&_.push(function(K){var X,O;const se=(O=(X=K.theme.components)==null?void 0:X[l])==null?void 0:O.styleOverrides;if(!se)return null;const ie={};for(const oe in se)ie[oe]=va(K,se[oe],K.theme.modularCssLayers?"theme":void 0);return p(K,ie)}),l&&!y&&_.push(function(K){var ie,X;const J=K.theme,se=(X=(ie=J==null?void 0:J.components)==null?void 0:ie[l])==null?void 0:X.variants;return se?zS(K,se,[],K.theme.modularCssLayers?"theme":void 0):null}),b||_.push(es),Array.isArray(P[0])){const N=P.shift(),K=new Array(E.length).fill(""),J=new Array(_.length).fill("");let se;se=[...K,...N,...J],se.raw=[...K,...N.raw,...J],E.unshift(se)}const k=[...E,...P,..._],I=C(...k);return a.muiName&&(I.muiName=a.muiName),process.env.NODE_ENV!=="production"&&(I.displayName=p5(l,d,a)),I};return C.withConfig&&(x.withConfig=C.withConfig),x}}function p5(t,e,n){return t?`${t}${ir(e||"")}`:`Styled(${d5(n)})`}function g5(t,e){let n;return process.env.NODE_ENV!=="production"&&t&&(n=`${t}-${WS(e||"Root")}`),n}function v5(t){for(const e in t)return!1;return!0}function y5(t){return typeof t=="string"&&t.charCodeAt(0)>96}function WS(t){return t&&t.charAt(0).toLowerCase()+t.slice(1)}function mu(t,e,n=!1){const i={...e};for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const s=r;if(s==="components"||s==="slots")i[s]={...t[s],...i[s]};else if(s==="componentsProps"||s==="slotProps"){const o=t[s],a=e[s];if(!a)i[s]=o||{};else if(!o)i[s]=a;else{i[s]={...a};for(const c in o)if(Object.prototype.hasOwnProperty.call(o,c)){const l=c;i[s][l]=mu(o[l],a[l],n)}}}else s==="className"&&n&&e.className?i.className=xu(t==null?void 0:t.className,e==null?void 0:e.className):s==="style"&&n&&e.style?i.style={...t==null?void 0:t.style,...e==null?void 0:e.style}:i[s]===void 0&&(i[s]=t[s])}return i}function b5(t,e=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(e,Math.min(t,n))}function eh(t,e=0,n=1){return process.env.NODE_ENV!=="production"&&(t<e||t>n)&&console.error(`MUI: The value provided ${t} is out of range [${e}, ${n}].`),b5(t,e,n)}function x5(t){t=t.slice(1);const e=new RegExp(`.{1,${t.length>=6?2:1}}`,"g");let n=t.match(e);return n&&n[0].length===1&&(n=n.map(i=>i+i)),process.env.NODE_ENV!=="production"&&t.length!==t.trim().length&&console.error(`MUI: The color: "${t}" is invalid. Make sure the color input doesn't contain leading/trailing space.`),n?`rgb${n.length===4?"a":""}(${n.map((i,r)=>r<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function Ci(t){if(t.type)return t;if(t.charAt(0)==="#")return Ci(x5(t));const e=t.indexOf("("),n=t.substring(0,e);if(!["rgb","rgba","hsl","hsla","color"].includes(n))throw new Error(process.env.NODE_ENV!=="production"?`MUI: Unsupported \`${t}\` color.
|
|
269
|
-
The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:wi(9,t));let i=t.substring(e+1,t.length-1),r;if(n==="color"){if(i=i.split(" "),r=i.shift(),i.length===4&&i[3].charAt(0)==="/"&&(i[3]=i[3].slice(1)),!["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].includes(r))throw new Error(process.env.NODE_ENV!=="production"?`MUI: unsupported \`${r}\` color space.
|
|
270
|
-
The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:wi(10,r))}else i=i.split(",");return i=i.map(s=>parseFloat(s)),{type:n,values:i,colorSpace:r}}const S5=t=>{const e=Ci(t);return e.values.slice(0,3).map((n,i)=>e.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},Ns=(t,e)=>{try{return S5(t)}catch{return e&&process.env.NODE_ENV!=="production"&&console.warn(e),t}};function kc(t){const{type:e,colorSpace:n}=t;let{values:i}=t;return e.includes("rgb")?i=i.map((r,s)=>s<3?parseInt(r,10):r):e.includes("hsl")&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),e.includes("color")?i=`${n} ${i.join(" ")}`:i=`${i.join(", ")}`,`${e}(${i})`}function qS(t){t=Ci(t);const{values:e}=t,n=e[0],i=e[1]/100,r=e[2]/100,s=i*Math.min(r,1-r),o=(l,d=(l+n/30)%12)=>r-s*Math.max(Math.min(d-3,9-d,1),-1);let a="rgb";const c=[Math.round(o(0)*255),Math.round(o(8)*255),Math.round(o(4)*255)];return t.type==="hsla"&&(a+="a",c.push(e[3])),kc({type:a,values:c})}function pu(t){t=Ci(t);let e=t.type==="hsl"||t.type==="hsla"?Ci(qS(t)).values:t.values;return e=e.map(n=>(t.type!=="color"&&(n/=255),n<=.03928?n/12.92:((n+.055)/1.055)**2.4)),Number((.2126*e[0]+.7152*e[1]+.0722*e[2]).toFixed(3))}function g0(t,e){const n=pu(t),i=pu(e);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function w5(t,e){return t=Ci(t),e=eh(e),(t.type==="rgb"||t.type==="hsl")&&(t.type+="a"),t.type==="color"?t.values[3]=`/${e}`:t.values[3]=e,kc(t)}function Ho(t,e,n){try{return w5(t,e)}catch{return t}}function th(t,e){if(t=Ci(t),e=eh(e),t.type.includes("hsl"))t.values[2]*=1-e;else if(t.type.includes("rgb")||t.type.includes("color"))for(let n=0;n<3;n+=1)t.values[n]*=1-e;return kc(t)}function Ve(t,e,n){try{return th(t,e)}catch{return t}}function nh(t,e){if(t=Ci(t),e=eh(e),t.type.includes("hsl"))t.values[2]+=(100-t.values[2])*e;else if(t.type.includes("rgb"))for(let n=0;n<3;n+=1)t.values[n]+=(255-t.values[n])*e;else if(t.type.includes("color"))for(let n=0;n<3;n+=1)t.values[n]+=(1-t.values[n])*e;return kc(t)}function Fe(t,e,n){try{return nh(t,e)}catch{return t}}function C5(t,e=.15){return pu(t)>.5?th(t,e):nh(t,e)}function zo(t,e,n){try{return C5(t,e)}catch{return t}}const k5=g.createContext(void 0);process.env.NODE_ENV!=="production"&&(Pe.node,Pe.object);function T5(t){const{theme:e,name:n,props:i}=t;if(!e||!e.components||!e.components[n])return i;const r=e.components[n];return r.defaultProps?mu(r.defaultProps,i,e.components.mergeClassNameAndStyle):!r.styleOverrides&&!r.variants?mu(r,i,e.components.mergeClassNameAndStyle):i}function E5({props:t,name:e}){const n=g.useContext(k5);return T5({props:t,name:e,theme:{components:n}})}const v0={theme:void 0};function P5(t){let e,n;return function(r){let s=e;return(s===void 0||r.theme!==n)&&(v0.theme=r.theme,s=HS(t(v0)),e=s,n=r.theme),s}}function R5(t=""){function e(...i){if(!i.length)return"";const r=i[0];return typeof r=="string"&&!r.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))|^(-?(\d*\.)?\d+)$|(\d+ \d+ \d+)/)?`, var(--${t?`${t}-`:""}${r}${e(...i.slice(1))})`:`, ${r}`}return(i,...r)=>`var(--${t?`${t}-`:""}${i}${e(...r)})`}const y0=(t,e,n,i=[])=>{let r=t;e.forEach((s,o)=>{o===e.length-1?Array.isArray(r)?r[Number(s)]=n:r&&typeof r=="object"&&(r[s]=n):r&&typeof r=="object"&&(r[s]||(r[s]=i.includes(s)?[]:{}),r=r[s])})},A5=(t,e,n)=>{function i(r,s=[],o=[]){Object.entries(r).forEach(([a,c])=>{(!n||n&&!n([...s,a]))&&c!=null&&(typeof c=="object"&&Object.keys(c).length>0?i(c,[...s,a],Array.isArray(c)?[...o,a]:o):e([...s,a],c,o))})}i(t)},I5=(t,e)=>typeof e=="number"?["lineHeight","fontWeight","opacity","zIndex"].some(i=>t.includes(i))||t[t.length-1].toLowerCase().includes("opacity")?e:`${e}px`:e;function Vl(t,e){const{prefix:n,shouldSkipGeneratingVar:i}=e||{},r={},s={},o={};return A5(t,(a,c,l)=>{if((typeof c=="string"||typeof c=="number")&&(!i||!i(a,c))){const d=`--${n?`${n}-`:""}${a.join("-")}`,u=I5(a,c);Object.assign(r,{[d]:u}),y0(s,a,`var(${d})`,l),y0(o,a,`var(${d}, ${u})`,l)}},a=>a[0]==="vars"),{css:r,vars:s,varsWithDefaults:o}}function M5(t,e={}){const{getSelector:n=y,disableCssColorScheme:i,colorSchemeSelector:r}=e,{colorSchemes:s={},components:o,defaultColorScheme:a="light",...c}=t,{vars:l,css:d,varsWithDefaults:u}=Vl(c,e);let f=u;const p={},{[a]:v,...h}=s;if(Object.entries(h||{}).forEach(([C,S])=>{const{vars:x,css:T,varsWithDefaults:E}=Vl(S,e);f=zt(f,E),p[C]={css:T,vars:x}}),v){const{css:C,vars:S,varsWithDefaults:x}=Vl(v,e);f=zt(f,x),p[a]={css:C,vars:S}}function y(C,S){var T,E;let x=r;if(r==="class"&&(x=".%s"),r==="data"&&(x="[data-%s]"),r!=null&&r.startsWith("data-")&&!r.includes("%s")&&(x=`[${r}="%s"]`),C){if(x==="media")return t.defaultColorScheme===C?":root":{[`@media (prefers-color-scheme: ${((E=(T=s[C])==null?void 0:T.palette)==null?void 0:E.mode)||C})`]:{":root":S}};if(x)return t.defaultColorScheme===C?`:root, ${x.replace("%s",String(C))}`:x.replace("%s",String(C))}return":root"}return{vars:f,generateThemeVars:()=>{let C={...l};return Object.entries(p).forEach(([,{vars:S}])=>{C=zt(C,S)}),C},generateStyleSheets:()=>{var P,_;const C=[],S=t.defaultColorScheme||"light";function x(k,I){Object.keys(I).length&&C.push(typeof k=="string"?{[k]:{...I}}:k)}x(n(void 0,{...d}),d);const{[S]:T,...E}=p;if(T){const{css:k}=T,I=(_=(P=s[S])==null?void 0:P.palette)==null?void 0:_.mode,N=!i&&I?{colorScheme:I,...k}:{...k};x(n(S,{...N}),N)}return Object.entries(E).forEach(([k,{css:I}])=>{var J,se;const N=(se=(J=s[k])==null?void 0:J.palette)==null?void 0:se.mode,K=!i&&N?{colorScheme:N,...I}:{...I};x(n(k,{...K}),K)}),C}}}function _5(t){return function(n){return t==="media"?(process.env.NODE_ENV!=="production"&&n!=="light"&&n!=="dark"&&console.error(`MUI: @media (prefers-color-scheme) supports only 'light' or 'dark', but receive '${n}'.`),`@media (prefers-color-scheme: ${n})`):t?t.startsWith("data-")&&!t.includes("%s")?`[${t}="${n}"] &`:t==="class"?`.${n} &`:t==="data"?`[data-${n}] &`:`${t.replace("%s",n)} &`:"&"}}const oo={black:"#000",white:"#fff"},N5={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"},vr={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},yr={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},Rs={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},br={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},xr={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},Sr={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function KS(){return{text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.38)"},divider:"rgba(0, 0, 0, 0.12)",background:{paper:oo.white,default:oo.white},action:{active:"rgba(0, 0, 0, 0.54)",hover:"rgba(0, 0, 0, 0.04)",hoverOpacity:.04,selected:"rgba(0, 0, 0, 0.08)",selectedOpacity:.08,disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(0, 0, 0, 0.12)",disabledOpacity:.38,focus:"rgba(0, 0, 0, 0.12)",focusOpacity:.12,activatedOpacity:.12}}}const O5=KS();function GS(){return{text:{primary:oo.white,secondary:"rgba(255, 255, 255, 0.7)",disabled:"rgba(255, 255, 255, 0.5)",icon:"rgba(255, 255, 255, 0.5)"},divider:"rgba(255, 255, 255, 0.12)",background:{paper:"#121212",default:"#121212"},action:{active:oo.white,hover:"rgba(255, 255, 255, 0.08)",hoverOpacity:.08,selected:"rgba(255, 255, 255, 0.16)",selectedOpacity:.16,disabled:"rgba(255, 255, 255, 0.3)",disabledBackground:"rgba(255, 255, 255, 0.12)",disabledOpacity:.38,focus:"rgba(255, 255, 255, 0.12)",focusOpacity:.12,activatedOpacity:.24}}}const b0=GS();function x0(t,e,n,i){const r=i.light||i,s=i.dark||i*1.5;t[e]||(t.hasOwnProperty(n)?t[e]=t[n]:e==="light"?t.light=nh(t.main,r):e==="dark"&&(t.dark=th(t.main,s)))}function D5(t="light"){return t==="dark"?{main:br[200],light:br[50],dark:br[400]}:{main:br[700],light:br[400],dark:br[800]}}function j5(t="light"){return t==="dark"?{main:vr[200],light:vr[50],dark:vr[400]}:{main:vr[500],light:vr[300],dark:vr[700]}}function L5(t="light"){return t==="dark"?{main:yr[500],light:yr[300],dark:yr[700]}:{main:yr[700],light:yr[400],dark:yr[800]}}function V5(t="light"){return t==="dark"?{main:xr[400],light:xr[300],dark:xr[700]}:{main:xr[700],light:xr[500],dark:xr[900]}}function F5(t="light"){return t==="dark"?{main:Sr[400],light:Sr[300],dark:Sr[700]}:{main:Sr[800],light:Sr[500],dark:Sr[900]}}function U5(t="light"){return t==="dark"?{main:Rs[400],light:Rs[300],dark:Rs[700]}:{main:"#ed6c02",light:Rs[500],dark:Rs[900]}}function ih(t){const{mode:e="light",contrastThreshold:n=3,tonalOffset:i=.2,...r}=t,s=t.primary||D5(e),o=t.secondary||j5(e),a=t.error||L5(e),c=t.info||V5(e),l=t.success||F5(e),d=t.warning||U5(e);function u(h){const y=g0(h,b0.text.primary)>=n?b0.text.primary:O5.text.primary;if(process.env.NODE_ENV!=="production"){const b=g0(h,y);b<3&&console.error([`MUI: The contrast ratio of ${b}:1 for ${y} on ${h}`,"falls below the WCAG recommended absolute minimum contrast ratio of 3:1.","https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast"].join(`
|
|
271
|
-
`))}return y}const f=({color:h,name:y,mainShade:b=500,lightShade:w=300,darkShade:C=700})=>{if(h={...h},!h.main&&h[b]&&(h.main=h[b]),!h.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${y?` (${y})`:""} provided to augmentColor(color) is invalid.
|
|
272
|
-
The color object needs to have a \`main\` property or a \`${b}\` property.`:wi(11,y?` (${y})`:"",b));if(typeof h.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${y?` (${y})`:""} provided to augmentColor(color) is invalid.
|
|
273
|
-
\`color.main\` should be a string, but \`${JSON.stringify(h.main)}\` was provided instead.
|
|
274
|
-
|
|
275
|
-
Did you intend to use one of the following approaches?
|
|
276
|
-
|
|
277
|
-
import { green } from "@mui/material/colors";
|
|
278
|
-
|
|
279
|
-
const theme1 = createTheme({ palette: {
|
|
280
|
-
primary: green,
|
|
281
|
-
} });
|
|
282
|
-
|
|
283
|
-
const theme2 = createTheme({ palette: {
|
|
284
|
-
primary: { main: green[500] },
|
|
285
|
-
} });`:wi(12,y?` (${y})`:"",JSON.stringify(h.main)));return x0(h,"light",w,i),x0(h,"dark",C,i),h.contrastText||(h.contrastText=u(h.main)),h};let p;return e==="light"?p=KS():e==="dark"&&(p=GS()),process.env.NODE_ENV!=="production"&&(p||console.error(`MUI: The palette mode \`${e}\` is not supported.`)),zt({common:{...oo},mode:e,primary:f({color:s,name:"primary"}),secondary:f({color:o,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:f({color:a,name:"error"}),warning:f({color:d,name:"warning"}),info:f({color:c,name:"info"}),success:f({color:l,name:"success"}),grey:N5,contrastThreshold:n,getContrastText:u,augmentColor:f,tonalOffset:i,...p},r)}function B5(t){const e={};return Object.entries(t).forEach(i=>{const[r,s]=i;typeof s=="object"&&(e[r]=`${s.fontStyle?`${s.fontStyle} `:""}${s.fontVariant?`${s.fontVariant} `:""}${s.fontWeight?`${s.fontWeight} `:""}${s.fontStretch?`${s.fontStretch} `:""}${s.fontSize||""}${s.lineHeight?`/${s.lineHeight} `:""}${s.fontFamily||""}`)}),e}function $5(t,e){return{toolbar:{minHeight:56,[t.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[t.up("sm")]:{minHeight:64}},...e}}function H5(t){return Math.round(t*1e5)/1e5}const S0={textTransform:"uppercase"},w0='"Roboto", "Helvetica", "Arial", sans-serif';function z5(t,e){const{fontFamily:n=w0,fontSize:i=14,fontWeightLight:r=300,fontWeightRegular:s=400,fontWeightMedium:o=500,fontWeightBold:a=700,htmlFontSize:c=16,allVariants:l,pxToRem:d,...u}=typeof e=="function"?e(t):e;process.env.NODE_ENV!=="production"&&(typeof i!="number"&&console.error("MUI: `fontSize` is required to be a number."),typeof c!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const f=i/14,p=d||(y=>`${y/c*f}rem`),v=(y,b,w,C,S)=>({fontFamily:n,fontWeight:y,fontSize:p(b),lineHeight:w,...n===w0?{letterSpacing:`${H5(C/b)}em`}:{},...S,...l}),h={h1:v(r,96,1.167,-1.5),h2:v(r,60,1.2,-.5),h3:v(s,48,1.167,0),h4:v(s,34,1.235,.25),h5:v(s,24,1.334,0),h6:v(o,20,1.6,.15),subtitle1:v(s,16,1.75,.15),subtitle2:v(o,14,1.57,.1),body1:v(s,16,1.5,.15),body2:v(s,14,1.43,.15),button:v(o,14,1.75,.4,S0),caption:v(s,12,1.66,.4),overline:v(s,12,2.66,1,S0),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return zt({htmlFontSize:c,pxToRem:p,fontFamily:n,fontSize:i,fontWeightLight:r,fontWeightRegular:s,fontWeightMedium:o,fontWeightBold:a,...h},u,{clone:!1})}const W5=.2,q5=.14,K5=.12;function He(...t){return[`${t[0]}px ${t[1]}px ${t[2]}px ${t[3]}px rgba(0,0,0,${W5})`,`${t[4]}px ${t[5]}px ${t[6]}px ${t[7]}px rgba(0,0,0,${q5})`,`${t[8]}px ${t[9]}px ${t[10]}px ${t[11]}px rgba(0,0,0,${K5})`].join(",")}const G5=["none",He(0,2,1,-1,0,1,1,0,0,1,3,0),He(0,3,1,-2,0,2,2,0,0,1,5,0),He(0,3,3,-2,0,3,4,0,0,1,8,0),He(0,2,4,-1,0,4,5,0,0,1,10,0),He(0,3,5,-1,0,5,8,0,0,1,14,0),He(0,3,5,-1,0,6,10,0,0,1,18,0),He(0,4,5,-2,0,7,10,1,0,2,16,1),He(0,5,5,-3,0,8,10,1,0,3,14,2),He(0,5,6,-3,0,9,12,1,0,3,16,2),He(0,6,6,-3,0,10,14,1,0,4,18,3),He(0,6,7,-4,0,11,15,1,0,4,20,3),He(0,7,8,-4,0,12,17,2,0,5,22,4),He(0,7,8,-4,0,13,19,2,0,5,24,4),He(0,7,9,-4,0,14,21,2,0,5,26,4),He(0,8,9,-5,0,15,22,2,0,6,28,5),He(0,8,10,-5,0,16,24,2,0,6,30,5),He(0,8,11,-5,0,17,26,2,0,6,32,5),He(0,9,11,-5,0,18,28,2,0,7,34,6),He(0,9,12,-6,0,19,29,2,0,7,36,6),He(0,10,13,-6,0,20,31,3,0,8,38,7),He(0,10,13,-6,0,21,33,3,0,8,40,7),He(0,10,14,-6,0,22,35,3,0,8,42,7),He(0,11,14,-7,0,23,36,3,0,9,44,8),He(0,11,15,-7,0,24,38,3,0,9,46,8)],Z5={easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",easeOut:"cubic-bezier(0.0, 0, 0.2, 1)",easeIn:"cubic-bezier(0.4, 0, 1, 1)",sharp:"cubic-bezier(0.4, 0, 0.6, 1)"},Y5={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function C0(t){return`${Math.round(t)}ms`}function J5(t){if(!t)return 0;const e=t/36;return Math.min(Math.round((4+15*e**.25+e/5)*10),3e3)}function X5(t){const e={...Z5,...t.easing},n={...Y5,...t.duration};return{getAutoHeightDuration:J5,create:(r=["all"],s={})=>{const{duration:o=n.standard,easing:a=e.easeInOut,delay:c=0,...l}=s;if(process.env.NODE_ENV!=="production"){const d=f=>typeof f=="string",u=f=>!Number.isNaN(parseFloat(f));!d(r)&&!Array.isArray(r)&&console.error('MUI: Argument "props" must be a string or Array.'),!u(o)&&!d(o)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${o}.`),d(a)||console.error('MUI: Argument "easing" must be a string.'),!u(c)&&!d(c)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof s!="object"&&console.error(["MUI: Secong argument of transition.create must be an object.","Arguments should be either `create('prop1', options)` or `create(['prop1', 'prop2'], options)`"].join(`
|
|
286
|
-
`)),Object.keys(l).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(l).join(",")}].`)}return(Array.isArray(r)?r:[r]).map(d=>`${d} ${typeof o=="string"?o:C0(o)} ${a} ${typeof c=="string"?c:C0(c)}`).join(",")},...t,easing:e,duration:n}}const Q5={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function ej(t){return qn(t)||typeof t>"u"||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||Array.isArray(t)}function ZS(t={}){const e={...t};function n(i){const r=Object.entries(i);for(let s=0;s<r.length;s++){const[o,a]=r[s];!ej(a)||o.startsWith("unstable_")?delete i[o]:qn(a)&&(i[o]={...a},n(i[o]))}}return n(e),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
|
|
287
|
-
|
|
288
|
-
const theme = ${JSON.stringify(e,null,2)};
|
|
289
|
-
|
|
290
|
-
theme.breakpoints = createBreakpoints(theme.breakpoints || {});
|
|
291
|
-
theme.transitions = createTransitions(theme.transitions || {});
|
|
292
|
-
|
|
293
|
-
export default theme;`}function gu(t={},...e){const{breakpoints:n,mixins:i={},spacing:r,palette:s={},transitions:o={},typography:a={},shape:c,...l}=t;if(t.vars&&t.generateThemeVars===void 0)throw new Error(process.env.NODE_ENV!=="production"?"MUI: `vars` is a private field used for CSS variables support.\nPlease use another name or follow the [docs](https://mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.":wi(20));const d=ih(s),u=BS(t);let f=zt(u,{mixins:$5(u.breakpoints,i),palette:d,shadows:G5.slice(),typography:z5(d,a),transitions:X5(o),zIndex:{...Q5}});if(f=zt(f,l),f=e.reduce((p,v)=>zt(p,v),f),process.env.NODE_ENV!=="production"){const p=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],v=(h,y)=>{let b;for(b in h){const w=h[b];if(p.includes(b)&&Object.keys(w).length>0){if(process.env.NODE_ENV!=="production"){const C=Qf("",b);console.error([`MUI: The \`${y}\` component increases the CSS specificity of the \`${b}\` internal state.`,"You can not override it like this: ",JSON.stringify(h,null,2),"",`Instead, you need to use the '&.${C}' syntax:`,JSON.stringify({root:{[`&.${C}`]:w}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
|
|
294
|
-
`))}h[b]={}}}};Object.keys(f.components).forEach(h=>{const y=f.components[h].styleOverrides;y&&h.startsWith("Mui")&&v(y,h)})}return f.unstable_sxConfig={...xc,...l==null?void 0:l.unstable_sxConfig},f.unstable_sx=function(v){return es({sx:v,theme:this})},f.toRuntimeSource=ZS,f}function tj(t){let e;return t<1?e=5.11916*t**2:e=4.5*Math.log(t+1)+2,Math.round(e*10)/1e3}const nj=[...Array(25)].map((t,e)=>{if(e===0)return"none";const n=tj(e);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function YS(t){return{inputPlaceholder:t==="dark"?.5:.42,inputUnderline:t==="dark"?.7:.42,switchTrackDisabled:t==="dark"?.2:.12,switchTrack:t==="dark"?.3:.38}}function JS(t){return t==="dark"?nj:[]}function ij(t){const{palette:e={mode:"light"},opacity:n,overlays:i,...r}=t,s=ih(e);return{palette:s,opacity:{...YS(s.mode),...n},overlays:i||JS(s.mode),...r}}function rj(t){var e;return!!t[0].match(/(cssVarPrefix|colorSchemeSelector|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!t[0].match(/sxConfig$/)||t[0]==="palette"&&!!((e=t[1])!=null&&e.match(/(mode|contrastThreshold|tonalOffset)/))}const sj=t=>[...[...Array(25)].map((e,n)=>`--${t?`${t}-`:""}overlays-${n}`),`--${t?`${t}-`:""}palette-AppBar-darkBg`,`--${t?`${t}-`:""}palette-AppBar-darkColor`],oj=t=>(e,n)=>{const i=t.rootSelector||":root",r=t.colorSchemeSelector;let s=r;if(r==="class"&&(s=".%s"),r==="data"&&(s="[data-%s]"),r!=null&&r.startsWith("data-")&&!r.includes("%s")&&(s=`[${r}="%s"]`),t.defaultColorScheme===e){if(e==="dark"){const o={};return sj(t.cssVarPrefix).forEach(a=>{o[a]=n[a],delete n[a]}),s==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:o}}:s?{[s.replace("%s",e)]:o,[`${i}, ${s.replace("%s",e)}`]:n}:{[i]:{...n,...o}}}if(s&&s!=="media")return`${i}, ${s.replace("%s",String(e))}`}else if(e){if(s==="media")return{[`@media (prefers-color-scheme: ${String(e)})`]:{[i]:n}};if(s)return s.replace("%s",String(e))}return i};function aj(t,e){e.forEach(n=>{t[n]||(t[n]={})})}function H(t,e,n){!t[e]&&n&&(t[e]=n)}function Os(t){return typeof t!="string"||!t.startsWith("hsl")?t:qS(t)}function Fn(t,e){`${e}Channel`in t||(t[`${e}Channel`]=Ns(Os(t[e]),`MUI: Can't create \`palette.${e}Channel\` because \`palette.${e}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
|
|
295
|
-
To suppress this warning, you need to explicitly provide the \`palette.${e}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function cj(t){return typeof t=="number"?`${t}px`:typeof t=="string"||typeof t=="function"||Array.isArray(t)?t:"8px"}const yn=t=>{try{return t()}catch{}},lj=(t="mui")=>R5(t);function Fl(t,e,n,i){if(!e)return;e=e===!0?{}:e;const r=i==="dark"?"dark":"light";if(!n){t[i]=ij({...e,palette:{mode:r,...e==null?void 0:e.palette}});return}const{palette:s,...o}=gu({...n,palette:{mode:r,...e==null?void 0:e.palette}});return t[i]={...e,palette:s,opacity:{...YS(r),...e==null?void 0:e.opacity},overlays:(e==null?void 0:e.overlays)||JS(r)},o}function dj(t={},...e){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:r=!1,cssVarPrefix:s="mui",shouldSkipGeneratingVar:o=rj,colorSchemeSelector:a=n.light&&n.dark?"media":void 0,rootSelector:c=":root",...l}=t,d=Object.keys(n)[0],u=i||(n.light&&d!=="light"?"light":d),f=lj(s),{[u]:p,light:v,dark:h,...y}=n,b={...y};let w=p;if((u==="dark"&&!("dark"in n)||u==="light"&&!("light"in n))&&(w=!0),!w)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${u}\` option is either missing or invalid.`:wi(21,u));const C=Fl(b,w,l,u);v&&!b.light&&Fl(b,v,void 0,"light"),h&&!b.dark&&Fl(b,h,void 0,"dark");let S={defaultColorScheme:u,...C,cssVarPrefix:s,colorSchemeSelector:a,rootSelector:c,getCssVar:f,colorSchemes:b,font:{...B5(C.typography),...C.font},spacing:cj(l.spacing)};Object.keys(S.colorSchemes).forEach(_=>{const k=S.colorSchemes[_].palette,I=N=>{const K=N.split("-"),J=K[1],se=K[2];return f(N,k[J][se])};if(k.mode==="light"&&(H(k.common,"background","#fff"),H(k.common,"onBackground","#000")),k.mode==="dark"&&(H(k.common,"background","#000"),H(k.common,"onBackground","#fff")),aj(k,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),k.mode==="light"){H(k.Alert,"errorColor",Ve(k.error.light,.6)),H(k.Alert,"infoColor",Ve(k.info.light,.6)),H(k.Alert,"successColor",Ve(k.success.light,.6)),H(k.Alert,"warningColor",Ve(k.warning.light,.6)),H(k.Alert,"errorFilledBg",I("palette-error-main")),H(k.Alert,"infoFilledBg",I("palette-info-main")),H(k.Alert,"successFilledBg",I("palette-success-main")),H(k.Alert,"warningFilledBg",I("palette-warning-main")),H(k.Alert,"errorFilledColor",yn(()=>k.getContrastText(k.error.main))),H(k.Alert,"infoFilledColor",yn(()=>k.getContrastText(k.info.main))),H(k.Alert,"successFilledColor",yn(()=>k.getContrastText(k.success.main))),H(k.Alert,"warningFilledColor",yn(()=>k.getContrastText(k.warning.main))),H(k.Alert,"errorStandardBg",Fe(k.error.light,.9)),H(k.Alert,"infoStandardBg",Fe(k.info.light,.9)),H(k.Alert,"successStandardBg",Fe(k.success.light,.9)),H(k.Alert,"warningStandardBg",Fe(k.warning.light,.9)),H(k.Alert,"errorIconColor",I("palette-error-main")),H(k.Alert,"infoIconColor",I("palette-info-main")),H(k.Alert,"successIconColor",I("palette-success-main")),H(k.Alert,"warningIconColor",I("palette-warning-main")),H(k.AppBar,"defaultBg",I("palette-grey-100")),H(k.Avatar,"defaultBg",I("palette-grey-400")),H(k.Button,"inheritContainedBg",I("palette-grey-300")),H(k.Button,"inheritContainedHoverBg",I("palette-grey-A100")),H(k.Chip,"defaultBorder",I("palette-grey-400")),H(k.Chip,"defaultAvatarColor",I("palette-grey-700")),H(k.Chip,"defaultIconColor",I("palette-grey-700")),H(k.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),H(k.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),H(k.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),H(k.LinearProgress,"primaryBg",Fe(k.primary.main,.62)),H(k.LinearProgress,"secondaryBg",Fe(k.secondary.main,.62)),H(k.LinearProgress,"errorBg",Fe(k.error.main,.62)),H(k.LinearProgress,"infoBg",Fe(k.info.main,.62)),H(k.LinearProgress,"successBg",Fe(k.success.main,.62)),H(k.LinearProgress,"warningBg",Fe(k.warning.main,.62)),H(k.Skeleton,"bg",`rgba(${I("palette-text-primaryChannel")} / 0.11)`),H(k.Slider,"primaryTrack",Fe(k.primary.main,.62)),H(k.Slider,"secondaryTrack",Fe(k.secondary.main,.62)),H(k.Slider,"errorTrack",Fe(k.error.main,.62)),H(k.Slider,"infoTrack",Fe(k.info.main,.62)),H(k.Slider,"successTrack",Fe(k.success.main,.62)),H(k.Slider,"warningTrack",Fe(k.warning.main,.62));const N=zo(k.background.default,.8);H(k.SnackbarContent,"bg",N),H(k.SnackbarContent,"color",yn(()=>k.getContrastText(N))),H(k.SpeedDialAction,"fabHoverBg",zo(k.background.paper,.15)),H(k.StepConnector,"border",I("palette-grey-400")),H(k.StepContent,"border",I("palette-grey-400")),H(k.Switch,"defaultColor",I("palette-common-white")),H(k.Switch,"defaultDisabledColor",I("palette-grey-100")),H(k.Switch,"primaryDisabledColor",Fe(k.primary.main,.62)),H(k.Switch,"secondaryDisabledColor",Fe(k.secondary.main,.62)),H(k.Switch,"errorDisabledColor",Fe(k.error.main,.62)),H(k.Switch,"infoDisabledColor",Fe(k.info.main,.62)),H(k.Switch,"successDisabledColor",Fe(k.success.main,.62)),H(k.Switch,"warningDisabledColor",Fe(k.warning.main,.62)),H(k.TableCell,"border",Fe(Ho(k.divider,1),.88)),H(k.Tooltip,"bg",Ho(k.grey[700],.92))}if(k.mode==="dark"){H(k.Alert,"errorColor",Fe(k.error.light,.6)),H(k.Alert,"infoColor",Fe(k.info.light,.6)),H(k.Alert,"successColor",Fe(k.success.light,.6)),H(k.Alert,"warningColor",Fe(k.warning.light,.6)),H(k.Alert,"errorFilledBg",I("palette-error-dark")),H(k.Alert,"infoFilledBg",I("palette-info-dark")),H(k.Alert,"successFilledBg",I("palette-success-dark")),H(k.Alert,"warningFilledBg",I("palette-warning-dark")),H(k.Alert,"errorFilledColor",yn(()=>k.getContrastText(k.error.dark))),H(k.Alert,"infoFilledColor",yn(()=>k.getContrastText(k.info.dark))),H(k.Alert,"successFilledColor",yn(()=>k.getContrastText(k.success.dark))),H(k.Alert,"warningFilledColor",yn(()=>k.getContrastText(k.warning.dark))),H(k.Alert,"errorStandardBg",Ve(k.error.light,.9)),H(k.Alert,"infoStandardBg",Ve(k.info.light,.9)),H(k.Alert,"successStandardBg",Ve(k.success.light,.9)),H(k.Alert,"warningStandardBg",Ve(k.warning.light,.9)),H(k.Alert,"errorIconColor",I("palette-error-main")),H(k.Alert,"infoIconColor",I("palette-info-main")),H(k.Alert,"successIconColor",I("palette-success-main")),H(k.Alert,"warningIconColor",I("palette-warning-main")),H(k.AppBar,"defaultBg",I("palette-grey-900")),H(k.AppBar,"darkBg",I("palette-background-paper")),H(k.AppBar,"darkColor",I("palette-text-primary")),H(k.Avatar,"defaultBg",I("palette-grey-600")),H(k.Button,"inheritContainedBg",I("palette-grey-800")),H(k.Button,"inheritContainedHoverBg",I("palette-grey-700")),H(k.Chip,"defaultBorder",I("palette-grey-700")),H(k.Chip,"defaultAvatarColor",I("palette-grey-300")),H(k.Chip,"defaultIconColor",I("palette-grey-300")),H(k.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),H(k.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),H(k.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),H(k.LinearProgress,"primaryBg",Ve(k.primary.main,.5)),H(k.LinearProgress,"secondaryBg",Ve(k.secondary.main,.5)),H(k.LinearProgress,"errorBg",Ve(k.error.main,.5)),H(k.LinearProgress,"infoBg",Ve(k.info.main,.5)),H(k.LinearProgress,"successBg",Ve(k.success.main,.5)),H(k.LinearProgress,"warningBg",Ve(k.warning.main,.5)),H(k.Skeleton,"bg",`rgba(${I("palette-text-primaryChannel")} / 0.13)`),H(k.Slider,"primaryTrack",Ve(k.primary.main,.5)),H(k.Slider,"secondaryTrack",Ve(k.secondary.main,.5)),H(k.Slider,"errorTrack",Ve(k.error.main,.5)),H(k.Slider,"infoTrack",Ve(k.info.main,.5)),H(k.Slider,"successTrack",Ve(k.success.main,.5)),H(k.Slider,"warningTrack",Ve(k.warning.main,.5));const N=zo(k.background.default,.98);H(k.SnackbarContent,"bg",N),H(k.SnackbarContent,"color",yn(()=>k.getContrastText(N))),H(k.SpeedDialAction,"fabHoverBg",zo(k.background.paper,.15)),H(k.StepConnector,"border",I("palette-grey-600")),H(k.StepContent,"border",I("palette-grey-600")),H(k.Switch,"defaultColor",I("palette-grey-300")),H(k.Switch,"defaultDisabledColor",I("palette-grey-600")),H(k.Switch,"primaryDisabledColor",Ve(k.primary.main,.55)),H(k.Switch,"secondaryDisabledColor",Ve(k.secondary.main,.55)),H(k.Switch,"errorDisabledColor",Ve(k.error.main,.55)),H(k.Switch,"infoDisabledColor",Ve(k.info.main,.55)),H(k.Switch,"successDisabledColor",Ve(k.success.main,.55)),H(k.Switch,"warningDisabledColor",Ve(k.warning.main,.55)),H(k.TableCell,"border",Ve(Ho(k.divider,1),.68)),H(k.Tooltip,"bg",Ho(k.grey[700],.92))}Fn(k.background,"default"),Fn(k.background,"paper"),Fn(k.common,"background"),Fn(k.common,"onBackground"),Fn(k,"divider"),Object.keys(k).forEach(N=>{const K=k[N];N!=="tonalOffset"&&K&&typeof K=="object"&&(K.main&&H(k[N],"mainChannel",Ns(Os(K.main))),K.light&&H(k[N],"lightChannel",Ns(Os(K.light))),K.dark&&H(k[N],"darkChannel",Ns(Os(K.dark))),K.contrastText&&H(k[N],"contrastTextChannel",Ns(Os(K.contrastText))),N==="text"&&(Fn(k[N],"primary"),Fn(k[N],"secondary")),N==="action"&&(K.active&&Fn(k[N],"active"),K.selected&&Fn(k[N],"selected")))})}),S=e.reduce((_,k)=>zt(_,k),S);const x={prefix:s,disableCssColorScheme:r,shouldSkipGeneratingVar:o,getSelector:oj(S)},{vars:T,generateThemeVars:E,generateStyleSheets:P}=M5(S,x);return S.vars=T,Object.entries(S.colorSchemes[S.defaultColorScheme]).forEach(([_,k])=>{S[_]=k}),S.generateThemeVars=E,S.generateStyleSheets=P,S.generateSpacing=function(){return US(l.spacing,Gf(this))},S.getColorSchemeSelector=_5(a),S.spacing=S.generateSpacing(),S.shouldSkipGeneratingVar=o,S.unstable_sxConfig={...xc,...l==null?void 0:l.unstable_sxConfig},S.unstable_sx=function(k){return es({sx:k,theme:this})},S.toRuntimeSource=ZS,S}function k0(t,e,n){t.colorSchemes&&n&&(t.colorSchemes[e]={...n!==!0&&n,palette:ih({...n===!0?{}:n.palette,mode:e})})}function uj(t={},...e){const{palette:n,cssVariables:i=!1,colorSchemes:r=n?void 0:{light:!0},defaultColorScheme:s=n==null?void 0:n.mode,...o}=t,a=s||"light",c=r==null?void 0:r[a],l={...r,...n?{[a]:{...typeof c!="boolean"&&c,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in t))return gu(t,...e);let d=n;"palette"in t||l[a]&&(l[a]!==!0?d=l[a].palette:a==="dark"&&(d={mode:"dark"}));const u=gu({...t,palette:d},...e);return u.defaultColorScheme=a,u.colorSchemes=l,u.palette.mode==="light"&&(u.colorSchemes.light={...l.light!==!0&&l.light,palette:u.palette},k0(u,"dark",l.dark)),u.palette.mode==="dark"&&(u.colorSchemes.dark={...l.dark!==!0&&l.dark,palette:u.palette},k0(u,"light",l.light)),u}return!n&&!("light"in l)&&a==="light"&&(l.light=!0),dj({...o,colorSchemes:l,defaultColorScheme:a,...typeof i!="boolean"&&i},...e)}const fj=uj(),hj="$$material";function mj(t){return t!=="ownerState"&&t!=="theme"&&t!=="sx"&&t!=="as"}const pj=t=>mj(t)&&t!=="classes",gj=m5({themeId:hj,defaultTheme:fj,rootShouldForwardProp:pj}),vj=P5;process.env.NODE_ENV!=="production"&&(Pe.node,Pe.object.isRequired);function yj(t){return E5(t)}function bj(t){return Qf("MuiSvgIcon",t)}l5("MuiSvgIcon",["root","colorPrimary","colorSecondary","colorAction","colorError","colorDisabled","fontSizeInherit","fontSizeSmall","fontSizeMedium","fontSizeLarge"]);const xj=t=>{const{color:e,fontSize:n,classes:i}=t,r={root:["root",e!=="inherit"&&`color${ir(e)}`,`fontSize${ir(n)}`]};return fD(r,bj,i)},Sj=gj("svg",{name:"MuiSvgIcon",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,n.color!=="inherit"&&e[`color${ir(n.color)}`],e[`fontSize${ir(n.fontSize)}`]]}})(vj(({theme:t})=>{var e,n,i,r,s,o,a,c,l,d,u,f,p,v;return{userSelect:"none",width:"1em",height:"1em",display:"inline-block",flexShrink:0,transition:(r=(e=t.transitions)==null?void 0:e.create)==null?void 0:r.call(e,"fill",{duration:(i=(n=(t.vars??t).transitions)==null?void 0:n.duration)==null?void 0:i.shorter}),variants:[{props:h=>!h.hasSvgAsChild,style:{fill:"currentColor"}},{props:{fontSize:"inherit"},style:{fontSize:"inherit"}},{props:{fontSize:"small"},style:{fontSize:((o=(s=t.typography)==null?void 0:s.pxToRem)==null?void 0:o.call(s,20))||"1.25rem"}},{props:{fontSize:"medium"},style:{fontSize:((c=(a=t.typography)==null?void 0:a.pxToRem)==null?void 0:c.call(a,24))||"1.5rem"}},{props:{fontSize:"large"},style:{fontSize:((d=(l=t.typography)==null?void 0:l.pxToRem)==null?void 0:d.call(l,35))||"2.1875rem"}},...Object.entries((t.vars??t).palette).filter(([,h])=>h&&h.main).map(([h])=>{var y,b;return{props:{color:h},style:{color:(b=(y=(t.vars??t).palette)==null?void 0:y[h])==null?void 0:b.main}}}),{props:{color:"action"},style:{color:(f=(u=(t.vars??t).palette)==null?void 0:u.action)==null?void 0:f.active}},{props:{color:"disabled"},style:{color:(v=(p=(t.vars??t).palette)==null?void 0:p.action)==null?void 0:v.disabled}},{props:{color:"inherit"},style:{color:void 0}}]}})),za=g.forwardRef(function(e,n){const i=yj({props:e,name:"MuiSvgIcon"}),{children:r,className:s,color:o="inherit",component:a="svg",fontSize:c="medium",htmlColor:l,inheritViewBox:d=!1,titleAccess:u,viewBox:f="0 0 24 24",...p}=i,v=g.isValidElement(r)&&r.type==="svg",h={...i,color:o,component:a,fontSize:c,instanceFontSize:e.fontSize,inheritViewBox:d,viewBox:f,hasSvgAsChild:v},y={};d||(y.viewBox=f);const b=xj(h);return m.jsxs(Sj,{as:a,className:xu(b.root,s),focusable:"false",color:l,"aria-hidden":u?void 0:!0,role:u?"img":void 0,ref:n,...y,...p,...v&&r.props,ownerState:h,children:[v?r.props.children:r,u?m.jsx("title",{children:u}):null]})});process.env.NODE_ENV!=="production"&&(za.propTypes={children:Pe.node,classes:Pe.object,className:Pe.string,color:Pe.oneOfType([Pe.oneOf(["inherit","action","disabled","primary","secondary","error","info","success","warning"]),Pe.string]),component:Pe.elementType,fontSize:Pe.oneOfType([Pe.oneOf(["inherit","large","medium","small"]),Pe.string]),htmlColor:Pe.string,inheritViewBox:Pe.bool,shapeRendering:Pe.string,sx:Pe.oneOfType([Pe.arrayOf(Pe.oneOfType([Pe.func,Pe.object,Pe.bool])),Pe.func,Pe.object]),titleAccess:Pe.string,viewBox:Pe.string});za.muiName="SvgIcon";function hs(t,e){function n(i,r){return m.jsx(za,{"data-testid":process.env.NODE_ENV!=="production"?`${e}Icon`:void 0,ref:r,...i,children:t})}return process.env.NODE_ENV!=="production"&&(n.displayName=`${e}Icon`),n.muiName=za.muiName,g.memo(g.forwardRef(n))}const wj=hs(m.jsx("path",{d:"M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6z"}),"AttachFile"),Cj=hs(m.jsx("path",{d:"M12 9c-1.6 0-3.15.25-4.6.72v3.1c0 .39-.23.74-.56.9-.98.49-1.87 1.12-2.66 1.85-.18.18-.43.28-.7.28-.28 0-.53-.11-.71-.29L.29 13.08c-.18-.17-.29-.42-.29-.7s.11-.53.29-.71C3.34 8.78 7.46 7 12 7s8.66 1.78 11.71 4.67c.18.18.29.43.29.71s-.11.53-.29.71l-2.48 2.48c-.18.18-.43.29-.71.29-.27 0-.52-.11-.7-.28-.79-.74-1.69-1.36-2.67-1.85-.33-.16-.56-.5-.56-.9v-3.1C15.15 9.25 13.6 9 12 9"}),"CallEnd"),kj=hs([m.jsx("circle",{cx:"12",cy:"12",r:"3.2"},"0"),m.jsx("path",{d:"M9 2 7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5"},"1")],"CameraAlt"),XS=hs(m.jsx("path",{d:"M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2M6 9h12v2H6zm8 5H6v-2h8zm4-6H6V6h12z"}),"Chat"),QS=hs(m.jsx("path",{d:"M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3m5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72z"}),"Mic"),ew=hs(m.jsx("path",{d:"M17 10.5V7c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11z"}),"Videocam"),Tj=({disabled:t,capabilities:e,sessionStarted:n,ref:i,participantName:r="User",loadingText:s="Waiting for agent to connect...",theme:o="vox",client:a,displayType:c="widget",onBack:l})=>{var J,se,ie,X,O,oe,L;const[d,u]=R.useState(!1),[f,p]=R.useState(!1),[v,h]=R.useState(()=>{var te;const F=(te=a==null?void 0:a.getCurrentInteraction)==null?void 0:te.call(a);return console.log("SessionView: Initializing with existing interaction:",(F==null?void 0:F.methodName)||"none"),F||null}),{messages:y,send:b}=eD(),w=R.useRef(null),C=R.useRef(null),{agent:{isActive:S=!1}={}}=j1(),x=St(o),T=R.useMemo(()=>a&&typeof a.getCurrentSession=="function"?!!a.getCurrentSession():!1,[a]),E=S||T;R.useEffect(()=>{var F,te;console.log("🤖 SessionView agent state:",{isAgentActive:S,hasActiveSession:T,effectiveAgentActive:E,sessionStarted:n,clientSession:(te=(F=a==null?void 0:a.getCurrentSession)==null?void 0:F.call(a))==null?void 0:te.id})},[S,T,E,n,a]),R.useEffect(()=>{console.log("🤖 Agent active state changed:",S)},[S]),R.useEffect(()=>{console.log("📋 Session state changed:",{sessionStarted:n,disabled:t,participantName:r,effectiveAgentActive:E,chatOpen:d,currentInteraction:(v==null?void 0:v.methodName)||"none"})},[n,t,r,E,d,v]),R.useEffect(()=>{if(n&&!S){console.log("⏰ Starting agent timeout detection...");const F=setTimeout(()=>{console.log("⚠️ Agent timeout: Agent did not become active within 30 seconds"),p(!0)},3e4);return()=>{clearTimeout(F)}}else S&&(console.log("✅ Agent is active, clearing timeout"),p(!1))},[n,S]),R.useEffect(()=>{if(!a)return;const F=()=>{console.log("🔄 Client connection state changed:",a.connected)},te=j=>{console.log("🔴 Client disconnected:",j),h(null),u(!1),p(!1)};return a.on("connection.connected",F),a.on("connection.disconnected",te),()=>{a.off("connection.connected",F),a.off("connection.disconnected",te)}},[a]),R.useEffect(()=>{if(!a)return;const F=ee=>{console.log("🎯 SessionView: RPC Interaction started:",ee);const G=a.getCurrentInteraction();G&&(console.log("📱 SessionView: Setting current interaction:",G.methodName,"mode:",G.presentationMode),h(G))},te=ee=>{console.log("✅ SessionView: RPC Interaction completed:",ee),h(null)},j=async ee=>{console.log("⏰ SessionView: RPC Interaction timeout:",ee),h(null)},q=async ee=>{console.log("❌ SessionView: RPC Interaction dismissed:",ee),h(null)};return a.on("rpc.interaction.started",F),a.on("rpc.interaction.completed",te),a.on("rpc.interaction.timeout",j),a.on("rpc.interaction.dismissed",q),()=>{a.off("rpc.interaction.started",F),a.off("rpc.interaction.completed",te),a.off("rpc.interaction.timeout",j),a.off("rpc.interaction.dismissed",q)}},[a]),R.useEffect(()=>{if(!a)return;const F=a.getCurrentInteraction();F?(console.log("🔄 SessionView: Syncing with existing interaction:",F.methodName),h(F)):h(null)},[a]),R.useEffect(()=>{console.log("🎭 SessionView: Current interaction changed:",(v==null?void 0:v.methodName)||"none","mode:",(v==null?void 0:v.presentationMode)||"none")},[v]),R.useEffect(()=>{var F,te,j;console.log("📱 SessionView: Display type changed to:",c),console.log("📱 SessionView: Current session state during display change:",{sessionStarted:n,effectiveAgentActive:E,hasSession:!!((F=a==null?void 0:a.getCurrentSession)!=null&&F.call(a)),sessionId:(j=(te=a==null?void 0:a.getCurrentSession)==null?void 0:te.call(a))==null?void 0:j.id})},[c,n,E,a]),R.useEffect(()=>{console.log("💬 SessionView: Chat open state changed:",d)},[d]),R.useEffect(()=>{v&&d&&(console.log("🎭 SessionView: Interactive UI appeared, closing chat"),u(!1))},[v,d]),tD(),R.useEffect(()=>{w.current&&d&&y.length>0&&(console.log("📜 SessionView: Auto-scrolling to latest message, count:",y.length),setTimeout(()=>{if(w.current){let F=w.current.parentElement;for(;F&&F.scrollHeight<=F.clientHeight;)F=F.parentElement;F?(console.log("📜 SessionView: Scrolling container found, scrolling to bottom"),F.scrollTo({top:F.scrollHeight,behavior:"smooth"})):(console.log("📜 SessionView: Using fallback scroll method"),w.current.scrollIntoView({behavior:"smooth",block:"end",inline:"nearest"}))}},100))},[y.length,d]),R.useEffect(()=>{var j,q;console.log("📝 SessionView: Messages updated, count:",y.length),y.length>0&&console.log("📝 SessionView: Latest messages:",y.slice(-3).map(ee=>{var G,D,$,Q,W,ce,z;return{id:ee.id,message:ee.message,timestamp:ee.timestamp,from:((G=ee.from)==null?void 0:G.name)||((D=ee.from)==null?void 0:D.identity),fromType:ee.from===void 0?"unknown":"participant",isLocal:(($=ee.from)==null?void 0:$.identity)===((ce=(W=(Q=a==null?void 0:a.getCurrentSession)==null?void 0:Q.call(a))==null?void 0:W.localParticipant)==null?void 0:ce.identity),messageLength:((z=ee.message)==null?void 0:z.length)||0}}));const F=((j=a==null?void 0:a.getTranscriptions)==null?void 0:j.call(a))||[],te=((q=a==null?void 0:a.getChatMessages)==null?void 0:q.call(a))||[];console.log("📝 SessionView: Raw transcriptions count:",F.length),console.log("📝 SessionView: Raw chat messages count:",te.length)},[y.length,y,a]),R.useEffect(()=>{console.log("💬 SessionView: Chat state changed:",{chatOpen:d,messagesCount:y.length,displayType:c,hasMessages:y.length>0})},[d,y.length,c]);async function P(F){await b(F)}const _=R.useCallback(F=>{console.log("📝 SessionView: Adding local message for voice session context:",F)},[]),k=R.useCallback(async F=>{try{a&&typeof a.sendAttachments=="function"&&(await a.sendAttachments(F),console.log("📎 SessionView: Attachments sent successfully:",F.map(te=>te.name)))}catch(te){console.error("❌ SessionView: Failed to send attachments:",te)}},[a]),I=R.useCallback(()=>{try{console.log("📞 SessionView: Ending call..."),console.log("📞 SessionView: Current state before ending:",{sessionStarted:n,effectiveAgentActive:E,chatOpen:d,currentInteraction:v==null?void 0:v.methodName,hasOnBack:!!l}),v&&(console.log("🎭 SessionView: Dismissing current interaction:",v.methodName),h(null),a&&typeof a.dismissCurrentInteraction=="function"&&a.dismissCurrentInteraction()),u(!1),p(!1),console.log("✅ SessionView: Local state reset"),a&&typeof a.endSession=="function"&&(a.endSession(),console.log("✅ SessionView: Session ended via client.endSession()")),a&&typeof a.disconnect=="function"&&(a.disconnect(),console.log("✅ SessionView: Client disconnected")),l?(console.log("🔄 SessionView: Calling onBack to return to welcome..."),setTimeout(()=>{l(),console.log("✅ SessionView: onBack called")},150)):console.warn("⚠️ SessionView: No onBack function provided - cannot return to welcome"),console.log("🏁 SessionView: Call ended and cleanup completed")}catch(F){console.error("❌ SessionView: Failed to end call:",F),h(null),u(!1),p(!1),l&&(console.log("🔄 SessionView: Error occurred, still calling onBack..."),l())}},[a,l,v,n,E,d]);R.useEffect(()=>(console.log("🔄 SessionView: Component mounted/props changed:",{sessionStarted:n,disabled:t,participantName:r,displayType:c,hasOnBack:!!l,hasClient:!!a}),()=>{console.log("🧹 SessionView: Component unmounting or props changing")}),[n,t,r,c,l,a]),R.useEffect(()=>{console.log("🔗 SessionView: onBack prop:",{hasOnBack:!!l,onBackType:typeof l})},[l]),R.useEffect(()=>{var te,j;const F=((j=(te=a==null?void 0:a.getCurrentSession)==null?void 0:te.call(a))==null?void 0:j.id)||null;C.current&&!F&&console.warn("⚠️ SessionView: Session was lost unexpectedly!",{previousSession:C.current,currentSession:F,displayType:c,sessionStarted:n,effectiveAgentActive:E}),C.current=F},[a,c,n,E]);const N=fe("w-full flex flex-col items-center justify-center",c==="fullscreen"?"w-full max-w-none mx-0 h-full":"w-full mx-auto",x.main,c==="fullscreen"?"max-w-none":"","overflow-hidden","h-full"),K=l&&(c==="popup"||c==="fullscreen");return m.jsxs("main",{ref:i,inert:t,className:fe(N,"relative"),style:{minHeight:0},children:[K&&m.jsx("div",{className:`flex items-center justify-between w-full p-4 border-b ${((J=x.chatHeader)==null?void 0:J.container)||"border-gray-200"}`,children:m.jsx("div",{className:"flex items-center",children:m.jsxs("div",{children:[m.jsx("h3",{className:`font-semibold ${x.text.primary}`,children:"Voice Session"}),m.jsx("p",{className:`text-sm ${x.text.muted}`,children:r})]})})}),m.jsxs("div",{className:"w-full flex-1 flex flex-col items-center px-0 min-h-0 overflow-hidden",children:[!E&&m.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full min-h-[180px]",children:[m.jsx(xe.div,{animate:{rotate:360,scale:[1,1.1,1]},transition:{rotate:{duration:2,repeat:1/0,ease:"linear"},scale:{duration:1,repeat:1/0,ease:"easeInOut"}},className:"w-12 h-12 mb-4",children:m.jsx(Nf,{className:x.spinner,weight:"bold"})}),m.jsx(xe.span,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`text-sm opacity-80 ${x.text.muted} text-center max-w-xs`,children:f?"Agent is taking longer than expected...":s}),m.jsx(xe.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:2},className:`text-xs ${x.text.muted} mt-2 text-center opacity-60`,children:f?"Please check your connection or try again.":"Agent is connecting... This may take a moment."}),f&&l&&m.jsx(xe.button,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{delay:.5},onClick:l,className:`mt-4 px-4 py-2 rounded-lg ${((se=x.chatHeader)==null?void 0:se.backButton)||"bg-gray-100 hover:bg-gray-200"} transition-colors`,children:"Go Back"})]}),E&&m.jsxs(m.Fragment,{children:[d&&m.jsxs("div",{className:fe("absolute inset-0 w-full h-full flex flex-col transition-[opacity,translate] duration-300 ease-out z-10",o==="light"?"bg-white":"bg-gray-900/95 backdrop-blur-sm",d?"translate-y-0 opacity-100 delay-200":"translate-y-10 opacity-0"),children:[m.jsxs("div",{className:fe("flex-shrink-0 px-4 py-3 border-b",c==="fullscreen"?"px-8":"px-5",((ie=x.chatHeader)==null?void 0:ie.container)||"border-gray-200 dark:border-gray-700"),children:[m.jsx("h3",{className:fe("font-semibold text-lg",((X=x.text)==null?void 0:X.primary)||"text-gray-900 dark:text-white"),children:"Transcription & Chat"}),m.jsxs("p",{className:fe("text-sm",((O=x.text)==null?void 0:O.muted)||"text-gray-600 dark:text-gray-400"),children:[y.length," messages"]})]}),m.jsx("div",{className:fe("flex-1 flex flex-col min-h-0",c==="fullscreen"?"px-8":"px-5"),children:m.jsx(l6,{className:"flex-1 flex flex-col min-h-0 h-full",children:m.jsxs("div",{className:`flex-1 flex flex-col h-full ${fe("overflow-y-auto scrollbar-hide py-4")}`,style:{scrollbarWidth:"none",scrollBehavior:"smooth",paddingBottom:"120px"},children:[y.length===0&&m.jsx("div",{className:"flex-1 flex items-center justify-center",children:m.jsxs("div",{className:"text-center",children:[m.jsx("p",{className:fe("text-lg font-medium mb-2",((oe=x.text)==null?void 0:oe.primary)||"text-gray-900 dark:text-white"),children:"Start Speaking"}),m.jsx("p",{className:fe("text-sm",((L=x.text)==null?void 0:L.muted)||"text-gray-600 dark:text-gray-400"),children:"Your conversation will appear here"})]})}),y.length>0&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"flex-1 min-h-4"}),m.jsx("div",{ref:w,className:"space-y-4 relative whitespace-pre-wrap z-0",children:m.jsx(Vr,{mode:"popLayout",children:y.map((F,te)=>m.jsx(xe.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3,ease:"easeOut",delay:te*.02},layout:!0,children:m.jsx(a6,{participantName:r,entry:F})},F.id||`message-${te}`))})})]})]})})})]}),!d&&m.jsxs("div",{className:fe("flex-1 flex flex-col items-center w-full h-full min-h-0",(v==null?void 0:v.presentationMode)==="embedded"?"justify-end":"justify-center"),children:[m.jsx(xe.div,{className:"w-full flex justify-center",animate:{y:(v==null?void 0:v.presentationMode)==="embedded"?-8:0},transition:{duration:.3,ease:"easeOut"},children:m.jsx(v6,{chatOpen:d})}),m.jsx(Vr,{mode:"wait",children:v&&v.presentationMode==="embedded"&&m.jsx(xe.div,{initial:{opacity:0,y:20,height:0},animate:{opacity:1,y:0,height:"auto"},exit:{opacity:0,y:20,height:0},transition:{duration:.3,ease:"easeOut"},className:fe("w-full relative mt-4 flex justify-center",c==="fullscreen"?"max-w-4xl":"max-w-md"),children:m.jsx("div",{className:"bg-white/10 backdrop-blur-sm rounded-xl border border-white/20 shadow-lg overflow-hidden",children:m.jsx(Qr,{interaction:v,theme:o,onDismiss:()=>{var F;return(F=a==null?void 0:a.dismissCurrentInteraction)==null?void 0:F.call(a)},client:a,addLocalMessage:_})})},`embedded-${v.methodName}`)})]})]})]}),m.jsx(Vr,{mode:"wait",children:v&&v.presentationMode!=="embedded"&&!d&&m.jsx("div",{className:fe("absolute inset-0 z-50 flex items-center justify-center backdrop-blur-sm",c==="fullscreen"?"bg-black/70":"bg-black/50"),children:m.jsx(xe.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.2,ease:"easeOut"},className:fe("relative w-full overflow-hidden",c==="fullscreen"?"max-w-2xl mx-8 max-h-[85vh]":"max-w-lg mx-4 max-h-[80vh]","bg-white dark:bg-gray-900 rounded-2xl shadow-2xl","border border-gray-200 dark:border-gray-700"),children:m.jsx(Qr,{interaction:v,theme:o,onDismiss:()=>{var F;return(F=a==null?void 0:a.dismissCurrentInteraction)==null?void 0:F.call(a)},client:a,addLocalMessage:_})},`modal-${v.methodName}`)})}),m.jsx(xe.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},className:"absolute bottom-0 left-0 right-0 flex-shrink-0 w-full z-20",children:m.jsx(Ej,{capabilities:e,onSendMessage:P,onSendAttachments:k,onEndCall:I,onChatOpenChange:u,disabled:t,theme:o,client:a,sessionStarted:n})})]})};function Ej({capabilities:t,onSendMessage:e,onSendAttachments:n,onEndCall:i,onChatOpenChange:r,disabled:s=!1,theme:o,client:a,sessionStarted:c=!1}){const[l,d]=R.useState(!1),u=R.useRef(null),f=R.useRef(null);R.useEffect(()=>{const w=()=>{const C=navigator.userAgent.toLowerCase(),x=["android","iphone","ipad","mobile","tablet"].some(P=>C.includes(P)),T="ontouchstart"in window||navigator.maxTouchPoints>0,E=window.innerWidth<=768;d(x||T&&E)};return w(),window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[]);const p=w=>{const C=w.target.files;if(C&&C.length>0){const x=Array.from(C).filter(T=>T.type.startsWith("image/"));if(x.length===0){console.warn("No valid image files selected");return}n&&n(x),u.current&&(u.current.value="")}},v=w=>{const C=w.target.files;if(C&&C.length>0){const S=C[0];S.type.startsWith("image/")&&n&&n([S]),f.current&&(f.current.value="")}},h=()=>{!s&&u.current&&u.current.click()},y=()=>{!s&&l&&f.current&&f.current.click()},b=()=>{console.log("🔴 VoiceControlPanel: End call button clicked"),console.log("🔴 VoiceControlPanel: Current state:",{disabled:s,sessionStarted:c,hasOnEndCall:!!i}),i?i():console.warn("⚠️ VoiceControlPanel: No onEndCall function provided")};return m.jsx("div",{className:fe("px-4 py-3 !w-full backdrop-blur-xl border-0 shadow-lg",o==="light"?"bg-white/95 border-t border-gray-200":"bg-gray-900/95 border-t border-gray-700"),children:m.jsxs("div",{className:"flex items-center justify-between !w-full mx-auto max-w-4xl",children:[m.jsx("input",{ref:u,type:"file",multiple:!0,onChange:p,className:"hidden",accept:"image/*"}),m.jsx("input",{ref:f,type:"file",onChange:v,className:"hidden",accept:"image/*",capture:"environment"}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("button",{onClick:h,disabled:s,className:fe("p-3 rounded-full transition-all duration-200 hover:scale-105 active:scale-95",s?"opacity-50 cursor-not-allowed":"hover:shadow-md",o==="light"?"bg-gray-100 hover:bg-gray-200 text-gray-600":"bg-gray-700/50 hover:bg-gray-600/50 text-gray-300"),title:"Attach files",children:m.jsx(wj,{className:"w-5 h-5"})}),l&&m.jsx("button",{onClick:y,disabled:s,className:fe("p-3 rounded-full transition-all duration-200 hover:scale-105 active:scale-95",s?"opacity-50 cursor-not-allowed":"hover:shadow-md",o==="light"?"bg-gray-100 hover:bg-gray-200 text-gray-600":"bg-gray-700/50 hover:bg-gray-600/50 text-gray-300"),title:"Take photo",children:m.jsx(kj,{className:"w-5 h-5"})})]}),m.jsx("div",{className:"flex-1 flex justify-center px-4",children:m.jsx(s6,{capabilities:t,onChatOpenChange:r,onSendMessage:e,theme:o,client:a,className:"border-none py-1 rounded-xl max-w-md w-full"})}),m.jsx("div",{className:"flex items-center",children:m.jsx("button",{onClick:b,disabled:s||!c,className:fe("p-3 rounded-full transition-all duration-200 hover:scale-105 active:scale-95",s||!c?"opacity-50 cursor-not-allowed":"hover:shadow-md","bg-red-500 hover:bg-red-600 text-white"),title:"End call",children:m.jsx(Cj,{className:"w-5 h-5"})})})]})})}function Pj({onSendMessage:t,onSendAttachments:e,disabled:n,theme:i,onEndChat:r}){const[s,o]=g.useState(""),[a,c]=g.useState(!1),l=g.useRef(null),d=g.useRef(null),[u,f]=g.useState(!1),p=St(i);g.useEffect(()=>{const S=()=>{const x=navigator.userAgent.toLowerCase(),E=["android","iphone","ipad","mobile","tablet"].some(k=>x.includes(k)),P="ontouchstart"in window||navigator.maxTouchPoints>0,_=window.innerWidth<=768;f(E||P&&_)};return S(),window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);const v=S=>{S.preventDefault(),s.trim()&&!n&&(t(s.trim()),o(""))},h=S=>{S.key==="Enter"&&!S.shiftKey&&(S.preventDefault(),v(S))},y=S=>{const x=S.target.files;if(x&&x.length>0){const T=Array.from(x),E=T.filter(P=>P.type.startsWith("image/"));if(E.length===0){console.warn("No valid image files selected");return}E.length!==T.length&&console.warn("Some non-image files were filtered out"),console.log("Selected image files:",E),e(E),l.current&&(l.current.value="")}},b=()=>{!n&&l.current&&l.current.click()},w=()=>{!n&&u&&d.current&&d.current.click()},C=S=>{const x=S.target.files;if(x&&x.length>0){const T=x[0];T.type.startsWith("image/")?e([T]):console.warn("Selected file is not an image"),d.current&&(d.current.value="")}};return m.jsx("div",{className:"px-4 py-3 !w-full backdrop-blur-xl border-0 shadow-lg ",children:m.jsx("form",{onSubmit:v,className:"flex items-center !w-full mx-auto max-w-4xl",children:m.jsxs("div",{className:`flex items-center gap-2 !w-full backdrop-blur-md rounded-full px-3 py-2 shadow-sm hover:shadow-md focus-within:shadow-lg focus-within:ring-2 focus-within:ring-blue-500/30 focus-within:border-blue-500/50 transition-all duration-200 border ${i==="light"?"bg-white/90 border-gray-200":p.chatInput.container}`,children:[m.jsx(xe.button,{type:"button",onClick:b,whileHover:{scale:1.05},whileTap:{scale:.95},className:`p-1 rounded-full transition-all duration-200 border-0 ${p.chatInput.attachButton}`,disabled:n,"aria-label":"Attach file",children:m.jsx($6,{className:"w-4 h-4"})}),u&&m.jsx(xe.button,{type:"button",onClick:w,whileHover:{scale:1.05},whileTap:{scale:.95},className:`p-1 rounded-full transition-all duration-200 border-0 ${p.chatInput.attachButton}`,disabled:n,"aria-label":"Take photo",children:m.jsx(wS,{className:"w-4 h-4"})}),m.jsx("input",{ref:l,type:"file",multiple:!0,onChange:y,className:"hidden",accept:"image/*"}),m.jsx("input",{ref:d,type:"file",onChange:C,className:"hidden",accept:"image/*",capture:"environment"}),m.jsx("textarea",{value:s,onChange:S=>o(S.target.value),onKeyDown:h,onFocus:()=>c(!0),onBlur:()=>c(!1),placeholder:"Type your message...",disabled:n,className:`flex-1 px-2 py-1 bg-transparent resize-none min-h-[32px] max-h-20 focus:outline-none text-sm border-0 ${p.chatInput.textarea}`,rows:1,style:{height:"auto",minHeight:"32px"},onInput:S=>{const x=S.target;x.style.height="auto",x.style.height=`${Math.min(x.scrollHeight,80)}px`}}),m.jsx(xe.button,{type:"submit",disabled:n||!s.trim(),whileHover:{scale:1.05},whileTap:{scale:.95},className:`p-1 rounded-full transition-all duration-200 border-0 flex-shrink-0 ${s.trim()&&!n?p.chatInput.sendButton:i==="light"?"bg-gray-200 text-gray-400 cursor-not-allowed opacity-70":"bg-gray-600/50 text-gray-500 cursor-not-allowed opacity-50"}`,"aria-label":"Send message",children:m.jsx(W6,{className:"w-4 h-4"})}),r&&m.jsx(xe.button,{type:"button",onClick:r,whileHover:{scale:1.05},whileTap:{scale:.95},className:`p-1 rounded-full transition-all duration-200 border-0 flex-shrink-0 ${p.chatInput.endButton}`,"aria-label":"End chat",children:m.jsx(CS,{className:"w-4 h-4"})})]})})})}function Rj({text:t,isComplete:e,isRealTimeStream:n=!1,speed:i=50}){const[r,s]=g.useState(""),[o,a]=g.useState(0);return g.useEffect(()=>{if(n){s(t);return}if(e){s(t);return}if(o<t.length){const c=setTimeout(()=>{s(t.slice(0,o+1)),a(o+1)},i);return()=>clearTimeout(c)}},[t,o,e,i,n]),g.useEffect(()=>{n||(a(0),s(""))},[t,n]),m.jsxs("span",{className:"relative",children:[m.jsx("span",{className:"inline-block",children:r}),!e&&m.jsx("span",{className:"inline-flex items-center ml-1",children:[0,1,2].map(c=>m.jsx(xe.span,{className:"w-1.5 h-1.5 bg-current rounded-full mx-0.5",animate:{y:[0,-4,0],opacity:[.4,1,.4],scale:[.8,1,.8]},transition:{duration:.8,repeat:1/0,repeatType:"mirror",delay:c*.2,ease:"easeInOut"}},c))})]})}function Aj({message:t,theme:e,isOwn:n,isStreaming:i=!1}){var o,a;const r=St(e),s=t.sender.name?t.sender.name.split(" ").map(c=>c[0]).join("").toUpperCase().slice(0,2):"U";return m.jsx("div",{className:`flex w-full ${n?"justify-end":"justify-start"} mb-4 px-1`,children:m.jsxs("div",{className:`relative group ${n?"flex-row-reverse":"flex-row"} flex items-end gap-3 max-w-[85%]`,children:[m.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-semibold flex-shrink-0 shadow-lg ${n?e==="light"?"bg-gradient-to-br from-blue-500 to-purple-600":"bg-gradient-to-br from-gray-600 to-gray-700":e==="light"?"bg-gradient-to-br from-blue-500 to-purple-600":"bg-gradient-to-br from-gray-600 to_gray-700"}`,children:s}),m.jsxs("div",{className:`
|
|
9
|
+
`),()=>{x.contains(g)&&x.removeChild(g)}},[t]),a.jsx(dd,{isPresent:t,childRef:r,sizeRef:i,children:h.cloneElement(e,{ref:r})})}const hd=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:o,presenceAffectsLayout:r,mode:i,anchorX:l,root:c})=>{const d=xs(md),u=y.useId();let m=!0,f=y.useMemo(()=>(m=!1,{id:u,initial:t,isPresent:n,custom:o,onExitComplete:p=>{d.set(p,!0);for(const g of d.values())if(!g)return;s&&s()},register:p=>(d.set(p,!1),()=>d.delete(p))}),[n,d,s]);return r&&m&&(f={...f}),y.useMemo(()=>{d.forEach((p,g)=>d.set(g,!1))},[n]),h.useEffect(()=>{!n&&!d.size&&s&&s()},[n]),i==="popLayout"&&(e=a.jsx(ud,{isPresent:n,anchorX:l,root:c,children:e})),a.jsx(hn.Provider,{value:f,children:e})};function md(){return new Map}function Vr(e=!0){const t=y.useContext(hn);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:o}=t,r=y.useId();y.useEffect(()=>{if(e)return o(r)},[e]);const i=y.useCallback(()=>e&&s&&s(r),[r,s,e]);return!n&&s?[!1,i]:[!0]}const Kt=e=>e.key||"";function Mo(e){const t=[];return y.Children.forEach(e,n=>{y.isValidElement(n)&&t.push(n)}),t}const ut=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:o=!0,mode:r="sync",propagate:i=!1,anchorX:l="left",root:c})=>{const[d,u]=Vr(i),m=y.useMemo(()=>Mo(e),[e]),f=i&&!d?[]:m.map(Kt),p=y.useRef(!0),g=y.useRef(m),x=xs(()=>new Map),[v,E]=y.useState(m),[b,S]=y.useState(m);$i(()=>{p.current=!1,g.current=m;for(let A=0;A<b.length;A++){const j=Kt(b[A]);f.includes(j)?x.delete(j):x.get(j)!==!0&&x.set(j,!1)}},[b,f.length,f.join("-")]);const w=[];if(m!==v){let A=[...m];for(let j=0;j<b.length;j++){const k=b[j],D=Kt(k);f.includes(D)||(A.splice(j,0,k),w.push(k))}return r==="wait"&&w.length&&(A=w),S(Mo(A)),E(m),null}process.env.NODE_ENV!=="production"&&r==="wait"&&b.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:C}=y.useContext(gs);return a.jsx(a.Fragment,{children:b.map(A=>{const j=Kt(A),k=i&&!d?!1:m===b||f.includes(j),D=()=>{if(x.has(j))x.set(j,!0);else return;let L=!0;x.forEach(W=>{W||(L=!1)}),L&&(C==null||C(),S(g.current),i&&(u==null||u()),s&&s())};return a.jsx(hd,{isPresent:k,initial:!p.current||n?void 0:!1,custom:t,presenceAffectsLayout:o,mode:r,root:c,onExitComplete:k?void 0:D,anchorX:l,children:A},j)})})},Nr=y.createContext({strict:!1}),To={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"]},ft={};for(const e in To)ft[e]={isEnabled:t=>To[e].some(n=>!!t[n])};function fd(e){for(const t in e)ft[t]={...ft[t],...e[t]}}const pd=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 cn(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||pd.has(e)}let Pr=e=>!cn(e);function gd(e){typeof e=="function"&&(Pr=t=>t.startsWith("on")?!cn(t):e(t))}try{gd(require("@emotion/is-prop-valid").default)}catch{}function xd(e,t,n){const s={};for(const o in e)o==="values"&&typeof e.values=="object"||(Pr(o)||n===!0&&cn(o)||!t&&!cn(o)||e.draggable&&o.startsWith("onDrag"))&&(s[o]=e[o]);return s}const mn=y.createContext({});function fn(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function It(e){return typeof e=="string"||Array.isArray(e)}const _s=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Hs=["initial",..._s];function pn(e){return fn(e.animate)||Hs.some(t=>It(e[t]))}function Rr(e){return!!(pn(e)||e.variants)}function yd(e,t){if(pn(e)){const{initial:n,animate:s}=e;return{initial:n===!1||It(n)?n:void 0,animate:It(s)?s:void 0}}return e.inherit!==!1?t:{}}function bd(e){const{initial:t,animate:n}=yd(e,y.useContext(mn));return y.useMemo(()=>({initial:t,animate:n}),[Vo(t),Vo(n)])}function Vo(e){return Array.isArray(e)?e.join(" "):e}const Dt={};function vd(e){for(const t in e)Dt[t]=e[t],Es(t)&&(Dt[t].isCSSVariable=!0)}function Ir(e,{layout:t,layoutId:n}){return bt.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Dt[e]||e==="opacity")}const wd={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Sd=yt.length;function Cd(e,t,n){let s="",o=!0;for(let r=0;r<Sd;r++){const i=yt[r],l=e[i];if(l===void 0)continue;let c=!0;if(typeof l=="number"?c=l===(i.startsWith("scale")?1:0):c=parseFloat(l)===0,!c||n){const d=kr(l,Ls[i]);if(!c){o=!1;const u=wd[i]||i;s+=`${u}(${d}) `}n&&(t[i]=d)}}return s=s.trim(),n?s=n(t,o?"":s):o&&(s="none"),s}function Zs(e,t,n){const{style:s,vars:o,transformOrigin:r}=e;let i=!1,l=!1;for(const c in t){const d=t[c];if(bt.has(c)){i=!0;continue}else if(Es(c)){o[c]=d;continue}else{const u=kr(d,Ls[c]);c.startsWith("origin")?(l=!0,r[c]=u):s[c]=u}}if(t.transform||(i||n?s.transform=Cd(t,e.transform,n):s.transform&&(s.transform="none")),l){const{originX:c="50%",originY:d="50%",originZ:u=0}=r;s.transformOrigin=`${c} ${d} ${u}`}}const Us=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Dr(e,t,n){for(const s in t)!be(t[s])&&!Ir(s,n)&&(e[s]=t[s])}function kd({transformTemplate:e},t){return y.useMemo(()=>{const n=Us();return Zs(n,t,e),Object.assign({},n.vars,n.style)},[t])}function jd(e,t){const n=e.style||{},s={};return Dr(s,n,e),Object.assign(s,kd(e,t)),s}function Ed(e,t){const n={},s=jd(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.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=s,n}const Ad={offset:"stroke-dashoffset",array:"stroke-dasharray"},Md={offset:"strokeDashoffset",array:"strokeDasharray"};function Td(e,t,n=1,s=0,o=!0){e.pathLength=1;const r=o?Ad:Md;e[r.offset]=U.transform(-s);const i=U.transform(t),l=U.transform(n);e[r.array]=`${i} ${l}`}function Fr(e,{attrX:t,attrY:n,attrScale:s,pathLength:o,pathSpacing:r=1,pathOffset:i=0,...l},c,d,u){if(Zs(e,l,d),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:m,style:f}=e;m.transform&&(f.transform=m.transform,delete m.transform),(f.transform||m.transformOrigin)&&(f.transformOrigin=m.transformOrigin??"50% 50%",delete m.transformOrigin),f.transform&&(f.transformBox=(u==null?void 0:u.transformBox)??"fill-box",delete m.transformBox),t!==void 0&&(m.x=t),n!==void 0&&(m.y=n),s!==void 0&&(m.scale=s),o!==void 0&&Td(m,o,r,i,!1)}const Lr=()=>({...Us(),attrs:{}}),Br=e=>typeof e=="string"&&e.toLowerCase()==="svg";function Vd(e,t,n,s){const o=y.useMemo(()=>{const r=Lr();return Fr(r,t,Br(s),e.transformTemplate,e.style),{...r.attrs,style:{...r.style}}},[t]);if(e.style){const r={};Dr(r,e.style,e),o.style={...r,...o.style}}return o}const Nd=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function zs(e){return typeof e!="string"||e.includes("-")?!1:!!(Nd.indexOf(e)>-1||/[A-Z]/u.test(e))}function Pd(e,t,n,{latestValues:s},o,r=!1){const l=(zs(e)?Vd:Ed)(t,s,o,e),c=xd(t,typeof e=="string",r),d=e!==y.Fragment?{...c,...l,ref:n}:{},{children:u}=t,m=y.useMemo(()=>be(u)?u.get():u,[u]);return y.createElement(e,{...d,children:m})}function No(e){const t=[{},{}];return e==null||e.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function Ws(e,t,n,s){if(typeof t=="function"){const[o,r]=No(s);t=t(n!==void 0?n:e.custom,o,r)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[o,r]=No(s);t=t(n!==void 0?n:e.custom,o,r)}return t}function tn(e){return be(e)?e.get():e}function Rd({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,o){return{latestValues:Id(n,s,o,e),renderState:t()}}function Id(e,t,n,s){const o={},r=s(e,{});for(const f in r)o[f]=tn(r[f]);let{initial:i,animate:l}=e;const c=pn(e),d=Rr(e);t&&d&&!c&&e.inherit!==!1&&(i===void 0&&(i=t.initial),l===void 0&&(l=t.animate));let u=n?n.initial===!1:!1;u=u||i===!1;const m=u?l:i;if(m&&typeof m!="boolean"&&!fn(m)){const f=Array.isArray(m)?m:[m];for(let p=0;p<f.length;p++){const g=Ws(e,f[p]);if(g){const{transitionEnd:x,transition:v,...E}=g;for(const b in E){let S=E[b];if(Array.isArray(S)){const w=u?S.length-1:0;S=S[w]}S!==null&&(o[b]=S)}for(const b in x)o[b]=x[b]}}}return o}const $r=e=>(t,n)=>{const s=y.useContext(mn),o=y.useContext(hn),r=()=>Rd(e,t,s,o);return n?r():xs(r)};function Ks(e,t,n){var r;const{style:s}=e,o={};for(const i in s)(be(s[i])||t.style&&be(t.style[i])||Ir(i,e)||((r=n==null?void 0:n.getValue(i))==null?void 0:r.liveStyle)!==void 0)&&(o[i]=s[i]);return o}const Dd=$r({scrapeMotionValuesFromProps:Ks,createRenderState:Us});function Or(e,t,n){const s=Ks(e,t,n);for(const o in e)if(be(e[o])||be(t[o])){const r=yt.indexOf(o)!==-1?"attr"+o.charAt(0).toUpperCase()+o.substring(1):o;s[r]=e[o]}return s}const Fd=$r({scrapeMotionValuesFromProps:Or,createRenderState:Lr}),Ld=Symbol.for("motionComponentSymbol");function at(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Bd(e,t,n){return y.useCallback(s=>{s&&e.onMount&&e.onMount(s),t&&(s?t.mount(s):t.unmount()),n&&(typeof n=="function"?n(s):at(n)&&(n.current=s))},[t])}const Gs=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),$d="framerAppearId",_r="data-"+Gs($d),Hr=y.createContext({});function Od(e,t,n,s,o){var x,v;const{visualElement:r}=y.useContext(mn),i=y.useContext(Nr),l=y.useContext(hn),c=y.useContext(Os).reducedMotion,d=y.useRef(null);s=s||i.renderer,!d.current&&s&&(d.current=s(e,{visualState:t,parent:r,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:c}));const u=d.current,m=y.useContext(Hr);u&&!u.projection&&o&&(u.type==="html"||u.type==="svg")&&_d(d.current,n,o,m);const f=y.useRef(!1);y.useInsertionEffect(()=>{u&&f.current&&u.update(n,l)});const p=n[_r],g=y.useRef(!!p&&!((x=window.MotionHandoffIsComplete)!=null&&x.call(window,p))&&((v=window.MotionHasOptimisedAnimation)==null?void 0:v.call(window,p)));return $i(()=>{u&&(f.current=!0,window.MotionIsMounted=!0,u.updateFeatures(),u.scheduleRenderMicrotask(),g.current&&u.animationState&&u.animationState.animateChanges())}),y.useEffect(()=>{u&&(!g.current&&u.animationState&&u.animationState.animateChanges(),g.current&&(queueMicrotask(()=>{var E;(E=window.MotionHandoffMarkAsComplete)==null||E.call(window,p)}),g.current=!1),u.enteringChildren=void 0)}),u}function _d(e,t,n,s){const{layoutId:o,layout:r,drag:i,dragConstraints:l,layoutScroll:c,layoutRoot:d,layoutCrossfade:u}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Zr(e.parent)),e.projection.setOptions({layoutId:o,layout:r,alwaysMeasureLayout:!!i||l&&at(l),visualElement:e,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,crossfade:u,layoutScroll:c,layoutRoot:d})}function Zr(e){if(e)return e.options.allowProjection!==!1?e.projection:Zr(e.parent)}function An(e,{forwardMotionProps:t=!1}={},n,s){n&&fd(n);const o=zs(e)?Fd:Dd;function r(l,c){let d;const u={...y.useContext(Os),...l,layoutId:Hd(l)},{isStatic:m}=u,f=bd(l),p=o(l,m);if(!m&&ys){Zd(u,n);const g=Ud(u);d=g.MeasureLayout,f.visualElement=Od(e,p,u,s,g.ProjectionNode)}return a.jsxs(mn.Provider,{value:f,children:[d&&f.visualElement?a.jsx(d,{visualElement:f.visualElement,...u}):null,Pd(e,l,Bd(p,f.visualElement,c),p,m,t)]})}r.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const i=y.forwardRef(r);return i[Ld]=e,i}function Hd({layoutId:e}){const t=y.useContext(gs).id;return t&&e!==void 0?t+"-"+e:e}function Zd(e,t){const n=y.useContext(Nr).strict;if(process.env.NODE_ENV!=="production"&&t&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?gt(!1,s,"lazy-strict-mode"):Oe(!1,s,"lazy-strict-mode")}}function Ud(e){const{drag:t,layout:n}=ft;if(!t&&!n)return{};const s={...t,...n};return{MeasureLayout:t!=null&&t.isEnabled(e)||n!=null&&n.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function zd(e,t){if(typeof Proxy>"u")return An;const n=new Map,s=(r,i)=>An(r,i,e,t),o=(r,i)=>(process.env.NODE_ENV!=="production"&&Cs(!1,"motion() is deprecated. Use motion.create() instead."),s(r,i));return new Proxy(o,{get:(r,i)=>i==="create"?s:(n.has(i)||n.set(i,An(i,void 0,e,t)),n.get(i))})}function Ur({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function Wd({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Kd(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),s=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function Mn(e){return e===void 0||e===1}function ns({scale:e,scaleX:t,scaleY:n}){return!Mn(e)||!Mn(t)||!Mn(n)}function qe(e){return ns(e)||zr(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function zr(e){return Po(e.x)||Po(e.y)}function Po(e){return e&&e!=="0%"}function dn(e,t,n){const s=e-n,o=t*s;return n+o}function Ro(e,t,n,s,o){return o!==void 0&&(e=dn(e,o,s)),dn(e,n,s)+t}function ss(e,t=0,n=1,s,o){e.min=Ro(e.min,t,n,s,o),e.max=Ro(e.max,t,n,s,o)}function Wr(e,{x:t,y:n}){ss(e.x,t.translate,t.scale,t.originPoint),ss(e.y,n.translate,n.scale,n.originPoint)}const Io=.999999999999,Do=1.0000000000001;function Gd(e,t,n,s=!1){const o=n.length;if(!o)return;t.x=t.y=1;let r,i;for(let l=0;l<o;l++){r=n[l],i=r.projectionDelta;const{visualElement:c}=r.options;c&&c.props.style&&c.props.style.display==="contents"||(s&&r.options.layoutScroll&&r.scroll&&r!==r.root&&ct(e,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),i&&(t.x*=i.x.scale,t.y*=i.y.scale,Wr(e,i)),s&&qe(r.latestValues)&&ct(e,r.latestValues))}t.x<Do&&t.x>Io&&(t.x=1),t.y<Do&&t.y>Io&&(t.y=1)}function lt(e,t){e.min=e.min+t,e.max=e.max+t}function Fo(e,t,n,s,o=.5){const r=le(e.min,e.max,o);ss(e,t,n,r,s)}function ct(e,t){Fo(e.x,t.x,t.scaleX,t.scale,t.originX),Fo(e.y,t.y,t.scaleY,t.scale,t.originY)}function Kr(e,t){return Ur(Kd(e.getBoundingClientRect(),t))}function Yd(e,t,n){const s=Kr(e,n),{scroll:o}=t;return o&&(lt(s.x,o.offset.x),lt(s.y,o.offset.y)),s}const Lo=()=>({translate:0,scale:1,origin:0,originPoint:0}),dt=()=>({x:Lo(),y:Lo()}),Bo=()=>({min:0,max:0}),de=()=>({x:Bo(),y:Bo()}),os={current:null},Gr={current:!1};function qd(){if(Gr.current=!0,!!ys)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>os.current=e.matches;e.addEventListener("change",t),t()}else os.current=!1}const Xd=new WeakMap;function Jd(e,t,n){for(const s in t){const o=t[s],r=n[s];if(be(o))e.addValue(s,o);else if(be(r))e.addValue(s,mt(o,{owner:e}));else if(r!==o)if(e.hasValue(s)){const i=e.getValue(s);i.liveStyle===!0?i.jump(o):i.hasAnimated||i.set(o)}else{const i=e.getStaticValue(s);e.addValue(s,mt(i!==void 0?i:o,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const $o=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Qd{scrapeMotionValuesFromProps(t,n,s){return{}}constructor({parent:t,props:n,presenceContext:s,reducedMotionConfig:o,blockInitialAnimation:r,visualState:i},l={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Ds,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 f=Se.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,ie.render(this.render,!1,!0))};const{latestValues:c,renderState:d}=i;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=d,this.parent=t,this.props=n,this.presenceContext=s,this.depth=t?t.depth+1:0,this.reducedMotionConfig=o,this.options=l,this.blockInitialAnimation=!!r,this.isControllingVariants=pn(n),this.isVariantNode=Rr(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:u,...m}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in m){const p=m[f];c[f]!==void 0&&be(p)&&p.set(c[f])}}mount(t){var n;this.current=t,Xd.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((s,o)=>this.bindToMotionValue(o,s)),Gr.current||qd(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:os.current,process.env.NODE_ENV!=="production"&&Cs(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),(n=this.parent)==null||n.addChild(this),this.update(this.props,this.presenceContext)}unmount(){var t;this.projection&&this.projection.unmount(),ze(this.notifyUpdate),ze(this.render),this.valueSubscriptions.forEach(n=>n()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(t=this.parent)==null||t.removeChild(this);for(const n in this.events)this.events[n].clear();for(const n in this.features){const s=this.features[n];s&&(s.unmount(),s.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const s=bt.has(t);s&&this.onBindTransform&&this.onBindTransform();const o=n.on("change",i=>{this.latestValues[t]=i,this.props.onUpdate&&ie.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let r;window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{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 ft){const n=ft[t];if(!n)continue;const{isEnabled:s,Feature:o}=n;if(!this.features[t]&&o&&s(this.props)&&(this.features[t]=new o(this)),this.features[t]){const r=this.features[t];r.isMounted?r.update():(r.mount(),r.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):de()}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 s=0;s<$o.length;s++){const o=$o[s];this.propEventSubscriptions[o]&&(this.propEventSubscriptions[o](),delete this.propEventSubscriptions[o]);const r="on"+o,i=t[r];i&&(this.propEventSubscriptions[o]=this.on(o,i))}this.prevMotionValues=Jd(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 s=this.values.get(t);n!==s&&(s&&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 s=this.values.get(t);return s===void 0&&n!==void 0&&(s=mt(n===null?void 0:n,{owner:this}),this.addValue(t,s)),s}readValue(t,n){let s=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return s!=null&&(typeof s=="string"&&(Oi(s)||Hi(s))?s=parseFloat(s):!cd(s)&&We.test(n)&&(s=Cr(t,n)),this.setBaseTarget(t,be(s)?s.get():s)),be(s)?s.get():s}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var r;const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const i=Ws(this.props,n,(r=this.presenceContext)==null?void 0:r.custom);i&&(s=i[t])}if(n&&s!==void 0)return s;const o=this.getBaseTargetFromProps(this.props,t);return o!==void 0&&!be(o)?o:this.initialValues[t]!==void 0&&s===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new Ss),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){Bs.render(this.render)}}class Yr extends Qd{constructor(){super(...arguments),this.KeyframeResolver=Xc}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:s}){delete n[t],delete s[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;be(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function qr(e,{style:t,vars:n},s,o){const r=e.style;let i;for(i in t)r[i]=t[i];o==null||o.applyProjectionStyles(r,s);for(i in n)r.setProperty(i,n[i])}function eu(e){return window.getComputedStyle(e)}class tu extends Yr{constructor(){super(...arguments),this.type="html",this.renderInstance=qr}readValueFromInstance(t,n){var s;if(bt.has(n))return(s=this.projection)!=null&&s.isProjecting?Yn(n):pc(t,n);{const o=eu(t),r=(Es(n)?o.getPropertyValue(n):o[n])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(t,{transformPagePoint:n}){return Kr(t,n)}build(t,n,s){Zs(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return Ks(t,n,s)}}const Xr=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 nu(e,t,n,s){qr(e,t,void 0,s);for(const o in t.attrs)e.setAttribute(Xr.has(o)?o:Gs(o),t.attrs[o])}class su extends Yr{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=de}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(bt.has(n)){const s=Sr(n);return s&&s.default||0}return n=Xr.has(n)?n:Gs(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return Or(t,n,s)}build(t,n,s){Fr(t,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(t,n,s,o){nu(t,n,s,o)}mount(t){this.isSVGTag=Br(t.tagName),super.mount(t)}}const ou=(e,t)=>zs(e)?new su(t):new tu(t,{allowProjection:e!==y.Fragment});function ht(e,t,n){const s=e.getProps();return Ws(s,t,n!==void 0?n:s.custom,e)}const is=e=>Array.isArray(e);function iu(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,mt(n))}function ru(e){return is(e)?e[e.length-1]||0:e}function au(e,t){const n=ht(e,t);let{transitionEnd:s={},transition:o={},...r}=n||{};r={...r,...s};for(const i in r){const l=ru(r[i]);iu(e,i,l)}}function lu(e){return!!(be(e)&&e.add)}function rs(e,t){const n=e.getValue("willChange");if(lu(n))return n.add(t);if(!n&&_e.WillChange){const s=new _e.WillChange("auto");e.addValue("willChange",s),s.add(t)}}function Jr(e){return e.props[_r]}const cu=e=>e!==null;function du(e,{repeat:t,repeatType:n="loop"},s){const o=e.filter(cu),r=t&&n!=="loop"&&t%2===1?0:o.length-1;return o[r]}const uu={type:"spring",stiffness:500,damping:25,restSpeed:10},hu=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),mu={type:"keyframes",duration:.8},fu={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},pu=(e,{keyframes:t})=>t.length>2?mu:bt.has(e)?e.startsWith("scale")?hu(t[1]):uu:fu;function gu({when:e,delay:t,delayChildren:n,staggerChildren:s,staggerDirection:o,repeat:r,repeatType:i,repeatDelay:l,from:c,elapsed:d,...u}){return!!Object.keys(u).length}const Ys=(e,t,n,s={},o,r)=>i=>{const l=Fs(s,e)||{},c=l.delay||s.delay||0;let{elapsed:d=0}=s;d=d-Ve(c);const u={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...l,delay:-d,onUpdate:f=>{t.set(f),l.onUpdate&&l.onUpdate(f)},onComplete:()=>{i(),l.onComplete&&l.onComplete()},name:e,motionValue:t,element:r?void 0:o};gu(l)||Object.assign(u,pu(e,u)),u.duration&&(u.duration=Ve(u.duration)),u.repeatDelay&&(u.repeatDelay=Ve(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let m=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(es(u),u.delay===0&&(m=!0)),(_e.instantAnimations||_e.skipAnimations)&&(m=!0,es(u),u.delay=0),u.allowFlatten=!l.type&&!l.ease,m&&!r&&t.get()!==void 0){const f=du(u.keyframes,l);if(f!==void 0){ie.update(()=>{u.onUpdate(f),u.onComplete()});return}}return l.isSync?new Is(u):new Bc(u)};function xu({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function Qr(e,t,{delay:n=0,transitionOverride:s,type:o}={}){let{transition:r=e.getDefaultTransition(),transitionEnd:i,...l}=t;s&&(r=s);const c=[],d=o&&e.animationState&&e.animationState.getState()[o];for(const u in l){const m=e.getValue(u,e.latestValues[u]??null),f=l[u];if(f===void 0||d&&xu(d,u))continue;const p={delay:n,...Fs(r||{},u)},g=m.get();if(g!==void 0&&!m.isAnimating&&!Array.isArray(f)&&f===g&&!p.velocity)continue;let x=!1;if(window.MotionHandoffAnimation){const E=Jr(e);if(E){const b=window.MotionHandoffAnimation(E,u,ie);b!==null&&(p.startTime=b,x=!0)}}rs(e,u),m.start(Ys(u,m,f,e.shouldReduceMotion&&br.has(u)?{type:!1}:p,e,x));const v=m.animation;v&&c.push(v)}return i&&Promise.all(c).then(()=>{ie.update(()=>{i&&au(e,i)})}),c}function ea(e,t,n,s=0,o=1){const r=Array.from(e).sort((d,u)=>d.sortNodePosition(u)).indexOf(t),i=e.size,l=(i-1)*s;return typeof n=="function"?n(r,i):o===1?r*s:l-r*s}function as(e,t,n={}){var c;const s=ht(e,t,n.type==="exit"?(c=e.presenceContext)==null?void 0:c.custom:void 0);let{transition:o=e.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(o=n.transitionOverride);const r=s?()=>Promise.all(Qr(e,s,n)):()=>Promise.resolve(),i=e.variantChildren&&e.variantChildren.size?(d=0)=>{const{delayChildren:u=0,staggerChildren:m,staggerDirection:f}=o;return yu(e,t,d,u,m,f,n)}:()=>Promise.resolve(),{when:l}=o;if(l){const[d,u]=l==="beforeChildren"?[r,i]:[i,r];return d().then(()=>u())}else return Promise.all([r(),i(n.delay)])}function yu(e,t,n=0,s=0,o=0,r=1,i){const l=[];for(const c of e.variantChildren)c.notify("AnimationStart",t),l.push(as(c,t,{...i,delay:n+(typeof s=="function"?0:s)+ea(e.variantChildren,c,s,o,r)}).then(()=>c.notify("AnimationComplete",t)));return Promise.all(l)}function bu(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const o=t.map(r=>as(e,r,n));s=Promise.all(o)}else if(typeof t=="string")s=as(e,t,n);else{const o=typeof t=="function"?ht(e,t,n.custom):t;s=Promise.all(Qr(e,o,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}function ta(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let s=0;s<n;s++)if(t[s]!==e[s])return!1;return!0}const vu=Hs.length;function na(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?na(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<vu;n++){const s=Hs[n],o=e.props[s];(It(o)||o===!1)&&(t[s]=o)}return t}const wu=[..._s].reverse(),Su=_s.length;function Cu(e){return t=>Promise.all(t.map(({animation:n,options:s})=>bu(e,n,s)))}function ku(e){let t=Cu(e),n=Oo(),s=!0;const o=c=>(d,u)=>{var f;const m=ht(e,u,c==="exit"?(f=e.presenceContext)==null?void 0:f.custom:void 0);if(m){const{transition:p,transitionEnd:g,...x}=m;d={...d,...x,...g}}return d};function r(c){t=c(e)}function i(c){const{props:d}=e,u=na(e.parent)||{},m=[],f=new Set;let p={},g=1/0;for(let v=0;v<Su;v++){const E=wu[v],b=n[E],S=d[E]!==void 0?d[E]:u[E],w=It(S),C=E===c?b.isActive:null;C===!1&&(g=v);let A=S===u[E]&&S!==d[E]&&w;if(A&&s&&e.manuallyAnimateOnMount&&(A=!1),b.protectedKeys={...p},!b.isActive&&C===null||!S&&!b.prevProp||fn(S)||typeof S=="boolean")continue;const j=ju(b.prevProp,S);let k=j||E===c&&b.isActive&&!A&&w||v>g&&w,D=!1;const L=Array.isArray(S)?S:[S];let W=L.reduce(o(E),{});C===!1&&(W={});const{prevResolvedValues:H={}}=b,Ce={...H,...W},ne=z=>{k=!0,f.has(z)&&(D=!0,f.delete(z)),b.needsAnimating[z]=!0;const M=e.getValue(z);M&&(M.liveStyle=!1)};for(const z in Ce){const M=W[z],G=H[z];if(p.hasOwnProperty(z))continue;let Y=!1;is(M)&&is(G)?Y=!ta(M,G):Y=M!==G,Y?M!=null?ne(z):f.add(z):M!==void 0&&f.has(z)?ne(z):b.protectedKeys[z]=!0}b.prevProp=S,b.prevResolvedValues=W,b.isActive&&(p={...p,...W}),s&&e.blockInitialAnimation&&(k=!1);const te=A&&j;k&&(!te||D)&&m.push(...L.map(z=>{const M={type:E};if(typeof z=="string"&&s&&!te&&e.manuallyAnimateOnMount&&e.parent){const{parent:G}=e,Y=ht(G,z);if(G.enteringChildren&&Y){const{delayChildren:V}=Y.transition||{};M.delay=ea(G.enteringChildren,e,V)}}return{animation:z,options:M}}))}if(f.size){const v={};if(typeof d.initial!="boolean"){const E=ht(e,Array.isArray(d.initial)?d.initial[0]:d.initial);E&&E.transition&&(v.transition=E.transition)}f.forEach(E=>{const b=e.getBaseTarget(E),S=e.getValue(E);S&&(S.liveStyle=!0),v[E]=b??null}),m.push({animation:v})}let x=!!m.length;return s&&(d.initial===!1||d.initial===d.animate)&&!e.manuallyAnimateOnMount&&(x=!1),s=!1,x?t(m):Promise.resolve()}function l(c,d){var m;if(n[c].isActive===d)return Promise.resolve();(m=e.variantChildren)==null||m.forEach(f=>{var p;return(p=f.animationState)==null?void 0:p.setActive(c,d)}),n[c].isActive=d;const u=i(c);for(const f in n)n[f].protectedKeys={};return u}return{animateChanges:i,setActive:l,setAnimateFunction:r,getState:()=>n,reset:()=>{n=Oo(),s=!0}}}function ju(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!ta(t,e):!1}function Ge(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Oo(){return{animate:Ge(!0),whileInView:Ge(),whileHover:Ge(),whileTap:Ge(),whileDrag:Ge(),whileFocus:Ge(),exit:Ge()}}class Ke{constructor(t){this.isMounted=!1,this.node=t}update(){}}class Eu extends Ke{constructor(t){super(t),t.animationState||(t.animationState=ku(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();fn(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 Au=0;class Mu extends Ke{constructor(){super(...arguments),this.id=Au++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const o=this.node.animationState.setActive("exit",!t);n&&!t&&o.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 Tu={animation:{Feature:Eu},exit:{Feature:Mu}};function Ft(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}function Ot(e){return{point:{x:e.pageX,y:e.pageY}}}const Vu=e=>t=>$s(t)&&e(t,Ot(t));function Mt(e,t,n,s){return Ft(e,t,Vu(n),s)}const sa=1e-4,Nu=1-sa,Pu=1+sa,oa=.01,Ru=0-oa,Iu=0+oa;function we(e){return e.max-e.min}function Du(e,t,n){return Math.abs(e-t)<=n}function _o(e,t,n,s=.5){e.origin=s,e.originPoint=le(t.min,t.max,e.origin),e.scale=we(n)/we(t),e.translate=le(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Nu&&e.scale<=Pu||isNaN(e.scale))&&(e.scale=1),(e.translate>=Ru&&e.translate<=Iu||isNaN(e.translate))&&(e.translate=0)}function Tt(e,t,n,s){_o(e.x,t.x,n.x,s?s.originX:void 0),_o(e.y,t.y,n.y,s?s.originY:void 0)}function Ho(e,t,n){e.min=n.min+t.min,e.max=e.min+we(t)}function Fu(e,t,n){Ho(e.x,t.x,n.x),Ho(e.y,t.y,n.y)}function Zo(e,t,n){e.min=t.min-n.min,e.max=e.min+we(t)}function Vt(e,t,n){Zo(e.x,t.x,n.x),Zo(e.y,t.y,n.y)}function je(e){return[e("x"),e("y")]}const ia=({current:e})=>e?e.ownerDocument.defaultView:null,Uo=(e,t)=>Math.abs(e-t);function Lu(e,t){const n=Uo(e.x,t.x),s=Uo(e.y,t.y);return Math.sqrt(n**2+s**2)}class ra{constructor(t,n,{transformPagePoint:s,contextWindow:o=window,dragSnapToOrigin:r=!1,distanceThreshold:i=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 f=Vn(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,g=Lu(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!g)return;const{point:x}=f,{timestamp:v}=xe;this.history.push({...x,timestamp:v});const{onStart:E,onMove:b}=this.handlers;p||(E&&E(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),b&&b(this.lastMoveEvent,f)},this.handlePointerMove=(f,p)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=Tn(p,this.transformPagePoint),ie.update(this.updatePoint,!0)},this.handlePointerUp=(f,p)=>{this.end();const{onEnd:g,onSessionEnd:x,resumeAnimation:v}=this.handlers;if(this.dragSnapToOrigin&&v&&v(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const E=Vn(f.type==="pointercancel"?this.lastMoveEventInfo:Tn(p,this.transformPagePoint),this.history);this.startEvent&&g&&g(f,E),x&&x(f,E)},!$s(t))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=i,this.contextWindow=o||window;const l=Ot(t),c=Tn(l,this.transformPagePoint),{point:d}=c,{timestamp:u}=xe;this.history=[{...d,timestamp:u}];const{onSessionStart:m}=n;m&&m(t,Vn(c,this.history)),this.removeListeners=Lt(Mt(this.contextWindow,"pointermove",this.handlePointerMove),Mt(this.contextWindow,"pointerup",this.handlePointerUp),Mt(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),ze(this.updatePoint)}}function Tn(e,t){return t?{point:t(e.point)}:e}function zo(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Vn({point:e},t){return{point:e,delta:zo(e,aa(t)),offset:zo(e,Bu(t)),velocity:$u(t,.1)}}function Bu(e){return e[0]}function aa(e){return e[e.length-1]}function $u(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const o=aa(e);for(;n>=0&&(s=e[n],!(o.timestamp-s.timestamp>Ve(t)));)n--;if(!s)return{x:0,y:0};const r=Pe(o.timestamp-s.timestamp);if(r===0)return{x:0,y:0};const i={x:(o.x-s.x)/r,y:(o.y-s.y)/r};return i.x===1/0&&(i.x=0),i.y===1/0&&(i.y=0),i}function Ou(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?le(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?le(n,e,s.max):Math.min(e,n)),e}function Wo(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 _u(e,{top:t,left:n,bottom:s,right:o}){return{x:Wo(e.x,n,o),y:Wo(e.y,t,s)}}function Ko(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function Hu(e,t){return{x:Ko(e.x,t.x),y:Ko(e.y,t.y)}}function Zu(e,t){let n=.5;const s=we(e),o=we(t);return o>s?n=Nt(t.min,t.max-s,e.min):s>o&&(n=Nt(e.min,e.max-o,t.min)),$e(0,1,n)}function Uu(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 ls=.35;function zu(e=ls){return e===!1?e=0:e===!0&&(e=ls),{x:Go(e,"left","right"),y:Go(e,"top","bottom")}}function Go(e,t,n){return{min:Yo(e,t),max:Yo(e,n)}}function Yo(e,t){return typeof e=="number"?e:e[t]||0}const Wu=new WeakMap;class Ku{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=de(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:o}=this.visualElement;if(o&&o.isPresent===!1)return;const r=m=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Ot(m).point)},i=(m,f)=>{const{drag:p,dragPropagation:g,onDragStart:x}=this.getProps();if(p&&!g&&(this.openDragLock&&this.openDragLock(),this.openDragLock=td(p),!this.openDragLock))return;this.latestPointerEvent=m,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),je(E=>{let b=this.getAxisMotionValue(E).get()||0;if(Re.test(b)){const{projection:S}=this.visualElement;if(S&&S.layout){const w=S.layout.layoutBox[E];w&&(b=we(w)*(parseFloat(b)/100))}}this.originPoint[E]=b}),x&&ie.postRender(()=>x(m,f)),rs(this.visualElement,"transform");const{animationState:v}=this.visualElement;v&&v.setActive("whileDrag",!0)},l=(m,f)=>{this.latestPointerEvent=m,this.latestPanInfo=f;const{dragPropagation:p,dragDirectionLock:g,onDirectionLock:x,onDrag:v}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:E}=f;if(g&&this.currentDirection===null){this.currentDirection=Gu(E),this.currentDirection!==null&&x&&x(this.currentDirection);return}this.updateAxis("x",f.point,E),this.updateAxis("y",f.point,E),this.visualElement.render(),v&&v(m,f)},c=(m,f)=>{this.latestPointerEvent=m,this.latestPanInfo=f,this.stop(m,f),this.latestPointerEvent=null,this.latestPanInfo=null},d=()=>je(m=>{var f;return this.getAnimationState(m)==="paused"&&((f=this.getAxisMotionValue(m).animation)==null?void 0:f.play())}),{dragSnapToOrigin:u}=this.getProps();this.panSession=new ra(t,{onSessionStart:r,onStart:i,onMove:l,onSessionEnd:c,resumeAnimation:d},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,distanceThreshold:s,contextWindow:ia(this.visualElement)})}stop(t,n){const s=t||this.latestPointerEvent,o=n||this.latestPanInfo,r=this.isDragging;if(this.cancel(),!r||!o||!s)return;const{velocity:i}=o;this.startAnimation(i);const{onDragEnd:l}=this.getProps();l&&ie.postRender(()=>l(s,o))}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:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,s){const{drag:o}=this.getProps();if(!s||!Gt(t,o,this.currentDirection))return;const r=this.getAxisMotionValue(t);let i=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(i=Ou(i,this.constraints[t],this.elastic[t])),r.set(i)}resolveConstraints(){var r;const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(r=this.visualElement.projection)==null?void 0:r.layout,o=this.constraints;t&&at(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=_u(s.layoutBox,t):this.constraints=!1,this.elastic=zu(n),o!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&je(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=Uu(s.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!at(t))return!1;const s=t.current;Oe(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:o}=this.visualElement;if(!o||!o.layout)return!1;const r=Yd(s,o.root,this.visualElement.getTransformPagePoint());let i=Hu(o.layout.layoutBox,r);if(n){const l=n(Wd(i));this.hasMutatedConstraints=!!l,l&&(i=Ur(l))}return i}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:o,dragTransition:r,dragSnapToOrigin:i,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},d=je(u=>{if(!Gt(u,n,this.currentDirection))return;let m=c&&c[u]||{};i&&(m={min:0,max:0});const f=o?200:1e6,p=o?40:1e7,g={type:"inertia",velocity:s?t[u]:0,bounceStiffness:f,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...r,...m};return this.startAxisValueAnimation(u,g)});return Promise.all(d).then(l)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return rs(this.visualElement,t),s.start(Ys(t,s,0,n,this.visualElement,!1))}stopAnimation(){je(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){je(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()}`,s=this.visualElement.getProps(),o=s[n];return o||this.visualElement.getValue(t,(s.initial?s.initial[t]:void 0)||0)}snapToCursor(t){je(n=>{const{drag:s}=this.getProps();if(!Gt(n,s,this.currentDirection))return;const{projection:o}=this.visualElement,r=this.getAxisMotionValue(n);if(o&&o.layout){const{min:i,max:l}=o.layout.layoutBox[n];r.set(t[n]-le(i,l,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!at(n)||!s||!this.constraints)return;this.stopAnimation();const o={x:0,y:0};je(i=>{const l=this.getAxisMotionValue(i);if(l&&this.constraints!==!1){const c=l.get();o[i]=Zu({min:c,max:c},this.constraints[i])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),je(i=>{if(!Gt(i,t,null))return;const l=this.getAxisMotionValue(i),{min:c,max:d}=this.constraints[i];l.set(le(c,d,o[i]))})}addListeners(){if(!this.visualElement.current)return;Wu.set(this.visualElement,this);const t=this.visualElement.current,n=Mt(t,"pointerdown",c=>{const{drag:d,dragListener:u=!0}=this.getProps();d&&u&&this.start(c)}),s=()=>{const{dragConstraints:c}=this.getProps();at(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:o}=this.visualElement,r=o.addEventListener("measure",s);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),ie.read(s);const i=Ft(window,"resize",()=>this.scalePositionWithinConstraints()),l=o.addEventListener("didUpdate",({delta:c,hasLayoutChanged:d})=>{this.isDragging&&d&&(je(u=>{const m=this.getAxisMotionValue(u);m&&(this.originPoint[u]+=c[u].translate,m.set(m.get()+c[u].translate))}),this.visualElement.render())});return()=>{i(),n(),r(),l&&l()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:o=!1,dragConstraints:r=!1,dragElastic:i=ls,dragMomentum:l=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:o,dragConstraints:r,dragElastic:i,dragMomentum:l}}}function Gt(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Gu(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Yu extends Ke{constructor(t){super(t),this.removeGroupControls=Ae,this.removeListeners=Ae,this.controls=new Ku(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ae}unmount(){this.removeGroupControls(),this.removeListeners()}}const qo=e=>(t,n)=>{e&&ie.postRender(()=>e(t,n))};class qu extends Ke{constructor(){super(...arguments),this.removePointerDownListener=Ae}onPointerDown(t){this.session=new ra(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:ia(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:o}=this.node.getProps();return{onSessionStart:qo(t),onStart:qo(n),onMove:s,onEnd:(r,i)=>{delete this.session,o&&ie.postRender(()=>o(r,i))}}}mount(){this.removePointerDownListener=Mt(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 nn={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Xo(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const kt={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(U.test(e))e=parseFloat(e);else return e;const n=Xo(e,t.target.x),s=Xo(e,t.target.y);return`${n}% ${s}%`}},Xu={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,o=We.parse(e);if(o.length>5)return s;const r=We.createTransformer(e),i=typeof o[0]!="number"?1:0,l=n.x.scale*t.x,c=n.y.scale*t.y;o[0+i]/=l,o[1+i]/=c;const d=le(l,c,.5);return typeof o[2+i]=="number"&&(o[2+i]/=d),typeof o[3+i]=="number"&&(o[3+i]/=d),r(o)}};let Nn=!1;class Ju extends y.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:o}=this.props,{projection:r}=t;vd(Qu),r&&(n.group&&n.group.add(r),s&&s.register&&o&&s.register(r),Nn&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),nn.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:o,isPresent:r}=this.props,{projection:i}=s;return i&&(i.isPresent=r,Nn=!0,o||t.layoutDependency!==n||n===void 0||t.isPresent!==r?i.willUpdate():this.safeToRemove(),t.isPresent!==r&&(r?i.promote():i.relegate()||ie.postRender(()=>{const l=i.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Bs.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:o}=t;Nn=!0,o&&(o.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(o),s&&s.deregister&&s.deregister(o))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function la(e){const[t,n]=Vr(),s=y.useContext(gs);return a.jsx(Ju,{...e,layoutGroup:s,switchLayoutGroup:y.useContext(Hr),isPresent:t,safeToRemove:n})}const Qu={borderRadius:{...kt,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:kt,borderTopRightRadius:kt,borderBottomLeftRadius:kt,borderBottomRightRadius:kt,boxShadow:Xu};function eh(e,t,n){const s=be(e)?e:mt(e);return s.start(Ys("",s,t,n)),s.animation}const th=(e,t)=>e.depth-t.depth;class nh{constructor(){this.children=[],this.isDirty=!1}add(t){bs(this.children,t),this.isDirty=!0}remove(t){vs(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(th),this.isDirty=!1,this.children.forEach(t)}}function sh(e,t){const n=Se.now(),s=({timestamp:o})=>{const r=o-n;r>=t&&(ze(s),e(r-t))};return ie.setup(s,!0),()=>ze(s)}const ca=["TopLeft","TopRight","BottomLeft","BottomRight"],oh=ca.length,Jo=e=>typeof e=="string"?parseFloat(e):e,Qo=e=>typeof e=="number"||U.test(e);function ih(e,t,n,s,o,r){o?(e.opacity=le(0,n.opacity??1,rh(s)),e.opacityExit=le(t.opacity??1,0,ah(s))):r&&(e.opacity=le(t.opacity??1,n.opacity??1,s));for(let i=0;i<oh;i++){const l=`border${ca[i]}Radius`;let c=ei(t,l),d=ei(n,l);if(c===void 0&&d===void 0)continue;c||(c=0),d||(d=0),c===0||d===0||Qo(c)===Qo(d)?(e[l]=Math.max(le(Jo(c),Jo(d),s),0),(Re.test(d)||Re.test(c))&&(e[l]+="%")):e[l]=d}(t.rotate||n.rotate)&&(e.rotate=le(t.rotate||0,n.rotate||0,s))}function ei(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const rh=da(0,.5,qi),ah=da(.5,.95,Ae);function da(e,t,n){return s=>s<e?0:s>t?1:n(Nt(e,t,s))}function ti(e,t){e.min=t.min,e.max=t.max}function ke(e,t){ti(e.x,t.x),ti(e.y,t.y)}function ni(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function si(e,t,n,s,o){return e-=t,e=dn(e,1/n,s),o!==void 0&&(e=dn(e,1/o,s)),e}function lh(e,t=0,n=1,s=.5,o,r=e,i=e){if(Re.test(t)&&(t=parseFloat(t),t=le(i.min,i.max,t/100)-i.min),typeof t!="number")return;let l=le(r.min,r.max,s);e===r&&(l-=t),e.min=si(e.min,t,n,l,o),e.max=si(e.max,t,n,l,o)}function oi(e,t,[n,s,o],r,i){lh(e,t[n],t[s],t[o],t.scale,r,i)}const ch=["x","scaleX","originX"],dh=["y","scaleY","originY"];function ii(e,t,n,s){oi(e.x,t,ch,n?n.x:void 0,s?s.x:void 0),oi(e.y,t,dh,n?n.y:void 0,s?s.y:void 0)}function ri(e){return e.translate===0&&e.scale===1}function ua(e){return ri(e.x)&&ri(e.y)}function ai(e,t){return e.min===t.min&&e.max===t.max}function uh(e,t){return ai(e.x,t.x)&&ai(e.y,t.y)}function li(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function ha(e,t){return li(e.x,t.x)&&li(e.y,t.y)}function ci(e){return we(e.x)/we(e.y)}function di(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class hh{constructor(){this.members=[]}add(t){bs(this.members,t),t.scheduleRender()}remove(t){if(vs(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(o=>t===o);if(n===0)return!1;let s;for(let o=n;o>=0;o--){const r=this.members[o];if(r.isPresent!==!1){s=r;break}}return s?(this.promote(s),!0):!1}promote(t,n){const s=this.lead;if(t!==s&&(this.prevLead=s,this.lead=t,t.show(),s)){s.instance&&s.scheduleRender(),t.scheduleRender(),t.resumeFrom=s,n&&(t.resumeFrom.preserveOpacity=!0),s.snapshot&&(t.snapshot=s.snapshot,t.snapshot.latestValues=s.animationValues||s.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:o}=t.options;o===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:s}=t;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function mh(e,t,n){let s="";const o=e.x.translate/t.x,r=e.y.translate/t.y,i=(n==null?void 0:n.z)||0;if((o||r||i)&&(s=`translate3d(${o}px, ${r}px, ${i}px) `),(t.x!==1||t.y!==1)&&(s+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:d,rotate:u,rotateX:m,rotateY:f,skewX:p,skewY:g}=n;d&&(s=`perspective(${d}px) ${s}`),u&&(s+=`rotate(${u}deg) `),m&&(s+=`rotateX(${m}deg) `),f&&(s+=`rotateY(${f}deg) `),p&&(s+=`skewX(${p}deg) `),g&&(s+=`skewY(${g}deg) `)}const l=e.x.scale*t.x,c=e.y.scale*t.y;return(l!==1||c!==1)&&(s+=`scale(${l}, ${c})`),s||"none"}const Pn=["","X","Y","Z"],fh=1e3;let ph=0;function Rn(e,t,n,s){const{latestValues:o}=t;o[e]&&(n[e]=o[e],t.setStaticValue(e,0),s&&(s[e]=0))}function ma(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Jr(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:o,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",ie,!(o||r))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&ma(s)}function fa({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:o}){return class{constructor(i={},l=t==null?void 0:t()){this.id=ph++,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(yh),this.nodes.forEach(Sh),this.nodes.forEach(Ch),this.nodes.forEach(bh)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=i,this.root=l?l.root||l:this,this.path=l?[...l.path,l]:[],this.parent=l,this.depth=l?l.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new nh)}addEventListener(i,l){return this.eventHandlers.has(i)||this.eventHandlers.set(i,new Ss),this.eventHandlers.get(i).add(l)}notifyListeners(i,...l){const c=this.eventHandlers.get(i);c&&c.notify(...l)}hasListeners(i){return this.eventHandlers.has(i)}mount(i){if(this.instance)return;this.isSVG=Tr(i)&&!ad(i),this.instance=i;const{layoutId:l,layout:c,visualElement:d}=this.options;if(d&&!d.current&&d.mount(i),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||l)&&(this.isLayoutDirty=!0),e){let u,m=0;const f=()=>this.root.updateBlockedByResize=!1;ie.read(()=>{m=window.innerWidth}),e(i,()=>{const p=window.innerWidth;p!==m&&(m=p,this.root.updateBlockedByResize=!0,u&&u(),u=sh(f,250),nn.hasAnimatedSinceResize&&(nn.hasAnimatedSinceResize=!1,this.nodes.forEach(mi)))})}l&&this.root.registerSharedNode(l,this),this.options.animate!==!1&&d&&(l||c)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:m,hasRelativeLayoutChanged:f,layout:p})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const g=this.options.transition||d.getDefaultTransition()||Mh,{onLayoutAnimationStart:x,onLayoutAnimationComplete:v}=d.getProps(),E=!this.targetLayout||!ha(this.targetLayout,p),b=!m&&f;if(this.options.layoutRoot||this.resumeFrom||b||m&&(E||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const S={...Fs(g,"layout"),onPlay:x,onComplete:v};(d.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S),this.setAnimationOrigin(u,b)}else m||mi(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=p})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const i=this.getStack();i&&i.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),ze(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(kh),this.animationId++)}getTransformTemplate(){const{visualElement:i}=this.options;return i&&i.getProps().transformTemplate}willUpdate(i=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&ma(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){const m=this.path[u];m.shouldResetTransform=!0,m.updateScroll("snapshot"),m.options.layoutRoot&&m.willUpdate(!1)}const{layoutId:l,layout:c}=this.options;if(l===void 0&&!c)return;const d=this.getTransformTemplate();this.prevTransformTemplateValue=d?d(this.latestValues,""):void 0,this.updateSnapshot(),i&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(ui);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(hi);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(wh),this.nodes.forEach(gh),this.nodes.forEach(xh)):this.nodes.forEach(hi),this.clearAllSnapshots();const l=Se.now();xe.delta=$e(0,1e3/60,l-xe.timestamp),xe.timestamp=l,xe.isProcessing=!0,wn.update.process(xe),wn.preRender.process(xe),wn.render.process(xe),xe.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Bs.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(vh),this.sharedNodes.forEach(jh)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ie.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ie.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!we(this.snapshot.measuredBox.x)&&!we(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const i=this.layout;this.layout=this.measure(!1),this.layoutCorrected=de(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:l}=this.options;l&&l.notify("LayoutMeasure",this.layout.layoutBox,i?i.layoutBox:void 0)}updateScroll(i="measure"){let l=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===i&&(l=!1),l&&this.instance){const c=s(this.instance);this.scroll={animationId:this.root.animationId,phase:i,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!o)return;const i=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,l=this.projectionDelta&&!ua(this.projectionDelta),c=this.getTransformTemplate(),d=c?c(this.latestValues,""):void 0,u=d!==this.prevTransformTemplateValue;i&&this.instance&&(l||qe(this.latestValues)||u)&&(o(this.instance,d),this.shouldResetTransform=!1,this.scheduleRender())}measure(i=!0){const l=this.measurePageBox();let c=this.removeElementScroll(l);return i&&(c=this.removeTransform(c)),Th(c),{animationId:this.root.animationId,measuredBox:l,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){var d;const{visualElement:i}=this.options;if(!i)return de();const l=i.measureViewportBox();if(!(((d=this.scroll)==null?void 0:d.wasRoot)||this.path.some(Vh))){const{scroll:u}=this.root;u&&(lt(l.x,u.offset.x),lt(l.y,u.offset.y))}return l}removeElementScroll(i){var c;const l=de();if(ke(l,i),(c=this.scroll)!=null&&c.wasRoot)return l;for(let d=0;d<this.path.length;d++){const u=this.path[d],{scroll:m,options:f}=u;u!==this.root&&m&&f.layoutScroll&&(m.wasRoot&&ke(l,i),lt(l.x,m.offset.x),lt(l.y,m.offset.y))}return l}applyTransform(i,l=!1){const c=de();ke(c,i);for(let d=0;d<this.path.length;d++){const u=this.path[d];!l&&u.options.layoutScroll&&u.scroll&&u!==u.root&&ct(c,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),qe(u.latestValues)&&ct(c,u.latestValues)}return qe(this.latestValues)&&ct(c,this.latestValues),c}removeTransform(i){const l=de();ke(l,i);for(let c=0;c<this.path.length;c++){const d=this.path[c];if(!d.instance||!qe(d.latestValues))continue;ns(d.latestValues)&&d.updateSnapshot();const u=de(),m=d.measurePageBox();ke(u,m),ii(l,d.latestValues,d.snapshot?d.snapshot.layoutBox:void 0,u)}return qe(this.latestValues)&&ii(l,this.latestValues),l}setTargetDelta(i){this.targetDelta=i,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(i){this.options={...this.options,...i,crossfade:i.crossfade!==void 0?i.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!==xe.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(i=!1){var f;const l=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=l.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=l.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=l.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==l;if(!(i||c&&this.isSharedProjectionDirty||this.isProjectionDirty||(f=this.parent)!=null&&f.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:u,layoutId:m}=this.options;if(!(!this.layout||!(u||m))){if(this.resolvedRelativeTargetAt=xe.timestamp,!this.targetDelta&&!this.relativeTarget){const p=this.getClosestProjectingParent();p&&p.layout&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=de(),this.relativeTargetOrigin=de(),Vt(this.relativeTargetOrigin,this.layout.layoutBox,p.layout.layoutBox),ke(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=de(),this.targetWithTransforms=de()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Fu(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):ke(this.target,this.layout.layoutBox),Wr(this.target,this.targetDelta)):ke(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const p=this.getClosestProjectingParent();p&&!!p.resumingFrom==!!this.resumingFrom&&!p.options.layoutScroll&&p.target&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=de(),this.relativeTargetOrigin=de(),Vt(this.relativeTargetOrigin,this.target,p.target),ke(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||ns(this.parent.latestValues)||zr(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 g;const i=this.getLead(),l=!!this.resumingFrom||this!==i;let c=!0;if((this.isProjectionDirty||(g=this.parent)!=null&&g.isProjectionDirty)&&(c=!1),l&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===xe.timestamp&&(c=!1),c)return;const{layout:d,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(d||u))return;ke(this.layoutCorrected,this.layout.layoutBox);const m=this.treeScale.x,f=this.treeScale.y;Gd(this.layoutCorrected,this.treeScale,this.path,l),i.layout&&!i.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(i.target=i.layout.layoutBox,i.targetWithTransforms=de());const{target:p}=i;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(ni(this.prevProjectionDelta.x,this.projectionDelta.x),ni(this.prevProjectionDelta.y,this.projectionDelta.y)),Tt(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==m||this.treeScale.y!==f||!di(this.projectionDelta.x,this.prevProjectionDelta.x)||!di(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",p))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(i=!0){var l;if((l=this.options.visualElement)==null||l.scheduleRender(),i){const c=this.getStack();c&&c.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=dt(),this.projectionDelta=dt(),this.projectionDeltaWithTransform=dt()}setAnimationOrigin(i,l=!1){const c=this.snapshot,d=c?c.latestValues:{},u={...this.latestValues},m=dt();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!l;const f=de(),p=c?c.source:void 0,g=this.layout?this.layout.source:void 0,x=p!==g,v=this.getStack(),E=!v||v.members.length<=1,b=!!(x&&!E&&this.options.crossfade===!0&&!this.path.some(Ah));this.animationProgress=0;let S;this.mixTargetDelta=w=>{const C=w/1e3;fi(m.x,i.x,C),fi(m.y,i.y,C),this.setTargetDelta(m),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Vt(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Eh(this.relativeTarget,this.relativeTargetOrigin,f,C),S&&uh(this.relativeTarget,S)&&(this.isProjectionDirty=!1),S||(S=de()),ke(S,this.relativeTarget)),x&&(this.animationValues=u,ih(u,d,this.latestValues,C,b,E)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=C},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(i){var l,c,d;this.notifyListeners("animationStart"),(l=this.currentAnimation)==null||l.stop(),(d=(c=this.resumingFrom)==null?void 0:c.currentAnimation)==null||d.stop(),this.pendingAnimation&&(ze(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ie.update(()=>{nn.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=mt(0)),this.currentAnimation=eh(this.motionValue,[0,1e3],{...i,velocity:0,isSync:!0,onUpdate:u=>{this.mixTargetDelta(u),i.onUpdate&&i.onUpdate(u)},onStop:()=>{},onComplete:()=>{i.onComplete&&i.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 i=this.getStack();i&&i.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(fh),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const i=this.getLead();let{targetWithTransforms:l,target:c,layout:d,latestValues:u}=i;if(!(!l||!c||!d)){if(this!==i&&this.layout&&d&&pa(this.options.animationType,this.layout.layoutBox,d.layoutBox)){c=this.target||de();const m=we(this.layout.layoutBox.x);c.x.min=i.target.x.min,c.x.max=c.x.min+m;const f=we(this.layout.layoutBox.y);c.y.min=i.target.y.min,c.y.max=c.y.min+f}ke(l,c),ct(l,u),Tt(this.projectionDeltaWithTransform,this.layoutCorrected,l,u)}}registerSharedNode(i,l){this.sharedNodes.has(i)||this.sharedNodes.set(i,new hh),this.sharedNodes.get(i).add(l);const d=l.options.initialPromotionConfig;l.promote({transition:d?d.transition:void 0,preserveFollowOpacity:d&&d.shouldPreserveFollowOpacity?d.shouldPreserveFollowOpacity(l):void 0})}isLead(){const i=this.getStack();return i?i.lead===this:!0}getLead(){var l;const{layoutId:i}=this.options;return i?((l=this.getStack())==null?void 0:l.lead)||this:this}getPrevLead(){var l;const{layoutId:i}=this.options;return i?(l=this.getStack())==null?void 0:l.prevLead:void 0}getStack(){const{layoutId:i}=this.options;if(i)return this.root.sharedNodes.get(i)}promote({needsReset:i,transition:l,preserveFollowOpacity:c}={}){const d=this.getStack();d&&d.promote(this,c),i&&(this.projectionDelta=void 0,this.needsReset=!0),l&&this.setOptions({transition:l})}relegate(){const i=this.getStack();return i?i.relegate(this):!1}resetSkewAndRotation(){const{visualElement:i}=this.options;if(!i)return;let l=!1;const{latestValues:c}=i;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(l=!0),!l)return;const d={};c.z&&Rn("z",i,d,this.animationValues);for(let u=0;u<Pn.length;u++)Rn(`rotate${Pn[u]}`,i,d,this.animationValues),Rn(`skew${Pn[u]}`,i,d,this.animationValues);i.render();for(const u in d)i.setStaticValue(u,d[u]),this.animationValues&&(this.animationValues[u]=d[u]);i.scheduleRender()}applyProjectionStyles(i,l){if(!this.instance||this.isSVG)return;if(!this.isVisible){i.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,i.visibility="",i.opacity="",i.pointerEvents=tn(l==null?void 0:l.pointerEvents)||"",i.transform=c?c(this.latestValues,""):"none";return}const d=this.getLead();if(!this.projectionDelta||!this.layout||!d.target){this.options.layoutId&&(i.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,i.pointerEvents=tn(l==null?void 0:l.pointerEvents)||""),this.hasProjected&&!qe(this.latestValues)&&(i.transform=c?c({},""):"none",this.hasProjected=!1);return}i.visibility="";const u=d.animationValues||d.latestValues;this.applyTransformsToTarget();let m=mh(this.projectionDeltaWithTransform,this.treeScale,u);c&&(m=c(u,m)),i.transform=m;const{x:f,y:p}=this.projectionDelta;i.transformOrigin=`${f.origin*100}% ${p.origin*100}% 0`,d.animationValues?i.opacity=d===this?u.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:u.opacityExit:i.opacity=d===this?u.opacity!==void 0?u.opacity:"":u.opacityExit!==void 0?u.opacityExit:0;for(const g in Dt){if(u[g]===void 0)continue;const{correct:x,applyTo:v,isCSSVariable:E}=Dt[g],b=m==="none"?u[g]:x(u[g],d);if(v){const S=v.length;for(let w=0;w<S;w++)i[v[w]]=b}else E?this.options.visualElement.renderState.vars[g]=b:i[g]=b}this.options.layoutId&&(i.pointerEvents=d===this?tn(l==null?void 0:l.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(i=>{var l;return(l=i.currentAnimation)==null?void 0:l.stop()}),this.root.nodes.forEach(ui),this.root.sharedNodes.clear()}}}function gh(e){e.updateLayout()}function xh(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:s,measuredBox:o}=e.layout,{animationType:r}=e.options,i=t.source!==e.layout.source;r==="size"?je(m=>{const f=i?t.measuredBox[m]:t.layoutBox[m],p=we(f);f.min=s[m].min,f.max=f.min+p}):pa(r,t.layoutBox,s)&&je(m=>{const f=i?t.measuredBox[m]:t.layoutBox[m],p=we(s[m]);f.max=f.min+p,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[m].max=e.relativeTarget[m].min+p)});const l=dt();Tt(l,s,t.layoutBox);const c=dt();i?Tt(c,e.applyTransform(o,!0),t.measuredBox):Tt(c,s,t.layoutBox);const d=!ua(l);let u=!1;if(!e.resumeFrom){const m=e.getClosestProjectingParent();if(m&&!m.resumeFrom){const{snapshot:f,layout:p}=m;if(f&&p){const g=de();Vt(g,t.layoutBox,f.layoutBox);const x=de();Vt(x,s,p.layoutBox),ha(g,x)||(u=!0),m.options.layoutRoot&&(e.relativeTarget=x,e.relativeTargetOrigin=g,e.relativeParent=m)}}}e.notifyListeners("didUpdate",{layout:s,snapshot:t,delta:c,layoutDelta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:u})}else if(e.isLead()){const{onExitComplete:s}=e.options;s&&s()}e.options.transition=void 0}function yh(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 bh(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function vh(e){e.clearSnapshot()}function ui(e){e.clearMeasurements()}function hi(e){e.isLayoutDirty=!1}function wh(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function mi(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Sh(e){e.resolveTargetDelta()}function Ch(e){e.calcProjection()}function kh(e){e.resetSkewAndRotation()}function jh(e){e.removeLeadSnapshot()}function fi(e,t,n){e.translate=le(t.translate,0,n),e.scale=le(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function pi(e,t,n,s){e.min=le(t.min,n.min,s),e.max=le(t.max,n.max,s)}function Eh(e,t,n,s){pi(e.x,t.x,n.x,s),pi(e.y,t.y,n.y,s)}function Ah(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const Mh={duration:.45,ease:[.4,0,.1,1]},gi=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),xi=gi("applewebkit/")&&!gi("chrome/")?Math.round:Ae;function yi(e){e.min=xi(e.min),e.max=xi(e.max)}function Th(e){yi(e.x),yi(e.y)}function pa(e,t,n){return e==="position"||e==="preserve-aspect"&&!Du(ci(t),ci(n),.2)}function Vh(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const Nh=fa({attachResizeListener:(e,t)=>Ft(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),In={current:void 0},ga=fa({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!In.current){const e=new Nh({});e.mount(window),e.setOptions({layoutScroll:!0}),In.current=e}return In.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Ph={pan:{Feature:qu},drag:{Feature:Yu,ProjectionNode:ga,MeasureLayout:la}};function bi(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const o="onHover"+n,r=s[o];r&&ie.postRender(()=>r(t,Ot(t)))}class Rh extends Ke{mount(){const{current:t}=this.node;t&&(this.unmount=nd(t,(n,s)=>(bi(this.node,s,"Start"),o=>bi(this.node,o,"End"))))}unmount(){}}class Ih extends Ke{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=Lt(Ft(this.node.current,"focus",()=>this.onFocus()),Ft(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function vi(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const o="onTap"+(n==="End"?"":n),r=s[o];r&&ie.postRender(()=>r(t,Ot(t)))}class Dh extends Ke{mount(){const{current:t}=this.node;t&&(this.unmount=rd(t,(n,s)=>(vi(this.node,s,"Start"),(o,{success:r})=>vi(this.node,o,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const cs=new WeakMap,Dn=new WeakMap,Fh=e=>{const t=cs.get(e.target);t&&t(e)},Lh=e=>{e.forEach(Fh)};function Bh({root:e,...t}){const n=e||document;Dn.has(n)||Dn.set(n,{});const s=Dn.get(n),o=JSON.stringify(t);return s[o]||(s[o]=new IntersectionObserver(Lh,{root:e,...t})),s[o]}function $h(e,t,n){const s=Bh(t);return cs.set(e,n),s.observe(e),()=>{cs.delete(e),s.unobserve(e)}}const Oh={some:0,all:1};class _h extends Ke{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:o="some",once:r}=t,i={root:n?n.current:void 0,rootMargin:s,threshold:typeof o=="number"?o:Oh[o]},l=c=>{const{isIntersecting:d}=c;if(this.isInView===d||(this.isInView=d,r&&!d&&this.hasEnteredView))return;d&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",d);const{onViewportEnter:u,onViewportLeave:m}=this.node.getProps(),f=d?u:m;f&&f(c)};return $h(this.node.current,i,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Hh(t,n))&&this.startObserver()}unmount(){}}function Hh({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const Zh={inView:{Feature:_h},tap:{Feature:Dh},focus:{Feature:Ih},hover:{Feature:Rh}},Uh={layout:{ProjectionNode:ga,MeasureLayout:la}},zh={...Tu,...Zh,...Ph,...Uh},Q=zd(zh,ou),qs="-",Wh=e=>{const t=Gh(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:i=>{const l=i.split(qs);return l[0]===""&&l.length!==1&&l.shift(),xa(l,t)||Kh(i)},getConflictingClassGroupIds:(i,l)=>{const c=n[i]||[];return l&&s[i]?[...c,...s[i]]:c}}},xa=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],s=t.nextPart.get(n),o=s?xa(e.slice(1),s):void 0;if(o)return o;if(t.validators.length===0)return;const r=e.join(qs);return(i=t.validators.find(({validator:l})=>l(r)))==null?void 0:i.classGroupId},wi=/^\[(.+)\]$/,Kh=e=>{if(wi.test(e)){const t=wi.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Gh=e=>{const{theme:t,classGroups:n}=e,s={nextPart:new Map,validators:[]};for(const o in n)ds(n[o],s,o,t);return s},ds=(e,t,n,s)=>{e.forEach(o=>{if(typeof o=="string"){const r=o===""?t:Si(t,o);r.classGroupId=n;return}if(typeof o=="function"){if(Yh(o)){ds(o(s),t,n,s);return}t.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([r,i])=>{ds(i,Si(t,r),n,s)})})},Si=(e,t)=>{let n=e;return t.split(qs).forEach(s=>{n.nextPart.has(s)||n.nextPart.set(s,{nextPart:new Map,validators:[]}),n=n.nextPart.get(s)}),n},Yh=e=>e.isThemeGetter,qh=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,s=new Map;const o=(r,i)=>{n.set(r,i),t++,t>e&&(t=0,s=n,n=new Map)};return{get(r){let i=n.get(r);if(i!==void 0)return i;if((i=s.get(r))!==void 0)return o(r,i),i},set(r,i){n.has(r)?n.set(r,i):o(r,i)}}},us="!",hs=":",Xh=hs.length,Jh=e=>{const{prefix:t,experimentalParseClassName:n}=e;let s=o=>{const r=[];let i=0,l=0,c=0,d;for(let g=0;g<o.length;g++){let x=o[g];if(i===0&&l===0){if(x===hs){r.push(o.slice(c,g)),c=g+Xh;continue}if(x==="/"){d=g;continue}}x==="["?i++:x==="]"?i--:x==="("?l++:x===")"&&l--}const u=r.length===0?o:o.substring(c),m=Qh(u),f=m!==u,p=d&&d>c?d-c:void 0;return{modifiers:r,hasImportantModifier:f,baseClassName:m,maybePostfixModifierPosition:p}};if(t){const o=t+hs,r=s;s=i=>i.startsWith(o)?r(i.substring(o.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:i,maybePostfixModifierPosition:void 0}}if(n){const o=s;s=r=>n({className:r,parseClassName:o})}return s},Qh=e=>e.endsWith(us)?e.substring(0,e.length-1):e.startsWith(us)?e.substring(1):e,em=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(s=>[s,!0]));return s=>{if(s.length<=1)return s;const o=[];let r=[];return s.forEach(i=>{i[0]==="["||t[i]?(o.push(...r.sort(),i),r=[]):r.push(i)}),o.push(...r.sort()),o}},tm=e=>({cache:qh(e.cacheSize),parseClassName:Jh(e),sortModifiers:em(e),...Wh(e)}),nm=/\s+/,sm=(e,t)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:o,sortModifiers:r}=t,i=[],l=e.trim().split(nm);let c="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:m,modifiers:f,hasImportantModifier:p,baseClassName:g,maybePostfixModifierPosition:x}=n(u);if(m){c=u+(c.length>0?" "+c:c);continue}let v=!!x,E=s(v?g.substring(0,x):g);if(!E){if(!v){c=u+(c.length>0?" "+c:c);continue}if(E=s(g),!E){c=u+(c.length>0?" "+c:c);continue}v=!1}const b=r(f).join(":"),S=p?b+us:b,w=S+E;if(i.includes(w))continue;i.push(w);const C=o(E,v);for(let A=0;A<C.length;++A){const j=C[A];i.push(S+j)}c=u+(c.length>0?" "+c:c)}return c};function om(){let e=0,t,n,s="";for(;e<arguments.length;)(t=arguments[e++])&&(n=ya(t))&&(s&&(s+=" "),s+=n);return s}const ya=e=>{if(typeof e=="string")return e;let t,n="";for(let s=0;s<e.length;s++)e[s]&&(t=ya(e[s]))&&(n&&(n+=" "),n+=t);return n};function im(e,...t){let n,s,o,r=i;function i(c){const d=t.reduce((u,m)=>m(u),e());return n=tm(d),s=n.cache.get,o=n.cache.set,r=l,l(c)}function l(c){const d=s(c);if(d)return d;const u=sm(c,n);return o(c,u),u}return function(){return r(om.apply(null,arguments))}}const ge=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},ba=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,va=/^\((?:(\w[\w-]*):)?(.+)\)$/i,rm=/^\d+\/\d+$/,am=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,lm=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,cm=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,dm=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,um=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,st=e=>rm.test(e),X=e=>!!e&&!Number.isNaN(Number(e)),Ze=e=>!!e&&Number.isInteger(Number(e)),Fn=e=>e.endsWith("%")&&X(e.slice(0,-1)),Fe=e=>am.test(e),hm=()=>!0,mm=e=>lm.test(e)&&!cm.test(e),wa=()=>!1,fm=e=>dm.test(e),pm=e=>um.test(e),gm=e=>!N(e)&&!P(e),xm=e=>vt(e,ka,wa),N=e=>ba.test(e),Ye=e=>vt(e,ja,mm),Ln=e=>vt(e,Sm,X),Ci=e=>vt(e,Sa,wa),ym=e=>vt(e,Ca,pm),Yt=e=>vt(e,Ea,fm),P=e=>va.test(e),jt=e=>wt(e,ja),bm=e=>wt(e,Cm),ki=e=>wt(e,Sa),vm=e=>wt(e,ka),wm=e=>wt(e,Ca),qt=e=>wt(e,Ea,!0),vt=(e,t,n)=>{const s=ba.exec(e);return s?s[1]?t(s[1]):n(s[2]):!1},wt=(e,t,n=!1)=>{const s=va.exec(e);return s?s[1]?t(s[1]):n:!1},Sa=e=>e==="position"||e==="percentage",Ca=e=>e==="image"||e==="url",ka=e=>e==="length"||e==="size"||e==="bg-size",ja=e=>e==="length",Sm=e=>e==="number",Cm=e=>e==="family-name",Ea=e=>e==="shadow",km=()=>{const e=ge("color"),t=ge("font"),n=ge("text"),s=ge("font-weight"),o=ge("tracking"),r=ge("leading"),i=ge("breakpoint"),l=ge("container"),c=ge("spacing"),d=ge("radius"),u=ge("shadow"),m=ge("inset-shadow"),f=ge("text-shadow"),p=ge("drop-shadow"),g=ge("blur"),x=ge("perspective"),v=ge("aspect"),E=ge("ease"),b=ge("animate"),S=()=>["auto","avoid","all","avoid-page","page","left","right","column"],w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],C=()=>[...w(),P,N],A=()=>["auto","hidden","clip","visible","scroll"],j=()=>["auto","contain","none"],k=()=>[P,N,c],D=()=>[st,"full","auto",...k()],L=()=>[Ze,"none","subgrid",P,N],W=()=>["auto",{span:["full",Ze,P,N]},Ze,P,N],H=()=>[Ze,"auto",P,N],Ce=()=>["auto","min","max","fr",P,N],ne=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],te=()=>["start","end","center","stretch","center-safe","end-safe"],se=()=>["auto",...k()],z=()=>[st,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...k()],M=()=>[e,P,N],G=()=>[...w(),ki,Ci,{position:[P,N]}],Y=()=>["no-repeat",{repeat:["","x","y","space","round"]}],V=()=>["auto","cover","contain",vm,xm,{size:[P,N]}],q=()=>[Fn,jt,Ye],T=()=>["","none","full",d,P,N],F=()=>["",X,jt,Ye],Z=()=>["solid","dashed","dotted","double"],B=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],R=()=>[X,Fn,ki,Ci],_=()=>["","none",g,P,N],K=()=>["none",X,P,N],O=()=>["none",X,P,N],re=()=>[X,P,N],oe=()=>[st,"full",...k()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Fe],breakpoint:[Fe],color:[hm],container:[Fe],"drop-shadow":[Fe],ease:["in","out","in-out"],font:[gm],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Fe],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Fe],shadow:[Fe],spacing:["px",X],text:[Fe],"text-shadow":[Fe],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",st,N,P,v]}],container:["container"],columns:[{columns:[X,N,P,l]}],"break-after":[{"break-after":S()}],"break-before":[{"break-before":S()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:C()}],overflow:[{overflow:A()}],"overflow-x":[{"overflow-x":A()}],"overflow-y":[{"overflow-y":A()}],overscroll:[{overscroll:j()}],"overscroll-x":[{"overscroll-x":j()}],"overscroll-y":[{"overscroll-y":j()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:D()}],"inset-x":[{"inset-x":D()}],"inset-y":[{"inset-y":D()}],start:[{start:D()}],end:[{end:D()}],top:[{top:D()}],right:[{right:D()}],bottom:[{bottom:D()}],left:[{left:D()}],visibility:["visible","invisible","collapse"],z:[{z:[Ze,"auto",P,N]}],basis:[{basis:[st,"full","auto",l,...k()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[X,st,"auto","initial","none",N]}],grow:[{grow:["",X,P,N]}],shrink:[{shrink:["",X,P,N]}],order:[{order:[Ze,"first","last","none",P,N]}],"grid-cols":[{"grid-cols":L()}],"col-start-end":[{col:W()}],"col-start":[{"col-start":H()}],"col-end":[{"col-end":H()}],"grid-rows":[{"grid-rows":L()}],"row-start-end":[{row:W()}],"row-start":[{"row-start":H()}],"row-end":[{"row-end":H()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Ce()}],"auto-rows":[{"auto-rows":Ce()}],gap:[{gap:k()}],"gap-x":[{"gap-x":k()}],"gap-y":[{"gap-y":k()}],"justify-content":[{justify:[...ne(),"normal"]}],"justify-items":[{"justify-items":[...te(),"normal"]}],"justify-self":[{"justify-self":["auto",...te()]}],"align-content":[{content:["normal",...ne()]}],"align-items":[{items:[...te(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...te(),{baseline:["","last"]}]}],"place-content":[{"place-content":ne()}],"place-items":[{"place-items":[...te(),"baseline"]}],"place-self":[{"place-self":["auto",...te()]}],p:[{p:k()}],px:[{px:k()}],py:[{py:k()}],ps:[{ps:k()}],pe:[{pe:k()}],pt:[{pt:k()}],pr:[{pr:k()}],pb:[{pb:k()}],pl:[{pl:k()}],m:[{m:se()}],mx:[{mx:se()}],my:[{my:se()}],ms:[{ms:se()}],me:[{me:se()}],mt:[{mt:se()}],mr:[{mr:se()}],mb:[{mb:se()}],ml:[{ml:se()}],"space-x":[{"space-x":k()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":k()}],"space-y-reverse":["space-y-reverse"],size:[{size:z()}],w:[{w:[l,"screen",...z()]}],"min-w":[{"min-w":[l,"screen","none",...z()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...z()]}],h:[{h:["screen","lh",...z()]}],"min-h":[{"min-h":["screen","lh","none",...z()]}],"max-h":[{"max-h":["screen","lh",...z()]}],"font-size":[{text:["base",n,jt,Ye]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,P,Ln]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Fn,N]}],"font-family":[{font:[bm,N,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,P,N]}],"line-clamp":[{"line-clamp":[X,"none",P,Ln]}],leading:[{leading:[r,...k()]}],"list-image":[{"list-image":["none",P,N]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",P,N]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:M()}],"text-color":[{text:M()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Z(),"wavy"]}],"text-decoration-thickness":[{decoration:[X,"from-font","auto",P,Ye]}],"text-decoration-color":[{decoration:M()}],"underline-offset":[{"underline-offset":[X,"auto",P,N]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:k()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",P,N]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",P,N]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:G()}],"bg-repeat":[{bg:Y()}],"bg-size":[{bg:V()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ze,P,N],radial:["",P,N],conic:[Ze,P,N]},wm,ym]}],"bg-color":[{bg:M()}],"gradient-from-pos":[{from:q()}],"gradient-via-pos":[{via:q()}],"gradient-to-pos":[{to:q()}],"gradient-from":[{from:M()}],"gradient-via":[{via:M()}],"gradient-to":[{to:M()}],rounded:[{rounded:T()}],"rounded-s":[{"rounded-s":T()}],"rounded-e":[{"rounded-e":T()}],"rounded-t":[{"rounded-t":T()}],"rounded-r":[{"rounded-r":T()}],"rounded-b":[{"rounded-b":T()}],"rounded-l":[{"rounded-l":T()}],"rounded-ss":[{"rounded-ss":T()}],"rounded-se":[{"rounded-se":T()}],"rounded-ee":[{"rounded-ee":T()}],"rounded-es":[{"rounded-es":T()}],"rounded-tl":[{"rounded-tl":T()}],"rounded-tr":[{"rounded-tr":T()}],"rounded-br":[{"rounded-br":T()}],"rounded-bl":[{"rounded-bl":T()}],"border-w":[{border:F()}],"border-w-x":[{"border-x":F()}],"border-w-y":[{"border-y":F()}],"border-w-s":[{"border-s":F()}],"border-w-e":[{"border-e":F()}],"border-w-t":[{"border-t":F()}],"border-w-r":[{"border-r":F()}],"border-w-b":[{"border-b":F()}],"border-w-l":[{"border-l":F()}],"divide-x":[{"divide-x":F()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":F()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Z(),"hidden","none"]}],"divide-style":[{divide:[...Z(),"hidden","none"]}],"border-color":[{border:M()}],"border-color-x":[{"border-x":M()}],"border-color-y":[{"border-y":M()}],"border-color-s":[{"border-s":M()}],"border-color-e":[{"border-e":M()}],"border-color-t":[{"border-t":M()}],"border-color-r":[{"border-r":M()}],"border-color-b":[{"border-b":M()}],"border-color-l":[{"border-l":M()}],"divide-color":[{divide:M()}],"outline-style":[{outline:[...Z(),"none","hidden"]}],"outline-offset":[{"outline-offset":[X,P,N]}],"outline-w":[{outline:["",X,jt,Ye]}],"outline-color":[{outline:M()}],shadow:[{shadow:["","none",u,qt,Yt]}],"shadow-color":[{shadow:M()}],"inset-shadow":[{"inset-shadow":["none",m,qt,Yt]}],"inset-shadow-color":[{"inset-shadow":M()}],"ring-w":[{ring:F()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:M()}],"ring-offset-w":[{"ring-offset":[X,Ye]}],"ring-offset-color":[{"ring-offset":M()}],"inset-ring-w":[{"inset-ring":F()}],"inset-ring-color":[{"inset-ring":M()}],"text-shadow":[{"text-shadow":["none",f,qt,Yt]}],"text-shadow-color":[{"text-shadow":M()}],opacity:[{opacity:[X,P,N]}],"mix-blend":[{"mix-blend":[...B(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":B()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[X]}],"mask-image-linear-from-pos":[{"mask-linear-from":R()}],"mask-image-linear-to-pos":[{"mask-linear-to":R()}],"mask-image-linear-from-color":[{"mask-linear-from":M()}],"mask-image-linear-to-color":[{"mask-linear-to":M()}],"mask-image-t-from-pos":[{"mask-t-from":R()}],"mask-image-t-to-pos":[{"mask-t-to":R()}],"mask-image-t-from-color":[{"mask-t-from":M()}],"mask-image-t-to-color":[{"mask-t-to":M()}],"mask-image-r-from-pos":[{"mask-r-from":R()}],"mask-image-r-to-pos":[{"mask-r-to":R()}],"mask-image-r-from-color":[{"mask-r-from":M()}],"mask-image-r-to-color":[{"mask-r-to":M()}],"mask-image-b-from-pos":[{"mask-b-from":R()}],"mask-image-b-to-pos":[{"mask-b-to":R()}],"mask-image-b-from-color":[{"mask-b-from":M()}],"mask-image-b-to-color":[{"mask-b-to":M()}],"mask-image-l-from-pos":[{"mask-l-from":R()}],"mask-image-l-to-pos":[{"mask-l-to":R()}],"mask-image-l-from-color":[{"mask-l-from":M()}],"mask-image-l-to-color":[{"mask-l-to":M()}],"mask-image-x-from-pos":[{"mask-x-from":R()}],"mask-image-x-to-pos":[{"mask-x-to":R()}],"mask-image-x-from-color":[{"mask-x-from":M()}],"mask-image-x-to-color":[{"mask-x-to":M()}],"mask-image-y-from-pos":[{"mask-y-from":R()}],"mask-image-y-to-pos":[{"mask-y-to":R()}],"mask-image-y-from-color":[{"mask-y-from":M()}],"mask-image-y-to-color":[{"mask-y-to":M()}],"mask-image-radial":[{"mask-radial":[P,N]}],"mask-image-radial-from-pos":[{"mask-radial-from":R()}],"mask-image-radial-to-pos":[{"mask-radial-to":R()}],"mask-image-radial-from-color":[{"mask-radial-from":M()}],"mask-image-radial-to-color":[{"mask-radial-to":M()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":w()}],"mask-image-conic-pos":[{"mask-conic":[X]}],"mask-image-conic-from-pos":[{"mask-conic-from":R()}],"mask-image-conic-to-pos":[{"mask-conic-to":R()}],"mask-image-conic-from-color":[{"mask-conic-from":M()}],"mask-image-conic-to-color":[{"mask-conic-to":M()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:G()}],"mask-repeat":[{mask:Y()}],"mask-size":[{mask:V()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",P,N]}],filter:[{filter:["","none",P,N]}],blur:[{blur:_()}],brightness:[{brightness:[X,P,N]}],contrast:[{contrast:[X,P,N]}],"drop-shadow":[{"drop-shadow":["","none",p,qt,Yt]}],"drop-shadow-color":[{"drop-shadow":M()}],grayscale:[{grayscale:["",X,P,N]}],"hue-rotate":[{"hue-rotate":[X,P,N]}],invert:[{invert:["",X,P,N]}],saturate:[{saturate:[X,P,N]}],sepia:[{sepia:["",X,P,N]}],"backdrop-filter":[{"backdrop-filter":["","none",P,N]}],"backdrop-blur":[{"backdrop-blur":_()}],"backdrop-brightness":[{"backdrop-brightness":[X,P,N]}],"backdrop-contrast":[{"backdrop-contrast":[X,P,N]}],"backdrop-grayscale":[{"backdrop-grayscale":["",X,P,N]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[X,P,N]}],"backdrop-invert":[{"backdrop-invert":["",X,P,N]}],"backdrop-opacity":[{"backdrop-opacity":[X,P,N]}],"backdrop-saturate":[{"backdrop-saturate":[X,P,N]}],"backdrop-sepia":[{"backdrop-sepia":["",X,P,N]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":k()}],"border-spacing-x":[{"border-spacing-x":k()}],"border-spacing-y":[{"border-spacing-y":k()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",P,N]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[X,"initial",P,N]}],ease:[{ease:["linear","initial",E,P,N]}],delay:[{delay:[X,P,N]}],animate:[{animate:["none",b,P,N]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,P,N]}],"perspective-origin":[{"perspective-origin":C()}],rotate:[{rotate:K()}],"rotate-x":[{"rotate-x":K()}],"rotate-y":[{"rotate-y":K()}],"rotate-z":[{"rotate-z":K()}],scale:[{scale:O()}],"scale-x":[{"scale-x":O()}],"scale-y":[{"scale-y":O()}],"scale-z":[{"scale-z":O()}],"scale-3d":["scale-3d"],skew:[{skew:re()}],"skew-x":[{"skew-x":re()}],"skew-y":[{"skew-y":re()}],transform:[{transform:[P,N,"","none","gpu","cpu"]}],"transform-origin":[{origin:C()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:oe()}],"translate-x":[{"translate-x":oe()}],"translate-y":[{"translate-y":oe()}],"translate-z":[{"translate-z":oe()}],"translate-none":["translate-none"],accent:[{accent:M()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:M()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",P,N]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":k()}],"scroll-mx":[{"scroll-mx":k()}],"scroll-my":[{"scroll-my":k()}],"scroll-ms":[{"scroll-ms":k()}],"scroll-me":[{"scroll-me":k()}],"scroll-mt":[{"scroll-mt":k()}],"scroll-mr":[{"scroll-mr":k()}],"scroll-mb":[{"scroll-mb":k()}],"scroll-ml":[{"scroll-ml":k()}],"scroll-p":[{"scroll-p":k()}],"scroll-px":[{"scroll-px":k()}],"scroll-py":[{"scroll-py":k()}],"scroll-ps":[{"scroll-ps":k()}],"scroll-pe":[{"scroll-pe":k()}],"scroll-pt":[{"scroll-pt":k()}],"scroll-pr":[{"scroll-pr":k()}],"scroll-pb":[{"scroll-pb":k()}],"scroll-pl":[{"scroll-pl":k()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",P,N]}],fill:[{fill:["none",...M()]}],"stroke-w":[{stroke:[X,jt,Ye,Ln]}],stroke:[{stroke:["none",...M()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},jm=im(km);function $(...e){return jm(cl.clsx(e))}function Em(e,t){return{id:e.streamInfo.id,timestamp:e.streamInfo.timestamp,message:e.text,from:e.participantInfo.identity===t.localParticipant.identity?t.localParticipant:Array.from(t.remoteParticipants.values()).find(n=>n.identity===e.participantInfo.identity)}}const Am=un.cva(["relative w-full rounded-lg border px-4 py-3 text-sm grid grid-cols-[0_1fr] gap-y-0.5 items-start","has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current"],{variants:{variant:{default:"bg-card text-card-foreground",destructive:["text-destructive-foreground bg-destructive border-destructive-border","[&>svg]:text-current *:data-[slot=alert-description]:text-destructive-foreground/90"]}},defaultVariants:{variant:"default"}});function Mm({className:e,variant:t,...n}){return a.jsx("div",{"data-slot":"alert",role:"alert",className:$(Am({variant:t}),e),...n})}function Tm({className:e,...t}){return a.jsx("div",{"data-slot":"alert-title",className:$("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t})}function Vm({className:e,...t}){return a.jsx("div",{"data-slot":"alert-description",className:$("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t})}function Xt(e){return Bi.toast.custom(t=>a.jsx(Nm,{id:t,title:e.title,description:e.description}),{duration:1e4})}function Nm(e){const{title:t,id:n,description:s}=e;return a.jsxs(Mm,{onClick:()=>Bi.toast.dismiss(n),className:"bg-gradient-to-br from-[#181825] to-[#232336] border border-[#232336] shadow-lg shadow-black/40 rounded-xl px-4 py-3 flex items-start gap-3 hover:shadow-xl transition-all duration-200",style:{color:"#F3F4F6"},children:[a.jsx(ll.WarningIcon,{weight:"bold",className:"text-yellow-400 mt-1 flex-shrink-0",size:24}),a.jsxs("div",{className:"flex flex-col",children:[a.jsx(Tm,{className:"text-base font-semibold text-white mb-1",children:t}),a.jsx(Vm,{className:"text-sm text-gray-300 leading-snug",children:s})]})]})}const Ne=h.forwardRef((e,t)=>{const{alt:n,color:s="currentColor",size:o="1em",weight:r="regular",mirrored:i=!1,children:l,weights:c,...d}=e;return h.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:s,viewBox:"0 0 256 256",transform:i?"scale(-1, 1)":void 0,...d},!!n&&h.createElement("title",null,n),l,c.get(r))});Ne.displayName="SSRBase";const Pm=new Map([["bold",h.createElement(h.Fragment,null,h.createElement("path",{d:"M216.49,104.49l-80,80a12,12,0,0,1-17,0l-80-80a12,12,0,0,1,17-17L128,159l71.51-71.52a12,12,0,0,1,17,17Z"}))],["duotone",h.createElement(h.Fragment,null,h.createElement("path",{d:"M208,96l-80,80L48,96Z",opacity:"0.2"}),h.createElement("path",{d:"M215.39,92.94A8,8,0,0,0,208,88H48a8,8,0,0,0-5.66,13.66l80,80a8,8,0,0,0,11.32,0l80-80A8,8,0,0,0,215.39,92.94ZM128,164.69,67.31,104H188.69Z"}))],["fill",h.createElement(h.Fragment,null,h.createElement("path",{d:"M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,48,88H208a8,8,0,0,1,5.66,13.66Z"}))],["light",h.createElement(h.Fragment,null,h.createElement("path",{d:"M212.24,100.24l-80,80a6,6,0,0,1-8.48,0l-80-80a6,6,0,0,1,8.48-8.48L128,167.51l75.76-75.75a6,6,0,0,1,8.48,8.48Z"}))],["regular",h.createElement(h.Fragment,null,h.createElement("path",{d:"M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"}))],["thin",h.createElement(h.Fragment,null,h.createElement("path",{d:"M210.83,98.83l-80,80a4,4,0,0,1-5.66,0l-80-80a4,4,0,0,1,5.66-5.66L128,170.34l77.17-77.17a4,4,0,1,1,5.66,5.66Z"}))]]),Xs=h.forwardRef((e,t)=>h.createElement(Ne,{ref:t,...e,weights:Pm}));Xs.displayName="CaretDownIcon";const Rm=new Map([["bold",h.createElement(h.Fragment,null,h.createElement("path",{d:"M216.49,168.49a12,12,0,0,1-17,0L128,97,56.49,168.49a12,12,0,0,1-17-17l80-80a12,12,0,0,1,17,0l80,80A12,12,0,0,1,216.49,168.49Z"}))],["duotone",h.createElement(h.Fragment,null,h.createElement("path",{d:"M208,160H48l80-80Z",opacity:"0.2"}),h.createElement("path",{d:"M213.66,154.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,48,168H208a8,8,0,0,0,5.66-13.66ZM67.31,152,128,91.31,188.69,152Z"}))],["fill",h.createElement(h.Fragment,null,h.createElement("path",{d:"M215.39,163.06A8,8,0,0,1,208,168H48a8,8,0,0,1-5.66-13.66l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,215.39,163.06Z"}))],["light",h.createElement(h.Fragment,null,h.createElement("path",{d:"M212.24,164.24a6,6,0,0,1-8.48,0L128,88.49,52.24,164.24a6,6,0,0,1-8.48-8.48l80-80a6,6,0,0,1,8.48,0l80,80A6,6,0,0,1,212.24,164.24Z"}))],["regular",h.createElement(h.Fragment,null,h.createElement("path",{d:"M213.66,165.66a8,8,0,0,1-11.32,0L128,91.31,53.66,165.66a8,8,0,0,1-11.32-11.32l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,213.66,165.66Z"}))],["thin",h.createElement(h.Fragment,null,h.createElement("path",{d:"M210.83,162.83a4,4,0,0,1-5.66,0L128,85.66,50.83,162.83a4,4,0,0,1-5.66-5.66l80-80a4,4,0,0,1,5.66,0l80,80A4,4,0,0,1,210.83,162.83Z"}))]]),Aa=h.forwardRef((e,t)=>h.createElement(Ne,{ref:t,...e,weights:Rm}));Aa.displayName="CaretUpIcon";const Im=new Map([["bold",h.createElement(h.Fragment,null,h.createElement("path",{d:"M216,44H40A20,20,0,0,0,20,64V224A19.82,19.82,0,0,0,31.56,242.1a20.14,20.14,0,0,0,8.49,1.9,19.91,19.91,0,0,0,12.82-4.72l.12-.11L84.47,212H216a20,20,0,0,0,20-20V64A20,20,0,0,0,216,44Zm-4,144H80a11.93,11.93,0,0,0-7.84,2.92L44,215.23V68H212ZM84,108A12,12,0,0,1,96,96h64a12,12,0,1,1,0,24H96A12,12,0,0,1,84,108Zm0,40a12,12,0,0,1,12-12h64a12,12,0,0,1,0,24H96A12,12,0,0,1,84,148Z"}))],["duotone",h.createElement(h.Fragment,null,h.createElement("path",{d:"M224,64V192a8,8,0,0,1-8,8H80L45.15,230.11A8,8,0,0,1,32,224V64a8,8,0,0,1,8-8H216A8,8,0,0,1,224,64Z",opacity:"0.2"}),h.createElement("path",{d:"M216,48H40A16,16,0,0,0,24,64V224a15.85,15.85,0,0,0,9.24,14.5A16.13,16.13,0,0,0,40,240a15.89,15.89,0,0,0,10.25-3.78l.09-.07L83,208H216a16,16,0,0,0,16-16V64A16,16,0,0,0,216,48ZM40,224h0ZM216,192H80a8,8,0,0,0-5.23,1.95L40,224V64H216ZM88,112a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H96A8,8,0,0,1,88,112Zm0,32a8,8,0,0,1,8-8h64a8,8,0,1,1,0,16H96A8,8,0,0,1,88,144Z"}))],["fill",h.createElement(h.Fragment,null,h.createElement("path",{d:"M216,48H40A16,16,0,0,0,24,64V224a15.84,15.84,0,0,0,9.25,14.5A16.05,16.05,0,0,0,40,240a15.89,15.89,0,0,0,10.25-3.78l.09-.07L83,208H216a16,16,0,0,0,16-16V64A16,16,0,0,0,216,48ZM160,152H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm0-32H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Z"}))],["light",h.createElement(h.Fragment,null,h.createElement("path",{d:"M216,50H40A14,14,0,0,0,26,64V224a13.88,13.88,0,0,0,8.09,12.69A14.11,14.11,0,0,0,40,238a13.87,13.87,0,0,0,9-3.31l.06-.05L82.23,206H216a14,14,0,0,0,14-14V64A14,14,0,0,0,216,50Zm2,142a2,2,0,0,1-2,2H80a6,6,0,0,0-3.92,1.46L41.26,225.53A2,2,0,0,1,38,224V64a2,2,0,0,1,2-2H216a2,2,0,0,1,2,2Zm-52-80a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,112Zm0,32a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,144Z"}))],["regular",h.createElement(h.Fragment,null,h.createElement("path",{d:"M216,48H40A16,16,0,0,0,24,64V224a15.85,15.85,0,0,0,9.24,14.5A16.13,16.13,0,0,0,40,240a15.89,15.89,0,0,0,10.25-3.78l.09-.07L83,208H216a16,16,0,0,0,16-16V64A16,16,0,0,0,216,48ZM40,224h0ZM216,192H80a8,8,0,0,0-5.23,1.95L40,224V64H216ZM88,112a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H96A8,8,0,0,1,88,112Zm0,32a8,8,0,0,1,8-8h64a8,8,0,1,1,0,16H96A8,8,0,0,1,88,144Z"}))],["thin",h.createElement(h.Fragment,null,h.createElement("path",{d:"M216,52H40A12,12,0,0,0,28,64V224a11.89,11.89,0,0,0,6.93,10.88A12.17,12.17,0,0,0,40,236a11.89,11.89,0,0,0,7.69-2.83l0,0L81.49,204H216a12,12,0,0,0,12-12V64A12,12,0,0,0,216,52Zm4,140a4,4,0,0,1-4,4H80a4,4,0,0,0-2.62,1L42.56,227.06A4,4,0,0,1,36,224V64a4,4,0,0,1,4-4H216a4,4,0,0,1,4,4Zm-56-80a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,112Zm0,32a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,144Z"}))]]),Ma=h.forwardRef((e,t)=>h.createElement(Ne,{ref:t,...e,weights:Im}));Ma.displayName="ChatTextIcon";const Dm=new Map([["bold",h.createElement(h.Fragment,null,h.createElement("path",{d:"M232.49,80.49l-128,128a12,12,0,0,1-17,0l-56-56a12,12,0,1,1,17-17L96,183,215.51,63.51a12,12,0,0,1,17,17Z"}))],["duotone",h.createElement(h.Fragment,null,h.createElement("path",{d:"M232,56V200a16,16,0,0,1-16,16H40a16,16,0,0,1-16-16V56A16,16,0,0,1,40,40H216A16,16,0,0,1,232,56Z",opacity:"0.2"}),h.createElement("path",{d:"M205.66,85.66l-96,96a8,8,0,0,1-11.32,0l-40-40a8,8,0,0,1,11.32-11.32L104,164.69l90.34-90.35a8,8,0,0,1,11.32,11.32Z"}))],["fill",h.createElement(h.Fragment,null,h.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM205.66,85.66l-96,96a8,8,0,0,1-11.32,0l-40-40a8,8,0,0,1,11.32-11.32L104,164.69l90.34-90.35a8,8,0,0,1,11.32,11.32Z"}))],["light",h.createElement(h.Fragment,null,h.createElement("path",{d:"M228.24,76.24l-128,128a6,6,0,0,1-8.48,0l-56-56a6,6,0,0,1,8.48-8.48L96,191.51,219.76,67.76a6,6,0,0,1,8.48,8.48Z"}))],["regular",h.createElement(h.Fragment,null,h.createElement("path",{d:"M229.66,77.66l-128,128a8,8,0,0,1-11.32,0l-56-56a8,8,0,0,1,11.32-11.32L96,188.69,218.34,66.34a8,8,0,0,1,11.32,11.32Z"}))],["thin",h.createElement(h.Fragment,null,h.createElement("path",{d:"M226.83,74.83l-128,128a4,4,0,0,1-5.66,0l-56-56a4,4,0,0,1,5.66-5.66L96,194.34,221.17,69.17a4,4,0,1,1,5.66,5.66Z"}))]]),Ta=h.forwardRef((e,t)=>h.createElement(Ne,{ref:t,...e,weights:Dm}));Ta.displayName="CheckIcon";const Fm=new Map([["bold",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,180a52.06,52.06,0,0,0,52-52V64A52,52,0,0,0,76,64v64A52.06,52.06,0,0,0,128,180ZM100,64a28,28,0,0,1,56,0v64a28,28,0,0,1-56,0Zm40,155.22V240a12,12,0,0,1-24,0V219.22A92.14,92.14,0,0,1,36,128a12,12,0,0,1,24,0,68,68,0,0,0,136,0,12,12,0,0,1,24,0A92.14,92.14,0,0,1,140,219.22Z"}))],["duotone",h.createElement(h.Fragment,null,h.createElement("path",{d:"M168,64v64a40,40,0,0,1-40,40h0a40,40,0,0,1-40-40V64a40,40,0,0,1,40-40h0A40,40,0,0,1,168,64Z",opacity:"0.2"}),h.createElement("path",{d:"M128,176a48.05,48.05,0,0,0,48-48V64a48,48,0,0,0-96,0v64A48.05,48.05,0,0,0,128,176ZM96,64a32,32,0,0,1,64,0v64a32,32,0,0,1-64,0Zm40,143.6V240a8,8,0,0,1-16,0V207.6A80.11,80.11,0,0,1,48,128a8,8,0,0,1,16,0,64,64,0,0,0,128,0,8,8,0,0,1,16,0A80.11,80.11,0,0,1,136,207.6Z"}))],["fill",h.createElement(h.Fragment,null,h.createElement("path",{d:"M80,128V64a48,48,0,0,1,96,0v64a48,48,0,0,1-96,0Zm128,0a8,8,0,0,0-16,0,64,64,0,0,1-128,0,8,8,0,0,0-16,0,80.11,80.11,0,0,0,72,79.6V240a8,8,0,0,0,16,0V207.6A80.11,80.11,0,0,0,208,128Z"}))],["light",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,174a46.06,46.06,0,0,0,46-46V64a46,46,0,0,0-92,0v64A46.06,46.06,0,0,0,128,174ZM94,64a34,34,0,0,1,68,0v64a34,34,0,0,1-68,0Zm40,141.75V240a6,6,0,0,1-12,0V205.75A78.09,78.09,0,0,1,50,128a6,6,0,0,1,12,0,66,66,0,0,0,132,0,6,6,0,0,1,12,0A78.09,78.09,0,0,1,134,205.75Z"}))],["regular",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,176a48.05,48.05,0,0,0,48-48V64a48,48,0,0,0-96,0v64A48.05,48.05,0,0,0,128,176ZM96,64a32,32,0,0,1,64,0v64a32,32,0,0,1-64,0Zm40,143.6V240a8,8,0,0,1-16,0V207.6A80.11,80.11,0,0,1,48,128a8,8,0,0,1,16,0,64,64,0,0,0,128,0,8,8,0,0,1,16,0A80.11,80.11,0,0,1,136,207.6Z"}))],["thin",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,172a44.05,44.05,0,0,0,44-44V64a44,44,0,0,0-88,0v64A44.05,44.05,0,0,0,128,172ZM92,64a36,36,0,0,1,72,0v64a36,36,0,0,1-72,0Zm40,139.89V240a4,4,0,0,1-8,0V203.89A76.09,76.09,0,0,1,52,128a4,4,0,0,1,8,0,68,68,0,0,0,136,0,4,4,0,0,1,8,0A76.09,76.09,0,0,1,132,203.89Z"}))]]),Va=h.forwardRef((e,t)=>h.createElement(Ne,{ref:t,...e,weights:Fm}));Va.displayName="MicrophoneIcon";const Lm=new Map([["bold",h.createElement(h.Fragment,null,h.createElement("path",{d:"M56.88,39.93A12,12,0,1,0,39.12,56.07L76,96.64V128a52,52,0,0,0,72.11,48l11.26,12.39A67.34,67.34,0,0,1,128,196a68.07,68.07,0,0,1-68-68,12,12,0,0,0-24,0,92.14,92.14,0,0,0,80,91.22V240a12,12,0,0,0,24,0V219.23a90.39,90.39,0,0,0,35.92-12.68l23.2,25.52a12,12,0,0,0,17.76-16.14ZM128,156a28,28,0,0,1-28-28v-5l29.9,32.89C129.27,156,128.64,156,128,156Zm63-2.42A67.63,67.63,0,0,0,196,128a12,12,0,0,1,24,0,91.48,91.48,0,0,1-6.74,34.61,12,12,0,0,1-22.23-9ZM85.7,33.75A52,52,0,0,1,180,64v56.54a12,12,0,0,1-24,0V64a28,28,0,0,0-50.79-16.28,12,12,0,0,1-19.51-14Z"}))],["duotone",h.createElement(h.Fragment,null,h.createElement("path",{d:"M168,64v64a40,40,0,0,1-40,40h0a40,40,0,0,1-40-40V64a40,40,0,0,1,40-40h0A40,40,0,0,1,168,64Z",opacity:"0.2"}),h.createElement("path",{d:"M213.92,218.62l-160-176A8,8,0,0,0,42.08,53.38L80,95.09V128a48,48,0,0,0,69.11,43.12l11.1,12.2A63.41,63.41,0,0,1,128,192a64.07,64.07,0,0,1-64-64,8,8,0,0,0-16,0,80.11,80.11,0,0,0,72,79.6V240a8,8,0,0,0,16,0V207.59a78.83,78.83,0,0,0,35.16-12.22l30.92,34a8,8,0,1,0,11.84-10.76ZM128,160a32,32,0,0,1-32-32V112.69l41.66,45.82A32,32,0,0,1,128,160Zm57.52-3.91A63.32,63.32,0,0,0,192,128a8,8,0,0,1,16,0,79.16,79.16,0,0,1-8.11,35.12,8,8,0,0,1-7.19,4.49,7.88,7.88,0,0,1-3.51-.82A8,8,0,0,1,185.52,156.09ZM84,44.87A48,48,0,0,1,176,64v64a49.19,49.19,0,0,1-.26,5,8,8,0,0,1-8,7.17,8.13,8.13,0,0,1-.84,0,8,8,0,0,1-7.12-8.79c.11-1.1.17-2.24.17-3.36V64A32,32,0,0,0,98.64,51.25,8,8,0,1,1,84,44.87Z"}))],["fill",h.createElement(h.Fragment,null,h.createElement("path",{d:"M213.38,229.92a8,8,0,0,1-11.3-.54l-30.92-34A78.83,78.83,0,0,1,136,207.59V240a8,8,0,0,1-16,0V207.6A80.11,80.11,0,0,1,48,128a8,8,0,0,1,16,0,64.07,64.07,0,0,0,64,64,63.41,63.41,0,0,0,32.21-8.68l-11.1-12.2A48,48,0,0,1,80,128V95.09L42.08,53.38A8,8,0,0,1,53.92,42.62l160,176A8,8,0,0,1,213.38,229.92Zm-24.19-63.13a7.88,7.88,0,0,0,3.51.82,8,8,0,0,0,7.19-4.49A79.16,79.16,0,0,0,208,128a8,8,0,0,0-16,0,63.32,63.32,0,0,1-6.48,28.09A8,8,0,0,0,189.19,166.79Zm-27.33-29.22A8,8,0,0,0,175.74,133a49.49,49.49,0,0,0,.26-5V64A48,48,0,0,0,84,44.87a8,8,0,0,0,1.41,8.57Z"}))],["light",h.createElement(h.Fragment,null,h.createElement("path",{d:"M212.44,220,52.44,44A6,6,0,0,0,43.56,52L82,94.32V128a46,46,0,0,0,67.56,40.64l13.75,15.12A65.26,65.26,0,0,1,128,194a66.08,66.08,0,0,1-66-66,6,6,0,0,0-12,0,78.09,78.09,0,0,0,72,77.75V240a6,6,0,0,0,12,0V205.77a76.93,76.93,0,0,0,37.48-13L203.56,228a6,6,0,0,0,8.88-8.08ZM128,162a34,34,0,0,1-34-34V107.52l47.12,51.84A33.82,33.82,0,0,1,128,162Zm59.32-5A65.38,65.38,0,0,0,194,128a6,6,0,0,1,12,0,77.33,77.33,0,0,1-7.9,34.25A6,6,0,1,1,187.32,157ZM85.8,45.67A46,46,0,0,1,174,64v64a45.17,45.17,0,0,1-.25,4.81,6,6,0,0,1-6,5.38q-.31,0-.63,0a6,6,0,0,1-5.34-6.59A35.41,35.41,0,0,0,162,128V64A34,34,0,0,0,96.8,50.45a6,6,0,0,1-11-4.78Z"}))],["regular",h.createElement(h.Fragment,null,h.createElement("path",{d:"M213.92,218.62l-160-176A8,8,0,0,0,42.08,53.38L80,95.09V128a48,48,0,0,0,69.11,43.12l11.1,12.2A63.41,63.41,0,0,1,128,192a64.07,64.07,0,0,1-64-64,8,8,0,0,0-16,0,80.11,80.11,0,0,0,72,79.6V240a8,8,0,0,0,16,0V207.59a78.83,78.83,0,0,0,35.16-12.22l30.92,34a8,8,0,1,0,11.84-10.76ZM128,160a32,32,0,0,1-32-32V112.69l41.66,45.82A32,32,0,0,1,128,160Zm57.52-3.91A63.32,63.32,0,0,0,192,128a8,8,0,0,1,16,0,79.16,79.16,0,0,1-8.11,35.12,8,8,0,0,1-7.19,4.49,7.88,7.88,0,0,1-3.51-.82A8,8,0,0,1,185.52,156.09ZM84,44.87A48,48,0,0,1,176,64v64a49.19,49.19,0,0,1-.26,5,8,8,0,0,1-8,7.17,8.13,8.13,0,0,1-.84,0,8,8,0,0,1-7.12-8.79c.11-1.1.17-2.24.17-3.36V64A32,32,0,0,0,98.64,51.25,8,8,0,1,1,84,44.87Z"}))],["thin",h.createElement(h.Fragment,null,h.createElement("path",{d:"M211,221.31,51,45.31A4,4,0,0,0,45,50.69L84,93.55V128a44,44,0,0,0,66,38.12l16.38,18A67.21,67.21,0,0,1,128,196a68.07,68.07,0,0,1-68-68,4,4,0,0,0-8,0,76.09,76.09,0,0,0,72,75.89V240a4,4,0,0,0,8,0V203.89a75.1,75.1,0,0,0,39.79-13.77L205,226.69a4,4,0,1,0,5.92-5.38ZM128,164a36,36,0,0,1-36-36V102.35L144.43,160A35.83,35.83,0,0,1,128,164Zm61.12-6.15A67.44,67.44,0,0,0,196,128a4,4,0,0,1,8,0,75.28,75.28,0,0,1-7.7,33.37,4,4,0,0,1-7.18-3.52ZM87.63,46.46A44,44,0,0,1,172,64v64a44.2,44.2,0,0,1-.24,4.61,4,4,0,0,1-4,3.58l-.42,0a4,4,0,0,1-3.57-4.39A36.67,36.67,0,0,0,164,128V64A36,36,0,0,0,95,49.66a4,4,0,0,1-7.34-3.2Z"}))]]),Na=h.forwardRef((e,t)=>h.createElement(Ne,{ref:t,...e,weights:Lm}));Na.displayName="MicrophoneSlashIcon";const Bm=new Map([["bold",h.createElement(h.Fragment,null,h.createElement("path",{d:"M208,36H48A28,28,0,0,0,20,64V176a28,28,0,0,0,28,28H208a28,28,0,0,0,28-28V64A28,28,0,0,0,208,36Zm4,140a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V64a4,4,0,0,1,4-4H208a4,4,0,0,1,4,4Zm-40,52a12,12,0,0,1-12,12H96a12,12,0,0,1,0-24h64A12,12,0,0,1,172,228ZM160.49,103.51a12,12,0,0,1-17,17L140,117v35a12,12,0,0,1-24,0V117l-3.51,3.52a12,12,0,0,1-17-17l24-24a12,12,0,0,1,17,0Z"}))],["duotone",h.createElement(h.Fragment,null,h.createElement("path",{d:"M224,64V176a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V64A16,16,0,0,1,48,48H208A16,16,0,0,1,224,64Z",opacity:"0.2"}),h.createElement("path",{d:"M208,40H48A24,24,0,0,0,24,64V176a24,24,0,0,0,24,24H208a24,24,0,0,0,24-24V64A24,24,0,0,0,208,40Zm8,136a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V64a8,8,0,0,1,8-8H208a8,8,0,0,1,8,8Zm-48,48a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,224ZM157.66,106.34a8,8,0,0,1-11.32,11.32L136,107.31V152a8,8,0,0,1-16,0V107.31l-10.34,10.35a8,8,0,0,1-11.32-11.32l24-24a8,8,0,0,1,11.32,0Z"}))],["fill",h.createElement(h.Fragment,null,h.createElement("path",{d:"M168,224a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,224ZM232,64V176a24,24,0,0,1-24,24H48a24,24,0,0,1-24-24V64A24,24,0,0,1,48,40H208A24,24,0,0,1,232,64Zm-74.34,42.34-24-24a8,8,0,0,0-11.32,0l-24,24a8,8,0,0,0,11.32,11.32L120,107.31V152a8,8,0,0,0,16,0V107.31l10.34,10.35a8,8,0,0,0,11.32-11.32Z"}))],["light",h.createElement(h.Fragment,null,h.createElement("path",{d:"M208,42H48A22,22,0,0,0,26,64V176a22,22,0,0,0,22,22H208a22,22,0,0,0,22-22V64A22,22,0,0,0,208,42Zm10,134a10,10,0,0,1-10,10H48a10,10,0,0,1-10-10V64A10,10,0,0,1,48,54H208a10,10,0,0,1,10,10Zm-52,48a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,224Zm-9.76-116.24a6,6,0,1,1-8.48,8.48L134,102.49V152a6,6,0,0,1-12,0V102.49l-13.76,13.75a6,6,0,0,1-8.48-8.48l24-24a6,6,0,0,1,8.48,0Z"}))],["regular",h.createElement(h.Fragment,null,h.createElement("path",{d:"M208,40H48A24,24,0,0,0,24,64V176a24,24,0,0,0,24,24H208a24,24,0,0,0,24-24V64A24,24,0,0,0,208,40Zm8,136a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V64a8,8,0,0,1,8-8H208a8,8,0,0,1,8,8Zm-48,48a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,224ZM157.66,106.34a8,8,0,0,1-11.32,11.32L136,107.31V152a8,8,0,0,1-16,0V107.31l-10.34,10.35a8,8,0,0,1-11.32-11.32l24-24a8,8,0,0,1,11.32,0Z"}))],["thin",h.createElement(h.Fragment,null,h.createElement("path",{d:"M208,44H48A20,20,0,0,0,28,64V176a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V64A20,20,0,0,0,208,44Zm12,132a12,12,0,0,1-12,12H48a12,12,0,0,1-12-12V64A12,12,0,0,1,48,52H208a12,12,0,0,1,12,12Zm-56,48a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,224Zm-9.17-114.83a4,4,0,0,1-5.66,5.66L132,97.66V152a4,4,0,0,1-8,0V97.66l-17.17,17.17a4,4,0,0,1-5.66-5.66l24-24a4,4,0,0,1,5.66,0Z"}))]]),Pa=h.forwardRef((e,t)=>h.createElement(Ne,{ref:t,...e,weights:Bm}));Pa.displayName="MonitorArrowUpIcon";const $m=new Map([["bold",h.createElement(h.Fragment,null,h.createElement("path",{d:"M140,32V64a12,12,0,0,1-24,0V32a12,12,0,0,1,24,0Zm33.25,62.75a12,12,0,0,0,8.49-3.52L204.37,68.6a12,12,0,0,0-17-17L164.77,74.26a12,12,0,0,0,8.48,20.49ZM224,116H192a12,12,0,0,0,0,24h32a12,12,0,0,0,0-24Zm-42.26,48.77a12,12,0,1,0-17,17l22.63,22.63a12,12,0,0,0,17-17ZM128,180a12,12,0,0,0-12,12v32a12,12,0,0,0,24,0V192A12,12,0,0,0,128,180ZM74.26,164.77,51.63,187.4a12,12,0,0,0,17,17l22.63-22.63a12,12,0,1,0-17-17ZM76,128a12,12,0,0,0-12-12H32a12,12,0,0,0,0,24H64A12,12,0,0,0,76,128ZM68.6,51.63a12,12,0,1,0-17,17L74.26,91.23a12,12,0,0,0,17-17Z"}))],["duotone",h.createElement(h.Fragment,null,h.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),h.createElement("path",{d:"M136,32V64a8,8,0,0,1-16,0V32a8,8,0,0,1,16,0Zm37.25,58.75a8,8,0,0,0,5.66-2.35l22.63-22.62a8,8,0,0,0-11.32-11.32L167.6,77.09a8,8,0,0,0,5.65,13.66ZM224,120H192a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16Zm-45.09,47.6a8,8,0,0,0-11.31,11.31l22.62,22.63a8,8,0,0,0,11.32-11.32ZM128,184a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V192A8,8,0,0,0,128,184ZM77.09,167.6,54.46,190.22a8,8,0,0,0,11.32,11.32L88.4,178.91A8,8,0,0,0,77.09,167.6ZM72,128a8,8,0,0,0-8-8H32a8,8,0,0,0,0,16H64A8,8,0,0,0,72,128ZM65.78,54.46A8,8,0,0,0,54.46,65.78L77.09,88.4A8,8,0,0,0,88.4,77.09Z"}))],["fill",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm33.94,58.75,17-17a8,8,0,0,1,11.32,11.32l-17,17a8,8,0,0,1-11.31-11.31ZM48,136a8,8,0,0,1,0-16H72a8,8,0,0,1,0,16Zm46.06,37.25-17,17a8,8,0,0,1-11.32-11.32l17-17a8,8,0,0,1,11.31,11.31Zm0-79.19a8,8,0,0,1-11.31,0l-17-17A8,8,0,0,1,77.09,65.77l17,17A8,8,0,0,1,94.06,94.06ZM136,208a8,8,0,0,1-16,0V184a8,8,0,0,1,16,0Zm0-136a8,8,0,0,1-16,0V48a8,8,0,0,1,16,0Zm54.23,118.23a8,8,0,0,1-11.32,0l-17-17a8,8,0,0,1,11.31-11.31l17,17A8,8,0,0,1,190.23,190.23ZM208,136H184a8,8,0,0,1,0-16h24a8,8,0,0,1,0,16Z"}))],["light",h.createElement(h.Fragment,null,h.createElement("path",{d:"M134,32V64a6,6,0,0,1-12,0V32a6,6,0,0,1,12,0Zm39.25,56.75A6,6,0,0,0,177.5,87l22.62-22.63a6,6,0,0,0-8.48-8.48L169,78.5a6,6,0,0,0,4.24,10.25ZM224,122H192a6,6,0,0,0,0,12h32a6,6,0,0,0,0-12Zm-46.5,47A6,6,0,0,0,169,177.5l22.63,22.62a6,6,0,0,0,8.48-8.48ZM128,186a6,6,0,0,0-6,6v32a6,6,0,0,0,12,0V192A6,6,0,0,0,128,186ZM78.5,169,55.88,191.64a6,6,0,1,0,8.48,8.48L87,177.5A6,6,0,1,0,78.5,169ZM70,128a6,6,0,0,0-6-6H32a6,6,0,0,0,0,12H64A6,6,0,0,0,70,128ZM64.36,55.88a6,6,0,0,0-8.48,8.48L78.5,87A6,6,0,1,0,87,78.5Z"}))],["regular",h.createElement(h.Fragment,null,h.createElement("path",{d:"M136,32V64a8,8,0,0,1-16,0V32a8,8,0,0,1,16,0Zm37.25,58.75a8,8,0,0,0,5.66-2.35l22.63-22.62a8,8,0,0,0-11.32-11.32L167.6,77.09a8,8,0,0,0,5.65,13.66ZM224,120H192a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16Zm-45.09,47.6a8,8,0,0,0-11.31,11.31l22.62,22.63a8,8,0,0,0,11.32-11.32ZM128,184a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V192A8,8,0,0,0,128,184ZM77.09,167.6,54.46,190.22a8,8,0,0,0,11.32,11.32L88.4,178.91A8,8,0,0,0,77.09,167.6ZM72,128a8,8,0,0,0-8-8H32a8,8,0,0,0,0,16H64A8,8,0,0,0,72,128ZM65.78,54.46A8,8,0,0,0,54.46,65.78L77.09,88.4A8,8,0,0,0,88.4,77.09Z"}))],["thin",h.createElement(h.Fragment,null,h.createElement("path",{d:"M132,32V64a4,4,0,0,1-8,0V32a4,4,0,0,1,8,0Zm41.25,54.75a4,4,0,0,0,2.83-1.18L198.71,63a4,4,0,0,0-5.66-5.66L170.43,79.92a4,4,0,0,0,2.82,6.83ZM224,124H192a4,4,0,0,0,0,8h32a4,4,0,0,0,0-8Zm-47.92,46.43a4,4,0,1,0-5.65,5.65l22.62,22.63a4,4,0,0,0,5.66-5.66ZM128,188a4,4,0,0,0-4,4v32a4,4,0,0,0,8,0V192A4,4,0,0,0,128,188ZM79.92,170.43,57.29,193.05A4,4,0,0,0,63,198.71l22.62-22.63a4,4,0,1,0-5.65-5.65ZM68,128a4,4,0,0,0-4-4H32a4,4,0,0,0,0,8H64A4,4,0,0,0,68,128ZM63,57.29A4,4,0,0,0,57.29,63L79.92,85.57a4,4,0,1,0,5.65-5.65Z"}))]]),Js=h.forwardRef((e,t)=>h.createElement(Ne,{ref:t,...e,weights:$m}));Js.displayName="SpinnerIcon";const Om=new Map([["bold",h.createElement(h.Fragment,null,h.createElement("path",{d:"M249.45,69.31a12,12,0,0,0-12.51,1L212,88.43V72a20,20,0,0,0-20-20H32A20,20,0,0,0,12,72V184a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V167.57l24.94,18.14A12,12,0,0,0,256,176V80A12,12,0,0,0,249.45,69.31ZM188,180H36V76H188Zm44-27.57-20-14.54V118.11l20-14.54Z"}))],["duotone",h.createElement(h.Fragment,null,h.createElement("path",{d:"M200,72V184a8,8,0,0,1-8,8H32a8,8,0,0,1-8-8V72a8,8,0,0,1,8-8H192A8,8,0,0,1,200,72Z",opacity:"0.2"}),h.createElement("path",{d:"M251.77,73a8,8,0,0,0-8.21.39L208,97.05V72a16,16,0,0,0-16-16H32A16,16,0,0,0,16,72V184a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V159l35.56,23.71A8,8,0,0,0,248,184a8,8,0,0,0,8-8V80A8,8,0,0,0,251.77,73ZM192,184H32V72H192V184Zm48-22.95-32-21.33V116.28L240,95Z"}))],["fill",h.createElement(h.Fragment,null,h.createElement("path",{d:"M192,72V184a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V72A16,16,0,0,1,32,56H176A16,16,0,0,1,192,72Zm58,.25a8.23,8.23,0,0,0-6.63,1.22L209.78,95.86A4,4,0,0,0,208,99.19v57.62a4,4,0,0,0,1.78,3.33l33.78,22.52a8,8,0,0,0,8.58.19,8.33,8.33,0,0,0,3.86-7.17V80A8,8,0,0,0,250,72.25Z"}))],["light",h.createElement(h.Fragment,null,h.createElement("path",{d:"M250.83,74.71a6,6,0,0,0-6.16.3L206,100.79V72a14,14,0,0,0-14-14H32A14,14,0,0,0,18,72V184a14,14,0,0,0,14,14H192a14,14,0,0,0,14-14V155.21L244.67,181a6,6,0,0,0,9.33-5V80A6,6,0,0,0,250.83,74.71ZM194,184a2,2,0,0,1-2,2H32a2,2,0,0,1-2-2V72a2,2,0,0,1,2-2H192a2,2,0,0,1,2,2Zm48-19.21-36-24V115.21l36-24Z"}))],["regular",h.createElement(h.Fragment,null,h.createElement("path",{d:"M251.77,73a8,8,0,0,0-8.21.39L208,97.05V72a16,16,0,0,0-16-16H32A16,16,0,0,0,16,72V184a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V159l35.56,23.71A8,8,0,0,0,248,184a8,8,0,0,0,8-8V80A8,8,0,0,0,251.77,73ZM192,184H32V72H192V184Zm48-22.95-32-21.33V116.28L240,95Z"}))],["thin",h.createElement(h.Fragment,null,h.createElement("path",{d:"M249.89,76.47a4,4,0,0,0-4.11.2L204,104.53V72a12,12,0,0,0-12-12H32A12,12,0,0,0,20,72V184a12,12,0,0,0,12,12H192a12,12,0,0,0,12-12V151.47l41.78,27.86A4,4,0,0,0,252,176V80A4,4,0,0,0,249.89,76.47ZM196,184a4,4,0,0,1-4,4H32a4,4,0,0,1-4-4V72a4,4,0,0,1,4-4H192a4,4,0,0,1,4,4Zm48-15.47-40-26.67V114.14l40-26.67Z"}))]]),Ra=h.forwardRef((e,t)=>h.createElement(Ne,{ref:t,...e,weights:Om}));Ra.displayName="VideoCameraIcon";const _m=new Map([["bold",h.createElement(h.Fragment,null,h.createElement("path",{d:"M249.45,69.31a12,12,0,0,0-12.51,1L212,88.43V72a20,20,0,0,0-20-20H123.88a12,12,0,0,0,0,24H188v68a12,12,0,0,0,4.46,9.33c.15.13.31.25.48.38l44,32A12,12,0,0,0,256,176V80A12,12,0,0,0,249.45,69.31ZM232,152.43l-20-14.54V118.11l20-14.54ZM56.88,31.93A12,12,0,1,0,39.12,48.07L42.69,52H32A20,20,0,0,0,12,72V184a20,20,0,0,0,20,20H180.87l18.25,20.07a12,12,0,0,0,17.76-16.14ZM36,180V76H64.51l94.55,104Z"}))],["duotone",h.createElement(h.Fragment,null,h.createElement("path",{d:"M200,72V184a8,8,0,0,1-8,8H32a8,8,0,0,1-8-8V72a8,8,0,0,1,8-8H192A8,8,0,0,1,200,72Z",opacity:"0.2"}),h.createElement("path",{d:"M251.77,73a8,8,0,0,0-8.21.39L208,97.05V72a16,16,0,0,0-16-16H113.06a8,8,0,0,0,0,16H192v87.63a8,8,0,0,0,16,0V159l35.56,23.71A8,8,0,0,0,248,184a8,8,0,0,0,8-8V80A8,8,0,0,0,251.77,73ZM240,161.05l-32-21.33V116.28L240,95ZM53.92,34.62A8,8,0,1,0,42.08,45.38L51.73,56H32A16,16,0,0,0,16,72V184a16,16,0,0,0,16,16H182.64l19.44,21.38a8,8,0,1,0,11.84-10.76ZM32,184V72H66.28L168.1,184Z"}))],["fill",h.createElement(h.Fragment,null,h.createElement("path",{d:"M256,80.23v95.45a8.33,8.33,0,0,1-3.86,7.17,8,8,0,0,1-8.58-.19l-33.78-22.52a4,4,0,0,1-1.78-3.33V99.19a4,4,0,0,1,1.78-3.32l33.78-22.53a8,8,0,0,1,9.73.66A8.23,8.23,0,0,1,256,80.23ZM53.92,34.62A8,8,0,1,0,42.08,45.38L51.73,56H32A16,16,0,0,0,16,72V184a16,16,0,0,0,16,16H182.64l19.44,21.38a8,8,0,1,0,11.84-10.76ZM185,155.07a4,4,0,0,0,7-2.7V72a16,16,0,0,0-16-16H104a4,4,0,0,0-3,6.69Z"}))],["light",h.createElement(h.Fragment,null,h.createElement("path",{d:"M250.83,74.71a6,6,0,0,0-6.16.3L206,100.79V72a14,14,0,0,0-14-14H113.06a6,6,0,0,0,0,12H192a2,2,0,0,1,2,2v87.63a6,6,0,0,0,12,0v-4.42L244.67,181a6,6,0,0,0,9.33-5V80A6,6,0,0,0,250.83,74.71ZM242,164.79l-36-24V115.21l36-24ZM52.44,36A6,6,0,0,0,43.56,44L56.25,58H32A14,14,0,0,0,18,72V184a14,14,0,0,0,14,14H183.53l20,22a6,6,0,0,0,8.88-8.08ZM32,186a2,2,0,0,1-2-2V72a2,2,0,0,1,2-2H67.16L172.62,186Z"}))],["regular",h.createElement(h.Fragment,null,h.createElement("path",{d:"M251.77,73a8,8,0,0,0-8.21.39L208,97.05V72a16,16,0,0,0-16-16H113.06a8,8,0,0,0,0,16H192v87.63a8,8,0,0,0,16,0V159l35.56,23.71A8,8,0,0,0,248,184a8,8,0,0,0,8-8V80A8,8,0,0,0,251.77,73ZM240,161.05l-32-21.33V116.28L240,95ZM53.92,34.62A8,8,0,1,0,42.08,45.38L51.73,56H32A16,16,0,0,0,16,72V184a16,16,0,0,0,16,16H182.64l19.44,21.38a8,8,0,1,0,11.84-10.76ZM32,184V72H66.28L168.1,184Z"}))],["thin",h.createElement(h.Fragment,null,h.createElement("path",{d:"M249.89,76.47a4,4,0,0,0-4.11.2L204,104.53V72a12,12,0,0,0-12-12H113.06a4,4,0,0,0,0,8H192a4,4,0,0,1,4,4v87.63a4,4,0,0,0,8,0v-8.16l41.78,27.86A4,4,0,0,0,252,176V80A4,4,0,0,0,249.89,76.47ZM244,168.53l-40-26.67V114.14l40-26.67ZM51,37.31A4,4,0,0,0,45,42.69L60.78,60H32A12,12,0,0,0,20,72V184a12,12,0,0,0,12,12H184.41L205,218.69a4,4,0,1,0,5.92-5.38ZM32,188a4,4,0,0,1-4-4V72a4,4,0,0,1,4-4H68.05L177.14,188Z"}))]]),Ia=h.forwardRef((e,t)=>h.createElement(Ne,{ref:t,...e,weights:_m}));Ia.displayName="VideoCameraSlashIcon";function ji(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Hm(...e){return t=>{let n=!1;const s=e.map(o=>{const r=ji(o,t);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let o=0;o<s.length;o++){const r=s[o];typeof r=="function"?r():ji(e[o],null)}}}}function Zm(e){const t=zm(e),n=h.forwardRef((s,o)=>{const{children:r,...i}=s,l=h.Children.toArray(r),c=l.find(Km);if(c){const d=c.props.children,u=l.map(m=>m===c?h.Children.count(d)>1?h.Children.only(null):h.isValidElement(d)?d.props.children:null:m);return a.jsx(t,{...i,ref:o,children:h.isValidElement(d)?h.cloneElement(d,void 0,u):null})}return a.jsx(t,{...i,ref:o,children:r})});return n.displayName=`${e}.Slot`,n}var Um=Zm("Slot");function zm(e){const t=h.forwardRef((n,s)=>{const{children:o,...r}=n;if(h.isValidElement(o)){const i=Ym(o),l=Gm(r,o.props);return o.type!==h.Fragment&&(l.ref=s?Hm(s,i):i),h.cloneElement(o,l)}return h.Children.count(o)>1?h.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Wm=Symbol("radix.slottable");function Km(e){return h.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Wm}function Gm(e,t){const n={...t};for(const s in t){const o=e[s],r=t[s];/^on[A-Z]/.test(s)?o&&r?n[s]=(...l)=>{const c=r(...l);return o(...l),c}:o&&(n[s]=o):s==="style"?n[s]={...o,...r}:s==="className"&&(n[s]=[o,r].filter(Boolean).join(" "))}return{...e,...n}}function Ym(e){var s,o;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const qm=un.cva(["text-xs font-bold tracking-wider uppercase whitespace-nowrap","inline-flex items-center justify-center gap-2 shrink-0 rounded-full cursor-pointer outline-none transition-colors duration-300","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","disabled:pointer-events-none disabled:opacity-50","aria-invalid:ring-destructive/20 aria-invalid:border-destructive dark:aria-invalid:ring-destructive/40 ","[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0"],{variants:{variant:{default:"bg-button text-button-foreground hover:bg-muted focus:bg-muted",destructive:["bg-destructive text-destructive-foreground","hover:bg-destructive-hover focus:bg-destructive-hover focus-visible:ring-destructive-foreground/20","dark:focus-visible:ring-destructive-foreground/40"],outline:["border bg-background","hover:bg-accent hover:text-accent-foreground","dark:bg-input/30 dark:border-input dark:hover:bg-input/50"],primary:"",secondary:"bg-secondary text-secondary-foregroun hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function Xm({className:e,variant:t,size:n,asChild:s=!1,...o}){const r=s?Um:"button";return a.jsx(r,{"data-slot":"button",className:$(qm({variant:t,size:n,className:e})),...o})}function Jm({onSend:e,className:t,disabled:n,...s}){const o=y.useRef(null),[r,i]=y.useState(""),l=d=>{var u,m;d.preventDefault(),(u=s.onSubmit)==null||u.call(s,d),e==null||e(r),i(""),(m=o.current)==null||m.focus({preventScroll:!0})},c=n||r.trim().length===0;return a.jsxs("form",{...s,onSubmit:l,className:$("flex items-center rounded-md pl-1 text-sm",t),children:[a.jsx("input",{ref:o,type:"text",className:"flex-1 focus:outline-none",placeholder:"Type something...",value:r,onChange:d=>i(d.target.value),disabled:n}),a.jsx(Xm,{size:"sm",type:"submit",variant:c?"secondary":"primary",disabled:c,className:"font-mono",children:"SEND"})]})}const Qm=un.cva(["inline-flex items-center justify-center gap-2 rounded-full","text-sm font-medium whitespace-nowrap","cursor-pointer outline-none transition-[color,border,background-color]","!focus:ring-0 !focus-visible:ring-0 !focus:border-none !focus-visible:border-none !ring-0 !border-none !outline-none","aria-invalid:ring-0 dark:aria-invalid:ring-0 aria-invalid:border-0","disabled:pointer-events-none disabled:opacity-50 disabled:not-allowed","data-[state=on]:bg-button-selected data-[state=on]:border-button-border-selected","[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0"],{variants:{variant:{default:"bg-button hover:bg-muted focus:bg-muted hover:text-muted-foreground focus:text-muted-foreground",primary:"text-fg1 bg-button hover:bg-button-hover focus:bg-button-hover data-[state=off]:bg-button-primary hover:data-[state=off]:bg-button-hover data-[state=off]:text-button-primary-foreground",secondary:"text-fg1 bg-button hover:bg-button-hover focus:bg-button-hover data-[state=on]:bg-button-secondary hover:data-[state=on]:bg-button-secondary data-[state=on]:text-button-secondary-foreground",outline:["border border-button-border bg-button text-button-foreground","hover:bg-background focus:bg-background"]},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-1.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}});function Da({className:e,variant:t,size:n,...s}){return a.jsx(ml.Root,{"data-slot":"toggle",className:$(Qm({variant:t,size:n,className:e})),...s})}function ef(e){const[t,n]=y.useState(()=>e.getPublishPermissions());return y.useEffect(()=>{const s=()=>{n(e.getPublishPermissions())},o=()=>{s()};return e.on("connection.connected",o),e.on("connection.disconnected",o),()=>{e.off("connection.connected",o),e.off("connection.disconnected",o)}},[e]),t}function tf(e){const[t,n]=y.useState(()=>e.getLocalParticipant()),[s,o]=y.useState(()=>e.getMicrophoneTrack());return y.useEffect(()=>{const r=()=>{const l=e.getLocalParticipant(),c=e.getMicrophoneTrack();console.log("🎤 useVoxketLocalParticipant: Updating state:",{hasParticipant:!!l,hasMicTrack:!!c,isMicEnabled:e.isMicrophoneEnabled,trackPublications:l?l.trackPublications.size:0}),n(l),o(c)};r(),e.on("connection.connected",r),e.on("connection.disconnected",r),e.on("track.muted",r),e.on("track.unmuted",r);const i=e.getRoom();if(i){const l=()=>{console.log("🎤 Track published, updating participant state"),r()},c=()=>{console.log("🎤 Track unpublished, updating participant state"),r()};return i.on("localTrackPublished",l),i.on("localTrackUnpublished",c),()=>{e.off("connection.connected",r),e.off("connection.disconnected",r),e.off("track.muted",r),e.off("track.unmuted",r),i.off("localTrackPublished",l),i.off("localTrackUnpublished",c)}}else return()=>{e.off("connection.connected",r),e.off("connection.disconnected",r),e.off("track.muted",r),e.off("track.unmuted",r)}},[e]),{localParticipant:t,microphoneTrack:s}}function Bn(e,t,n){const[s,o]=y.useState(!1),[r,i]=y.useState(!1);return y.useEffect(()=>{const c=()=>{let d=!1;switch(t){case"microphone":d=e.isMicrophoneEnabled;break;case"camera":d=e.isCameraEnabled;break;case"screenShare":d=e.isScreenShareEnabled;break}console.log(`useVoxketTrackToggle: ${t} enabled state updated to:`,d),o(d)};return c(),e.on("track.muted",c),e.on("track.unmuted",c),e.on("connection.connected",c),()=>{e.off("track.muted",c),e.off("track.unmuted",c),e.off("connection.connected",c)}},[e,t]),{enabled:s,pending:r,toggle:async c=>{var d;try{i(!0);const u=c!==void 0?c:!s;switch(t){case"microphone":await e.toggleMicrophone(u);break;case"camera":await e.toggleCamera(u);break;case"screenShare":u?await e.startScreenShare():await e.stopScreenShare();break}}catch(u){(d=n==null?void 0:n.onDeviceError)==null||d.call(n,u)}finally{i(!1)}}}}function nf(e){const[t,n]=y.useState(()=>e.getRoom()),[s,o]=y.useState(()=>e.getConnectionState());return y.useEffect(()=>{const r=()=>{n(e.getRoom()),o(e.getConnectionState())};return e.on("connection.connected",r),e.on("connection.disconnected",r),e.on("connection.connecting",r),()=>{e.off("connection.connected",r),e.off("connection.disconnected",r),e.off("connection.connecting",r)}},[e]),t}function sf(e,t){const[n,s]=y.useState([]),[o,r]=y.useState("");return y.useEffect(()=>{var d;const l=async()=>{try{const u=t==="audioinput"?await e.getAudioInputDevices():await e.getVideoInputDevices();s(u)}catch(u){console.error("Failed to load devices:",u)}};l();const c=()=>{l()};return(d=navigator.mediaDevices)==null||d.addEventListener("devicechange",c),()=>{var u;(u=navigator.mediaDevices)==null||u.removeEventListener("devicechange",c)}},[e,t]),{devices:n,activeDeviceId:o,setActiveMediaDevice:async l=>{try{t==="audioinput"?await e.setAudioInputDevice(l):await e.setVideoInputDevice(l),r(l)}catch(c){console.error("Failed to set device:",c)}}}}function of(e){const{preventSave:t=!1}=e||{};return{saveAudioInputEnabled:i=>{t||localStorage.setItem("voxket-audio-input-enabled",i.toString())},saveAudioInputDeviceId:i=>{t||localStorage.setItem("voxket-audio-input-device-id",i)},saveVideoInputEnabled:i=>{t||localStorage.setItem("voxket-video-input-enabled",i.toString())},saveVideoInputDeviceId:i=>{t||localStorage.setItem("voxket-video-input-device-id",i)}}}function Ei({...e}){return a.jsx(Ee.Root,{"data-slot":"select",...e})}function Ai({...e}){return a.jsx(Ee.Value,{"data-slot":"select-value",...e})}function Mi({className:e,size:t="default",children:n,...s}){return a.jsxs(Ee.Trigger,{"data-slot":"select-trigger","data-size":t,className:$(["flex w-fit cursor-pointer items-center justify-between gap-2","rounded-full px-3 py-2 text-sm whitespace-nowrap","bg-button transition-[color,border,background-color]","disabled:cursor-not-allowed disabled:opacity-50","hover:bg-muted hover:text-muted-foreground","!focus:ring-0 !focus-visible:ring-0 !focus:border-none !focus-visible:border-none !ring-0 !border-none !outline-none","aria-invalid:ring-0 dark:aria-invalid:ring-0","data-[placeholder]:text-muted-foreground","data-[size=default]:h-9 data-[size=sm]:h-8","*:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2","[&:not([class*='text-'])_svg:not([class*='text-'])]:text-muted-foreground","[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"],e),...s,children:[n,a.jsx(Ee.Icon,{asChild:!0,children:a.jsx(Xs,{weight:"bold",className:"size-4 transition-colors"})})]})}function Ti({className:e,children:t,position:n="popper",...s}){return a.jsx(Ee.Portal,{children:a.jsxs(Ee.Content,{"data-slot":"select-content",className:$(["bg-[#18182a]/90 backdrop-blur-md text-white border border-[#23233a] shadow-2xl","relative z-50 overflow-x-hidden overflow-y-auto rounded-xl","max-h-(--radix-select-content-available-height) min-w-[8rem]","origin-(--radix-select-content-transform-origin)","data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95","data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95","data-[side=top]:slide-in-from-bottom-2","data-[side=right]:slide-in-from-left-2","data-[side=bottom]:slide-in-from-top-2","data-[side=left]:slide-in-from-right-2"],n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...s,children:[a.jsx(rf,{}),a.jsx(Ee.Viewport,{className:$("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),a.jsx(af,{})]})})}function Vi({className:e,children:t,...n}){return a.jsxs(Ee.Item,{"data-slot":"select-item",className:$(["relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none","cursor-pointer disabled:cursor-not-allowed","focus:bg-accent focus:text-accent-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50","*:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2","[&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"],e),...n,children:[a.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:a.jsx(Ee.ItemIndicator,{children:a.jsx(Ta,{className:"size-4",weight:"bold"})})}),a.jsx(Ee.ItemText,{children:t})]})}function rf({className:e,...t}){return a.jsx(Ee.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:$("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(Aa,{className:"size-4",weight:"bold"})})}function af({className:e,...t}){return a.jsx(Ee.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:$("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(Xs,{className:"size-4",weight:"bold"})})}const Ni=un.cva(["w-full rounded-full px-3 py-2 text-sm cursor-pointer","disabled:not-allowed hover:bg-button-hover focus:bg-button-hover"],{variants:{size:{default:"w-[180px]",sm:"w-auto"}},defaultVariants:{size:"default"}});function Pi({kind:e,track:t,requestPermissions:n,onError:s,client:o,...r}){const i=r.size||"default";if(!o)return a.jsxs(Ei,{disabled:!0,children:[a.jsx(Mi,{className:$(Ni({size:i}),r.className),children:a.jsx(Ai,{placeholder:`Select a ${e}`})}),a.jsx(Ti,{children:a.jsx(Vi,{value:"none",children:"No devices available"})})]});const{devices:l,activeDeviceId:c,setActiveMediaDevice:d}=sf(o,e==="audioinput"?"audioinput":"videoinput");return a.jsxs(Ei,{value:c,onValueChange:d,children:[a.jsx(Mi,{className:$(Ni({size:i}),r.className,"hover:bg"),children:i!=="sm"&&a.jsx(Ai,{className:"font-mono text-sm",placeholder:`Select a ${e}`})}),a.jsx(Ti,{children:l.map(u=>a.jsx(Vi,{value:u.deviceId,className:"font-mono text-xs",children:u.label},u.deviceId))})]})}function lf(e,t,n=!1){if(n)return Js;switch(e){case I.Track.Source.Microphone:return t?Va:Na;case I.Track.Source.Camera:return t?Ra:Ia;case I.Track.Source.ScreenShare:return Pa;default:return h.Fragment}}function $n({source:e,pressed:t,pending:n,className:s,...o}){const r=lf(e,t??!1,n),i=e===I.Track.Source.Microphone&&!(t??!1)&&!n,l=e===I.Track.Source.Camera&&!(t??!1)&&!n;return h.useEffect(()=>{console.log(`TrackToggle for ${e} changed: pressed=${t}, pending=${n}, actualState=${t?"enabled":"disabled"}`)},[e,t,n]),a.jsxs(Da,{pressed:t,"aria-label":`Toggle ${e}`,className:$(s),...o,children:[a.jsx(r,{weight:"bold",className:$(n&&"animate-spin",i||l?"text-red-500":void 0)}),o.children]})}function cf(e){return e?ef(e):{camera:!0,microphone:!0,screenShare:!0,data:!0}}function df(e={}){const{controls:t,saveUserChoices:n=!0,client:s}=e,o={leave:!0,...t};if(!s)return{micTrackRef:{participant:void 0,source:I.Track.Source.Microphone,publication:void 0},visibleControls:o,microphoneToggle:{enabled:!1,pending:!1,toggle:async()=>{}},cameraToggle:{enabled:!1,pending:!1,toggle:async()=>{}},screenShareToggle:{enabled:!1,pending:!1,toggle:async()=>{}},handleDisconnect:()=>{},handleAudioDeviceChange:()=>{},handleVideoDeviceChange:()=>{}};const{microphoneTrack:r,localParticipant:i}=tf(s),l=cf(s);nf(s);const c=Bn(s,"microphone",{onDeviceError:A=>{var j;return(j=e.onDeviceError)==null?void 0:j.call(e,{source:I.Track.Source.Microphone,error:A})}}),d=Bn(s,"camera",{onDeviceError:A=>{var j;return(j=e.onDeviceError)==null?void 0:j.call(e,{source:I.Track.Source.Camera,error:A})}}),u=Bn(s,"screenShare",{onDeviceError:A=>{var j;return(j=e.onDeviceError)==null?void 0:j.call(e,{source:I.Track.Source.ScreenShare,error:A})}}),m=h.useMemo(()=>{let A;if(i){for(const[,j]of i.trackPublications)if(j.source===I.Track.Source.Microphone){A=j;break}}return console.log("🎤 Creating micTrackRef:",{hasParticipant:!!i,hasPublication:!!A,isTrackSubscribed:A==null?void 0:A.isSubscribed,isMuted:A==null?void 0:A.isMuted,trackSid:A==null?void 0:A.trackSid}),{participant:i??void 0,source:I.Track.Source.Microphone,publication:A}},[i,r]);o.microphone??(o.microphone=l.microphone),o.screenShare??(o.screenShare=l.screenShare),o.camera??(o.camera=l.camera),o.chat??(o.chat=l.data);const{saveAudioInputEnabled:f,saveAudioInputDeviceId:p,saveVideoInputEnabled:g,saveVideoInputDeviceId:x}=of({preventSave:!n}),v=h.useCallback(()=>{s&&s.disconnect()},[s]),E=h.useCallback(A=>{p(A??"default"),s&&s.setAudioInputDevice(A)},[p,s]),b=h.useCallback(A=>{x(A??"default"),s&&s.setVideoInputDevice(A)},[x,s]),S=h.useCallback(async A=>{u.enabled&&await u.toggle(!1),await d.toggle(A),g(!d.enabled)},[d,g,u]),w=h.useCallback(async A=>{await c.toggle(A),f(!c.enabled)},[c,f]),C=h.useCallback(async A=>{d.enabled&&await d.toggle(!1),await u.toggle(A)},[d,u]);return{micTrackRef:m,visibleControls:o,cameraToggle:{...d,toggle:S},microphoneToggle:{...c,toggle:w},screenShareToggle:{...u,toggle:C},handleDisconnect:v,handleAudioDeviceChange:E,handleVideoDeviceChange:b}}const uf={card:" bg-gradient-to-br from-black to-gray-900 border border-gray-900 w-full h-full flex flex-col justify-between overflow-hidden mx-auto my-auto rounded-2xl shadow-lg",cardTopGradient:"pointer-events-none absolute top-0 left-0 w-full h-10 z-10 bg-gradient-to-b from-black/90 to-transparent",cardRadial:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-gray-800/20 via-transparent to-transparent",cardPurpleBlur:"absolute top-0 right-0 w-32 h-32 bg-gradient-to-br from-gray-600/10 to-transparent rounded-full blur-2xl",cardPinkBlur:"absolute bottom-0 left-0 w-24 h-24 bg-gradient-to-tr from-gray-500/8 to-transparent rounded-full blur-xl",cardPulse1:"absolute -top-2 -left-2 w-6 h-6 bg-gradient-to-br from-gray-400 to-gray-500 rounded-full blur-sm opacity-20 animate-pulse",cardPulse2:"absolute -bottom-2 -right-2 w-4 h-4 bg-gradient-to-br from-gray-500 to-gray-600 rounded-full blur-sm opacity-15 animate-pulse",main:"w-full flex flex-col items-center justify-center max-w-md mx-auto bg-gradient-to-br from-black to-gray-900 rounded-2xl shadow-xl p-0 overflow-hidden h-full",text:{primary:"text-white",secondary:"text-gray-300",muted:"text-gray-400",accent:"bg-clip-text text-transparent bg-gradient-to-r from-white via-gray-200 to-gray-300"},micButton:"absolute w-20 h-20 bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 mic-glow shadow-2xl group",chatButton:"absolute w-20 h-20 bg-gradient-to-br from-[#10B981] to-[#059669] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",videoButton:"absolute w-20 h-20 bg-gradient-to-br from-[#8B5CF6] to-[#EC4899] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",popupTrigger:"bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] text-white font-medium hover:from-[#2563EB] hover:to-[#7C3AED] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-gray-900",promptSlider:"absolute w-full py-3 px-2 bg-gray-900 rounded-xl text-center text-white text-sm transition-opacity duration-700 ease-in-out border border-gray-600",statusIndicator:"w-2 h-2 bg-gray-400 rounded-full animate-pulse",pulseRings:{ring1:"w-32 h-32 rounded-full border-2 border-gray-600/30 pulse-ring",ring2:"absolute w-28 h-28 rounded-full border-2 border-gray-500/20 pulse-ring",ring3:"absolute w-24 h-24 rounded-full border-2 border-gray-400/15 pulse-ring"},controlBar:"border border-gray-600 rounded-3xl py-4 flex flex-col justify-end h-full bg-gray-900/50 backdrop-blur-sm",chatInput:{container:"bg-gray-900 w-full border-gray-600",textarea:"bg-gray-800 border-none text-white placeholder-gray-400",sendButton:"bg-blue-600 hover:bg-blue-700 disabled:bg-gray-600 disabled:opacity-50 text-white",attachButton:"text-gray-400 hover:text-gray-300 hover:bg-gray-700",endButton:"bg-red-900/20 hover:bg-red-800/30 text-red-400 border-red-800"},chatMessage:{own:"bg-gray-600 text-white",other:"bg-gray-700 text-white"},chatHeader:{container:"bg-gray-900 border-gray-600",backButton:"text-gray-400 hover:text-white hover:bg-gray-700"},spinner:"w-10 h-10 animate-spin text-gray-400 mb-2",suggestedResponse:{container:"bg-gray-800 text-blue-300 border-gray-700 hover:bg-gray-700 hover:text-white"},video:{container:"bg-gradient-to-br from-black to-gray-900 text-white",header:"border-gray-700 bg-gray-900/50",headerButton:"bg-gray-800 hover:bg-gray-700 text-gray-300",statusDot:"bg-green-500 animate-pulse",controlsBackground:"bg-gray-900/80 backdrop-blur-sm border-t border-gray-700",controlEnabled:"bg-blue-600 hover:bg-blue-700 text-white",controlDisabled:"bg-gray-700 hover:bg-gray-600 text-gray-300",endCall:"bg-red-600 hover:bg-red-700 text-white",tile:"bg-gray-800 border border-gray-700 shadow-lg",placeholder:"bg-gray-800 text-gray-300",avatar:"bg-gray-700 text-gray-300",nameOverlay:"bg-black/70 text-white",mutedIndicator:"bg-red-600/80 text-white"}},hf={card:" bg-gradient-to-br from-white to-gray-50 border border-gray-200 w-full h-full flex flex-col justify-between overflow-hidden mx-auto my-auto shadow-lg",cardTopGradient:"pointer-events-none absolute top-0 left-0 w-full h-10 z-10 bg-gradient-to-b from-white/90 to-transparent",cardRadial:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-blue-500/5 via-transparent to-transparent",cardPurpleBlur:"absolute top-0 right-0 w-32 h-32 bg-gradient-to-br from-purple-500/10 to-transparent rounded-full blur-2xl",cardPinkBlur:"absolute bottom-0 left-0 w-24 h-24 bg-gradient-to-tr from-pink-500/8 to-transparent rounded-full blur-xl",cardPulse1:"absolute -top-2 -left-2 w-6 h-6 bg-gradient-to-br from-blue-500 to-purple-500 rounded-full blur-sm opacity-30 animate-pulse",cardPulse2:"absolute -bottom-2 -right-2 w-4 h-4 bg-gradient-to-br from-pink-500 to-purple-500 rounded-full blur-sm opacity-20 animate-pulse",main:"w-full flex flex-col items-center justify-center max-w-md mx-auto bg-gradient-to-br from-white to-gray-50 rounded-2xl shadow-xl p-0 overflow-hidden h-full",text:{primary:"text-gray-900",secondary:"text-gray-700",muted:"text-gray-500",accent:"bg-clip-text text-transparent bg-gradient-to-r from-blue-600 via-purple-600 to-pink-600"},micButton:"absolute text-white w-20 h-20 bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 mic-glow shadow-2xl group",chatButton:"absolute text-white w-20 h-20 bg-gradient-to-br from-[#10B981] to-[#059669] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",videoButton:"absolute text-white w-20 h-20 bg-gradient-to-br from-[#8B5CF6] to-[#EC4899] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",popupTrigger:"bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] text-white font-medium hover:from-[#2563EB] hover:to-[#7C3AED] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-white",promptSlider:"absolute w-full py-3 px-2 bg-gray-100 rounded-xl text-center text-gray-700 text-sm transition-opacity duration-700 ease-in-out border border-gray-200",statusIndicator:"w-2 h-2 bg-green-500 rounded-full animate-pulse",pulseRings:{ring1:"w-32 h-32 rounded-full border-2 border-blue-500/20 pulse-ring",ring2:"absolute w-28 h-28 rounded-full border-2 border-purple-500/15 pulse-ring",ring3:"absolute w-24 h-24 rounded-full border-2 border-pink-500/10 pulse-ring"},controlBar:"border border-gray-200 rounded-3xl py-4 flex flex-col justify-end h-full bg-white/80 backdrop-blur-sm",chatInput:{container:"bg-white/90 border-gray-200 shadow-sm",textarea:"bg-white border-none text-gray-900 placeholder-gray-500 ",sendButton:"bg-blue-600 hover:bg-blue-700 disabled:bg-gray-300 disabled:opacity-50 text-white",attachButton:"text-gray-500 hover:text-gray-700 hover:bg-gray-100 bg-blue-50",endButton:"bg-red-50 hover:bg-red-100 text-red-600 border-red-200"},chatMessage:{own:"bg-blue-50 text-gray-900 border border-blue-100",other:"bg-gray-50 text-gray-900 border border-gray-200"},chatHeader:{container:"bg-white border-gray-200",backButton:"text-gray-500 hover:text-gray-700 hover:bg-gray-100"},spinner:"w-10 h-10 animate-spin text-blue-500 mb-2",suggestedResponse:{container:"bg-white text-blue-700 border-blue-200 hover:bg-blue-50 hover:text-blue-900"},video:{container:"bg-gradient-to-br from-white to-gray-50 text-gray-900",header:"border-gray-200 bg-white/80",headerButton:"bg-gray-100 hover:bg-gray-200 text-gray-600",statusDot:"bg-green-500 animate-pulse",controlsBackground:"bg-white/90 backdrop-blur-sm border-t border-gray-200",controlEnabled:"bg-blue-600 hover:bg-blue-700 text-white",controlDisabled:"bg-gray-200 hover:bg-gray-300 text-gray-600",endCall:"bg-red-600 hover:bg-red-700 text-white",tile:"bg-white border border-gray-200 shadow-sm",placeholder:"bg-gray-50 text-gray-600",avatar:"bg-gray-200 text-gray-600",nameOverlay:"bg-black/70 text-white",mutedIndicator:"bg-red-600/80 text-white"}},mf={card:" text-white bg-gradient-to-br from-[#171727] to-[#12121F] border border-gray-800 w-full h-full flex flex-col justify-between overflow-hidden mx-auto my-auto",cardTopGradient:"pointer-events-none absolute top-0 left-0 w-full h-10 z-10 bg-gradient-to-b from-[#171727]/90 to-transparent",cardRadial:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-[#3B82F6]/15 via-transparent to-transparent",cardPurpleBlur:"absolute top-0 right-0 w-32 h-32 bg-gradient-to-br from-[#8B5CF6]/25 to-transparent rounded-full blur-2xl",cardPinkBlur:"absolute bottom-0 left-0 w-24 h-24 bg-gradient-to-tr from-[#EC4899]/20 to-transparent rounded-full blur-xl",cardPulse1:"absolute -top-2 -left-2 w-6 h-6 bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] rounded-full blur-sm opacity-50 animate-pulse",cardPulse2:"absolute -bottom-2 -right-2 w-4 h-4 bg-gradient-to-br from-[#EC4899] to-[#8B5CF6] rounded-full blur-sm opacity-40 animate-pulse",main:"w-full flex flex-col items-center justify-center max-w-md mx-auto bg-gradient-to-br from-[#171727] to-[#12121F] rounded-2xl shadow-xl p-0 overflow-hidden h-full",text:{primary:"text-white",secondary:"text-gray-300",muted:"text-gray-400",accent:"bg-clip-text text-transparent bg-gradient-to-r from-[#3B82F6] via-[#8B5CF6] to-[#EC4899]"},micButton:"absolute w-20 h-20 bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 mic-glow shadow-2xl group",chatButton:"absolute w-20 h-20 bg-gradient-to-br from-[#10B981] to-[#059669] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",videoButton:"absolute w-20 h-20 bg-gradient-to-br from-[#8B5CF6] to-[#EC4899] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",popupTrigger:"bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] text-white font-medium hover:from-[#2563EB] hover:to-[#7C3AED] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-gray-900 shadow-xl",promptSlider:"absolute w-full py-3 px-2 bg-[#1E1E2E] rounded-xl text-center text-gray-200 text-sm transition-opacity duration-700 ease-in-out border border-gray-700",statusIndicator:"w-2 h-2 bg-[#10B981] rounded-full animate-pulse",pulseRings:{ring1:"w-32 h-32 rounded-full border-2 border-[#3B82F6]/40 pulse-ring",ring2:"absolute w-28 h-28 rounded-full border-2 border-[#8B5CF6]/30 pulse-ring",ring3:"absolute w-24 h-24 rounded-full border-2 border-[#EC4899]/20 pulse-ring"},controlBar:"border border-border rounded-3xl py-4 flex flex-col justify-end h-full",chatInput:{container:"bg-[#1E1E2E] border-gray-700",textarea:"bg-[#1E1E2E] border-none text-white placeholder-gray-400",sendButton:"bg-[#3B82F6] hover:bg-[#2563EB] disabled:bg-gray-600 disabled:opacity-50 text-white",attachButton:"text-gray-400 hover:text-gray-300 hover:bg-gray-700",endButton:"bg-red-900/20 hover:bg-red-800/30 text-red-400 border-red-800"},chatMessage:{own:"bg-[#1E1E2E]/80 text-white",other:"bg-[#1E1E2E] text-white border border-gray-700"},chatHeader:{container:"bg-[#1E1E2E] border-gray-700",backButton:"text-gray-400 hover:text-white hover:bg-gray-700"},spinner:"w-10 h-10 animate-spin text-blue-400 mb-2",suggestedResponse:{container:"bg-[#221f3f] text-white border-none"},video:{container:"bg-gradient-to-br from-[#171727] to-[#12121F] text-white",header:"border-gray-700 bg-[#1E1E2E]/80",headerButton:"bg-[#1E1E2E] hover:bg-gray-700 text-gray-300",statusDot:"bg-[#10B981] animate-pulse",controlsBackground:"bg-[#1E1E2E]/90 backdrop-blur-sm border-t border-gray-700",controlEnabled:"bg-[#3B82F6] hover:bg-[#2563EB] text-white",controlDisabled:"bg-gray-700 hover:bg-gray-600 text-gray-300",endCall:"bg-red-600 hover:bg-red-700 text-white",tile:"bg-[#1E1E2E] border border-gray-700 shadow-xl",placeholder:"bg-[#1E1E2E] text-gray-300",avatar:"bg-gray-700 text-gray-300",nameOverlay:"bg-black/70 text-white",mutedIndicator:"bg-red-600/80 text-white"}},Ri={dark:uf,light:hf,vox:mf};function ye(e){return Ri[e]||Ri.vox}function ff({controls:e,saveUserChoices:t=!0,capabilities:n,className:s,onSendMessage:o,onChatOpenChange:r,onDisconnect:i,onDeviceError:l,theme:c="vox",client:d,...u}){const[m,f]=h.useState(!1),[p,g]=h.useState(!1),x=ye(c),{micTrackRef:v,visibleControls:E,cameraToggle:b,microphoneToggle:S,screenShareToggle:w,handleAudioDeviceChange:C,handleVideoDeviceChange:A,handleDisconnect:j}=df({controls:e,saveUserChoices:t,client:d}),k=async D=>{g(!0);try{await(o==null?void 0:o(D))}finally{g(!1)}};return h.useEffect(()=>{r==null||r(m)},[m,r]),h.useEffect(()=>{var D,L,W,H;console.log("🎤 AgentControlBar: micTrackRef changed:",{hasParticipant:!!v.participant,hasPublication:!!v.publication,source:v.source,isSubscribed:(D=v.publication)==null?void 0:D.isSubscribed,isMuted:(L=v.publication)==null?void 0:L.isMuted,trackSid:(W=v.publication)==null?void 0:W.trackSid,hasTrack:!!((H=v.publication)!=null&&H.track)})},[v]),a.jsxs("div",{"aria-label":"Voice assistant controls",className:$(x.controlBar,s),...u,children:[n.suportsChatInput&&a.jsxs("div",{inert:!m,className:$("overflow-hidden transition-[height] relative duration-300 ease-in-out",m?"h-[64px] mb-3":"h-0"),children:[a.jsx("div",{className:"flex h-9 px-4 w-full",children:a.jsx(Jm,{onSend:k,disabled:p,className:$("w-full",x.chatInput)})}),a.jsx("hr",{className:"border-border my-2 mx-5"})]}),a.jsxs("div",{className:$("flex flex-row items-center gap-2 rounded-2xl mx-auto border-none backdrop-blur-lg px-2 py-2",c==="light"?"bg-white/80":"bg-[#18182a]/80"),children:[a.jsxs("div",{className:"flex gap-y-2 justify-start",children:[E.microphone&&a.jsxs("div",{className:"flex gap-y-2 items-center rounded-full overflow-hidden border-none ",children:[a.jsx($n,{variant:"primary",source:I.Track.Source.Microphone,pressed:S.enabled,disabled:S.pending,onPressedChange:S.toggle,className:"w-auto py-2 rounded-none border-none bg-transparent text-inherit focus:bg-primary/80 hover:bg-primary/80 transition-colors"}),a.jsx(ue.BarVisualizer,{barCount:3,trackRef:v,options:{minHeight:5},className:"flex h-full w-auto items-center justify-center gap-x-0.5",children:a.jsx("span",{className:$(["h-full w-0.5 origin-center rounded-2xl","bg-white","group-data-[state=on]/track:bg-white group-data-[state=off]/track:bg-white","data-lk-muted:bg-muted"])})}),a.jsx(Pi,{size:"sm",kind:"audioinput",client:d,onError:l?D=>D instanceof Error?l({source:I.Track.Source.Microphone,error:D}):void 0:void 0,onActiveDeviceChange:C,className:$(["h-full py-2 rounded-none border-none bg-transparent text-inherit focus:bg-primary/80 hover:bg-primary/30 transition-colors","min-w-[2.5rem]"])})]}),n.suportsVideoInput&&E.camera&&a.jsxs("div",{className:"flex items-center rounded-full overflow-hidden border-none ",children:[a.jsx($n,{variant:"primary",source:I.Track.Source.Camera,pressed:b.enabled,pending:b.pending,disabled:b.pending,onPressedChange:b.toggle,className:"w-auto py-2 rounded-none border-none bg-transparent text-inherit focus:bg-primary/80 hover:bg-primary/80 transition-colors"}),a.jsx(Pi,{size:"sm",kind:"videoinput",client:d,onError:l?D=>D instanceof Error?l({source:I.Track.Source.Camera,error:D}):void 0:void 0,onActiveDeviceChange:A,className:$(["h-full py-2 rounded-none border-none bg-transparent text-inherit focus:bg-primary/80 hover:bg-primary/80 transition-colors","min-w-[2.5rem]"])})]}),n.suportsScreenShare&&E.screenShare&&a.jsx("div",{className:"flex items-center rounded-full overflow-hidden border-none ",children:a.jsx($n,{variant:"secondary",source:I.Track.Source.ScreenShare,pressed:w.enabled,disabled:w.pending,onPressedChange:w.toggle,className:"w-auto py-2 disabled:opacity-70 rounded-none border-none bg-transparent text-inherit focus:bg-primary/80 hover:bg-primary/80 transition-colors"})})]}),E.chat&&a.jsx("div",{className:"flex items-center rounded-full overflow-hidden bg-secondary text-secondary-foreground border-none ",children:a.jsx(Da,{variant:"secondary","aria-label":"Toggle chat",pressed:m,onPressedChange:D=>{f(D)},className:"aspect-square h-full py-3 rounded-none border-none bg-transparent text-inherit focus:bg-secondary/80 hover:bg-secondary/80 transition-colors flex items-center",children:a.jsx(Ma,{weight:"bold",className:"h-5 w-5"})})})]})]})}const pf=(e,t)=>{var l,c;const n=h.useMemo(()=>t?t(e.message):e.message,[e.message,t]),s=!!e.editTimestamp,o=new Date(e.timestamp),r=typeof navigator<"u"?navigator.language:"en-US",i=(l=e.from)!=null&&l.name&&e.from.name!==""?e.from.name:(c=e.from)==null?void 0:c.identity;return{message:n,hasBeenEdited:s,time:o,locale:r,name:i}},gf=({entry:e,messageFormatter:t,className:n,participantName:s,...o})=>{var u,m;const{message:r,time:i,locale:l}=pf(e,t),c=((u=e.from)==null?void 0:u.isLocal)??!1;$("w-full px-3 py-2 rounded-2xl text-xs break-words whitespace-pre-line",c?" text-end border border-[#5078F2]/30":"bg-muted text-foreground border border-[#813aa7]/30","text-left");const d=$("inline-flex items-center justify-center w-6 h-6 rounded-full text-xs font-bold flex-shrink-0",c?"bg-[#5078F2] text-white":"bg-[#813aa7] ml-1 text-white");return a.jsx("li",{title:i.toLocaleTimeString(l,{timeStyle:"full"}),className:$("group flex mb-2",c?"justify-end":"justify-start",n),...o,children:a.jsxs("div",{className:$("flex w-fit max-w-full rounded-2xl border",c?"flex-row-reverse items-center border-[#5078F2]/30":"flex-row items-center border-[#813aa7]/30 bg-muted text-foreground"),children:[a.jsx("span",{className:d,children:c?((m=s==null?void 0:s[0])==null?void 0:m.toUpperCase())||"U":"A"}),a.jsx("span",{className:$("flex items-center text-xs break-words whitespace-pre-line",c?"ml-auto justify-end text-right":"justify-start text-left","px-3 py-2"),children:r})]})})};function xf(e){y.useEffect(()=>{function t(){const n=e.current;n&&(n.scrollTop=n.scrollHeight)}if(e.current){const n=new ResizeObserver(t);return n.observe(e.current),t(),()=>n.disconnect()}},[e])}const yf=({className:e,children:t,...n})=>{const s=y.useRef(null);return xf(s),a.jsx("div",{ref:s,className:$("flex flex-col justify-end",e),...n,children:t})},bf=({state:e,audioTrack:t,className:n,ref:s})=>a.jsx("div",{ref:s,className:$("",n),children:a.jsx(ue.BarVisualizer,{barCount:5,state:e,options:{minHeight:5},trackRef:t,className:$("flex aspect-video w-40 items-center justify-center gap-1"),children:a.jsx("span",{className:$(["bg-[#6721a4] min-h-2 w-2 rounded-full","origin-center transition-colors duration-250 ease-linear","data-[lk-highlighted=true]:bg-[#5c64f6]","data-[lk-muted=true]:bg-[#222222]"])})})}),vf=({videoTrack:e,className:t,ref:n})=>{var s,o;return a.jsx("div",{ref:n,className:$(t),children:a.jsx(ue.VideoTrack,{trackRef:e,width:((s=e==null?void 0:e.publication.dimensions)==null?void 0:s.width)??0,height:((o=e==null?void 0:e.publication.dimensions)==null?void 0:o.height)??0,className:"rounded-md"})})},wf=Q.create(ue.VideoTrack),Sf=({trackRef:e,className:t,ref:n})=>{var s,o;return a.jsx("div",{className:$("bg-muted overflow-hidden rounded-md",t),children:a.jsx(wf,{ref:n,trackRef:e,width:((s=e==null?void 0:e.publication.dimensions)==null?void 0:s.width)??0,height:((o=e==null?void 0:e.publication.dimensions)==null?void 0:o.height)??0,className:$("h-full w-auto")})})},Ii=Q.create(Sf),Cf=Q.create(bf),kf=Q.create(vf),Le={initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},exit:{opacity:0,scale:0},transition:{type:"spring",stiffness:675,damping:75,mass:1}},ot={grid:["h-full w-full","grid gap-x-2 place-content-center","grid-cols-[1fr_1fr] grid-rows-[90px_1fr_90px]"],agentChatOpenWithSecondTile:["col-start-1 row-start-1","self-center justify-self-end"],agentChatOpenWithoutSecondTile:["col-start-1 row-start-1","col-span-2","place-content-center"],agentChatClosed:["col-start-1 row-start-1","col-span-2 row-span-3","place-content-center"],secondTileChatOpen:["col-start-2 row-start-1","self-center justify-self-start"],secondTileChatClosed:["col-start-2 row-start-3","place-content-end"]};function jf(e){const{localParticipant:t}=ue.useLocalParticipant(),n=t.getTrackPublication(e);return y.useMemo(()=>n?{source:e,participant:t,publication:n}:void 0,[e,n,t])}function Ef({chatOpen:e}){const{state:t,audioTrack:n,videoTrack:s,agent:{isActive:o=!1}={}}=ue.useVoiceAssistant(),[r]=ue.useTracks([I.Track.Source.ScreenShare]),i=jf(I.Track.Source.Camera),l=i&&!i.publication.isMuted,c=r&&!r.publication.isMuted,d=l||c,u={...Le.transition,delay:e?0:.15},m={...Le.animate,scale:e?1:3,transition:u},f={...Le.animate,transition:u},p=u,g=u,x=s!==void 0;return a.jsx("div",{className:"relative w-full h-full z-10 flex items-center justify-center",children:a.jsx("div",{className:"relative w-full h-full max-w-2xl px-4 md:px-0",children:a.jsxs("div",{className:$(ot.grid),children:[o&&a.jsx("div",{className:$(["grid",!e&&ot.agentChatClosed,e&&d&&ot.agentChatOpenWithSecondTile,e&&!d&&ot.agentChatOpenWithoutSecondTile]),children:a.jsxs("div",{className:"h-full flex items-center justify-center",children:[!x&&a.jsx(Cf,{layoutId:"agent",...Le,animate:m,transition:p,state:t,audioTrack:n,className:$(e?"h-[90px]":"h-auto w-full")},"agent"),x&&a.jsx(kf,{layoutId:"avatar",...Le,animate:f,transition:g,videoTrack:s,className:$(e?"h-[90px] [&>video]:h-[90px] [&>video]:w-auto":"h-auto w-full")},"avatar")]})}),a.jsx("div",{className:$(["grid",e&&ot.secondTileChatOpen,!e&&ot.secondTileChatClosed]),children:a.jsxs("div",{className:"w-full px-10 flex items-center shadow-2xl justify-between",children:[i&&l&&a.jsx(Ii,{layout:"position",layoutId:"camera",...Le,trackRef:i,transition:{...Le.transition,delay:e?0:.15},className:"h-[60px] order-1"},"camera"),c&&a.jsx(Ii,{layout:"position",layoutId:"screen",...Le,trackRef:r,transition:{...Le.transition,delay:e?0:.15},className:"h-[70px] order-2"},"screen")]})})]})})})}function Di({timeout:e}){const[t,n]=y.useState(100),s=y.useRef(null),o=y.useRef(null);return y.useEffect(()=>{if(!e||e<=0)return;n(100),o.current=Date.now();const r=()=>{if(!e||o.current===null)return;const i=Date.now()-o.current,l=Math.max(0,100-i/e*100);n(l),l>0&&(s.current=requestAnimationFrame(r))};return s.current=requestAnimationFrame(r),()=>{s.current&&cancelAnimationFrame(s.current)}},[e]),!e||e<=0?null:a.jsx("div",{className:"w-full h-1 relative top-1 rounded-t-4xl bg-gray-700 overflow-hidden",children:a.jsx(Q.div,{className:"h-1 rounded-t-4xl dark:bg-white bg-blue-200 ",initial:{width:"100%"},animate:{width:`${Math.max(t,2)}%`},transition:{duration:.1,ease:"linear"},style:{minWidth:"2%"}})})}function pt({interaction:e,theme:t,onDismiss:n,client:s,addLocalMessage:o}){var l;if(!e||!e.isVisible||!e.component)return null;const[r]=h.useState(()=>Date.now()),i=()=>e.component?h.createElement(e.component,{handler:e.handler||void 0,timeout:e.timeout,loadData:async d=>{console.log("InteractiveComponent: Loading data:",d)},presentationMode:e.presentationMode,data:e.data,client:s,addLocalMessage:o}):a.jsx("div",{className:"p-4 text-red-500",children:"Component not found"});switch(e.presentationMode){case"fullscreen":return a.jsx(ut,{children:a.jsxs(Q.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[9999] bg-black",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx(Di,{timeout:e.timeout}),a.jsxs("div",{className:"flex items-center justify-between p-4 bg-black/80 text-white border-b border-gray-700",children:[a.jsx("h3",{className:"text-lg font-semibold",children:e.methodName.replace(/_/g," ").replace(/\b\w/g,c=>c.toUpperCase())}),a.jsx("button",{onClick:n||((l=e.handler)==null?void 0:l.dismissView),className:"p-2 rounded-full bg-white/20 hover:bg-white/30 text-white transition-colors",children:a.jsx(pe.X,{className:"w-5 h-5"})})]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:i()})]})});case"embedded":default:return a.jsx(ut,{children:a.jsx(Q.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"w-fit rounded-lg ",children:a.jsxs("div",{children:[a.jsx(Di,{timeout:e.timeout}),i()]})})})}}function Af(){const e=ue.useTranscriptions(),t=ue.useChat(),n=ue.useRoomContext();return{messages:y.useMemo(()=>[...e.map(r=>Em(r,n)),...t.chatMessages].sort((r,i)=>r.timestamp-i.timestamp),[e,t.chatMessages,n]),send:t.send}}const Mf=({logLevel:e}={})=>{const t=ue.useRoomContext();h.useEffect(()=>(I.setLogLevel(e??"debug"),window.__lk_room=t,()=>{window.__lk_room=void 0}),[t,e])},Tf=({disabled:e,capabilities:t,sessionStarted:n,ref:s,participantName:o="User",loadingText:r="Waiting for agent to connect...",theme:i="vox",client:l,displayType:c="widget",onBack:d})=>{var ne,te,se,z,M,G,Y;const[u,m]=y.useState(!1),[f,p]=y.useState(!1),[g,x]=y.useState(()=>{var q;const V=(q=l==null?void 0:l.getCurrentInteraction)==null?void 0:q.call(l);return console.log("SessionView: Initializing with existing interaction:",(V==null?void 0:V.methodName)||"none"),V||null}),{messages:v,send:E}=Af(),b=y.useRef(null),S=y.useRef(null),{agent:{isActive:w=!1}={}}=ue.useVoiceAssistant(),C=ye(i),A=y.useMemo(()=>l&&typeof l.getCurrentSession=="function"?!!l.getCurrentSession():!1,[l]),j=w||A;y.useEffect(()=>{var V,q;console.log("🤖 SessionView agent state:",{isAgentActive:w,hasActiveSession:A,effectiveAgentActive:j,sessionStarted:n,clientSession:(q=(V=l==null?void 0:l.getCurrentSession)==null?void 0:V.call(l))==null?void 0:q.id})},[w,A,j,n,l]),y.useEffect(()=>{console.log("🤖 Agent active state changed:",w)},[w]),y.useEffect(()=>{console.log("📋 Session state changed:",{sessionStarted:n,disabled:e,participantName:o,effectiveAgentActive:j,chatOpen:u,currentInteraction:(g==null?void 0:g.methodName)||"none"})},[n,e,o,j,u,g]),y.useEffect(()=>{if(n&&!w){console.log("⏰ Starting agent timeout detection...");const V=setTimeout(()=>{console.log("⚠️ Agent timeout: Agent did not become active within 30 seconds"),p(!0)},3e4);return()=>{clearTimeout(V)}}else w&&(console.log("✅ Agent is active, clearing timeout"),p(!1))},[n,w]),y.useEffect(()=>{if(!l)return;const V=()=>{console.log("🔄 Client connection state changed:",l.connected)},q=T=>{console.log("🔴 Client disconnected:",T),x(null),m(!1),p(!1)};return l.on("connection.connected",V),l.on("connection.disconnected",q),()=>{l.off("connection.connected",V),l.off("connection.disconnected",q)}},[l]),y.useEffect(()=>{if(!l)return;const V=Z=>{console.log("🎯 SessionView: RPC Interaction started:",Z);const B=l.getCurrentInteraction();B&&(console.log("📱 SessionView: Setting current interaction:",B.methodName,"mode:",B.presentationMode),x(B))},q=Z=>{console.log("✅ SessionView: RPC Interaction completed:",Z),x(null)},T=async Z=>{console.log("⏰ SessionView: RPC Interaction timeout:",Z),x(null)},F=async Z=>{console.log("❌ SessionView: RPC Interaction dismissed:",Z),x(null)};return l.on("rpc.interaction.started",V),l.on("rpc.interaction.completed",q),l.on("rpc.interaction.timeout",T),l.on("rpc.interaction.dismissed",F),()=>{l.off("rpc.interaction.started",V),l.off("rpc.interaction.completed",q),l.off("rpc.interaction.timeout",T),l.off("rpc.interaction.dismissed",F)}},[l]),y.useEffect(()=>{if(!l)return;const V=l.getCurrentInteraction();V?(console.log("🔄 SessionView: Syncing with existing interaction:",V.methodName),x(V)):x(null)},[l]),y.useEffect(()=>{console.log("🎭 SessionView: Current interaction changed:",(g==null?void 0:g.methodName)||"none","mode:",(g==null?void 0:g.presentationMode)||"none")},[g]),y.useEffect(()=>{var V,q,T;console.log("📱 SessionView: Display type changed to:",c),console.log("📱 SessionView: Current session state during display change:",{sessionStarted:n,effectiveAgentActive:j,hasSession:!!((V=l==null?void 0:l.getCurrentSession)!=null&&V.call(l)),sessionId:(T=(q=l==null?void 0:l.getCurrentSession)==null?void 0:q.call(l))==null?void 0:T.id})},[c,n,j,l]),y.useEffect(()=>{console.log("💬 SessionView: Chat open state changed:",u)},[u]),y.useEffect(()=>{g&&u&&(console.log("🎭 SessionView: Interactive UI appeared, closing chat"),m(!1))},[g,u]),Mf(),y.useEffect(()=>{b.current&&u&&v.length>0&&(console.log("📜 SessionView: Auto-scrolling to latest message, count:",v.length),setTimeout(()=>{if(b.current){let V=b.current.parentElement;for(;V&&V.scrollHeight<=V.clientHeight;)V=V.parentElement;V?(console.log("📜 SessionView: Scrolling container found, scrolling to bottom"),V.scrollTo({top:V.scrollHeight,behavior:"smooth"})):(console.log("📜 SessionView: Using fallback scroll method"),b.current.scrollIntoView({behavior:"smooth",block:"end",inline:"nearest"}))}},100))},[v.length,u]),y.useEffect(()=>{var T,F;console.log("📝 SessionView: Messages updated, count:",v.length),v.length>0&&console.log("📝 SessionView: Latest messages:",v.slice(-3).map(Z=>{var B,R,_,K,O,re,oe;return{id:Z.id,message:Z.message,timestamp:Z.timestamp,from:((B=Z.from)==null?void 0:B.name)||((R=Z.from)==null?void 0:R.identity),fromType:Z.from===void 0?"unknown":"participant",isLocal:((_=Z.from)==null?void 0:_.identity)===((re=(O=(K=l==null?void 0:l.getCurrentSession)==null?void 0:K.call(l))==null?void 0:O.localParticipant)==null?void 0:re.identity),messageLength:((oe=Z.message)==null?void 0:oe.length)||0}}));const V=((T=l==null?void 0:l.getTranscriptions)==null?void 0:T.call(l))||[],q=((F=l==null?void 0:l.getChatMessages)==null?void 0:F.call(l))||[];console.log("📝 SessionView: Raw transcriptions count:",V.length),console.log("📝 SessionView: Raw chat messages count:",q.length)},[v.length,v,l]),y.useEffect(()=>{console.log("💬 SessionView: Chat state changed:",{chatOpen:u,messagesCount:v.length,displayType:c,hasMessages:v.length>0})},[u,v.length,c]);async function k(V){await E(V)}const D=y.useCallback(V=>{console.log("📝 SessionView: Adding local message for voice session context:",V)},[]),L=y.useCallback(async V=>{try{l&&typeof l.sendAttachments=="function"&&(await l.sendAttachments(V),console.log("📎 SessionView: Attachments sent successfully:",V.map(q=>q.name)))}catch(q){console.error("❌ SessionView: Failed to send attachments:",q)}},[l]),W=y.useCallback(()=>{try{console.log("📞 SessionView: Ending call..."),console.log("📞 SessionView: Current state before ending:",{sessionStarted:n,effectiveAgentActive:j,chatOpen:u,currentInteraction:g==null?void 0:g.methodName,hasOnBack:!!d}),g&&(console.log("🎭 SessionView: Dismissing current interaction:",g.methodName),x(null),l&&typeof l.dismissCurrentInteraction=="function"&&l.dismissCurrentInteraction()),m(!1),p(!1),console.log("✅ SessionView: Local state reset"),l&&typeof l.endSession=="function"&&(l.endSession(),console.log("✅ SessionView: Session ended via client.endSession()")),l&&typeof l.disconnect=="function"&&(l.disconnect(),console.log("✅ SessionView: Client disconnected")),d?(console.log("🔄 SessionView: Calling onBack to return to welcome..."),setTimeout(()=>{d(),console.log("✅ SessionView: onBack called")},150)):console.warn("⚠️ SessionView: No onBack function provided - cannot return to welcome"),console.log("🏁 SessionView: Call ended and cleanup completed")}catch(V){console.error("❌ SessionView: Failed to end call:",V),x(null),m(!1),p(!1),d&&(console.log("🔄 SessionView: Error occurred, still calling onBack..."),d())}},[l,d,g,n,j,u]);y.useEffect(()=>(console.log("🔄 SessionView: Component mounted/props changed:",{sessionStarted:n,disabled:e,participantName:o,displayType:c,hasOnBack:!!d,hasClient:!!l}),()=>{console.log("🧹 SessionView: Component unmounting or props changing")}),[n,e,o,c,d,l]),y.useEffect(()=>{console.log("🔗 SessionView: onBack prop:",{hasOnBack:!!d,onBackType:typeof d})},[d]),y.useEffect(()=>{var q,T;const V=((T=(q=l==null?void 0:l.getCurrentSession)==null?void 0:q.call(l))==null?void 0:T.id)||null;S.current&&!V&&console.warn("⚠️ SessionView: Session was lost unexpectedly!",{previousSession:S.current,currentSession:V,displayType:c,sessionStarted:n,effectiveAgentActive:j}),S.current=V},[l,c,n,j]);const H=$("w-full flex flex-col items-center justify-center",c==="fullscreen"?"w-full max-w-none mx-0 h-full":"w-full mx-auto",C.main,c==="fullscreen"?"max-w-none":"","overflow-hidden","h-full"),Ce=d&&(c==="popup"||c==="fullscreen");return a.jsxs("main",{ref:s,inert:e,className:$(H,"relative"),style:{minHeight:0},children:[Ce&&a.jsx("div",{className:`flex items-center justify-between w-full p-4 border-b ${((ne=C.chatHeader)==null?void 0:ne.container)||"border-gray-200"}`,children:a.jsx("div",{className:"flex items-center",children:a.jsxs("div",{children:[a.jsx("h3",{className:`font-semibold ${C.text.primary}`,children:"Voice Session"}),a.jsx("p",{className:`text-sm ${C.text.muted}`,children:o})]})})}),a.jsxs("div",{className:"w-full flex-1 flex flex-col items-center px-0 min-h-0 overflow-hidden",children:[!j&&a.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full min-h-[180px]",children:[a.jsx(Q.div,{animate:{rotate:360,scale:[1,1.1,1]},transition:{rotate:{duration:2,repeat:1/0,ease:"linear"},scale:{duration:1,repeat:1/0,ease:"easeInOut"}},className:"w-12 h-12 mb-4",children:a.jsx(Js,{className:C.spinner,weight:"bold"})}),a.jsx(Q.span,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`text-sm opacity-80 ${C.text.muted} text-center max-w-xs`,children:f?"Agent is taking longer than expected...":r}),a.jsx(Q.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:2},className:`text-xs ${C.text.muted} mt-2 text-center opacity-60`,children:f?"Please check your connection or try again.":"Agent is connecting... This may take a moment."}),f&&d&&a.jsx(Q.button,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{delay:.5},onClick:d,className:`mt-4 px-4 py-2 rounded-lg ${((te=C.chatHeader)==null?void 0:te.backButton)||"bg-gray-100 hover:bg-gray-200"} transition-colors`,children:"Go Back"})]}),j&&a.jsxs(a.Fragment,{children:[u&&a.jsxs("div",{className:$("absolute inset-0 w-full h-full flex flex-col transition-[opacity,translate] duration-300 ease-out z-10",i==="light"?"bg-white":"bg-gray-900/95 backdrop-blur-sm",u?"translate-y-0 opacity-100 delay-200":"translate-y-10 opacity-0"),children:[a.jsxs("div",{className:$("flex-shrink-0 px-4 py-3 border-b",c==="fullscreen"?"px-8":"px-5",((se=C.chatHeader)==null?void 0:se.container)||"border-gray-200 dark:border-gray-700"),children:[a.jsx("h3",{className:$("font-semibold text-lg",((z=C.text)==null?void 0:z.primary)||"text-gray-900 dark:text-white"),children:"Transcription & Chat"}),a.jsxs("p",{className:$("text-sm",((M=C.text)==null?void 0:M.muted)||"text-gray-600 dark:text-gray-400"),children:[v.length," messages"]})]}),a.jsx("div",{className:$("flex-1 flex flex-col min-h-0",c==="fullscreen"?"px-8":"px-5"),children:a.jsx(yf,{className:"flex-1 flex flex-col min-h-0 h-full",children:a.jsxs("div",{className:`flex-1 flex flex-col h-full ${$("overflow-y-auto scrollbar-hide py-4")}`,style:{scrollbarWidth:"none",scrollBehavior:"smooth",paddingBottom:"120px"},children:[v.length===0&&a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:$("text-lg font-medium mb-2",((G=C.text)==null?void 0:G.primary)||"text-gray-900 dark:text-white"),children:"Start Speaking"}),a.jsx("p",{className:$("text-sm",((Y=C.text)==null?void 0:Y.muted)||"text-gray-600 dark:text-gray-400"),children:"Your conversation will appear here"})]})}),v.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex-1 min-h-4"}),a.jsx("div",{ref:b,className:"space-y-4 relative whitespace-pre-wrap z-0",children:a.jsx(ut,{mode:"popLayout",children:v.map((V,q)=>a.jsx(Q.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3,ease:"easeOut",delay:q*.02},layout:!0,children:a.jsx(gf,{participantName:o,entry:V})},V.id||`message-${q}`))})})]})]})})})]}),!u&&a.jsxs("div",{className:$("flex-1 flex flex-col items-center w-full h-full min-h-0",(g==null?void 0:g.presentationMode)==="embedded"?"justify-end":"justify-center"),children:[a.jsx(Q.div,{className:"w-full flex justify-center",animate:{y:(g==null?void 0:g.presentationMode)==="embedded"?-8:0},transition:{duration:.3,ease:"easeOut"},children:a.jsx(Ef,{chatOpen:u})}),a.jsx(ut,{mode:"wait",children:g&&g.presentationMode==="embedded"&&a.jsx(Q.div,{initial:{opacity:0,y:20,height:0},animate:{opacity:1,y:0,height:"auto"},exit:{opacity:0,y:20,height:0},transition:{duration:.3,ease:"easeOut"},className:$("w-full relative mt-4 flex justify-center",c==="fullscreen"?"max-w-4xl":"max-w-md"),children:a.jsx("div",{className:"bg-white/10 backdrop-blur-sm rounded-xl border border-white/20 shadow-lg overflow-hidden",children:a.jsx(pt,{interaction:g,theme:i,onDismiss:()=>{var V;return(V=l==null?void 0:l.dismissCurrentInteraction)==null?void 0:V.call(l)},client:l,addLocalMessage:D})})},`embedded-${g.methodName}`)})]})]})]}),a.jsx(ut,{mode:"wait",children:g&&g.presentationMode!=="embedded"&&!u&&a.jsx("div",{className:$("absolute inset-0 z-50 flex items-center justify-center backdrop-blur-sm",c==="fullscreen"?"bg-black/70":"bg-black/50"),children:a.jsx(Q.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.2,ease:"easeOut"},className:$("relative w-full overflow-hidden",c==="fullscreen"?"max-w-2xl mx-8 max-h-[85vh]":"max-w-lg mx-4 max-h-[80vh]","bg-white dark:bg-gray-900 rounded-2xl shadow-2xl","border border-gray-200 dark:border-gray-700"),children:a.jsx(pt,{interaction:g,theme:i,onDismiss:()=>{var V;return(V=l==null?void 0:l.dismissCurrentInteraction)==null?void 0:V.call(l)},client:l,addLocalMessage:D})},`modal-${g.methodName}`)})}),a.jsx(Q.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},className:"absolute bottom-0 left-0 right-0 flex-shrink-0 w-full z-20",children:a.jsx(Vf,{capabilities:t,onSendMessage:k,onSendAttachments:L,onEndCall:W,onChatOpenChange:m,disabled:e,theme:i,client:l,sessionStarted:n})})]})};function Vf({capabilities:e,onSendMessage:t,onSendAttachments:n,onEndCall:s,onChatOpenChange:o,disabled:r=!1,theme:i,client:l,sessionStarted:c=!1}){const[d,u]=y.useState(!1),m=y.useRef(null),f=y.useRef(null);y.useEffect(()=>{const b=()=>{const S=navigator.userAgent.toLowerCase(),C=["android","iphone","ipad","mobile","tablet"].some(k=>S.includes(k)),A="ontouchstart"in window||navigator.maxTouchPoints>0,j=window.innerWidth<=768;u(C||A&&j)};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[]);const p=b=>{const S=b.target.files;if(S&&S.length>0){const C=Array.from(S).filter(A=>A.type.startsWith("image/"));if(C.length===0){console.warn("No valid image files selected");return}n&&n(C),m.current&&(m.current.value="")}},g=b=>{const S=b.target.files;if(S&&S.length>0){const w=S[0];w.type.startsWith("image/")&&n&&n([w]),f.current&&(f.current.value="")}},x=()=>{!r&&m.current&&m.current.click()},v=()=>{!r&&d&&f.current&&f.current.click()},E=()=>{console.log("🔴 VoiceControlPanel: End call button clicked"),console.log("🔴 VoiceControlPanel: Current state:",{disabled:r,sessionStarted:c,hasOnEndCall:!!s}),s?s():console.warn("⚠️ VoiceControlPanel: No onEndCall function provided")};return a.jsx("div",{className:$("px-4 py-3 !w-full backdrop-blur-xl border-0 shadow-lg",i==="light"?"bg-white/95 border-t border-gray-200":"bg-gray-900/95 border-t border-gray-700"),children:a.jsxs("div",{className:"flex items-center justify-between !w-full mx-auto max-w-4xl",children:[a.jsx("input",{ref:m,type:"file",multiple:!0,onChange:p,className:"hidden",accept:"image/*"}),a.jsx("input",{ref:f,type:"file",onChange:g,className:"hidden",accept:"image/*",capture:"environment"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:x,disabled:r,className:$("p-3 rounded-full transition-all duration-200 hover:scale-105 active:scale-95",r?"opacity-50 cursor-not-allowed":"hover:shadow-md",i==="light"?"bg-gray-100 hover:bg-gray-200 text-gray-600":"bg-gray-700/50 hover:bg-gray-600/50 text-gray-300"),title:"Attach files",children:a.jsx(Be.AttachFile,{className:"w-5 h-5"})}),d&&a.jsx("button",{onClick:v,disabled:r,className:$("p-3 rounded-full transition-all duration-200 hover:scale-105 active:scale-95",r?"opacity-50 cursor-not-allowed":"hover:shadow-md",i==="light"?"bg-gray-100 hover:bg-gray-200 text-gray-600":"bg-gray-700/50 hover:bg-gray-600/50 text-gray-300"),title:"Take photo",children:a.jsx(Be.CameraAlt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"flex-1 flex justify-center px-4",children:a.jsx(ff,{capabilities:e,onChatOpenChange:o,onSendMessage:t,theme:i,client:l,className:"border-none py-1 rounded-xl max-w-md w-full"})}),a.jsx("div",{className:"flex items-center",children:a.jsx("button",{onClick:E,disabled:r||!c,className:$("p-3 rounded-full transition-all duration-200 hover:scale-105 active:scale-95",r||!c?"opacity-50 cursor-not-allowed":"hover:shadow-md","bg-red-500 hover:bg-red-600 text-white"),title:"End call",children:a.jsx(Be.CallEnd,{className:"w-5 h-5"})})})]})})}function Nf({onSendMessage:e,onSendAttachments:t,disabled:n,theme:s,onEndChat:o}){const[r,i]=h.useState(""),[l,c]=h.useState(!1),d=h.useRef(null),u=h.useRef(null),[m,f]=h.useState(!1),p=ye(s);h.useEffect(()=>{const w=()=>{const C=navigator.userAgent.toLowerCase(),j=["android","iphone","ipad","mobile","tablet"].some(L=>C.includes(L)),k="ontouchstart"in window||navigator.maxTouchPoints>0,D=window.innerWidth<=768;f(j||k&&D)};return w(),window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[]);const g=w=>{w.preventDefault(),r.trim()&&!n&&(e(r.trim()),i(""))},x=w=>{w.key==="Enter"&&!w.shiftKey&&(w.preventDefault(),g(w))},v=w=>{const C=w.target.files;if(C&&C.length>0){const A=Array.from(C),j=A.filter(k=>k.type.startsWith("image/"));if(j.length===0){console.warn("No valid image files selected");return}j.length!==A.length&&console.warn("Some non-image files were filtered out"),console.log("Selected image files:",j),t(j),d.current&&(d.current.value="")}},E=()=>{!n&&d.current&&d.current.click()},b=()=>{!n&&m&&u.current&&u.current.click()},S=w=>{const C=w.target.files;if(C&&C.length>0){const A=C[0];A.type.startsWith("image/")?t([A]):console.warn("Selected file is not an image"),u.current&&(u.current.value="")}};return a.jsx("div",{className:"px-4 py-3 !w-full backdrop-blur-xl border-0 shadow-lg ",children:a.jsx("form",{onSubmit:g,className:"flex items-center !w-full mx-auto max-w-4xl",children:a.jsxs("div",{className:`flex items-center gap-2 !w-full backdrop-blur-md rounded-full px-3 py-2 shadow-sm hover:shadow-md focus-within:shadow-lg focus-within:ring-2 focus-within:ring-blue-500/30 focus-within:border-blue-500/50 transition-all duration-200 border ${s==="light"?"bg-white/90 border-gray-200":p.chatInput.container}`,children:[a.jsx(Q.button,{type:"button",onClick:E,whileHover:{scale:1.05},whileTap:{scale:.95},className:`p-1 rounded-full transition-all duration-200 border-0 ${p.chatInput.attachButton}`,disabled:n,"aria-label":"Attach file",children:a.jsx(pe.Paperclip,{className:"w-4 h-4"})}),m&&a.jsx(Q.button,{type:"button",onClick:b,whileHover:{scale:1.05},whileTap:{scale:.95},className:`p-1 rounded-full transition-all duration-200 border-0 ${p.chatInput.attachButton}`,disabled:n,"aria-label":"Take photo",children:a.jsx(pe.Camera,{className:"w-4 h-4"})}),a.jsx("input",{ref:d,type:"file",multiple:!0,onChange:v,className:"hidden",accept:"image/*"}),a.jsx("input",{ref:u,type:"file",onChange:S,className:"hidden",accept:"image/*",capture:"environment"}),a.jsx("textarea",{value:r,onChange:w=>i(w.target.value),onKeyDown:x,onFocus:()=>c(!0),onBlur:()=>c(!1),placeholder:"Type your message...",disabled:n,className:`flex-1 px-2 py-1 bg-transparent resize-none min-h-[32px] max-h-20 focus:outline-none text-sm border-0 ${p.chatInput.textarea}`,rows:1,style:{height:"auto",minHeight:"32px"},onInput:w=>{const C=w.target;C.style.height="auto",C.style.height=`${Math.min(C.scrollHeight,80)}px`}}),a.jsx(Q.button,{type:"submit",disabled:n||!r.trim(),whileHover:{scale:1.05},whileTap:{scale:.95},className:`p-1 rounded-full transition-all duration-200 border-0 flex-shrink-0 ${r.trim()&&!n?p.chatInput.sendButton:s==="light"?"bg-gray-200 text-gray-400 cursor-not-allowed opacity-70":"bg-gray-600/50 text-gray-500 cursor-not-allowed opacity-50"}`,"aria-label":"Send message",children:a.jsx(pe.SendHorizontal,{className:"w-4 h-4"})}),o&&a.jsx(Q.button,{type:"button",onClick:o,whileHover:{scale:1.05},whileTap:{scale:.95},className:`p-1 rounded-full transition-all duration-200 border-0 flex-shrink-0 ${p.chatInput.endButton}`,"aria-label":"End chat",children:a.jsx(pe.PhoneOff,{className:"w-4 h-4"})})]})})})}function Pf({text:e,isComplete:t,isRealTimeStream:n=!1,speed:s=50}){const[o,r]=h.useState(""),[i,l]=h.useState(0);return h.useEffect(()=>{if(n){r(e);return}if(t){r(e);return}if(i<e.length){const c=setTimeout(()=>{r(e.slice(0,i+1)),l(i+1)},s);return()=>clearTimeout(c)}},[e,i,t,s,n]),h.useEffect(()=>{n||(l(0),r(""))},[e,n]),a.jsxs("span",{className:"relative",children:[a.jsx("span",{className:"inline-block",children:o}),!t&&a.jsx("span",{className:"inline-flex items-center ml-1",children:[0,1,2].map(c=>a.jsx(Q.span,{className:"w-1.5 h-1.5 bg-current rounded-full mx-0.5",animate:{y:[0,-4,0],opacity:[.4,1,.4],scale:[.8,1,.8]},transition:{duration:.8,repeat:1/0,repeatType:"mirror",delay:c*.2,ease:"easeInOut"}},c))})]})}function Rf({message:e,theme:t,isOwn:n,isStreaming:s=!1}){var i,l;const o=ye(t),r=e.sender.name?e.sender.name.split(" ").map(c=>c[0]).join("").toUpperCase().slice(0,2):"U";return a.jsx("div",{className:`flex w-full ${n?"justify-end":"justify-start"} mb-4 px-1`,children:a.jsxs("div",{className:`relative group ${n?"flex-row-reverse":"flex-row"} flex items-end gap-3 max-w-[85%]`,children:[a.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-semibold flex-shrink-0 shadow-lg ${n?t==="light"?"bg-gradient-to-br from-blue-500 to-purple-600":"bg-gradient-to-br from-gray-600 to-gray-700":t==="light"?"bg-gradient-to-br from-blue-500 to-purple-600":"bg-gradient-to-br from-gray-600 to_gray-700"}`,children:r}),a.jsxs("div",{className:`
|
|
296
10
|
relative px-3 py-2 rounded-2xl break-words shadow-lg backdrop-blur-sm message-bubble message-hover
|
|
297
|
-
${n?`${
|
|
298
|
-
${
|
|
11
|
+
${n?`${o.chatMessage.own} rounded-br-md`:`${o.chatMessage.other} rounded-bl-md`}
|
|
12
|
+
${s?"shimmer":""}
|
|
299
13
|
transition-all duration-200 group-hover:scale-[1.02]
|
|
300
|
-
`,style:{wordWrap:"break-word",overflowWrap:"break-word"},children:[
|
|
14
|
+
`,style:{wordWrap:"break-word",overflowWrap:"break-word"},children:[a.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-sm",children:((i=e.metadata)==null?void 0:i.type)==="attachment"?a.jsx(Ff,{message:e,theme:t,isOwn:n}):s&&!n?a.jsx(Pf,{text:e.content,isComplete:!s,isRealTimeStream:((l=e.metadata)==null?void 0:l.streaming)===!0,speed:35}):e.content}),a.jsx("div",{className:"text-xs",children:e.timestamp.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})]})})}function If(e,t){return e.startsWith("image/")?pe.Image:e.startsWith("video/")?pe.Video:e.startsWith("audio/")?pe.Music:e.includes("zip")||e.includes("rar")||e.includes("archive")?pe.Archive:pe.FileText}function Df(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],s=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,s)).toFixed(2))+" "+n[s]}function Ff({message:e,theme:t,isOwn:n}){const s=ye(t),o=e.metadata,r=(o==null?void 0:o.fileName)||"Unknown file",i=(o==null?void 0:o.fileSize)||0,l=(o==null?void 0:o.mimeType)||"application/octet-stream",c=o==null?void 0:o.downloading,d=o==null?void 0:o.uploading,u=(o==null?void 0:o.downloadProgress)||0,m=(o==null?void 0:o.uploadProgress)||0,f=o==null?void 0:o.downloadUrl,p=o==null?void 0:o.file,g=If(l),x=c||d,v=c?u:m,E=c?"Downloading...":d?"Uploading...":"Complete",[b,S]=h.useState(null);h.useEffect(()=>{if(f)S(f);else if(p&&l.startsWith("image/")){const j=URL.createObjectURL(p);return S(j),()=>URL.revokeObjectURL(j)}else S(null)},[f,p,l]);const w=()=>{if(f){const j=document.createElement("a");j.href=f,j.download=r,j.click()}},A=l.startsWith("image/")&&b;return a.jsxs("div",{className:"flex flex-col gap-2 max-w-sm",children:[A&&a.jsxs("div",{className:"relative rounded-lg overflow-hidden",children:[a.jsx("img",{src:b,alt:r,className:"max-w-full h-auto max-h-48 object-cover rounded-lg cursor-pointer",onClick:w}),a.jsx("div",{className:"absolute inset-0 bg-black/0 hover:bg-black/10 transition-colors duration-200 cursor-pointer"})]}),a.jsxs("div",{className:`
|
|
301
15
|
flex items-center gap-3 p-3 rounded-lg border transition-all duration-200
|
|
302
|
-
${
|
|
303
|
-
`,children:[
|
|
16
|
+
${t==="light"?"bg-gray-50 border-gray-200 hover:bg-gray-100":"bg-gray-800/50 border-gray-700 hover:bg-gray-700/50"}
|
|
17
|
+
`,children:[a.jsx("div",{className:`
|
|
304
18
|
p-2 rounded-lg flex-shrink-0
|
|
305
|
-
${
|
|
306
|
-
`,children:
|
|
19
|
+
${t==="light"?"bg-blue-100 text-blue-600":"bg-blue-900/50 text-blue-400"}
|
|
20
|
+
`,children:a.jsx(g,{className:"w-5 h-5"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:`font-medium text-sm truncate ${s.text.primary}`,children:r}),a.jsxs("div",{className:`text-xs ${s.text.muted}`,children:[i>0&&Df(i),x&&a.jsxs(a.Fragment,{children:[i>0&&" • ",E," ",Math.round(v*100),"%"]})]}),x&&a.jsx("div",{className:`
|
|
307
21
|
w-full h-1 rounded-full mt-1 overflow-hidden
|
|
308
|
-
${
|
|
309
|
-
`,children:
|
|
22
|
+
${t==="light"?"bg-gray-200":"bg-gray-700"}
|
|
23
|
+
`,children:a.jsx(Q.div,{className:`h-full ${t==="light"?"bg-blue-500":"bg-blue-400"}`,initial:{width:0},animate:{width:`${v*100}%`},transition:{duration:.3}})})]}),f&&!x&&a.jsx(Q.button,{onClick:w,whileHover:{scale:1.05},whileTap:{scale:.95},className:`
|
|
310
24
|
p-2 rounded-lg transition-colors duration-200
|
|
311
|
-
${
|
|
312
|
-
`,"aria-label":"Download file",children:m.jsx(R6,{className:"w-4 h-4"})})]})]})}function Nj(){return m.jsxs("div",{className:"max-w-xs mx-auto bg-green-50 border border-green-200 rounded-lg shadow p-3 flex flex-col items-center",children:[m.jsx("div",{className:"text-2xl mb-2",children:"✅"}),m.jsx("div",{className:"text-green-700 font-semibold text-sm mb-1",children:"Success!"}),m.jsx("div",{className:"text-xs text-gray-600 text-center mb-1",children:"Your action was completed successfully."})]})}function Oj(){return m.jsxs("div",{className:"max-w-xs mx-auto bg-yellow-50 border border-yellow-200 rounded-lg shadow p-3 flex flex-col items-center",children:[m.jsx("div",{className:"text-2xl mb-2",children:"⏰"}),m.jsx("div",{className:"text-yellow-700 font-semibold text-sm mb-1",children:"Interaction timed out"}),m.jsx("div",{className:"text-xs text-gray-600 text-center mb-1",children:"No response was provided in time."})]})}function Dj({client:t,theme:e="vox",onBack:n,disabled:i=!1,displayType:r="widget",onEndChat:s}){const[o,a]=g.useState(()=>{if(t&&typeof t.getChatMessages=="function"){const j=t.getChatMessages();return console.log("🔄 ChatView: Initializing with existing messages:",j.length),j}return[]}),[c,l]=g.useState(!0),[d,u]=g.useState(()=>{const j=t&&typeof t.getCurrentSession=="function"&&!!t.getCurrentSession(),q=t&&typeof t.getChatMessages=="function"&&t.getChatMessages().length>0;return!j&&!q}),[f,p]=g.useState(new Set),[v,h]=g.useState([]),[y,b]=g.useState(!1),[w,C]=g.useState(!1),[S,x]=g.useState(()=>{const j=t.getCurrentInteraction();return console.log("ChatView: Initializing with existing interaction:",(j==null?void 0:j.methodName)||"none"),j}),T=g.useRef(null),E=St(e);g.useEffect(()=>{const j=()=>{const q=navigator.userAgent.toLowerCase(),G=["android","iphone","ipad","mobile","tablet"].some(W=>q.includes(W)),D="ontouchstart"in window||navigator.maxTouchPoints>0,$=window.innerWidth<=768,Q=G||D&&$;b(Q),Q&&r==="widget"&&C(!0)};return j(),window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[r]),g.useEffect(()=>(w&&y&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.height="100%",document.documentElement.requestFullscreen&&document.documentElement.requestFullscreen().catch(console.log)),()=>{w&&y&&(document.body.style.overflow="unset",document.body.style.position="unset",document.body.style.width="unset",document.body.style.height="unset",document.fullscreenElement&&document.exitFullscreen().catch(console.log))}),[w,y]);const P=t.getCurrentAgentInfo(),_=(P==null?void 0:P.name)||"AI Assistant",k=_.split(" ").map(j=>j[0]).join("").toUpperCase().slice(0,2),I=g.useCallback(j=>{const q={id:`local_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,content:j,timestamp:new Date,sender:{id:"participant",name:"You",type:"participant"},metadata:{isLocal:!0}};a(ee=>(console.log("ChatView: Adding local message:",q.id),[...ee,q]))},[]);g.useEffect(()=>{var j,q,ee,G,D;console.log("💬 ChatView loading state:",{isLoading:d,hasActiveSession:!!((j=t==null?void 0:t.getCurrentSession)!=null&&j.call(t)),messagesCount:o.length,sessionId:(ee=(q=t==null?void 0:t.getCurrentSession)==null?void 0:q.call(t))==null?void 0:ee.id,hasStoredMessages:!!((D=(G=t==null?void 0:t.getChatMessages)==null?void 0:G.call(t))!=null&&D.length),isMobile:y,isFullscreen:w})},[d,o.length,t,y,w]);const N=g.useCallback((j=!1)=>{T.current&&(j?T.current.scrollIntoView({behavior:"auto"}):T.current.scrollIntoView({behavior:"smooth"}))},[]);g.useEffect(()=>{N(!0);const j=setTimeout(()=>{N(!1)},10);return()=>clearTimeout(j)},[o.length,N]),g.useEffect(()=>{if(S){N(!0);const j=setTimeout(()=>{N(!1)},50);return()=>clearTimeout(j)}},[S,N]),g.useEffect(()=>{const j=G=>{if(console.log("ChatView: Received message:",G),u(!1),S&&G.sender.type==="agent"){console.log("ChatView: Queuing agent message due to active interaction:",S.methodName),h(D=>[...D,G]);return}G.sender.type==="agent"&&l(!1),a(D=>{var Q;if(D.some(W=>W.id===G.id))return console.log("ChatView: Message already exists, skipping:",G.id),D;if(console.log("ChatView: Adding new message:",G.id),G.sender.type==="agent"&&(p(W=>new Set(W).add(G.id)),!((Q=G.metadata)!=null&&Q.streaming))){const W=G.content.length*35+1e3;setTimeout(()=>{p(ce=>{const z=new Set(ce);return z.delete(G.id),z})},W)}return[...D,G]}),setTimeout(()=>N(!0),0)},q=G=>{var D;if(console.log("ChatView: Updated message:",G),S&&G.sender.type==="agent"){console.log("ChatView: Queuing agent message update due to active interaction:",S.methodName),h($=>{const Q=$.findIndex(W=>W.id===G.id);if(Q>=0){const W=[...$];return W[Q]=G,W}else return[...$,G]});return}a($=>$.map(Q=>Q.id===G.id?{...G}:Q)),setTimeout(()=>N(!0),0),(D=G.metadata)!=null&&D.streaming||p($=>{const Q=new Set($);return Q.delete(G.id),Q})},ee=G=>{console.log("ChatView: Sent message:",G),u(!1),a(D=>D.some(Q=>Q.id===G.id)?(console.log("ChatView: Sent message already exists, skipping:",G.id),D):(console.log("ChatView: Adding sent message:",G.id),[...D,G])),setTimeout(()=>N(!0),0)};return t.on("chat.message.received",j),t.on("chat.message.updated",q),t.on("chat.message.sent",ee),()=>{t.off("chat.message.received",j),t.off("chat.message.updated",q),t.off("chat.message.sent",ee)}},[t,S]),g.useEffect(()=>{const j=D=>{console.log("ChatView: RPC interaction started:",D);const $=t.getCurrentInteraction();console.log("ChatView: Got interaction from client:",$==null?void 0:$.methodName),x($),l(!1),N(!0),setTimeout(()=>{N(!1)},100)},q=D=>{if(console.log("ChatView: RPC interaction completed:",D),x(null),v.length>0&&(console.log("ChatView: Processing",v.length,"queued messages"),a($=>{const Q=[...$];return v.forEach(W=>{var z;if(!Q.some(me=>me.id===W.id)&&(console.log("ChatView: Adding queued message:",W.id),Q.push(W),W.sender.type==="agent"&&(p(me=>new Set(me).add(W.id)),!((z=W.metadata)!=null&&z.streaming)))){const me=W.content.length*35+1e3;setTimeout(()=>{p(Ee=>{const qe=new Set(Ee);return qe.delete(W.id),qe})},me)}}),Q}),h([]),setTimeout(()=>N(!0),0)),D&&D.response&&D.response.success){let $=null;D.response.successView?$=D.response.successView:D.successView&&($=D.successView),a(Q=>{const W=[...Q].reverse().findIndex(Ee=>Ee.sender.type==="participant");let ce=Q.length;W!==-1&&(ce=Q.length-W);const z={id:`success_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,content:"",timestamp:new Date,sender:{id:"participant",name:"You",type:"participant"},metadata:{type:"successView",view:$||m.jsx(Nj,{})}};t&&typeof t.addChatMessage=="function"&&t.addChatMessage(z);const me=[...Q];return me.splice(ce,0,z),me})}},ee=async D=>{S&&(console.log("ChatView: Dismissing active interaction due to timeout"),t.dismissCurrentInteraction()),x(null),v.length>0&&(console.log("ChatView: Processing",v.length,"queued messages after timeout"),a(Q=>{const W=[...Q];return v.forEach(ce=>{var me;if(!W.some(Ee=>Ee.id===ce.id)&&(W.push(ce),ce.sender.type==="agent"&&(p(Ee=>new Set(Ee).add(ce.id)),!((me=ce.metadata)!=null&&me.streaming)))){const Ee=ce.content.length*35+1e3;setTimeout(()=>{p(qe=>{const Ct=new Set(qe);return Ct.delete(ce.id),Ct})},Ee)}}),W}),h([]),setTimeout(()=>N(!0),0));let $=null;D&&D.response&&D.response.timeoutView?$=D.response.timeoutView:D&&D.timeoutView&&($=D.timeoutView),a(Q=>{const W={id:`timeout_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,content:"",timestamp:new Date,sender:{id:"agent",name:_,type:"agent"},metadata:{type:"timeoutView",view:$||m.jsx(Oj,{})}};return t&&typeof t.addChatMessage=="function"&&t.addChatMessage(W),[...Q,W]}),setTimeout(()=>{t.getCurrentInteraction()||x(null)},100)},G=async D=>{console.log("ChatView: RPC interaction dismissed:",D),console.log("ChatView: Current interaction before dismiss:",S==null?void 0:S.methodName),x(null),v.length>0&&(console.log("ChatView: Processing",v.length,"queued messages after dismissal"),a($=>{const Q=[...$];return v.forEach(W=>{var z;if(!Q.some(me=>me.id===W.id)&&(Q.push(W),W.sender.type==="agent"&&(p(me=>new Set(me).add(W.id)),!((z=W.metadata)!=null&&z.streaming)))){const me=W.content.length*35+1e3;setTimeout(()=>{p(Ee=>{const qe=new Set(Ee);return qe.delete(W.id),qe})},me)}}),Q}),h([]),setTimeout(()=>N(!0),0)),setTimeout(()=>{const $=t.getCurrentInteraction();console.log("ChatView: Latest interaction from client after dismiss:",($==null?void 0:$.methodName)||"null"),$===null&&x(null)},50),console.log("ChatView: Set currentInteraction to null after dismiss")};return t.on("rpc.interaction.started",j),t.on("rpc.interaction.completed",q),t.on("rpc.interaction.timeout",ee),t.on("rpc.interaction.dismissed",G),()=>{t.off("rpc.interaction.started",j),t.off("rpc.interaction.completed",q),t.off("rpc.interaction.timeout",ee),t.off("rpc.interaction.dismissed",G)}},[t]),g.useEffect(()=>{const j=()=>{if(console.log("ChatView: Agent is thinking"),S){console.log("ChatView: Suppressing thinking indicator due to active interaction:",S.methodName);return}l(!0)},q=()=>{console.log("ChatView: Agent is speaking"),l(!1)};return t.on("agent.thinking",j),t.on("agent.speaking",q),()=>{t.off("agent.thinking",j),t.off("agent.speaking",q)}},[t,S]),g.useEffect(()=>{const j=t.getCurrentInteraction();j?(console.log("ChatView: Restoring interaction state on mount/client change:",j.methodName),x(j)):x(null)},[t]),g.useEffect(()=>{console.log("ChatView: Display type changed to:",r,"Current interaction:",(S==null?void 0:S.methodName)||"none")},[r,S]);const K=async j=>{try{S&&(console.log("ChatView: Dismissing active interaction due to user message send"),t.dismissCurrentInteraction(),x(null)),await t.sendChatMessage(j)}catch(q){console.error("Failed to send message:",q)}},J=async j=>{try{S&&(console.log("ChatView: Dismissing active interaction due to user attachment send"),t.dismissCurrentInteraction(),x(null)),await t.sendAttachments(j),console.log("Attachments sent successfully:",j.map(q=>q.name))}catch(q){console.error("Failed to send attachments:",q)}},[se,ie]=g.useState([]);if(g.useEffect(()=>{const j=q=>{ie(Array.isArray(q)?q:["tes","hello how are you","algebra make me learn that ","what is the meaning of life"])};return t.on("suggested.response",j),()=>{t.off("suggested.response",j)}},[t]),d){const j=w&&y?"fixed inset-0 z-[9999] flex flex-col items-center justify-center h-screen w-screen bg-black":"flex w-full flex-col items-center justify-center h-full p-8";return m.jsxs("div",{className:j,children:[m.jsx("div",{className:`${E.spinner} w-12 h-12 mb-6`}),m.jsxs("p",{className:`text-sm text-center ${w&&y?"text-white":""}`,children:["Connecting to ",_,"..."]})]})}const X=w&&y?"fullscreen":r,O=X==="fullscreen"?w&&y?"fixed inset-0 z-[9999] flex flex-col h-screen w-screen bg-black":"flex flex-col h-full w-full max-w-none":"flex flex-col h-full w-full backdrop-blur-sm",oe=X==="fullscreen"?w&&y?"flex items-center w-full justify-between px-4 pt-3 pb-3 bg-black/80 text-white border-b border-gray-700":`flex items-center w-full justify-between px-6 pt-5 pb-4 border-b ${E.chatHeader.container}`:`flex items-center w-full justify-between px-4 pt-5 pb-4 border-b ${E.chatHeader.container}`,L=X==="fullscreen"?w&&y?"flex-1 overflow-y-auto scrollbar-hide p-4 w-full max-w-none chat-scrollable min-h-0":"flex-1 overflow-y-auto scrollbar-hide p-6 w-full max-w-none chat-scrollable min-h-0":"flex-1 overflow-y-auto scrollbar-hide w-full p-4 chat-scrollable min-h-0",F="flex-shrink-0 !w-full",te=()=>{C(!1),n&&n()};return m.jsxs("div",{className:O,children:[m.jsx("div",{className:oe,children:m.jsxs("div",{className:"flex items-center gap-2",children:[w&&y&&m.jsx(xe.button,{onClick:te,whileHover:{scale:1.05},whileTap:{scale:.95},className:"p-2 rounded-full bg-white/20 hover:bg-white/30 text-white transition-colors mr-2","aria-label":"Exit fullscreen",children:"✕"}),m.jsxs("div",{children:[m.jsx("h3",{className:`font-semibold text-base leading-tight ${w&&y?"text-white":E.text.primary}`,children:_}),m.jsxs("p",{className:`text-xs flex items-center gap-1.5 mt-0.5 ${w&&y?"text-gray-300":E.text.muted}`,children:[m.jsx("span",{className:"w-1.5 h-1.5 bg-green-500 rounded-full animate-pulse"}),"Online"]})]})]})}),m.jsxs("div",{className:`${L} flex flex-col`,style:{scrollBehavior:"smooth",scrollbarWidth:"none"},children:[" ",o.length===0?m.jsxs("div",{className:"flex flex-col items-center justify-center flex-1 text-center py-12",children:[m.jsx(xe.div,{transition:{duration:2,repeat:1/0,ease:"easeInOut"},className:"w-16 h-16 rounded-full bg-gradient-to-br from-blue-500 to-purple-600 flex items-center justify-center text-white font-bold text-xl mb-6 shadow-xl",children:k}),m.jsxs("p",{className:`text-base mb-2 ${w&&y?"text-white":E.text.secondary}`,children:[_," is joining..."]}),m.jsx("p",{className:`text-xs ${w&&y?"text-gray-300":E.text.muted}`,children:"Your conversation will begin shortly"})]}):m.jsx("div",{className:"w-full max-w-5xl mx-auto space-y-3 py-4 flex-1 flex flex-col justify-end",children:m.jsxs("div",{className:"space-y-3",children:[o.map((j,q)=>{var ee,G;return m.jsx("div",{children:((ee=j.metadata)==null?void 0:ee.type)==="successView"?m.jsx("div",{className:"flex w-full justify-end mb-4 px-1",children:m.jsxs("div",{className:"relative group flex-row-reverse flex items-end gap-3 max-w-[85%]",children:[m.jsx(xe.div,{initial:{scale:0},animate:{scale:1},transition:{delay:.1},className:`w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-semibold flex-shrink-0 shadow-lg ${e==="light"?"bg-gradient-to-br from-blue-500 to-purple-600":"bg-gradient-to-br from-gray-600 to-gray-700"}`,children:"Y"}),m.jsxs("div",{className:`flex h-full flex-col justify-between border px-3 py-2 rounded-2xl shadow-lg backdrop-bl-sm message-bubble rounded-br-md message-hover border-gray-200 dark:border-gray-700 ${E.chatMessage.own}`,children:[j.metadata.view,m.jsx("div",{className:`text-xs ${E.text.muted} mt-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200 `,children:j.timestamp.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})]})}):((G=j.metadata)==null?void 0:G.type)==="timeoutView"?m.jsx("div",{className:"flex w-full justify-start mb-4 px-1",children:m.jsxs("div",{className:"relative group flex-row flex items-end gap-3 max-w-[85%]",children:[m.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-semibold flex-shrink-0 shadow-lg ${e==="light"?"bg-gradient-to-br from-blue-500 to-purple-600":"bg-gradient-to-br from-gray-600 to_gray-700"}`,children:k}),m.jsxs("div",{className:`flex h-full flex-col justify-between border px-3 py-2 rounded-2xl shadow-lg backdrop-bl-sm message-bubble rounded-bl-md message-hover border-gray-200 dark:border-gray-700 ${E.chatMessage.other}`,children:[j.metadata.view,m.jsx("div",{className:`text-xs ${E.text.muted} mt-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200 `,children:j.timestamp.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})]})}):m.jsx(Aj,{message:j,theme:e,isOwn:j.sender.type==="participant",isStreaming:f.has(j.id)})},j.id)}),c&&!S&&m.jsx(xe.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:o.length*.1},className:"flex w-full justify-start mb-4 px-1",children:m.jsxs("div",{className:"relative group flex-row flex items-end gap-3 max-w-[85%]",children:[m.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-semibold flex-shrink-0 shadow-lg ${e==="light"?"bg-gradient-to-br from-blue-500 to-purple-600":"bg-gradient-to-br from-gray-600 to-gray-700"}`,children:k}),m.jsx("div",{className:`relative px-3 py-2 rounded-2xl break-words shadow-lg backdrop-blur-sm message-bubble message-hover ${E.chatMessage.other} rounded-bl-md transition-all duration-200 group-hover:scale-[1.02]`,style:{wordWrap:"break-word",overflowWrap:"break-word",minWidth:48},children:m.jsx("span",{className:"inline-flex items-center",children:[0,1,2].map(j=>m.jsx(xe.span,{className:"w-1.5 h-1.5 bg-current rounded-full mx-0.5",animate:{y:[0,-4,0],opacity:[.4,1,.4],scale:[.8,1,.8]},transition:{duration:.8,repeat:1/0,repeatType:"mirror",delay:j*.2,ease:"easeInOut"}},j))})})]})}),S&&S.presentationMode==="embedded"&&m.jsxs("div",{className:"relative group flex-row flex items-end gap-3 max-w-[85%]",children:[m.jsx(xe.div,{initial:{scale:0},animate:{scale:1},transition:{delay:.1},className:`w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-semibold flex-shrink-0 shadow-lg ${e==="light"?"bg-gradient-to-br from-blue-500 to-purple-600":"bg-gradient-to-br from-gray-600 to_gray-700"}`,children:k}),m.jsxs("div",{className:`flex h-full flex-col justify-between border px-3 py-2 rounded-2xl shadow-lg backdrop-bl-sm message-bubble rounded-bl-md message-hover border-gray-200 dark:border-gray-700 ${E.chatMessage.other}`,children:[m.jsx(Qr,{interaction:S,theme:e,onDismiss:()=>t.dismissCurrentInteraction(),client:t,addLocalMessage:I},S.methodName),m.jsx(xe.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2},className:`text-xs ${E.text.muted} mt-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200 `,children:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})]}),m.jsx("div",{ref:T})]})})]}),se.length>0&&m.jsx("div",{className:"w-full flex overflow-x-auto gap-2 px-4 py-2 mb-1 scrollbar-hide",children:se.map((j,q)=>{var ee;return m.jsx("button",{className:`whitespace-nowrap px-3 py-1 rounded-full border shadow-sm flex-shrink-0 transition-all duration-150 font-medium text-sm focus:outline-none focus:ring-2 focus:ring-blue-400/40
|
|
313
|
-
${
|
|
314
|
-
`,style:{boxShadow:
|
|
25
|
+
${t==="light"?"hover:bg-gray-200 text-gray-600 hover:text-gray-800":"hover:bg-gray-600 text-gray-400 hover:text-gray-200"}
|
|
26
|
+
`,"aria-label":"Download file",children:a.jsx(pe.Download,{className:"w-4 h-4"})})]})]})}function Lf(){return a.jsxs("div",{className:"max-w-xs mx-auto bg-green-50 border border-green-200 rounded-lg shadow p-3 flex flex-col items-center",children:[a.jsx("div",{className:"text-2xl mb-2",children:"✅"}),a.jsx("div",{className:"text-green-700 font-semibold text-sm mb-1",children:"Success!"}),a.jsx("div",{className:"text-xs text-gray-600 text-center mb-1",children:"Your action was completed successfully."})]})}function Bf(){return a.jsxs("div",{className:"max-w-xs mx-auto bg-yellow-50 border border-yellow-200 rounded-lg shadow p-3 flex flex-col items-center",children:[a.jsx("div",{className:"text-2xl mb-2",children:"⏰"}),a.jsx("div",{className:"text-yellow-700 font-semibold text-sm mb-1",children:"Interaction timed out"}),a.jsx("div",{className:"text-xs text-gray-600 text-center mb-1",children:"No response was provided in time."})]})}function $f({client:e,theme:t="vox",onBack:n,disabled:s=!1,displayType:o="widget",onEndChat:r}){const[i,l]=h.useState(()=>{if(e&&typeof e.getChatMessages=="function"){const T=e.getChatMessages();return console.log("🔄 ChatView: Initializing with existing messages:",T.length),T}return[]}),[c,d]=h.useState(!0),[u,m]=h.useState(()=>{const T=e&&typeof e.getCurrentSession=="function"&&!!e.getCurrentSession(),F=e&&typeof e.getChatMessages=="function"&&e.getChatMessages().length>0;return!T&&!F}),[f,p]=h.useState(new Set),[g,x]=h.useState([]),[v,E]=h.useState(!1),[b,S]=h.useState(!1),[w,C]=h.useState(()=>{const T=e.getCurrentInteraction();return console.log("ChatView: Initializing with existing interaction:",(T==null?void 0:T.methodName)||"none"),T}),A=h.useRef(null),j=ye(t);h.useEffect(()=>{const T=()=>{const F=navigator.userAgent.toLowerCase(),B=["android","iphone","ipad","mobile","tablet"].some(O=>F.includes(O)),R="ontouchstart"in window||navigator.maxTouchPoints>0,_=window.innerWidth<=768,K=B||R&&_;E(K),K&&o==="widget"&&S(!0)};return T(),window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[o]),h.useEffect(()=>(b&&v&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.height="100%",document.documentElement.requestFullscreen&&document.documentElement.requestFullscreen().catch(console.log)),()=>{b&&v&&(document.body.style.overflow="unset",document.body.style.position="unset",document.body.style.width="unset",document.body.style.height="unset",document.fullscreenElement&&document.exitFullscreen().catch(console.log))}),[b,v]);const k=e.getCurrentAgentInfo(),D=(k==null?void 0:k.name)||"AI Assistant",L=D.split(" ").map(T=>T[0]).join("").toUpperCase().slice(0,2),W=h.useCallback(T=>{const F={id:`local_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,content:T,timestamp:new Date,sender:{id:"participant",name:"You",type:"participant"},metadata:{isLocal:!0}};l(Z=>(console.log("ChatView: Adding local message:",F.id),[...Z,F]))},[]);h.useEffect(()=>{var T,F,Z,B,R;console.log("💬 ChatView loading state:",{isLoading:u,hasActiveSession:!!((T=e==null?void 0:e.getCurrentSession)!=null&&T.call(e)),messagesCount:i.length,sessionId:(Z=(F=e==null?void 0:e.getCurrentSession)==null?void 0:F.call(e))==null?void 0:Z.id,hasStoredMessages:!!((R=(B=e==null?void 0:e.getChatMessages)==null?void 0:B.call(e))!=null&&R.length),isMobile:v,isFullscreen:b})},[u,i.length,e,v,b]);const H=h.useCallback((T=!1)=>{A.current&&(T?A.current.scrollIntoView({behavior:"auto"}):A.current.scrollIntoView({behavior:"smooth"}))},[]);h.useEffect(()=>{H(!0);const T=setTimeout(()=>{H(!1)},10);return()=>clearTimeout(T)},[i.length,H]),h.useEffect(()=>{if(w){H(!0);const T=setTimeout(()=>{H(!1)},50);return()=>clearTimeout(T)}},[w,H]),h.useEffect(()=>{const T=B=>{if(console.log("ChatView: Received message:",B),m(!1),w&&B.sender.type==="agent"){console.log("ChatView: Queuing agent message due to active interaction:",w.methodName),x(R=>[...R,B]);return}B.sender.type==="agent"&&d(!1),l(R=>{var K;if(R.some(O=>O.id===B.id))return console.log("ChatView: Message already exists, skipping:",B.id),R;if(console.log("ChatView: Adding new message:",B.id),B.sender.type==="agent"&&(p(O=>new Set(O).add(B.id)),!((K=B.metadata)!=null&&K.streaming))){const O=B.content.length*35+1e3;setTimeout(()=>{p(re=>{const oe=new Set(re);return oe.delete(B.id),oe})},O)}return[...R,B]}),setTimeout(()=>H(!0),0)},F=B=>{var R;if(console.log("ChatView: Updated message:",B),w&&B.sender.type==="agent"){console.log("ChatView: Queuing agent message update due to active interaction:",w.methodName),x(_=>{const K=_.findIndex(O=>O.id===B.id);if(K>=0){const O=[..._];return O[K]=B,O}else return[..._,B]});return}l(_=>_.map(K=>K.id===B.id?{...B}:K)),setTimeout(()=>H(!0),0),(R=B.metadata)!=null&&R.streaming||p(_=>{const K=new Set(_);return K.delete(B.id),K})},Z=B=>{console.log("ChatView: Sent message:",B),m(!1),l(R=>R.some(K=>K.id===B.id)?(console.log("ChatView: Sent message already exists, skipping:",B.id),R):(console.log("ChatView: Adding sent message:",B.id),[...R,B])),setTimeout(()=>H(!0),0)};return e.on("chat.message.received",T),e.on("chat.message.updated",F),e.on("chat.message.sent",Z),()=>{e.off("chat.message.received",T),e.off("chat.message.updated",F),e.off("chat.message.sent",Z)}},[e,w]),h.useEffect(()=>{const T=R=>{console.log("ChatView: RPC interaction started:",R);const _=e.getCurrentInteraction();console.log("ChatView: Got interaction from client:",_==null?void 0:_.methodName),C(_),d(!1),H(!0),setTimeout(()=>{H(!1)},100)},F=R=>{if(console.log("ChatView: RPC interaction completed:",R),C(null),g.length>0&&(console.log("ChatView: Processing",g.length,"queued messages"),l(_=>{const K=[..._];return g.forEach(O=>{var oe;if(!K.some(he=>he.id===O.id)&&(console.log("ChatView: Adding queued message:",O.id),K.push(O),O.sender.type==="agent"&&(p(he=>new Set(he).add(O.id)),!((oe=O.metadata)!=null&&oe.streaming)))){const he=O.content.length*35+1e3;setTimeout(()=>{p(ve=>{const De=new Set(ve);return De.delete(O.id),De})},he)}}),K}),x([]),setTimeout(()=>H(!0),0)),R&&R.response&&R.response.success){let _=null;R.response.successView?_=R.response.successView:R.successView&&(_=R.successView),l(K=>{const O=[...K].reverse().findIndex(ve=>ve.sender.type==="participant");let re=K.length;O!==-1&&(re=K.length-O);const oe={id:`success_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,content:"",timestamp:new Date,sender:{id:"participant",name:"You",type:"participant"},metadata:{type:"successView",view:_||a.jsx(Lf,{})}};e&&typeof e.addChatMessage=="function"&&e.addChatMessage(oe);const he=[...K];return he.splice(re,0,oe),he})}},Z=async R=>{w&&(console.log("ChatView: Dismissing active interaction due to timeout"),e.dismissCurrentInteraction()),C(null),g.length>0&&(console.log("ChatView: Processing",g.length,"queued messages after timeout"),l(K=>{const O=[...K];return g.forEach(re=>{var he;if(!O.some(ve=>ve.id===re.id)&&(O.push(re),re.sender.type==="agent"&&(p(ve=>new Set(ve).add(re.id)),!((he=re.metadata)!=null&&he.streaming)))){const ve=re.content.length*35+1e3;setTimeout(()=>{p(De=>{const Zt=new Set(De);return Zt.delete(re.id),Zt})},ve)}}),O}),x([]),setTimeout(()=>H(!0),0));let _=null;R&&R.response&&R.response.timeoutView?_=R.response.timeoutView:R&&R.timeoutView&&(_=R.timeoutView),l(K=>{const O={id:`timeout_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,content:"",timestamp:new Date,sender:{id:"agent",name:D,type:"agent"},metadata:{type:"timeoutView",view:_||a.jsx(Bf,{})}};return e&&typeof e.addChatMessage=="function"&&e.addChatMessage(O),[...K,O]}),setTimeout(()=>{e.getCurrentInteraction()||C(null)},100)},B=async R=>{console.log("ChatView: RPC interaction dismissed:",R),console.log("ChatView: Current interaction before dismiss:",w==null?void 0:w.methodName),C(null),g.length>0&&(console.log("ChatView: Processing",g.length,"queued messages after dismissal"),l(_=>{const K=[..._];return g.forEach(O=>{var oe;if(!K.some(he=>he.id===O.id)&&(K.push(O),O.sender.type==="agent"&&(p(he=>new Set(he).add(O.id)),!((oe=O.metadata)!=null&&oe.streaming)))){const he=O.content.length*35+1e3;setTimeout(()=>{p(ve=>{const De=new Set(ve);return De.delete(O.id),De})},he)}}),K}),x([]),setTimeout(()=>H(!0),0)),setTimeout(()=>{const _=e.getCurrentInteraction();console.log("ChatView: Latest interaction from client after dismiss:",(_==null?void 0:_.methodName)||"null"),_===null&&C(null)},50),console.log("ChatView: Set currentInteraction to null after dismiss")};return e.on("rpc.interaction.started",T),e.on("rpc.interaction.completed",F),e.on("rpc.interaction.timeout",Z),e.on("rpc.interaction.dismissed",B),()=>{e.off("rpc.interaction.started",T),e.off("rpc.interaction.completed",F),e.off("rpc.interaction.timeout",Z),e.off("rpc.interaction.dismissed",B)}},[e]),h.useEffect(()=>{const T=()=>{if(console.log("ChatView: Agent is thinking"),w){console.log("ChatView: Suppressing thinking indicator due to active interaction:",w.methodName);return}d(!0)},F=()=>{console.log("ChatView: Agent is speaking"),d(!1)};return e.on("agent.thinking",T),e.on("agent.speaking",F),()=>{e.off("agent.thinking",T),e.off("agent.speaking",F)}},[e,w]),h.useEffect(()=>{const T=e.getCurrentInteraction();T?(console.log("ChatView: Restoring interaction state on mount/client change:",T.methodName),C(T)):C(null)},[e]),h.useEffect(()=>{console.log("ChatView: Display type changed to:",o,"Current interaction:",(w==null?void 0:w.methodName)||"none")},[o,w]);const Ce=async T=>{try{w&&(console.log("ChatView: Dismissing active interaction due to user message send"),e.dismissCurrentInteraction(),C(null)),await e.sendChatMessage(T)}catch(F){console.error("Failed to send message:",F)}},ne=async T=>{try{w&&(console.log("ChatView: Dismissing active interaction due to user attachment send"),e.dismissCurrentInteraction(),C(null)),await e.sendAttachments(T),console.log("Attachments sent successfully:",T.map(F=>F.name))}catch(F){console.error("Failed to send attachments:",F)}},[te,se]=h.useState([]);if(h.useEffect(()=>{const T=F=>{se(Array.isArray(F)?F:["tes","hello how are you","algebra make me learn that ","what is the meaning of life"])};return e.on("suggested.response",T),()=>{e.off("suggested.response",T)}},[e]),u){const T=b&&v?"fixed inset-0 z-[9999] flex flex-col items-center justify-center h-screen w-screen bg-black":"flex w-full flex-col items-center justify-center h-full p-8";return a.jsxs("div",{className:T,children:[a.jsx("div",{className:`${j.spinner} w-12 h-12 mb-6`}),a.jsxs("p",{className:`text-sm text-center ${b&&v?"text-white":""}`,children:["Connecting to ",D,"..."]})]})}const z=b&&v?"fullscreen":o,M=z==="fullscreen"?b&&v?"fixed inset-0 z-[9999] flex flex-col h-screen w-screen bg-black":"flex flex-col h-full w-full max-w-none":"flex flex-col h-full w-full backdrop-blur-sm",G=z==="fullscreen"?b&&v?"flex items-center w-full justify-between px-4 pt-3 pb-3 bg-black/80 text-white border-b border-gray-700":`flex items-center w-full justify-between px-6 pt-5 pb-4 border-b ${j.chatHeader.container}`:`flex items-center w-full justify-between px-4 pt-5 pb-4 border-b ${j.chatHeader.container}`,Y=z==="fullscreen"?b&&v?"flex-1 overflow-y-auto scrollbar-hide p-4 w-full max-w-none chat-scrollable min-h-0":"flex-1 overflow-y-auto scrollbar-hide p-6 w-full max-w-none chat-scrollable min-h-0":"flex-1 overflow-y-auto scrollbar-hide w-full p-4 chat-scrollable min-h-0",V="flex-shrink-0 !w-full",q=()=>{S(!1),n&&n()};return a.jsxs("div",{className:M,children:[a.jsx("div",{className:G,children:a.jsxs("div",{className:"flex items-center gap-2",children:[b&&v&&a.jsx(Q.button,{onClick:q,whileHover:{scale:1.05},whileTap:{scale:.95},className:"p-2 rounded-full bg-white/20 hover:bg-white/30 text-white transition-colors mr-2","aria-label":"Exit fullscreen",children:"✕"}),a.jsxs("div",{children:[a.jsx("h3",{className:`font-semibold text-base leading-tight ${b&&v?"text-white":j.text.primary}`,children:D}),a.jsxs("p",{className:`text-xs flex items-center gap-1.5 mt-0.5 ${b&&v?"text-gray-300":j.text.muted}`,children:[a.jsx("span",{className:"w-1.5 h-1.5 bg-green-500 rounded-full animate-pulse"}),"Online"]})]})]})}),a.jsxs("div",{className:`${Y} flex flex-col`,style:{scrollBehavior:"smooth",scrollbarWidth:"none"},children:[" ",i.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center flex-1 text-center py-12",children:[a.jsx(Q.div,{transition:{duration:2,repeat:1/0,ease:"easeInOut"},className:"w-16 h-16 rounded-full bg-gradient-to-br from-blue-500 to-purple-600 flex items-center justify-center text-white font-bold text-xl mb-6 shadow-xl",children:L}),a.jsxs("p",{className:`text-base mb-2 ${b&&v?"text-white":j.text.secondary}`,children:[D," is joining..."]}),a.jsx("p",{className:`text-xs ${b&&v?"text-gray-300":j.text.muted}`,children:"Your conversation will begin shortly"})]}):a.jsx("div",{className:"w-full max-w-5xl mx-auto space-y-3 py-4 flex-1 flex flex-col justify-end",children:a.jsxs("div",{className:"space-y-3",children:[i.map((T,F)=>{var Z,B;return a.jsx("div",{children:((Z=T.metadata)==null?void 0:Z.type)==="successView"?a.jsx("div",{className:"flex w-full justify-end mb-4 px-1",children:a.jsxs("div",{className:"relative group flex-row-reverse flex items-end gap-3 max-w-[85%]",children:[a.jsx(Q.div,{initial:{scale:0},animate:{scale:1},transition:{delay:.1},className:`w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-semibold flex-shrink-0 shadow-lg ${t==="light"?"bg-gradient-to-br from-blue-500 to-purple-600":"bg-gradient-to-br from-gray-600 to-gray-700"}`,children:"Y"}),a.jsxs("div",{className:`flex h-full flex-col justify-between border px-3 py-2 rounded-2xl shadow-lg backdrop-bl-sm message-bubble rounded-br-md message-hover border-gray-200 dark:border-gray-700 ${j.chatMessage.own}`,children:[T.metadata.view,a.jsx("div",{className:`text-xs ${j.text.muted} mt-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200 `,children:T.timestamp.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})]})}):((B=T.metadata)==null?void 0:B.type)==="timeoutView"?a.jsx("div",{className:"flex w-full justify-start mb-4 px-1",children:a.jsxs("div",{className:"relative group flex-row flex items-end gap-3 max-w-[85%]",children:[a.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-semibold flex-shrink-0 shadow-lg ${t==="light"?"bg-gradient-to-br from-blue-500 to-purple-600":"bg-gradient-to-br from-gray-600 to_gray-700"}`,children:L}),a.jsxs("div",{className:`flex h-full flex-col justify-between border px-3 py-2 rounded-2xl shadow-lg backdrop-bl-sm message-bubble rounded-bl-md message-hover border-gray-200 dark:border-gray-700 ${j.chatMessage.other}`,children:[T.metadata.view,a.jsx("div",{className:`text-xs ${j.text.muted} mt-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200 `,children:T.timestamp.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})]})}):a.jsx(Rf,{message:T,theme:t,isOwn:T.sender.type==="participant",isStreaming:f.has(T.id)})},T.id)}),c&&!w&&a.jsx(Q.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:i.length*.1},className:"flex w-full justify-start mb-4 px-1",children:a.jsxs("div",{className:"relative group flex-row flex items-end gap-3 max-w-[85%]",children:[a.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-semibold flex-shrink-0 shadow-lg ${t==="light"?"bg-gradient-to-br from-blue-500 to-purple-600":"bg-gradient-to-br from-gray-600 to-gray-700"}`,children:L}),a.jsx("div",{className:`relative px-3 py-2 rounded-2xl break-words shadow-lg backdrop-blur-sm message-bubble message-hover ${j.chatMessage.other} rounded-bl-md transition-all duration-200 group-hover:scale-[1.02]`,style:{wordWrap:"break-word",overflowWrap:"break-word",minWidth:48},children:a.jsx("span",{className:"inline-flex items-center",children:[0,1,2].map(T=>a.jsx(Q.span,{className:"w-1.5 h-1.5 bg-current rounded-full mx-0.5",animate:{y:[0,-4,0],opacity:[.4,1,.4],scale:[.8,1,.8]},transition:{duration:.8,repeat:1/0,repeatType:"mirror",delay:T*.2,ease:"easeInOut"}},T))})})]})}),w&&w.presentationMode==="embedded"&&a.jsxs("div",{className:"relative group flex-row flex items-end gap-3 max-w-[85%]",children:[a.jsx(Q.div,{initial:{scale:0},animate:{scale:1},transition:{delay:.1},className:`w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-semibold flex-shrink-0 shadow-lg ${t==="light"?"bg-gradient-to-br from-blue-500 to-purple-600":"bg-gradient-to-br from-gray-600 to_gray-700"}`,children:L}),a.jsxs("div",{className:`flex h-full flex-col justify-between border px-3 py-2 rounded-2xl shadow-lg backdrop-bl-sm message-bubble rounded-bl-md message-hover border-gray-200 dark:border-gray-700 ${j.chatMessage.other}`,children:[a.jsx(pt,{interaction:w,theme:t,onDismiss:()=>e.dismissCurrentInteraction(),client:e,addLocalMessage:W},w.methodName),a.jsx(Q.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2},className:`text-xs ${j.text.muted} mt-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200 `,children:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})]}),a.jsx("div",{ref:A})]})})]}),te.length>0&&a.jsx("div",{className:"w-full flex overflow-x-auto gap-2 px-4 py-2 mb-1 scrollbar-hide",children:te.map((T,F)=>{var Z;return a.jsx("button",{className:`whitespace-nowrap px-3 py-1 rounded-full border shadow-sm flex-shrink-0 transition-all duration-150 font-medium text-sm focus:outline-none focus:ring-2 focus:ring-blue-400/40
|
|
27
|
+
${t==="light"?"bg-white text-blue-700 border-blue-200 hover:bg-blue-50 hover:text-blue-900":t==="dark"?"bg-gray-800 text-blue-300 border-gray-700 hover:bg-gray-700 hover:text-white":((Z=j.suggestedResponse)==null?void 0:Z.container)||"bg-gradient-to-br from-blue-500 to-purple-600 text-white border-blue-400 hover:from-blue-600 hover:to-purple-700"}
|
|
28
|
+
`,style:{boxShadow:t==="vox"?"0 2px 8px 0 rgba(80,60,200,0.10)":void 0,borderWidth:1},onClick:()=>{Ce(T),se([])},children:T},T+F)})}),w&&w.presentationMode!=="embedded"&&a.jsx(pt,{interaction:w,theme:t,onDismiss:()=>e.dismissCurrentInteraction(),client:e,addLocalMessage:W},w.methodName),a.jsx(Q.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},className:V,children:a.jsx(Nf,{onSendMessage:Ce,onSendAttachments:ne,disabled:s,theme:t,onEndChat:r})})]})}function Of({onToggleCamera:e,onToggleScreenShare:t,onEndCall:n,onBack:s,theme:o,cameraEnabled:r,screenShareEnabled:i,isCameraLoading:l,isScreenShareLoading:c,disabled:d}){const u=ye(o);return a.jsxs("div",{className:`flex items-center justify-center gap-3 p-4 ${u.video.controlsBackground}`,children:[a.jsx("button",{onClick:e,disabled:d||l,className:`p-3 rounded-full transition-all duration-200 ${r?u.video.controlEnabled:u.video.controlDisabled} ${d?"opacity-50 cursor-not-allowed":"hover:scale-105"}`,title:r?"Turn off camera":"Turn on camera",children:l?a.jsx("div",{className:"w-5 h-5 animate-spin rounded-full border-2 border-current border-t-transparent"}):r?a.jsx(pe.Camera,{className:"w-5 h-5"}):a.jsx(pe.CameraOff,{className:"w-5 h-5"})}),a.jsx("button",{onClick:t,disabled:d||c,className:`p-3 rounded-full transition-all duration-200 ${i?u.video.controlEnabled:u.video.controlDisabled} ${d?"opacity-50 cursor-not-allowed":"hover:scale-105"}`,title:i?"Stop screen share":"Share screen",children:c?a.jsx("div",{className:"w-5 h-5 animate-spin rounded-full border-2 border-current border-t-transparent"}):i?a.jsx(pe.MonitorOff,{className:"w-5 h-5"}):a.jsx(pe.Monitor,{className:"w-5 h-5"})}),n&&a.jsx("button",{onClick:n,disabled:d,className:`p-3 rounded-full transition-all duration-200 ${u.video.endCall} ${d?"opacity-50 cursor-not-allowed":"hover:scale-105"}`,title:"End call",children:a.jsx(pe.PhoneOff,{className:"w-5 h-5"})}),s&&a.jsx("button",{onClick:s,disabled:d,className:`p-3 rounded-full transition-all duration-200 ${u.video.controlDisabled} ${d?"opacity-50 cursor-not-allowed":"hover:scale-105"}`,title:"Back",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 19l-7-7m0 0l7-7m-7 7h18"})})})]})}function Fi({trackRef:e,participant:t,isLocal:n=!1,className:s="",theme:o}){var c;const r=ye(o),i=(t==null?void 0:t.name)||(t==null?void 0:t.identity)||(n?"You":"Participant"),l=(e==null?void 0:e.publication)&&!e.publication.isMuted;return a.jsxs("div",{className:`relative rounded-lg overflow-hidden ${r.video.tile} ${s}`,children:[l?a.jsx(ue.VideoTrack,{trackRef:e,className:"w-full h-full object-cover"}):a.jsx("div",{className:`w-full h-full flex items-center justify-center ${r.video.placeholder}`,children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:`w-16 h-16 mx-auto mb-2 rounded-full flex items-center justify-center ${r.video.avatar}`,children:a.jsx(pe.User,{className:"w-8 h-8"})}),a.jsx("p",{className:"text-sm opacity-80",children:i}),a.jsx("p",{className:"text-xs opacity-60",children:"Camera off"})]})}),a.jsx("div",{className:`absolute bottom-2 left-2 px-2 py-1 rounded text-xs ${r.video.nameOverlay}`,children:i}),((c=e==null?void 0:e.publication)==null?void 0:c.isMuted)&&a.jsx("div",{className:`absolute top-2 right-2 p-1 rounded ${r.video.mutedIndicator}`,children:a.jsx(pe.CameraOff,{className:"w-4 h-4"})})]})}function _f({trackRefs:e,participants:t,theme:n,localParticipant:s}){const o=e.find(u=>u.source===I.Track.Source.Camera&&u.participant===s),r=e.filter(u=>u.participant!==s),i=e.length,l=i<=1?1:i<=4?2:3,c="grid gap-2 h-full",d={gridTemplateColumns:`repeat(${l}, 1fr)`,gridAutoRows:"minmax(0, 1fr)"};return a.jsxs("div",{className:c,style:d,children:[o&&s&&a.jsx(Fi,{trackRef:o,participant:s,isLocal:!0,theme:n,className:"min-h-0"}),r.map((u,m)=>{var f;return a.jsx(Fi,{trackRef:u,participant:u.participant,isLocal:!1,theme:n,className:"min-h-0"},((f=u.publication)==null?void 0:f.trackSid)||m)}),i===0&&a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center",children:[a.jsx(pe.Users,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),a.jsx("p",{className:"text-lg opacity-70",children:"Waiting for participants..."}),a.jsx("p",{className:"text-sm opacity-50",children:"Turn on your camera to start the video call"})]})})]})}function Hf({client:e,theme:t="vox",onBack:n,disabled:s=!1,displayType:o,onEndCall:r}){const i=ye(t),l=ue.useMaybeRoomContext(),[c,d]=h.useState(!1),[u,m]=h.useState(!1),[f,p]=h.useState(!1),[g,x]=h.useState(!1),[v,E]=h.useState(null),b=ue.useTracks([I.Track.Source.Camera,I.Track.Source.ScreenShare],{onlySubscribed:!1});b.filter(j=>j.source===I.Track.Source.Camera),b.filter(j=>j.source===I.Track.Source.ScreenShare);const S=h.useMemo(()=>l?Array.from(l.remoteParticipants.values()):[],[l]),w=h.useCallback(async()=>{if(!(!l||f)){p(!0);try{const j=l.localParticipant;c?(await j.setCameraEnabled(!1),d(!1)):(await j.setCameraEnabled(!0),d(!0))}catch(j){console.error("Failed to toggle camera:",j)}finally{p(!1)}}},[l,c,f]),C=h.useCallback(async()=>{if(!(!l||g)){x(!0);try{const j=l.localParticipant;u?(await j.setScreenShareEnabled(!1),m(!1)):(await j.setScreenShareEnabled(!0),m(!0))}catch(j){console.error("Failed to toggle screen share:",j)}finally{x(!1)}}},[l,u,g]),A=h.useCallback(()=>{r?r():n&&n()},[r,n]);return h.useEffect(()=>{if(!e)return;const j=k=>{console.log("📺 Video: Interactive UI state updated:",k),E(k)};return e.on("interactive.ui.update",j),e.on("interactive.ui.show",j),()=>{e.off("interactive.ui.update",j),e.off("interactive.ui.show",j)}},[e]),a.jsxs("div",{className:`flex flex-col h-full ${i.video.container}`,children:[a.jsxs("div",{className:`flex items-center justify-between p-4 border-b ${i.video.header}`,children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`w-3 h-3 rounded-full ${i.video.statusDot}`}),a.jsx("span",{className:"font-medium",children:"Video Call"}),a.jsxs("span",{className:"text-sm opacity-70",children:[S.length+1," participant",S.length!==0?"s":""]})]}),a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("button",{className:`p-2 rounded-lg transition-colors ${i.video.headerButton}`,title:"Layout options",children:a.jsx(pe.LayoutGrid,{className:"w-4 h-4"})})})]}),a.jsx("div",{className:"flex-1 p-4 min-h-0",children:a.jsx(_f,{trackRefs:b,participants:S,localParticipant:l==null?void 0:l.localParticipant,theme:t})}),v&&a.jsx(Q.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},className:"absolute inset-4 z-10",children:a.jsx(pt,{interaction:v,onDismiss:()=>E(null),theme:t})}),a.jsx(Of,{onToggleCamera:w,onToggleScreenShare:C,onEndCall:A,onBack:n,theme:t,cameraEnabled:c,screenShareEnabled:u,isCameraLoading:f,isScreenShareLoading:g,disabled:s})]})}function Jt({onClick:e,disabled:t,theme:n}){const s=ye(n);return a.jsx("button",{className:s.micButton,onClick:e,disabled:t,"aria-label":"Start Voice Session",type:"button",children:a.jsx(Be.Mic,{})})}function On({onClick:e,disabled:t,theme:n}){const s=ye(n);return a.jsx("button",{className:s.chatButton,onClick:e,disabled:t,"aria-label":"Start Chat Session",type:"button",children:a.jsx(Be.Chat,{})})}function _n({onClick:e,disabled:t,theme:n}){const s=ye(n);return a.jsx("button",{className:s.videoButton,onClick:e,disabled:t,"aria-label":"Start Video Session",type:"button",children:a.jsx(Be.Videocam,{})})}function Zf({prompts:e,theme:t}){const n=ye(t),[s,o]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>{o(i=>(i+1)%e.length)},3e3);return()=>clearInterval(r)},[e.length]),a.jsx("div",{className:"w-96 min-h-[3rem] h-12 relative overflow-hidden flex items-center justify-center",children:e.map((r,i)=>a.jsx("div",{className:`
|
|
315
29
|
${n.promptSlider}
|
|
316
|
-
${
|
|
30
|
+
${i===s?"opacity-100":"opacity-0"}
|
|
317
31
|
whitespace-pre-line break-words
|
|
318
|
-
`,style:{minHeight:"2.5rem",display:o===i?"block":"none"},children:s},o))})}function Uj({statusMessage:t,theme:e}){const n=St(e);return m.jsxs("div",{className:"z-10 flex items-center space-x-2 mt-2 pb-2",children:[m.jsx("div",{className:n.statusIndicator}),m.jsx("span",{className:`text-xs ${n.text.muted}`,children:t})]})}const Bj=({disabled:t,onStartCall:e,onStartChat:n,onStartVideo:i,prompts:r=['"Book a meeting with the marketing team"',`"What's the status of project Alpha?"`,`"Summarize yesterday's sales report"`,'"Find a good Italian restaurant nearby"','"Remind me to call John tomorrow at 10 AM"'],statusMessage:s="Agent is ready",title:o="Choose how to interact",subTitle:a="Ask me anything or give me a task to complete",theme:c="vox",modalities:l=["voice","chat","video"]})=>{const d=St(c),u=l.includes("voice"),f=l.includes("chat"),p=l.includes("video"),v=[u,f,p].filter(Boolean).length;return console.log("🎯 Welcome component debug:",{modalities:l,hasVoice:u,hasChat:f,hasVideo:p,totalButtons:v,onStartVideo:!!i}),m.jsxs("div",{inert:t,className:"flex p-8 flex-col items-center h-full justify-center w-full",children:[m.jsxs("div",{className:"mt-1 relative flex items-center justify-center mb-8 w-full",style:{minHeight:"120px"},children:[m.jsxs("div",{className:"absolute inset-0 flex items-center justify-center",children:[m.jsx("div",{className:d.pulseRings.ring1}),m.jsx("div",{className:d.pulseRings.ring2,style:{animationDelay:"0.5s"}}),m.jsx("div",{className:d.pulseRings.ring3,style:{animationDelay:"1s"}})]}),m.jsx("div",{className:"relative z-10 flex items-center justify-center",children:u&&f&&p?m.jsxs("div",{className:"flex gap-4 items-center justify-center",children:[m.jsx(Wo,{onClick:e,disabled:t,theme:c}),m.jsx(Ul,{onClick:n,disabled:t,theme:c}),m.jsx(Bl,{onClick:i||e,disabled:t,theme:c})]}):v>1?m.jsxs("div",{className:"flex gap-6 items-center justify-center",children:[u&&m.jsx(Wo,{onClick:e,disabled:t,theme:c}),f&&m.jsx(Ul,{onClick:n,disabled:t,theme:c}),p&&i&&m.jsx(Bl,{onClick:i,disabled:t,theme:c})]}):m.jsx("div",{className:"flex items-center justify-center",children:u?m.jsx(Wo,{onClick:e,disabled:t,theme:c}):f?m.jsx(Ul,{onClick:n,disabled:t,theme:c}):p&&i?m.jsx(Bl,{onClick:i,disabled:t,theme:c}):m.jsx(Wo,{onClick:e,disabled:t,theme:c})})})]}),m.jsxs("div",{className:"text-center flex flex-col items-center gap-y-2 mb-6 w-full",children:[m.jsx("h3",{className:`text-xl font-semibold mb-2 ${d.text.accent}`,children:o}),m.jsx("p",{className:`text-sm leading-relaxed px-4 ${d.text.secondary}`,children:a}),v>1&&m.jsxs("div",{className:"flex gap-6 mt-4 text-xs justify-center",children:[u&&m.jsxs("div",{className:"flex flex-col items-center gap-1",children:[m.jsx(QS,{className:"w-4 h-4"}),m.jsx("span",{className:d.text.muted,children:"Voice"})]}),f&&m.jsxs("div",{className:"flex flex-col items-center gap-1",children:[m.jsx(XS,{className:"w-4 h-4"}),m.jsx("span",{className:d.text.muted,children:"Chat"})]}),p&&m.jsxs("div",{className:"flex flex-col items-center gap-1",children:[m.jsx(ew,{className:"w-4 h-4"}),m.jsx("span",{className:d.text.muted,children:"Video"})]})]})]}),m.jsx(Fj,{prompts:r,theme:c}),m.jsx(Uj,{statusMessage:s,theme:c})]})};function tw({room:t,onSessionEnd:e,onSessionStart:n,enableConsoleLogging:i=!0,enableLocalStorage:r=!0,voxketSessionId:s}={}){const[o,a]=g.useState(null),[c,l]=g.useState([]),[d,u]=g.useState(null),[f,p]=g.useState([]),v=g.useCallback((w,C)=>{const S={timestamp:new Date,event:w,data:C,sessionId:o==null?void 0:o.sessionId,participantId:d==null?void 0:d.identity};if(l(x=>[...x,S]),r){const x=JSON.parse(localStorage.getItem("voxket-session-logs")||"[]");x.push(S),localStorage.setItem("voxket-session-logs",JSON.stringify(x))}return S},[o==null?void 0:o.sessionId,d==null?void 0:d.identity,i,r]);g.useEffect(()=>{if(!t)return;const w=()=>{const k=s||`session-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,I=new Date,N={sessionId:k,startTime:I,totalMessages:0,connectionIssues:0,participantCount:f.length,events:[]};a(N),v("SESSION_STARTED",{sessionId:k,startTime:I}),n==null||n(k)},C=()=>{if(o){const k=new Date,I=k.getTime()-o.startTime.getTime(),N={...o,endTime:k,duration:I,events:c};v("SESSION_ENDED",{sessionId:o.sessionId,duration:`${Math.round(I/1e3)}s`,totalMessages:o.totalMessages,connectionIssues:o.connectionIssues}),e==null||e(N),a(null),l([])}},S=k=>{v("CONNECTION_STATE_CHANGED",{state:k}),k===ge.Reconnecting&&o&&(a(I=>I?{...I,connectionIssues:I.connectionIssues+1}:null),v("CONNECTION_ISSUE",{type:"reconnecting"}))},x=k=>{v("TRACK_PUBLISHED",{trackKind:k.kind,trackSource:k.source})},T=k=>{v("TRACK_UNPUBLISHED",{trackKind:k.kind,trackSource:k.source})},E=(k,I)=>{o&&a(N=>N?{...N,totalMessages:N.totalMessages+1}:null),v("DATA_RECEIVED",{participantId:I==null?void 0:I.identity,dataSize:k.length})},P=k=>{v("PARTICIPANT_CONNECTED",{participantId:k.identity,participantName:k.name}),p(I=>[...I,k]),o&&a(I=>I?{...I,participantCount:I.participantCount+1}:null)},_=k=>{v("PARTICIPANT_DISCONNECTED",{participantId:k.identity,participantName:k.name}),p(I=>I.filter(N=>N.identity!==k.identity))};return t.localParticipant&&u(t.localParticipant),t.on(U.Connected,w),t.on(U.Disconnected,C),t.on(U.ConnectionStateChanged,S),t.on(U.TrackPublished,x),t.on(U.TrackUnpublished,T),t.on(U.DataReceived,E),t.on(U.ParticipantConnected,P),t.on(U.ParticipantDisconnected,_),()=>{t.off(U.Connected,w),t.off(U.Disconnected,C),t.off(U.ConnectionStateChanged,S),t.off(U.TrackPublished,x),t.off(U.TrackUnpublished,T),t.off(U.DataReceived,E),t.off(U.ParticipantConnected,P),t.off(U.ParticipantDisconnected,_)}},[t,o,c,f.length,v,e,n]);const h=g.useCallback(()=>r?JSON.parse(localStorage.getItem("voxket-session-logs")||"[]"):c,[c,r]),y=g.useCallback(()=>{r&&localStorage.removeItem("voxket-session-logs"),l([])},[r]),b=g.useCallback(()=>{const w=h(),C=JSON.stringify(w,null,2),S="data:application/json;charset=utf-8,"+encodeURIComponent(C),x=`voxket-session-logs-${new Date().toISOString().split("T")[0]}.json`,T=document.createElement("a");T.setAttribute("href",S),T.setAttribute("download",x),T.click()},[h]);return{sessionMetrics:o,sessionLogs:c,logEvent:v,getSessionLogs:h,clearSessionLogs:y,exportSessionLogs:b}}var wr={},E0;function $j(){if(E0)return wr;E0=1;var t=bu;if(process.env.NODE_ENV==="production")wr.createRoot=t.createRoot,wr.hydrateRoot=t.hydrateRoot;else{var e=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;wr.createRoot=function(n,i){e.usingClientEntryPoint=!0;try{return t.createRoot(n,i)}finally{e.usingClientEntryPoint=!1}},wr.hydrateRoot=function(n,i,r){e.usingClientEntryPoint=!0;try{return t.hydrateRoot(n,i,r)}finally{e.usingClientEntryPoint=!1}}}return wr}var Hj=$j();class rh{constructor(){at(this,"listeners",{})}on(e,n){return this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(n),()=>this.off(e,n)}once(e,n){const i=(...r)=>{this.off(e,i),n(...r)};return this.on(e,i)}off(e,n){const i=this.listeners[e];if(!i)return;const r=i.indexOf(n);r>-1&&i.splice(r,1)}removeAllListeners(e){e?delete this.listeners[e]:this.listeners={}}emit(e,...n){const i=this.listeners[e];if(!i)return;const r=[...i];for(const s of r)try{s(...n)}catch(o){console.error(`Error in event listener for ${String(e)}:`,o)}}listenerCount(e){var n;return((n=this.listeners[e])==null?void 0:n.length)??0}eventNames(){return Object.keys(this.listeners)}}class nw{constructor(e){at(this,"plugins",new Map);at(this,"installedPlugins",new Set);at(this,"context");this.context={client:e,emit:e.emit.bind(e),on:e.on.bind(e),config:{}}}register(e){if(this.plugins.has(e.name))throw new Error(`Plugin '${e.name}' is already registered`);if(e.dependencies){for(const n of e.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin '${e.name}' depends on '${n}' which is not registered`)}this.plugins.set(e.name,e)}async install(e,n){const i=this.plugins.get(e);if(!i)throw new Error(`Plugin '${e}' is not registered`);if(this.installedPlugins.has(e))throw new Error(`Plugin '${e}' is already installed`);if(i.dependencies)for(const s of i.dependencies)this.installedPlugins.has(s)||await this.install(s);const r={...this.context,config:{...i.config,...n}};i.install&&await i.install(r),this.installedPlugins.add(e),this.setupPluginEvents(i,r)}async uninstall(e){var i;const n=this.plugins.get(e);if(!n)throw new Error(`Plugin '${e}' is not registered`);if(this.installedPlugins.has(e)){for(const[r,s]of this.plugins)if(this.installedPlugins.has(r)&&((i=s.dependencies)!=null&&i.includes(e)))throw new Error(`Cannot uninstall '${e}' because '${r}' depends on it`);n.uninstall&&await n.uninstall(this.context),this.installedPlugins.delete(e)}}isInstalled(e){return this.installedPlugins.has(e)}getInstalledPlugins(){return Array.from(this.installedPlugins)}getAvailablePlugins(){return Array.from(this.plugins.keys())}getPluginInfo(e){return this.plugins.get(e)}setupPluginEvents(e,n){e.onSessionStart&&n.on("session.started",i=>{e.onSessionStart(n,i.id)}),e.onSessionEnd&&n.on("session.ended",i=>{e.onSessionEnd(n,i.id)}),e.onAgentResponse&&n.on("agent.response",i=>{e.onAgentResponse(n,i)})}}function zj(t){return t}function sh(t,e,n){return{name:t,version:"1.0.0",description:`${e} modality plugin`,install:async i=>{n.onActivate&&await n.onActivate(i)},uninstall:async i=>{n.onDeactivate&&await n.onDeactivate(i)},onAgentResponse:n.onMessage}}const Wj={name:"analytics",version:"1.0.0",description:"Built-in analytics tracking",install:async t=>{console.log("Analytics plugin installed"),t.on("session.started",e=>{console.log("Analytics: Session started",e.id)}),t.on("session.ended",(e,n)=>{console.log("Analytics: Session ended",e.id,n)}),t.on("chat.message.sent",e=>{console.log("Analytics: User message sent",e.content.length)})}},qj={name:"debug",version:"1.0.0",description:"Debug logging and development tools",install:async t=>{console.log("Debug plugin installed");const e=t.emit;t.emit=(n,...i)=>(console.log(`[Debug] Event: ${String(n)}`,i),e(n,...i))}},Kj={name:"metrics",version:"1.0.0",description:"Advanced metrics collection",install:async t=>{console.log("Metrics plugin installed");const e=new Map;t.on("session.started",n=>{e.set(n.id,{startTime:Date.now(),events:[]})}),t.on("agent.response",n=>{console.log("Metrics: Agent response analyzed",{type:n.type,length:n.content.length,timestamp:n.timestamp})})}},iw=R.createContext(null);function rw({config:t,children:e,autoConnect:n=!1}){const[i,r]=R.useState(null),[s,o]=R.useState(!1),[a,c]=R.useState(!1),[l,d]=R.useState(null),[u,f]=R.useState(null),[p,v]=R.useState("idle"),[h,y]=R.useState(null),[b,w]=R.useState([]),[C,S]=R.useState([]),[x,T]=R.useState([]);R.useEffect(()=>{const O=new bo(t);return r(O),E(O),n&&P(O),()=>{O.disconnect().catch(console.error)}},[t,n]);const E=O=>{O.on("connection.connecting",()=>{c(!0),d(null)}),O.on("connection.connected",()=>{o(!0),c(!1),d(null)}),O.on("connection.disconnected",()=>{o(!1),c(!1),f(null),v("idle"),w([]),S([]),T([])}),O.on("connection.error",oe=>{d(oe),c(!1)}),O.on("session.created",oe=>{f(oe),v(oe.state)}),O.on("session.state.changed",oe=>{v(oe),u&&f({...u,state:oe})}),O.on("session.ended",(oe,L)=>{f(null),v("idle"),y(L),w([]),S([]),T([])}),O.on("participant.joined",oe=>{w(L=>[...L,oe])}),O.on("participant.left",oe=>{w(L=>L.filter(F=>F.id!==oe.id))}),O.on("chat.message.received",oe=>{S(L=>[...L,oe])}),O.on("chat.message.sent",oe=>{S(L=>[...L,oe])}),O.on("transcription.received",oe=>{T(L=>[...L,oe])})},P=async O=>{const oe=O||i;if(oe)try{await oe.connect()}catch(L){console.error("Failed to connect:",L)}},X={client:i,isConnected:s,isConnecting:a,connectionError:l,currentSession:u,sessionState:p,sessionMetrics:h,participants:b,chatMessages:C,transcriptions:x,connect:()=>P(),disconnect:async()=>{if(i)try{await i.disconnect()}catch(O){console.error("Failed to disconnect:",O)}},createSession:async(O,oe={})=>{if(!i)throw new Error("Client not initialized");const L={agentId:O,participantName:oe.participantName||"User",metadata:oe.metadata,modalities:oe.modalities||["voice"]};return await i.createSession(L)},endSession:async()=>i?await i.endSession():null,sendChatMessage:async O=>{if(!i)throw new Error("Client not initialized");await i.sendChatMessage(O)},setMicrophoneEnabled:async O=>{if(!i)throw new Error("Client not initialized");await i.setMicrophoneEnabled(O)},setCameraEnabled:async O=>{if(!i)throw new Error("Client not initialized");await i.setCameraEnabled(O)},startScreenShare:async()=>{if(!i)throw new Error("Client not initialized");await i.startScreenShare()},stopScreenShare:async()=>{if(!i)throw new Error("Client not initialized");await i.stopScreenShare()}};return m.jsx(iw.Provider,{value:X,children:e})}function jn(){const t=R.useContext(iw);if(!t)throw new Error("useVoxket must be used within a VoxketProvider");return t}class Gj extends rh{constructor(n){super();at(this,"room",null);at(this,"registeredMethods",new Map);at(this,"activeInteractions",new Map);at(this,"currentInteraction",null);n&&this.setRoom(n)}setRoom(n){this.room=n}async registerFrontendRPC(n,i,r="embedded"){if(console.log(`RpcManager: Starting registration for method '${n}'`),!this.room)throw console.error(`RpcManager: Cannot register '${n}' - no room instance`),new Error("Room not initialized. Cannot register RPC method.");if(!this.room.localParticipant)throw console.error(`RpcManager: Cannot register '${n}' - no local participant`),new Error("Local participant not available for RPC registration");console.log(`RpcManager: Room state: ${this.room.state}`),console.log(`RpcManager: Local participant: ${this.room.localParticipant.identity}`),console.log(`RpcManager: Registering frontend RPC method: ${n}`);const s={methodName:n,component:i,presentationMode:r};this.registeredMethods.set(n,s);try{this.room.registerRpcMethod(n,async o=>{console.log(`RpcManager: RPC method '${n}' called by ${o.callerIdentity}`),console.log("RpcManager: Payload:",o.payload),this.emit("rpc.method.called",{methodName:n,data:o});let a;console.log(`RpcManager: Current registration for '${n}':`,s);let c=o.responseTimeout||30;try{a=JSON.parse(o.payload)}catch{a=o.payload}try{const l=await this.awaitUserInteraction(n,i,r,a,c);return JSON.stringify(l)}catch(l){throw console.error(`RpcManager: Error in RPC method '${n}':`,l),l}}),this.emit("rpc.method.registered",{methodName:n}),console.log(`RpcManager: Successfully registered RPC method: ${n}`)}catch(o){throw console.error(`RpcManager: Failed to register RPC method '${n}':`,o),o}}async awaitUserInteraction(n,i,r,s,o){return new Promise((a,c)=>{const l=`${n}_${Date.now()}`;console.log(`RpcManager: Starting user interaction for method: ${n}, timeout: ${o} seconds`);const d={didSuccess:(f,p)=>{console.log(`RpcManager: User interaction successful for method: ${n}`,f),this.clearInteraction(l),this.currentInteraction=null;const v={success:!0,message:"User interaction completed successfully",data:f,timestamp:new Date,...p?{successView:p}:{}};this.emit("rpc.interaction.completed",{methodName:n,response:v}),a(v)},didFail:f=>{console.log(`RpcManager: User interaction failed for method: ${n}`,f),this.clearInteraction(l);const p={success:!1,message:"User interaction failed",error:f,timestamp:new Date};this.emit("rpc.interaction.completed",{methodName:n,response:p}),a(p)},dismissView:()=>{var p;console.log(`RpcManager: User dismissed interaction for method: ${n}`),console.log("RpcManager: Current interaction before dismiss:",(p=this.currentInteraction)==null?void 0:p.methodName),this.clearInteraction(l),this.currentInteraction=null,console.log("RpcManager: Current interaction after dismiss:",this.currentInteraction);const f={success:!0,data:{dismissed:!0,reason:"User dismissed the interaction"},message:"User interaction dismissed",timestamp:new Date};this.emit("rpc.interaction.dismissed",{methodName:n,response:f}),this.emit("rpc.interaction.completed",{methodName:n,response:f}),setTimeout(()=>{var v;((v=this.currentInteraction)==null?void 0:v.methodName)===n&&(console.log(`RpcManager: Force clearing interaction for ${n}`),this.currentInteraction=null)},0),a(f)},didTimeout:f=>{console.log(`RpcManager: User interaction timeout for method: ${n}`),this.clearInteraction(l),this.currentInteraction=null;const p={success:!0,message:`User interaction timed out after ${o} seconds, it should be considered as declined, agent don't need to retry`,timestamp:new Date,...f?{timeoutView:f}:{}};this.emit("rpc.interaction.timeout",{methodName:n,response:p}),setTimeout(()=>{var v;((v=this.currentInteraction)==null?void 0:v.methodName)===n&&(console.log(`RpcManager: Force clearing interaction for ${n}`),this.currentInteraction=null)},0),a(p)}},u=setTimeout(()=>{d.didTimeout&&d.didTimeout()},o);this.activeInteractions.set(l,{resolve:f=>a(JSON.parse(f)),reject:c,timeoutId:u}),this.currentInteraction={isVisible:!0,methodName:n,component:i,presentationMode:r,timeout:o,data:s,handler:d},this.emit("rpc.interaction.started",{methodName:n,presentationMode:r}),setTimeout(async()=>{var f;if((f=this.currentInteraction)!=null&&f.handler)try{console.log(`RpcManager: Component created for method: ${n} with data:`,s)}catch(p){console.error("RpcManager: Error loading data into component:",p),d.didFail({error:"Failed to load data into component"})}},100)})}clearInteraction(n){const i=this.activeInteractions.get(n);i&&(console.log(`RpcManager: Clearing interaction: ${n}`),clearTimeout(i.timeoutId),this.activeInteractions.delete(n))}getCurrentInteraction(){return this.currentInteraction}dismissCurrentInteraction(){var n;this.currentInteraction&&(console.log(`RpcManager: Dismissing current interaction: ${this.currentInteraction.methodName}`),(n=this.currentInteraction.handler)==null||n.dismissView(),setTimeout(()=>{this.currentInteraction&&(console.log("RpcManager: Force clearing lingering interaction"),this.currentInteraction=null)},0))}getRegisteredMethods(){return Array.from(this.registeredMethods.keys())}unregisterMethod(n){this.registeredMethods.delete(n),console.log(`RpcManager: Unregistered RPC method: ${n}`)}clear(){for(const[n,i]of this.activeInteractions)clearTimeout(i.timeoutId);this.activeInteractions.clear(),this.registeredMethods.clear(),this.currentInteraction=null,console.log("RpcManager: Cleared all registrations and interactions")}}class De extends Error{constructor(e,n,i){super(e),this.code=n,this.details=i,this.name="VoxketError"}}class bo extends rh{constructor(n){super();at(this,"config");at(this,"room",null);at(this,"pluginManager");at(this,"rpcManager");at(this,"isConnected",!1);at(this,"currentSession",null);at(this,"connectionState",ge.Disconnected);at(this,"renderedComponents",new Map);at(this,"textStreamHandlersRegistered",!1);at(this,"currentAgentInfo",null);at(this,"chatMessages",[]);this.config=n,this.pluginManager=new nw(this),this.rpcManager=new Gj,this.setupEventListeners(),this.initializeClient()}setupEventListeners(){this.on("connection.connected",()=>{var n,i;this.isConnected=!0,(i=(n=this.config).onConnected)==null||i.call(n)}),this.on("connection.disconnected",n=>{var i,r;this.isConnected=!1,(r=(i=this.config).onDisconnected)==null||r.call(i,n)}),this.on("connection.error",n=>{var i,r;(r=(i=this.config).onError)==null||r.call(i,n)}),this.on("chat.message.received",n=>{var i,r;this.addChatMessage(n),(r=(i=this.config).onMessageReceived)==null||r.call(i,n)}),this.on("chat.message.updated",n=>{this.updateChatMessage(n)}),this.on("chat.message.sent",n=>{this.addChatMessage(n)}),this.on("transcription.received",n=>{var i,r;(r=(i=this.config).onTranscriptionReceived)==null||r.call(i,n)}),this.on("session.state.changed",n=>{var i,r;(r=(i=this.config).onSessionStateChanged)==null||r.call(i,n)}),this.on("session.created",n=>{var i,r;(r=(i=this.config).onSessionStart)==null||r.call(i,n.id)}),this.on("session.ended",(n,i)=>{var r,s;(s=(r=this.config).onSessionEnd)==null||s.call(r,i)}),this.on("participant.joined",n=>{var i,r;(r=(i=this.config).onUserJoined)==null||r.call(i,n.id)}),this.on("participant.left",n=>{var i,r;(r=(i=this.config).onUserLeft)==null||r.call(i,n.id)}),this.setupRpcEventForwarding()}setupRpcEventForwarding(){if(!this.rpcManager){console.warn("RpcManager not initialized, skipping event forwarding setup");return}this.rpcManager.on("rpc.method.registered",n=>this.emit("rpc.method.registered",n)),this.rpcManager.on("rpc.method.called",n=>this.emit("rpc.method.called",n)),this.rpcManager.on("rpc.interaction.started",n=>this.emit("rpc.interaction.started",n)),this.rpcManager.on("rpc.interaction.completed",n=>this.emit("rpc.interaction.completed",n)),this.rpcManager.on("rpc.interaction.timeout",n=>this.emit("rpc.interaction.timeout",n)),this.rpcManager.on("rpc.interaction.dismissed",n=>this.emit("rpc.interaction.dismissed",n))}initializeClient(){this.room=new pi,this.setupRoomEventListeners()}setupRoomEventListeners(){this.room&&(this.room.on(U.Connected,()=>{var n,i;this.connectionState=ge.Connected,this.emit("connection.connected"),this.rpcManager.setRoom(this.room),(i=(n=this.currentSession)==null?void 0:n.activeModalities)!=null&&i.includes("voice")&&setTimeout(async()=>{var r;try{(r=this.room)!=null&&r.localParticipant&&(this.room.localParticipant.isMicrophoneEnabled?this.emit("track.unmuted",{source:"microphone",enabled:!0}):(await this.room.localParticipant.setMicrophoneEnabled(!0),this.emit("track.unmuted",{source:"microphone",enabled:!0})))}catch(s){console.warn("VoxketClient: Failed to enable microphone after room connection:",s)}},1e3),this.textStreamHandlersRegistered||this.setupTextStreamHandlers()}),this.room.on(U.Disconnected,n=>{this.connectionState=ge.Disconnected,this.textStreamHandlersRegistered=!1,this.emit("connection.disconnected",n==null?void 0:n.toString())}),this.room.on(U.ConnectionStateChanged,n=>{this.connectionState=n,n===ge.Connecting&&this.emit("connection.connecting")}),this.room.on(U.ParticipantConnected,n=>{const i={id:n.identity,name:n.name||n.identity,isLocal:!1};this.emit("participant.joined",i)}),this.room.on(U.ParticipantDisconnected,n=>{const i={id:n.identity,name:n.name||n.identity,isLocal:!1};this.emit("participant.left",i)}))}setupTextStreamHandlers(){if(this.room){try{this.room.registerTextStreamHandler("lk.chat",async(n,i)=>{try{const r=await n.readAll(),s={id:`msg_${Date.now()}_${i.identity||"user"}_${Math.random().toString(36).substr(2,9)}`,content:r,timestamp:new Date,sender:{id:i.identity||"user",name:i.identity||"User",type:"participant"},metadata:{topic:"lk.chat"}};this.emit("chat.message.received",s)}catch(r){console.error("VoxketClient: Failed to process lk.chat message:",r)}})}catch(n){console.warn("VoxketClient: lk.chat handler already registered, skipping:",n)}try{this.room.registerTextStreamHandler("lk.transcription",async(n,i)=>{var r,s;try{const o=`msg_${Date.now()}_agent_transcription_${Math.random().toString(36).substr(2,9)}`;let a="";const c=((r=this.currentAgentInfo)==null?void 0:r.name)||i.identity||"AI Assistant",l={id:o,content:"",timestamp:new Date,sender:{id:i.identity||"agent",name:c,type:"agent"},metadata:{topic:"lk.transcription",streaming:!0}};this.emit("chat.message.received",l);for await(const f of n){a+=f;const p=this.convertMarkdownToText(a),v={...l,content:p,metadata:{...l.metadata,streaming:!0}};this.emit("chat.message.updated",v)}const d=this.convertMarkdownToText(a),u={...l,content:d,metadata:{...l.metadata,streaming:!1}};this.emit("chat.message.updated",u)}catch(o){console.error("VoxketClient: Failed to process lk.transcription message:",o);try{const a=await n.readAll(),c=((s=this.currentAgentInfo)==null?void 0:s.name)||i.identity||"AI Assistant",l={id:`msg_${Date.now()}_agent_transcription_${Math.random().toString(36).substr(2,9)}`,content:a,timestamp:new Date,sender:{id:i.identity||"agent",name:c,type:"agent"},metadata:{topic:"lk.transcription"}};this.emit("chat.message.received",l)}catch(a){console.error("VoxketClient: Fallback failed for lk.transcription:",a)}}})}catch(n){console.warn("VoxketClient: lk.transcription handler already registered, skipping:",n)}try{this.room.registerTextStreamHandler("suggested_response",async n=>{const i=await n.readAll();let r=[];try{r=["tes","hello how are you","algebra make me learn that ","what is the meaning of life"]}catch(s){console.warn("VoxketClient: Failed to parse suggested_response:",s,i)}this.emit("suggested.response",r)})}catch(n){console.warn("VoxketClient: suggested_response handler already registered, skipping:",n)}try{this.room.registerTextStreamHandler("agent_state_changed",async(n,i)=>{const r=await n.readAll();let s={};try{s=typeof r=="string"?JSON.parse(r.replace(/'/g,'"')):r}catch(o){console.warn("VoxketClient: Failed to parse agent_state_changed:",o,r)}s.new_state==="speaking"?this.emit("agent.speaking",s):s.new_state==="thinking"&&this.emit("agent.thinking",s)})}catch(n){console.warn("VoxketClient: conversation_item_added handler already registered, skipping:",n)}try{this.room.registerTextStreamHandler("images",async(n,i)=>{try{const r=await n.readAll()}catch(r){console.error("VoxketClient: Error processing images stream:",r)}})}catch(n){console.warn("VoxketClient: images handler already registered, skipping:",n)}try{this.room.registerByteStreamHandler("images",async(n,i)=>{var r,s;try{const o=n.info,a={id:`img_${Date.now()}_${i.identity||"agent"}_${Math.random().toString(36).substr(2,9)}`,content:`�️ ${o.name||"Image"}`,sender:{id:i.identity||"agent",name:i.identity||"Agent",type:i.identity===((s=(r=this.room)==null?void 0:r.localParticipant)==null?void 0:s.identity)?"participant":"agent"},timestamp:new Date,metadata:{type:"attachment",fileName:o.name,fileSize:o.size,mimeType:o.mimeType,streamId:o.id,downloading:!0}};this.emit("chat.message.received",a),n.onProgress&&(n.onProgress=f=>{const p={...a,metadata:{...a.metadata,downloadProgress:f||0}};this.emit("chat.message.updated",p)});const c=[];for await(const f of n)c.push(f);const l=new Blob(c,{type:o.mimeType||"application/octet-stream"}),d=URL.createObjectURL(l),u={...a,metadata:{...a.metadata,downloading:!1,downloadProgress:1,downloadUrl:d,blob:l}};this.emit("chat.message.updated",u)}catch(o){console.error("VoxketClient: Error processing image attachment:",o)}})}catch(n){console.warn("VoxketClient: image handler already registered, skipping:",n)}this.textStreamHandlersRegistered=!0}}async fetchConnectionDetails(n,i,r){const s=n||this.config.agentId||"default-agent",o=i||this.config.participantName||"User",a=r||this.config.modalities||["voice"];try{const c={agent_id:s,participant_name:o,participant_metadata:{user_id:""},modality:a[0]},l=await fetch(`${this.config.baseUrl}/api/live/agent/session`,{method:"POST",headers:{accept:"application/json","X-APP-ID":this.config.appId,"X-APP-SECRET":this.config.appSecret,"Content-Type":"application/json"},body:JSON.stringify(c)});if(!l.ok){let f=`HTTP ${l.status}: Failed to fetch connection details`;try{const p=await l.json();p&&(p.error?f=`API Error: ${p.error}`:p.detail?f=`API Error: ${p.detail}`:p.message&&(f=`API Error: ${p.message}`))}catch{try{const v=await l.text();v&&(f=`API Error: ${v}`)}catch{}}throw new Error(f)}const d=await l.json();let u;return d.agent_info&&(u={id:d.agent_info.id||s,name:d.agent_info.name||"AI Assistant",avatar:d.agent_info.avatar,capabilities:d.agent_info.capabilities||["voice_interaction","text_chat"],metadata:d.agent_info.metadata||{}},this.currentAgentInfo=u),{serverUrl:d.wss_url,participantToken:d.token,voxketSessionId:d.session_id,agentInfo:u}}catch(c){console.error("VoxketClient: fetchConnectionDetails failed:",c);const l=new De(`Failed to fetch connection details: ${c instanceof Error?c.message:"Unknown error"}`,"CONNECTION_FAILED",c);throw this.emit("connection.error",l),l}}async connect(n,i,r){var s;try{this.emit("connection.connecting");const o=await this.fetchConnectionDetails(n,i,r);return await((s=this.room)==null?void 0:s.connect(o.serverUrl,o.participantToken)),this.isConnected=!0,o}catch(o){console.error("VoxketClient: Connection failed:",o);const a=new De(`Failed to connect to Voxket services: ${o instanceof Error?o.message:"Unknown error"}`,"CONNECTION_FAILED",o);throw this.emit("connection.error",a),a}}async disconnect(){var n;try{await((n=this.room)==null?void 0:n.disconnect()),this.isConnected=!1,this.currentSession=null,this.currentAgentInfo=null,this.textStreamHandlersRegistered=!1,this.clearChatMessages(),this.room=new pi,this.setupRoomEventListeners()}catch(i){const r=new De("Failed to disconnect properly","NETWORK_ERROR",i);throw this.emit("connection.error",r),r}}async createSession(n){var i,r;try{const s=await this.connect(n.agentId,n.participantName,n.modalities),o={id:s.voxketSessionId,agentId:n.agentId,state:"connecting",startedAt:new Date,metadata:n.metadata||{},activeModalities:n.modalities||["voice"],agentInfo:s.agentInfo||this.currentAgentInfo};if(this.currentSession=o,this.emit("session.created",o),(i=n.modalities)!=null&&i.includes("voice"))try{await new Promise(a=>setTimeout(a,500)),(r=this.room)!=null&&r.localParticipant?(await this.room.localParticipant.setMicrophoneEnabled(!0,void 0,{preConnectBuffer:!0}),this.emit("track.unmuted",{source:"microphone",enabled:!0})):console.warn("VoxketClient: No local participant found, microphone not enabled")}catch(a){console.warn("VoxketClient: Failed to enable microphone, but continuing with session:",a)}return setTimeout(()=>{this.currentSession&&(this.currentSession.state="active",this.emit("session.state.changed","active",this.currentSession.state))},1e3),o}catch(s){throw console.error("VoxketClient: Failed to create session:",s),s instanceof De?s:s instanceof TypeError&&s.message.includes("fetch")?new De("Network connection failed","CONNECTION_FAILED",s):s instanceof Error&&s.message.includes("Failed to fetch connection details")?new De(`API connection failed: ${s.message}`,"CONNECTION_FAILED",s):new De(`Failed to create session: ${s instanceof Error?s.message:"Unknown error"}`,"SESSION_NOT_FOUND",s)}}async startSession(n,i){const r={agentId:n||this.config.agentId||"default-agent",participantName:(i==null?void 0:i.participantName)||this.config.participantName||"User",modalities:(i==null?void 0:i.modalities)||this.config.modalities||["voice","chat"],metadata:i==null?void 0:i.metadata};return this.createSession(r)}async endSession(){var n,i;if(!this.currentSession)return null;try{const r={sessionId:this.currentSession.id,duration:Date.now()-(((n=this.currentSession.startedAt)==null?void 0:n.getTime())||0),messageCount:0,participantCount:((i=this.room)==null?void 0:i.remoteParticipants.size)||0,audioQuality:{avgBitrate:64e3,avgLatency:150,packetLoss:.01,jitter:.05},videoQuality:{avgBitrate:5e5,avgLatency:150,packetLoss:.01,jitter:.05},networkStats:{totalBytesReceived:0,totalBytesSent:0,connectionType:"webrtc",avgRoundTripTime:150},events:[]};return this.currentSession.endedAt=new Date,this.currentSession.state="disconnected",this.emit("session.ended",this.currentSession,r),await this.disconnect(),r}catch(r){throw new De("Failed to end session","SESSION_NOT_FOUND",r)}}getCurrentSession(){return this.currentSession}getCurrentAgentInfo(){return this.currentAgentInfo}getChatMessages(){return[...this.chatMessages]}addChatMessage(n){this.chatMessages.some(r=>r.id===n.id)||this.chatMessages.push(n)}updateChatMessage(n){const i=this.chatMessages.findIndex(r=>r.id===n.id);i!==-1&&(this.chatMessages[i]=n)}clearChatMessages(){this.chatMessages=[],this.dismissCurrentInteraction(),this.renderedComponents.clear(),this.forceCleanupFullscreenOverlays(),this.emit("chat.history.cleared")}renderUI(n={}){var c,l,d;const i=this.resolveTarget(n.target||"body"),r=this.getTargetKey(i),s=this.renderedComponents.get(r);s&&s.target===i||this.removeUI(i);const o=(s==null?void 0:s.root)||Hj.createRoot(i),a={agentId:n.agentId||this.config.agentId||"default-agent",participantName:n.participantName||this.config.participantName||"User",baseUrl:this.config.baseUrl,appSecret:this.config.appSecret,appId:this.config.appId,className:n.className,theme:typeof n.theme=="string"?n.theme:void 0,modalities:n.modality||this.config.modalities||["voice"],suportsChatInput:((c=n.modality)==null?void 0:c.includes("chat"))!==!1,suportsVideoInput:((l=n.modality)==null?void 0:l.includes("video"))===!0,suportsScreenShare:((d=n.modality)==null?void 0:d.includes("screen_share"))===!0,autoStart:n.autoStart,displayType:n.displayType||"widget",popupPosition:n.popupPosition||"bottom-right",popupTriggerText:n.popupTriggerText||"Open Chat",width:n.width,height:n.height,onDisplayTypeChange:n.onDisplayTypeChange,prompts:n.prompts,statusMessage:n.statusMessage,welcomeTitle:n.welcomeTitle,welcomeSubTitle:n.welcomeSubTitle,loadingText:n.loadingText,voxketClient:this};if(!o||typeof o.render!="function")throw new Error("Invalid React root. Make sure React 18+ is properly installed and configured.");try{o.render(R.createElement(rw,{config:this.config,autoConnect:n.autoStart||!1,children:R.createElement(sw,a)}))}catch(u){throw console.error("Error rendering Voxket widget:",u),new Error(`Failed to render Voxket widget: ${u instanceof Error?u.message:"Unknown error"}`)}this.renderedComponents.set(r,{root:o,target:i})}removeUI(n){const i=n?this.resolveTarget(n):null;if(i){const r=this.getTargetKey(i),s=this.renderedComponents.get(r);s&&(s.root.unmount(),this.renderedComponents.delete(r),i.querySelectorAll('[id*="voxket"], [class*="voxket"], .fixed.inset-0.z-50').forEach(a=>{try{a.remove()}catch(c){console.warn("Failed to remove element:",c)}}),i===document.body&&i.querySelectorAll(".fixed.z-50, .fixed.inset-0").forEach(c=>{if(c.classList.contains("bg-black")&&c.classList.contains("backdrop-blur-sm"))try{c.remove()}catch(l){console.warn("Failed to remove fixed element:",l)}}))}}removeAllUI(){for(const[n,i]of this.renderedComponents)i.root.unmount();this.renderedComponents.clear(),this.forceCleanupFullscreenOverlays()}forceCleanupFullscreenOverlays(){document.body.querySelectorAll(".fixed.inset-0.z-50").forEach(i=>{if(i.classList.contains("bg-black")&&(i.classList.contains("backdrop-blur-sm")||i.classList.contains("bg-opacity-30")))try{i.remove()}catch(r){console.warn("Failed to remove overlay:",r)}})}resolveTarget(n){if(typeof n=="string"){const i=document.querySelector(n);if(!i)throw new Error(`Target element not found: ${n}`);return i}return n}getTargetKey(n){return n.id?n.id:n.className?n.tagName+"_"+n.className.replace(/\s+/g,"_"):n.tagName+"_"+n.outerHTML.length%1e3}async sendMessage(n,i){var r;if(!this.currentSession)throw console.error("VoxketClient: No active session found"),new De("No active session","SESSION_NOT_FOUND");if(!this.room)throw console.error("VoxketClient: No room instance found"),new De("No room connection","CONNECTION_FAILED");if(!this.room.localParticipant)throw console.error("VoxketClient: No local participant found"),new De("No local participant","CONNECTION_FAILED");this.dismissCurrentInteraction();try{const s={id:`msg_${Date.now()}`,content:n,sender:{id:"user",name:this.config.participantName||"User",type:"participant"},timestamp:new Date,metadata:i||{}},o=await((r=this.room)==null?void 0:r.localParticipant.sendText(n,{topic:"lk.chat",destinationIdentities:[]}));this.emit("chat.message.sent",s)}catch(s){throw console.error("VoxketClient: Failed to send chat message:",s),new De("Failed to send message","NETWORK_ERROR",s)}}async sendChatMessage(n,i){return this.sendMessage(n,i)}async sendAttachments(n,i){if(!this.currentSession)throw console.error("VoxketClient: No active session found"),new De("No active session","SESSION_NOT_FOUND");if(!this.room)throw console.error("VoxketClient: No room instance found"),new De("No room connection","CONNECTION_FAILED");if(!this.room.localParticipant)throw console.error("VoxketClient: No local participant found"),new De("No local participant","CONNECTION_FAILED");if(!n||n.length===0)throw new De("No files provided","INVALID_PARAMETER");this.dismissCurrentInteraction();const r=n.filter(s=>s.type.startsWith("image/"));if(r.length===0)throw new De("Only image files are allowed","INVALID_PARAMETER");r.length!==n.length&&console.warn("VoxketClient: Some non-image files were filtered out");try{const s=r.map(async(o,a)=>{const l={id:`att_${Date.now()}_${a}`,content:`📎 ${o.name}`,sender:{id:"user",name:this.config.participantName||"User",type:"participant"},timestamp:new Date,metadata:{...i,type:"attachment",fileName:o.name,fileSize:o.size,mimeType:o.type,uploading:!0}};this.emit("chat.message.sent",l);const d=await this.room.localParticipant.sendFile(o,{mimeType:o.type,topic:"images",onProgress:f=>{const p={...l,metadata:{...l.metadata,uploadProgress:f}};this.emit("chat.message.updated",p)}});try{const f=new FileReader,p=new Promise((y,b)=>{f.onload=()=>{typeof f.result=="string"?y(f.result):b(new Error("Failed to convert to base64"))},f.onerror=b});f.readAsDataURL(o);const h={type:"image",data:await p,filename:o.name,mimeType:o.type,size:o.size};await this.room.localParticipant.sendText(JSON.stringify(h),{topic:"images",destinationIdentities:[]})}catch(f){console.warn("VoxketClient: Failed to send image data to agent:",f);try{const p=`I've shared an image: ${o.name}`;await this.room.localParticipant.sendText(p,{topic:"lk.chat",destinationIdentities:[]})}catch(p){console.warn("VoxketClient: Failed to send image notification to agent:",p)}}const u={...l,metadata:{...l.metadata,uploading:!1,uploadProgress:1,streamId:d.id}};return this.emit("chat.message.updated",u),d});await Promise.all(s)}catch(s){throw console.error("VoxketClient: Failed to send attachments:",s),new De("Failed to send attachments","NETWORK_ERROR",s)}}async sendAttachment(n,i){return this.sendAttachments([n],i)}toggleMicrophone(n){return this.setMicrophoneEnabled(n!==!1)}async setMicrophoneEnabled(n){var i,r;try{const s=(i=this.room)==null?void 0:i.localParticipant.isMicrophoneEnabled,o=n??!s;await((r=this.room)==null?void 0:r.localParticipant.setMicrophoneEnabled(o)),o?this.emit("track.unmuted",{source:"microphone",enabled:!0}):this.emit("track.muted",{source:"microphone",enabled:!1})}catch(s){throw console.error("VoxketClient: Failed to toggle microphone:",s),new De("Failed to toggle microphone","PERMISSION_DENIED",s)}}toggleCamera(n){return this.setCameraEnabled(n!==!1)}async setCameraEnabled(n){var i,r;try{const s=(i=this.room)==null?void 0:i.localParticipant.isCameraEnabled,o=n??!s;await((r=this.room)==null?void 0:r.localParticipant.setCameraEnabled(o)),o?this.emit("track.unmuted",{source:"camera",enabled:!0}):this.emit("track.muted",{source:"camera",enabled:!1})}catch(s){throw console.error("VoxketClient: Failed to toggle camera:",s),new De("Failed to toggle camera","PERMISSION_DENIED",s)}}async enableCamera(){return this.setCameraEnabled(!0)}async disableCamera(){return this.setCameraEnabled(!1)}async startScreenShare(){var n;try{await((n=this.room)==null?void 0:n.localParticipant.setScreenShareEnabled(!0))}catch(i){throw new De("Failed to start screen share","PERMISSION_DENIED",i)}}async stopScreenShare(){var n;try{await((n=this.room)==null?void 0:n.localParticipant.setScreenShareEnabled(!1))}catch(i){throw new De("Failed to stop screen share","PERMISSION_DENIED",i)}}async getAudioInputDevices(){try{return(await navigator.mediaDevices.enumerateDevices()).filter(i=>i.kind==="audioinput")}catch(n){throw new De("Failed to get audio input devices","DEVICE_ERROR",n)}}async getVideoInputDevices(){try{return(await navigator.mediaDevices.enumerateDevices()).filter(i=>i.kind==="videoinput")}catch(n){throw new De("Failed to get video input devices","DEVICE_ERROR",n)}}async setAudioInputDevice(n){var i;try{if(!((i=this.room)!=null&&i.localParticipant))throw new Error("Not connected to room")}catch(r){throw new De("Failed to set audio input device","DEVICE_ERROR",r)}}async setVideoInputDevice(n){var i;try{if(!((i=this.room)!=null&&i.localParticipant))throw new Error("Not connected to room")}catch(r){throw new De("Failed to set video input device","DEVICE_ERROR",r)}}getLocalParticipant(){var n;return((n=this.room)==null?void 0:n.localParticipant)??null}getRemoteParticipants(){var n;return Array.from(((n=this.room)==null?void 0:n.remoteParticipants.values())??[])}getPublishPermissions(){const n=this.getLocalParticipant();if(!n)return{camera:!1,microphone:!1,screenShare:!1,data:!1};const i=n.permissions;if(!i)return{camera:!0,microphone:!0,screenShare:!0,data:!0};const r=s=>!!i.canPublish&&(i.canPublishSources.length===0||i.canPublishSources.includes(s));return{camera:r(1),microphone:r(2),screenShare:r(3),data:i.canPublishData??!1}}canPublishSource(n){return this.getPublishPermissions()[n]}getRoom(){return this.room}getConnectionState(){return this.connectionState}get connected(){return this.isConnected&&this.connectionState===ge.Connected}getMicrophoneTrack(){const n=this.getLocalParticipant();if(!n)return null;for(const[,i]of n.trackPublications)if(i.source===V.Source.Microphone)return i.track;return null}getCameraTrack(){const n=this.getLocalParticipant();if(!n)return null;for(const[,i]of n.trackPublications)if(i.source===V.Source.Camera)return i.track;return null}getScreenShareTrack(){const n=this.getLocalParticipant();if(!n)return null;for(const[,i]of n.trackPublications)if(i.source===V.Source.ScreenShare)return i.track;return null}get isMicrophoneEnabled(){const n=this.getMicrophoneTrack();return n?!n.isMuted:!1}get isCameraEnabled(){const n=this.getCameraTrack();return n?!n.isMuted:!1}get isScreenShareEnabled(){const n=this.getScreenShareTrack();return n?!n.isMuted:!1}registerPlugin(n){this.pluginManager.register(n)}getPluginManager(){return this.pluginManager}getParticipants(){if(!this.room)return[];const n=[];return this.room.localParticipant&&n.push({id:this.room.localParticipant.identity,name:this.room.localParticipant.name||this.room.localParticipant.identity,isLocal:!0}),this.room.remoteParticipants.forEach(i=>{n.push({id:i.identity,name:i.name||i.identity,isLocal:!1})}),n}getSessionMetrics(){var n,i;return this.currentSession?{sessionId:this.currentSession.id,duration:Date.now()-(((n=this.currentSession.startedAt)==null?void 0:n.getTime())||0),messageCount:0,participantCount:((i=this.room)==null?void 0:i.remoteParticipants.size)||0,audioQuality:{avgBitrate:64e3,avgLatency:150,packetLoss:.01,jitter:.05},videoQuality:{avgBitrate:5e5,avgLatency:150,packetLoss:.01,jitter:.05},networkStats:{totalBytesReceived:0,totalBytesSent:0,connectionType:"webrtc",avgRoundTripTime:150},events:[]}:null}updateConfig(n){this.config={...this.config,...n}}async startRecording(){var n;try{this.emit("recording.started",{sessionId:(n=this.currentSession)==null?void 0:n.id,timestamp:new Date})}catch(i){throw new De("Failed to start recording","RECORDING_ERROR",i)}}async stopRecording(){var n;try{this.emit("recording.stopped",{sessionId:(n=this.currentSession)==null?void 0:n.id,timestamp:new Date})}catch(i){throw new De("Failed to stop recording","RECORDING_ERROR",i)}}async registerFrontendRPC(n,i,r="embedded"){return this.rpcManager.registerFrontendRPC(n,i,r)}getCurrentInteraction(){return this.rpcManager.getCurrentInteraction()}dismissCurrentInteraction(){this.rpcManager.dismissCurrentInteraction()}getRegisteredRpcMethods(){return this.rpcManager.getRegisteredMethods()}unregisterRpcMethod(n){this.rpcManager.unregisterMethod(n)}registerEventListener(n,i){return this.on(n,i)}registerEventEmitter(n,i){if(!this.room)throw new Error("Room not available");try{this.room.registerTextStreamHandler(n,async r=>{try{const s=await r.readAll();i(s)}catch(s){console.error(`Error processing event for topic '${n}':`,s)}})}catch(r){console.warn(`VoxketClient: Handler for topic '${n}' may already be registered:`,r)}}convertMarkdownToText(n){if(!n)return"";let i=n;return i=i.replace(/\*\*(.*?)\*\*/g,"$1"),i=i.replace(/__(.*?)__/g,"$1"),i=i.replace(/\*(.*?)\*/g,"$1"),i=i.replace(/_(.*?)_/g,"$1"),i=i.replace(/~~(.*?)~~/g,"$1"),i=i.replace(/`([^`]+)`/g,"$1"),i=i.replace(/```[\s\S]*?```/g,""),i=i.replace(/^#{1,6}\s+/gm,""),i=i.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1"),i.trim()}}const Zj=xe.create(Tj),Yj=xe.create(Dj),Jj=xe.create(Vj),Xj=xe.create(Bj);function Qj({onClick:t,text:e="Open Chat",position:n="bottom-right",theme:i}){const r={"top-left":"top-4 left-4","top-right":"top-4 right-4","bottom-left":"bottom-4 left-4","bottom-right":"bottom-4 right-4"},s=St(i);return m.jsx(xe.button,{onClick:t,className:`fixed ${r[n]} z-50 px-4 py-2 rounded-full shadow-lg ${s.popupTrigger} transition-all duration-200 hover:scale-105`,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},children:e})}function P0({children:t,theme:e,displayType:n="widget",onClose:i,popupPosition:r="bottom-right",onExpand:s}){const o=St(e);if(n==="fullscreen")return m.jsx("div",{className:"fixed inset-0 z-50 bg-black bg-opacity-30 backdrop-blur-sm flex items-center justify-center p-8",children:m.jsxs("div",{className:"w-full h-full max-w-6xl max-h-[90vh] rounded-2xl relative bg-transparent",children:[i&&m.jsx("button",{onClick:a=>{a.preventDefault(),a.stopPropagation(),i()},className:"absolute top-4 cursor-pointer right-4 z-[100] w-12 h-12 rounded-full bg-gray-900 bg-opacity-90 text-white flex items-center justify-center hover:bg-gray-800 transition-all duration-200 shadow-lg border border-gray-700 backdrop-blur-sm",title:"Exit Fullscreen",type:"button",children:m.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:m.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}),m.jsxs("div",{id:"voice-card",className:`${o.card} w-full h-full flex flex-col rounded-xl shadow-2xl`,style:{minHeight:"600px"},children:[m.jsx("div",{className:o.cardTopGradient}),m.jsx("div",{className:o.cardPurpleBlur}),m.jsx("div",{className:o.cardPinkBlur}),m.jsx("div",{className:" flex flex-col h-full",children:t}),m.jsx("div",{className:o.cardPulse1}),m.jsx("div",{className:o.cardPulse2,style:{animationDelay:"1s"}})]})]})});if(n==="popup"){const a={"top-left":"top-4 left-4","top-right":"top-4 right-4","bottom-left":"bottom-4 left-4","bottom-right":"bottom-4 right-4"};return m.jsx("div",{className:"fixed rounded-2xl inset-0 z-50 pointer-events-none",children:m.jsxs("div",{className:`fixed rounded-2xl ${a[r]} pointer-events-auto`,children:[i&&m.jsx("button",{onClick:i,className:"absolute -top-2 -right-2 z-10 w-8 h-8 rounded-full bg-gray-900 bg-opacity-90 text-white flex items-center justify-center hover:bg-gray-800 transition-all duration-200 text-sm shadow-lg border border-gray-700",children:"×"}),m.jsxs("div",{id:"voice-card",className:`${o.card} rounded-2xl flex flex-col`,style:{width:"300px",height:"450px"},children:[m.jsx("div",{className:o.cardPurpleBlur}),m.jsx("div",{className:o.cardPinkBlur}),m.jsx("div",{className:" flex flex-col h-full",children:t}),m.jsx("div",{className:o.cardPulse1}),m.jsx("div",{className:o.cardPulse2,style:{animationDelay:"1s"}})]})]})})}return m.jsxs("div",{id:"voice-card",className:`${o.card}`,children:[s&&m.jsx("button",{onClick:s,className:"absolute top-4 right-4 z-20 w-10 h-10 rounded-full bg-gray-900 bg-opacity-90 text-white flex items-center justify-center hover:bg-gray-800 transition-all duration-200 shadow-lg border border-gray-700 backdrop-blur-sm",title:"Enter Fullscreen",children:m.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:m.jsx("path",{d:"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"})})}),m.jsx("div",{className:o.cardTopGradient}),m.jsx("div",{className:o.cardPurpleBlur}),m.jsx("div",{className:o.cardPinkBlur}),t,m.jsx("div",{className:o.cardPulse1}),m.jsx("div",{className:o.cardPulse2,style:{animationDelay:"1s"}})]})}function sw(t){if(typeof window>"u")return null;console.log("🎯 Widget component rendering with props:",{displayType:t.displayType,popupPosition:t.popupPosition,theme:t.theme});const{agentId:e,participantName:n,baseUrl:i,appSecret:r,appId:s,prompts:o,statusMessage:a,welcomeTitle:c,welcomeSubTitle:l,className:d,width:u,height:f,loadingText:p,suportsChatInput:v=!0,suportsVideoInput:h=!0,suportsScreenShare:y=!0,theme:b="vox",onSessionStart:w,onSessionEnd:C,enableSessionLogging:S=!0,onSessionLogsUpdate:x,onSessionMetricsUpdate:T,modalities:E=["voice"],displayType:P="widget",popupPosition:_="bottom-right",popupTriggerText:k="Open Chat",onPopupToggle:I,voxketClient:N,onDisplayTypeChange:K}=t,[J,se]=g.useState(()=>N?!!N.getCurrentSession():!1),[ie,X]=g.useState(!1),[O,oe]=g.useState(e||""),[L,F]=g.useState(n||"User"),[te,j]=g.useState(()=>N?N.getCurrentSession():null),[q,ee]=g.useState(()=>{var ve,tn,At;if(N){const $e=N.getCurrentSession();if((ve=$e==null?void 0:$e.activeModalities)!=null&&ve.includes("chat"))return"chat";if((tn=$e==null?void 0:$e.activeModalities)!=null&&tn.includes("voice"))return"voice";if((At=$e==null?void 0:$e.activeModalities)!=null&&At.includes("video"))return"video"}return"welcome"}),[G,D]=g.useState(!1);g.useEffect(()=>{console.log("🎯 Widget displayType prop changed to:",P)},[P]),g.useEffect(()=>{console.log("📊 Session state changed:",{currentMode:q,sessionStarted:J,loading:ie,currentSession:te==null?void 0:te.id,isPopupOpen:G})},[q,J,ie,te,G]);const $=g.useMemo(()=>{if(N)return console.log("🔄 Using passed VoxketClient to preserve session state"),N;console.log("🆕 Creating new VoxketClient instance");const ve={appId:s,appSecret:r,baseUrl:i,agentId:O,participantName:L||"User",modalities:E};return new bo(ve)},[N,s,r,i,O,L,E]),Q=E,W=g.useMemo(()=>$.getRoom()||new pi,[$]),ce={suportsChatInput:v,suportsVideoInput:h,suportsScreenShare:y},{sessionMetrics:z,sessionLogs:me,logEvent:Ee}=tw({room:W,onSessionStart:w,onSessionEnd:C,enableConsoleLogging:S,enableLocalStorage:S,voxketSessionId:te==null?void 0:te.id});g.useEffect(()=>{x&&x(me)},[me,x]),g.useEffect(()=>{T&&z&&T(z)},[z,T]),g.useEffect(()=>{const ve=At=>{console.log("🔴 Room disconnected:",At),X(!1),se(!1),j(null),ee("welcome")},tn=At=>{console.log("📹 Media devices error:",At),No({title:"Allow access to your microphone/camera",description:`${At.name}: ${At.message}`})};return W.on(U.MediaDevicesError,tn),W.on(U.Disconnected,ve),()=>{W.off(U.Disconnected,ve),W.off(U.MediaDevicesError,tn)}},[W]);const qe=async()=>{try{console.log("🎤 Starting voice session...",{agentId:O,participantName:L}),console.log("🎤 Pre-start state:",{currentMode:q,sessionStarted:J,loading:ie}),X(!0),se(!0),ee("voice"),console.log("🎤 State after mode change:",{currentMode:"voice",sessionStarted:!0,loading:!0}),Ee("USER_STARTED_VOICE_SESSION",{agentId:O,participantName:L});const ve=await $.startSession(O,{participantName:L||"User",modalities:["voice",...h?["video"]:[]]});console.log("✅ Voice session started successfully:",ve.id),j(ve),X(!1),w&&w(ve.id)}catch(ve){console.error("❌ Failed to start voice session:",ve),No({title:"Failed to start voice session",description:ve instanceof Error?ve.message:"Unknown error occurred"}),X(!1),se(!1),ee("welcome")}},Ct=async()=>{try{X(!0),se(!0),ee("chat"),Ee("USER_STARTED_CHAT_SESSION",{agentId:O,participantName:L});const ve=await $.startSession(O,{participantName:L||"User",modalities:["chat"]});j(ve),X(!1),w&&w(ve.id)}catch(ve){console.error("Failed to start chat session:",ve),No({title:"Failed to start chat session",description:ve instanceof Error?ve.message:"Unknown error occurred"}),X(!1),se(!1),ee("welcome")}},gn=async()=>{try{console.log("📺 Starting video session...",{agentId:O,participantName:L}),console.log("📺 Pre-start state:",{currentMode:q,sessionStarted:J,loading:ie}),X(!0),se(!0),ee("video"),console.log("📺 State after mode change:",{currentMode:"video",sessionStarted:!0,loading:!0}),Ee("USER_STARTED_VIDEO_SESSION",{agentId:O,participantName:L});const ve=await $.startSession(O,{participantName:L||"User",modalities:["video","voice"]});console.log("✅ Video session started successfully:",ve.id),j(ve),X(!1),w&&w(ve.id)}catch(ve){console.error("❌ Failed to start video session:",ve),No({title:"Failed to start video session",description:ve instanceof Error?ve.message:"Unknown error occurred"}),X(!1),se(!1),ee("welcome")}},vn=()=>{ee("welcome"),K&&K(t.displayType||"widget"),te&&J&&(se(!1),j(null),$.disconnect()),P==="popup"&&!G&&D(!0)},Et=()=>{const ve=!G;D(ve),I&&I(ve),!ve&&!(te&&J)&&(ee("welcome"),se(!1),j(null))},Ec=()=>{console.log("🔄 Closing fullscreen, switching to widget display type"),t.onDisplayTypeChange?t.onDisplayTypeChange("widget"):console.warn("⚠️ No onDisplayTypeChange callback provided")},Pc=()=>{t.onDisplayTypeChange&&t.onDisplayTypeChange("fullscreen")};g.useEffect(()=>{var ve,tn,At;if(N&&$){console.log("🔄 Syncing widget state with existing client session state");const $e=$.getCurrentSession(),Rc=$.connected;console.log("🔍 Existing session state:",{hasSession:!!$e,sessionId:$e==null?void 0:$e.id,isConnected:Rc,activeModalities:$e==null?void 0:$e.activeModalities}),$e&&(console.log("✅ Restoring session state from existing client"),j($e),se(!0),X(!1),(ve=$e.activeModalities)!=null&&ve.includes("chat")?ee("chat"):(tn=$e.activeModalities)!=null&&tn.includes("voice")?ee("voice"):(At=$e.activeModalities)!=null&&At.includes("video")&&ee("video"))}},[N,$]),g.useEffect(()=>()=>{console.log("🧹 Cleaning up widget component"),N?console.log("🔄 Widget cleanup: preserving passed client instance"):(console.log("🧹 Widget cleanup: disconnecting self-created client"),$.disconnect())},[$,N]);let _i="w-96",ms="h-[25rem]",ps={};if(u&&(u.startsWith("w-")?_i=u:(ps.width=u,_i="")),f&&(f.startsWith("h-")?ms=f:(ps.height=f,ms="")),P==="popup"&&!G)return console.log("🟡 Showing popup trigger button"),m.jsx(Qj,{onClick:Et,text:k,position:_,theme:b});console.log("🟢 Rendering widget content, displayType:",P,"isPopupOpen:",G,"currentMode:",q,"sessionStarted:",J,"loading:",ie);let or=`voxket-widget-root theme-${b}`,Ni={scrollMargin:0,scrollPadding:0,contain:"layout style paint"};P==="widget"?(or+=` flex items-center justify-center min-h-fit ${_i} ${ms} ${d}`,Ni={...Ni,...ps}):(or=`${d||""}`,Ni={});const gs=m.jsx(m.Fragment,{children:m.jsxs(Vr,{mode:"wait",children:[q==="welcome"&&!ie&&m.jsx(Xj,{agentId:O,participantName:L||"",onAgentIdChange:oe,onParticipantNameChange:F,onStartCall:qe,onStartChat:Ct,onStartVideo:gn,disabled:J||ie,prompts:o,statusMessage:a,title:c,subTitle:l,theme:b,modalities:Q,initial:{opacity:0,y:0},animate:{opacity:1,y:0},exit:{opacity:0,y:40},transition:{duration:.3,ease:"easeInOut"}},"welcome"),q==="voice"&&m.jsxs(Da.Provider,{value:W,children:[m.jsx(tg,{}),m.jsx(Xp,{label:"Start Audio"}),m.jsx(Zj,{loadingText:p,participantName:L||"User",capabilities:ce,sessionStarted:J,disabled:!J,theme:b,client:$,displayType:P,onBack:P==="popup"?Et:vn,initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.3,ease:"easeInOut"}},"session-view")]}),q==="chat"&&m.jsx(Yj,{client:$,theme:b,displayType:P,onBack:P==="popup"?Et:vn,onEndChat:vn,disabled:!J,initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.3,ease:"easeInOut"}},"chat-view"),q==="video"&&m.jsxs(Da.Provider,{value:W,children:[m.jsx(tg,{}),m.jsx(Xp,{label:"Start Audio"}),m.jsx(Jj,{client:$,theme:b,displayType:P,onBack:P==="popup"?Et:vn,onEndCall:vn,disabled:!J,initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.3,ease:"easeInOut"}},"video-view")]})]})});return P==="fullscreen"||P==="popup"?(console.log("📱 Rendering fullscreen/popup mode, displayType:",P),m.jsx(P0,{theme:b,displayType:P,popupPosition:_,onClose:P==="fullscreen"?Ec:Et,children:gs})):(console.log("📦 Rendering widget mode"),m.jsx("div",{className:or,style:Ni,children:m.jsx(P0,{theme:b,displayType:P,popupPosition:_,onExpand:Pc,children:gs})}))}class ow extends g.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){console.error("VoxketWidget Error:",e,n)}render(){if(this.state.hasError){if(this.props.fallback){const e=this.props.fallback;return g.createElement(e,{error:this.state.error})}return g.createElement("div",{style:{padding:"20px",border:"1px solid #ff4444",borderRadius:"8px",background:"#fff5f5",color:"#cc0000"}},"VoxketWidget encountered an error. Please check the console for details.")}return this.props.children}}function eL({logs:t,onClear:e,onExport:n}){const[i,r]=R.useState(!1),[s,o]=R.useState(""),a=t.filter(c=>!s||c.event.toLowerCase().includes(s.toLowerCase()));return i?m.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:m.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-4xl w-full max-h-[80vh] flex flex-col m-4",children:[m.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[m.jsxs("h2",{className:"text-lg font-semibold",children:["Session Logs (",t.length,")"]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("input",{type:"text",placeholder:"Filter events...",value:s,onChange:c=>o(c.target.value),className:"px-3 py-1 border rounded text-sm"}),m.jsx("button",{onClick:e,className:"px-3 py-1 bg-red-600 text-white rounded text-sm hover:bg-red-700",children:"Clear"}),m.jsx("button",{onClick:n,className:"px-3 py-1 bg-green-600 text-white rounded text-sm hover:bg-green-700",children:"Export"}),m.jsx("button",{onClick:()=>r(!1),className:"px-3 py-1 bg-gray-600 text-white rounded text-sm hover:bg-gray-700",children:"Close"})]})]}),m.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.length===0?m.jsx("p",{className:"text-gray-500 text-center py-8",children:"No logs found"}):m.jsx("div",{className:"space-y-2",children:a.map((c,l)=>m.jsxs("div",{className:"border rounded p-3 text-sm",children:[m.jsxs("div",{className:"flex items-center justify-between mb-1",children:[m.jsx("span",{className:"font-semibold text-blue-600",children:c.event}),m.jsx("span",{className:"text-gray-500 text-xs",children:new Date(c.timestamp).toLocaleTimeString()})]}),c.sessionId&&m.jsxs("div",{className:"text-xs text-gray-600 mb-1",children:["Session: ",c.sessionId]}),c.data&&m.jsx("div",{className:"bg-gray-50 p-2 rounded text-xs",children:m.jsx("pre",{className:"whitespace-pre-wrap overflow-auto",children:JSON.stringify(c.data,null,2)})})]},l))})})]})}):m.jsxs("button",{onClick:()=>r(!0),className:"fixed bottom-4 right-4 bg-blue-600 text-white px-4 py-2 rounded-lg shadow-lg hover:bg-blue-700 transition-colors text-sm z-50",children:["Session Logs (",t.length,")"]})}function tL({metrics:t}){return t?m.jsxs("div",{className:"bg-gray-100 p-4 rounded-lg",children:[m.jsx("h3",{className:"font-semibold mb-2",children:"Current Session"}),m.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Session ID:"}),m.jsx("div",{className:"font-mono text-xs",children:t.sessionId})]}),m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Start Time:"}),m.jsx("div",{children:new Date(t.startTime).toLocaleString()})]}),m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Messages:"}),m.jsx("div",{children:t.totalMessages})]}),m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Participants:"}),m.jsx("div",{children:t.participantCount})]}),m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Connection Issues:"}),m.jsx("div",{children:t.connectionIssues})]}),m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Duration:"}),m.jsxs("div",{children:[Math.round((Date.now()-new Date(t.startTime).getTime())/1e3),"s"]})]})]})]}):null}function sr(){const{currentSession:t,sessionState:e,sessionMetrics:n,createSession:i,endSession:r}=jn(),s=R.useCallback(async(a,c)=>await i(a,c),[i]),o=R.useCallback(async()=>await r(),[r]);return{session:t,state:e,metrics:n,isActive:t!==null&&e!=="disconnected",isConnecting:e==="connecting",isConnected:e==="connected"||e==="active",start:s,stop:o}}function aw(){const{sessionMetrics:t,currentSession:e}=jn();return{metrics:t,sessionId:e==null?void 0:e.id,duration:t==null?void 0:t.duration,participantCount:t==null?void 0:t.participantCount,messageCount:t==null?void 0:t.messageCount,audioQuality:t==null?void 0:t.audioQuality,networkStats:t==null?void 0:t.networkStats}}function cw(){const{setMicrophoneEnabled:t,client:e}=jn(),[n,i]=R.useState(!1),[r,s]=R.useState(!1),o=R.useCallback(async()=>{if(!r){s(!0);try{const l=!n;await t(l),i(l)}catch(l){console.error("Failed to toggle microphone:",l)}finally{s(!1)}}},[n,r,t]),a=R.useCallback(async()=>{if(!(n||r)){s(!0);try{await t(!0),i(!0)}catch(l){console.error("Failed to enable microphone:",l)}finally{s(!1)}}},[n,r,t]),c=R.useCallback(async()=>{if(!(!n||r)){s(!0);try{await t(!1),i(!1)}catch(l){console.error("Failed to disable microphone:",l)}finally{s(!1)}}},[n,r,t]);return{isEnabled:n,isLoading:r,toggle:o,enable:a,disable:c}}function lw(){const{setCameraEnabled:t}=jn(),[e,n]=R.useState(!1),[i,r]=R.useState(!1),s=R.useCallback(async()=>{if(!i){r(!0);try{const c=!e;await t(c),n(c)}catch(c){console.error("Failed to toggle camera:",c)}finally{r(!1)}}},[e,i,t]),o=R.useCallback(async()=>{if(!(e||i)){r(!0);try{await t(!0),n(!0)}catch(c){console.error("Failed to enable camera:",c)}finally{r(!1)}}},[e,i,t]),a=R.useCallback(async()=>{if(!(!e||i)){r(!0);try{await t(!1),n(!1)}catch(c){console.error("Failed to disable camera:",c)}finally{r(!1)}}},[e,i,t]);return{isEnabled:e,isLoading:i,toggle:s,enable:o,disable:a}}function dw(){const{startScreenShare:t,stopScreenShare:e}=jn(),[n,i]=R.useState(!1),[r,s]=R.useState(!1),o=R.useCallback(async()=>{if(!(n||r)){s(!0);try{await t(),i(!0)}catch(l){console.error("Failed to start screen share:",l)}finally{s(!1)}}},[n,r,t]),a=R.useCallback(async()=>{if(!(!n||r)){s(!0);try{await e(),i(!1)}catch(l){console.error("Failed to stop screen share:",l)}finally{s(!1)}}},[n,r,e]),c=R.useCallback(async()=>{n?await a():await o()},[n,o,a]);return{isSharing:n,isLoading:r,start:o,stop:a,toggle:c}}function nL(){const{client:t}=jn(),[e,n]=R.useState({tracks:[],layout:{type:"grid",showLocalVideo:!0,aspectRatio:"16:9"},isRecording:!1}),i=R.useMemo(()=>e.tracks.find(h=>h.isLocal),[e.tracks]),r=R.useMemo(()=>e.tracks.filter(h=>!h.isLocal),[e.tracks]),s=R.useCallback(async()=>{try{i!=null&&i.isEnabled?await(t==null?void 0:t.disableCamera()):await(t==null?void 0:t.enableCamera())}catch(h){throw console.error("Failed to toggle camera:",h),h}},[t,i]),o=R.useCallback(async()=>{try{e.tracks.find(y=>y.isScreenShare)?await(t==null?void 0:t.stopScreenShare()):await(t==null?void 0:t.startScreenShare())}catch(h){throw console.error("Failed to toggle screen share:",h),h}},[t,e.tracks]),a=R.useCallback(h=>{n(y=>({...y,layout:h}))},[]),c=R.useCallback(h=>{n(y=>({...y,pinnedTrack:h}))},[]),l=R.useCallback(()=>{n(h=>({...h,pinnedTrack:void 0}))},[]),d=R.useCallback(async()=>{try{await(t==null?void 0:t.startRecording()),n(h=>({...h,isRecording:!0}))}catch(h){throw console.error("Failed to start recording:",h),h}},[t]),u=R.useCallback(async()=>{try{await(t==null?void 0:t.stopRecording()),n(h=>({...h,isRecording:!1}))}catch(h){throw console.error("Failed to stop recording:",h),h}},[t]),f=R.useCallback(h=>e.tracks.find(y=>y.id===h),[e.tracks]),p=R.useCallback(h=>e.tracks.filter(y=>y.participantId===h),[e.tracks]),v=R.useCallback(h=>h.isEnabled&&e.tracks.includes(h),[e.tracks]);return R.useEffect(()=>{if(!t)return;const h=w=>{n(C=>({...C,tracks:[...C.tracks.filter(S=>S.id!==w.id),w]}))},y=w=>{n(C=>{var S;return{...C,tracks:C.tracks.filter(x=>x.id!==w),pinnedTrack:((S=C.pinnedTrack)==null?void 0:S.id)===w?void 0:C.pinnedTrack}})},b=w=>{n(C=>({...C,tracks:C.tracks.map(S=>S.id===w.id?w:S)}))};return t.on("videoTrackAdded",h),t.on("videoTrackRemoved",y),t.on("videoTrackUpdated",b),()=>{t.off("videoTrackAdded",h),t.off("videoTrackRemoved",y),t.off("videoTrackUpdated",b)}},[t]),{tracks:e.tracks,localTrack:i,remoteTraracks:r,pinnedTrack:e.pinnedTrack,layout:e.layout,isRecording:e.isRecording,toggleCamera:s,toggleScreenShare:o,setLayout:a,pinTrack:c,unpinTrack:l,startRecording:d,stopRecording:u,getTrackById:f,getTracksByParticipant:p,isTrackActive:v}}function Tc(){const{chatMessages:t,sendChatMessage:e,currentSession:n}=jn(),[i,r]=R.useState(!1),s=R.useCallback(async l=>{if(!(!l.trim()||i||!n)){r(!0);try{await e(l.trim())}catch(d){throw console.error("Failed to send chat message:",d),d}finally{r(!1)}}},[e,i,n]),{userMessages:o,agentMessages:a,allMessages:c}=R.useMemo(()=>{const l=t.filter(u=>u.sender.type==="participant"),d=t.filter(u=>u.sender.type==="agent");return{userMessages:l,agentMessages:d,allMessages:t}},[t]);return{messages:c,userMessages:o,agentMessages:a,messageCount:c.length,isSending:i,canSend:!!n&&!i,send:s}}function iL(){const{send:t,isSending:e,canSend:n}=Tc(),[i,r]=R.useState(""),s=R.useCallback(async()=>{if(!(!i.trim()||!n))try{await t(i),r("")}catch(a){throw a}},[i,t,n]),o=R.useCallback(a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),s())},[s]);return{value:i,setValue:r,send:s,handleKeyPress:o,isSending:e,canSend:n&&i.trim().length>0}}function oh(){const{isConnected:t,isConnecting:e,connectionError:n,connect:i,disconnect:r}=jn(),s=R.useCallback(async()=>{if(!(t||e))try{await i()}catch(a){throw console.error("Failed to connect:",a),a}},[i,t,e]),o=R.useCallback(async()=>{if(t)try{await r()}catch(a){throw console.error("Failed to disconnect:",a),a}},[r,t]);return{isConnected:t,isConnecting:e,isDisconnected:!t&&!e,error:n,hasError:!!n,connect:s,disconnect:o}}function uw(){const{participants:t}=jn();return{participants:t,count:t.length,localParticipant:t.find(e=>e.isLocal),remoteParticipants:t.filter(e=>!e.isLocal)}}const fw=R.createContext({}),xo=()=>R.useContext(fw);function hw({children:t,...e}){return m.jsx(fw.Provider,{value:e,children:t})}function ya({name:t,children:e,fallback:n,className:i}){return m.jsx("div",{className:`voxket-slot voxket-slot--${t} ${i||""}`,children:e||n})}function mw(t,e={}){return Object.assign(t,e)}function pw({showMicrophoneControl:t=!0,showCameraControl:e=!0,showScreenShareControl:n=!0,showSessionActions:i=!0,customControls:r,className:s=""}){const o=sr(),a=cw(),c=lw(),l=dw(),d=xo(),u=["voxket-session-controls",`voxket-session-controls--${d.variant||"default"}`,`voxket-session-controls--${d.size||"md"}`,o.isActive?"voxket-session-controls--active":"voxket-session-controls--inactive",s].filter(Boolean).join(" ");return!o.isActive&&!i?m.jsx("div",{className:u,children:m.jsx("div",{className:"voxket-controls-inactive",children:m.jsx("p",{children:"Controls available during active session"})})}):m.jsxs("div",{className:u,children:[i&&m.jsx("div",{className:"voxket-session-actions",children:o.isActive?m.jsx("button",{onClick:o.stop,className:"voxket-button voxket-button--danger",children:"End Session"}):m.jsx(rL,{})}),o.isActive&&m.jsxs("div",{className:"voxket-media-controls",children:[t&&m.jsxs("button",{onClick:a.toggle,disabled:a.isLoading,className:`voxket-button voxket-button--media ${a.isEnabled?"voxket-button--active":""}`,title:a.isEnabled?"Mute microphone":"Unmute microphone",children:[m.jsx("span",{className:"voxket-icon",children:"🎤"}),a.isLoading?"Loading...":a.isEnabled?"Mute":"Unmute"]}),e&&m.jsxs("button",{onClick:c.toggle,disabled:c.isLoading,className:`voxket-button voxket-button--media ${c.isEnabled?"voxket-button--active":""}`,title:c.isEnabled?"Stop camera":"Start camera",children:[m.jsx("span",{className:"voxket-icon",children:"📹"}),c.isLoading?"Loading...":c.isEnabled?"Stop Video":"Start Video"]}),n&&m.jsxs("button",{onClick:l.toggle,disabled:l.isLoading,className:`voxket-button voxket-button--media ${l.isSharing?"voxket-button--active":""}`,title:l.isSharing?"Stop screen share":"Start screen share",children:[m.jsx("span",{className:"voxket-icon",children:"🖥️"}),l.isLoading?"Loading...":l.isSharing?"Stop Share":"Share Screen"]})]}),r&&m.jsx("div",{className:"voxket-custom-controls",children:r})]})}function rL(){sr();const[t,e]=R.useState(!1),n=async()=>{e(!0);try{console.log("Start session - agentId needed")}catch(i){console.error("Failed to start session:",i)}finally{e(!1)}};return m.jsx("button",{onClick:n,disabled:t,className:"voxket-button voxket-button--primary",children:t?"Starting...":"Start Session"})}function ah({showConnectionStatus:t=!0,showSessionInfo:e=!0,showAgentInfo:n=!0,className:i=""}){const r=sr(),s=oh(),o=xo(),a=["voxket-session-header",`voxket-session-header--${o.variant||"default"}`,`voxket-session-header--${o.size||"md"}`,i].filter(Boolean).join(" ");return m.jsxs("div",{className:a,children:[t&&m.jsxs("div",{className:"voxket-connection-status",children:[m.jsx("div",{className:`voxket-status-indicator ${s.isConnected?"connected":"disconnected"}`}),m.jsx("span",{className:"voxket-status-text",children:s.isConnecting?"Connecting...":s.isConnected?"Connected":"Disconnected"})]}),e&&r.session&&m.jsxs("div",{className:"voxket-session-info",children:[m.jsxs("div",{className:"voxket-session-id",children:["Session: ",r.session.id.slice(-8)]}),m.jsxs("div",{className:"voxket-session-state",children:["State: ",r.state]})]}),n&&r.session&&m.jsxs("div",{className:"voxket-agent-info",children:[m.jsxs("div",{className:"voxket-agent-id",children:["Agent: ",r.session.agentId]}),m.jsxs("div",{className:"voxket-modalities",children:["Modalities: ",r.session.activeModalities.join(", ")]})]}),s.error&&m.jsxs("div",{className:"voxket-error-message",children:["Error: ",s.error.message]})]})}function ch({showChat:t=!0,showTranscriptions:e=!1,customContent:n,className:i=""}){const r=sr(),s=Tc(),o=xo(),a=["voxket-session-content",`voxket-session-content--${o.variant||"default"}`,`voxket-session-content--${o.size||"md"}`,i].filter(Boolean).join(" ");return r.isActive?m.jsx("div",{className:a,children:n||m.jsxs(m.Fragment,{children:[t&&m.jsxs("div",{className:"voxket-chat-container",children:[m.jsxs("div",{className:"voxket-chat-messages",children:[s.messages.map(c=>m.jsxs("div",{className:`voxket-message voxket-message--${c.sender.type}`,children:[m.jsxs("div",{className:"voxket-message-header",children:[m.jsx("span",{className:"voxket-message-sender",children:c.sender.name}),m.jsx("span",{className:"voxket-message-time",children:c.timestamp.toLocaleTimeString()})]}),m.jsx("div",{className:"voxket-message-content",children:c.content})]},c.id)),s.messages.length===0&&m.jsx("div",{className:"voxket-empty-messages",children:m.jsx("p",{children:"No messages yet. Start the conversation!"})})]}),m.jsx(sL,{})]}),e&&m.jsx("div",{className:"voxket-transcriptions",children:m.jsx("div",{className:"voxket-transcription-placeholder",children:m.jsx("p",{children:"Voice transcriptions will appear here"})})})]})}):m.jsx("div",{className:a,children:m.jsx("div",{className:"voxket-inactive-state",children:m.jsxs("div",{className:"voxket-inactive-message",children:[m.jsx("h3",{children:"Start a conversation"}),m.jsx("p",{children:"Begin a session to start chatting with the AI agent"})]})})})}function sL(){const t=Tc(),[e,n]=R.useState(""),i=async()=>{if(!(!e.trim()||!t.canSend))try{await t.send(e),n("")}catch(s){console.error("Failed to send message:",s)}},r=s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),i())};return m.jsxs("div",{className:"voxket-chat-input",children:[m.jsx("input",{type:"text",value:e,onChange:s=>n(s.target.value),onKeyPress:r,placeholder:"Type your message...",disabled:!t.canSend,className:"voxket-input"}),m.jsx("button",{onClick:i,disabled:!t.canSend||!e.trim(),className:"voxket-send-button",children:t.isSending?"Sending...":"Send"})]})}function lh({showMetrics:t=!0,showParticipants:e=!0,showStatus:n=!0,customFooter:i,className:r=""}){const s=sr(),o=aw(),a=uw(),c=xo(),l=["voxket-session-footer",`voxket-session-footer--${c.variant||"default"}`,`voxket-session-footer--${c.size||"md"}`,r].filter(Boolean).join(" ");return s.isActive?m.jsx("div",{className:l,children:i||m.jsxs(m.Fragment,{children:[n&&m.jsxs("div",{className:"voxket-session-status",children:[m.jsx("div",{className:"voxket-status-indicator voxket-status-indicator--active"}),m.jsx("span",{className:"voxket-status-text",children:"Session Active"})]}),t&&o.metrics&&m.jsxs("div",{className:"voxket-session-metrics",children:[m.jsxs("div",{className:"voxket-metric",children:[m.jsx("span",{className:"voxket-metric-label",children:"Duration:"}),m.jsx("span",{className:"voxket-metric-value",children:oL(o.duration||0)})]}),m.jsxs("div",{className:"voxket-metric",children:[m.jsx("span",{className:"voxket-metric-label",children:"Messages:"}),m.jsx("span",{className:"voxket-metric-value",children:o.metrics.messageCount})]})]}),e&&m.jsxs("div",{className:"voxket-participants-info",children:[m.jsxs("span",{className:"voxket-participants-count",children:[a.count," participant",a.count!==1?"s":""]}),a.remoteParticipants.length>0&&m.jsx("div",{className:"voxket-participant-list",children:a.remoteParticipants.map(d=>m.jsx("span",{className:"voxket-participant-name",children:d.name},d.id))})]})]})}):m.jsx("div",{className:l,children:m.jsx("div",{className:"voxket-footer-inactive",children:m.jsx("span",{className:"voxket-status-text",children:"Ready to start session"})})})}function oL(t){const e=Math.floor(t/1e3),n=Math.floor(e/60),i=Math.floor(n/60);return i>0?`${i}:${(n%60).toString().padStart(2,"0")}:${(e%60).toString().padStart(2,"0")}`:`${n}:${(e%60).toString().padStart(2,"0")}`}function aL({agentId:t,sessionConfig:e,autoStart:n=!1,onSessionStart:i,onSessionEnd:r,variant:s="default",size:o="md",theme:a,className:c="",children:l}){var p;const d=sr(),u=oh();R.useEffect(()=>{n&&t&&u.isConnected&&!d.isActive&&d.start(t,e).catch(console.error)},[n,t,u.isConnected,d.isActive]),R.useEffect(()=>{var v;(v=d.session)!=null&&v.id&&i&&i(d.session.id)},[(p=d.session)==null?void 0:p.id,i]),R.useEffect(()=>()=>{d.isActive&&r&&d.stop().then(r).catch(console.error)},[]);const f=["voxket-session",`voxket-session--${s}`,`voxket-session--${o}`,d.isActive?"voxket-session--active":"voxket-session--inactive",c].filter(Boolean).join(" ");return m.jsx(hw,{variant:s,size:o,theme:a,className:c,children:m.jsx("div",{className:f,children:l||m.jsxs(m.Fragment,{children:[m.jsx(ya,{name:"header",fallback:m.jsx(ah,{})}),m.jsx(ya,{name:"content",fallback:m.jsx(ch,{})}),m.jsx(ya,{name:"footer",fallback:m.jsx(lh,{})})]})})})}const gw=mw(aL,{Header:ah,Content:ch,Footer:lh,Controls:pw}),Gi={name:"default",colors:{primary:"#3B82F6",secondary:"#6B7280",accent:"#8B5CF6",background:"#FFFFFF",surface:"#F9FAFB",text:{primary:"#111827",secondary:"#6B7280",muted:"#9CA3AF",inverse:"#FFFFFF"},status:{success:"#10B981",warning:"#F59E0B",error:"#EF4444",info:"#3B82F6"},border:"#E5E7EB",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1)"},typography:{fontFamily:"system-ui, -apple-system, sans-serif",fontSize:{xs:"0.75rem",sm:"0.875rem",md:"1rem",lg:"1.125rem",xl:"1.25rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700},lineHeight:{tight:1.25,normal:1.5,relaxed:1.75}},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},borderRadius:{none:"0",sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1)"}},vu={...Gi,name:"dark",colors:{primary:"#60A5FA",secondary:"#9CA3AF",accent:"#A78BFA",background:"#111827",surface:"#1F2937",text:{primary:"#F9FAFB",secondary:"#D1D5DB",muted:"#9CA3AF",inverse:"#111827"},status:{success:"#34D399",warning:"#FBBF24",error:"#F87171",info:"#60A5FA"},border:"#374151",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.3)"}},yu={...Gi,name:"enterprise",colors:{primary:"#1E40AF",secondary:"#64748B",accent:"#7C3AED",background:"#FFFFFF",surface:"#F8FAFC",text:{primary:"#0F172A",secondary:"#475569",muted:"#94A3B8",inverse:"#FFFFFF"},status:{success:"#059669",warning:"#D97706",error:"#DC2626",info:"#1E40AF"},border:"#CBD5E1",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1)"},borderRadius:{none:"0",sm:"0.125rem",md:"0.25rem",lg:"0.375rem",full:"9999px"}},vw=R.createContext(null),yw=()=>{const t=R.useContext(vw);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t};function cL({theme:t="default",themes:e={},children:n,cssVariables:i=!0,className:r=""}){const[s,o]=R.useState(()=>{const f={default:Gi,dark:vu,enterprise:yu,...e};return typeof t=="string"?f[t]||Gi:t}),[a,c]=R.useState(()=>({default:Gi,dark:vu,enterprise:yu,...e})),l=f=>{if(typeof f=="string"){const p=a[f];p&&o(p)}else o(f)},d=f=>{c(p=>({...p,[f.name]:f}))};R.useEffect(()=>{if(i&&typeof document<"u"){const f=document.documentElement;Object.entries(bw(s)).forEach(([p,v])=>{f.style.setProperty(`--voxket-${p}`,v)})}},[s,i]);const u={theme:s,setTheme:l,themes:a,registerTheme:d};return m.jsx(vw.Provider,{value:u,children:m.jsx("div",{className:`voxket-theme voxket-theme--${s.name} ${r}`,children:n})})}function bw(t){const e={},n=(i,r="")=>{for(const[s,o]of Object.entries(i)){const a=r?`${r}-${s}`:s;typeof o=="object"&&o!==null&&!Array.isArray(o)?n(o,a):e[a]=String(o)}};return n(t),e}function lL(t=Gi,e){return{...t,...e,colors:{...t.colors,...e.colors},typography:{...t.typography,...e.typography},spacing:{...t.spacing,...e.spacing},borderRadius:{...t.borderRadius,...e.borderRadius},shadows:{...t.shadows,...e.shadows}}}function dL(t){var n;const{theme:e}=yw();return((n=e.components)==null?void 0:n[t])||{}}const uL=sh("voice-modality","voice",{onActivate:async t=>{const e=t.config;e.enableTranscription&&fL(t),e.enableVoiceActivation&&hL(t,e),console.log("Voice modality activated",e)},onDeactivate:async t=>{console.log("Voice modality deactivated")},onMessage:async(t,e)=>{e.type==="audio"&&mL(t,e)}});function fL(t,e){t.on("participant.speaking.started",n=>{console.log("Transcription: Started for",n.name)}),t.on("participant.speaking.stopped",n=>{console.log("Transcription: Stopped for",n.name)})}function hL(t,e){const n=e.silenceThreshold||-50;console.log("Voice activation setup with threshold:",n)}function mL(t,e){console.log("Playing audio response:",e.content)}const pL=sh("chat-modality","chat",{onActivate:async t=>{const e=t.config;e.enableRichText&&gL(),e.enableFileUpload&&vL(t),e.enableCustomComponents&&yL(),console.log("Chat modality activated",e)},onDeactivate:async t=>{console.log("Chat modality deactivated")},onMessage:async(t,e)=>{const n=t.config;e.type==="ui_component"?bL(t,e):e.type==="text"&&n.enableRichText&&xL(t,e)}});function gL(t){console.log("Rich text support enabled")}function vL(t){console.log("File upload enabled"),t.on("chat.file.uploaded",e=>{console.log("File uploaded:",e.name)})}function yL(t){console.log("Custom components enabled");const e=new Map;e.set("quick-actions",SL),e.set("form",wL),e.set("card",CL),e.set("chart",kL)}function bL(t,e){const{componentType:n,props:i}=e.metadata;console.log("Rendering custom component:",n,i),t.emit("chat.component.render",{type:n,props:i,timestamp:new Date})}function xL(t,e){console.log("Processing rich text message:",e.content)}function SL(t){return{type:"quick-actions",actions:t.actions||[],layout:t.layout||"horizontal"}}function wL(t){return{type:"form",fields:t.fields||[],submitAction:t.submitAction,validation:t.validation}}function CL(t){return{type:"card",title:t.title,content:t.content,actions:t.actions,variant:t.variant||"default"}}function kL(t){return{type:"chart",chartType:t.chartType||"line",data:t.data,options:t.options}}function ba({track:t,participantName:e,showControls:n=!0,showName:i=!0,showMuteIndicator:r=!0,isPinned:s=!1,className:o="",onClick:a,onPin:c,onUnpin:l}){const d=R.useRef(null),[u,f]=R.useState(!1);R.useEffect(()=>{if(!d.current||!t.isEnabled)return;const y=d.current;return y.srcObject=null,()=>{y.srcObject&&(y.srcObject=null)}},[t]);const p=()=>{a==null||a(t)},v=y=>{y.stopPropagation(),s?l==null||l(t):c==null||c(t)},h=["voxket-video-tile",t.isLocal?"voxket-video-tile--local":"voxket-video-tile--remote",t.isScreenShare?"voxket-video-tile--screen-share":"voxket-video-tile--camera",s?"voxket-video-tile--pinned":"",t.isEnabled?"":"voxket-video-tile--disabled",u?"voxket-video-tile--hovered":"",o].filter(Boolean).join(" ");return m.jsxs("div",{className:h,onClick:p,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),style:{aspectRatio:t.dimensions?`${t.dimensions.width} / ${t.dimensions.height}`:"16 / 9"},children:[m.jsx("video",{ref:d,className:"voxket-video-element",autoPlay:!0,playsInline:!0,muted:t.isLocal}),!t.isEnabled&&m.jsxs("div",{className:"voxket-video-placeholder",children:[m.jsx("div",{className:"voxket-video-placeholder-icon",children:t.isScreenShare?"🖥️":"📹"}),m.jsx("p",{className:"voxket-video-placeholder-text",children:t.isScreenShare?"Screen sharing paused":"Camera off"})]}),m.jsxs("div",{className:"voxket-video-overlay",children:[i&&e&&m.jsxs("div",{className:"voxket-video-name",children:[e,t.isLocal&&" (You)"]}),r&&!t.isEnabled&&m.jsx("div",{className:"voxket-video-mute-indicator",children:"🔇"}),n&&(u||s)&&m.jsxs("div",{className:"voxket-video-controls",children:[m.jsx("button",{className:`voxket-video-control-btn ${s?"voxket-video-control-btn--active":""}`,onClick:v,title:s?"Unpin video":"Pin video",children:"📌"}),t.isScreenShare&&m.jsx("div",{className:"voxket-video-indicator",children:"🖥️"}),t.source&&m.jsx("div",{className:"voxket-video-source",children:t.source})]})]}),!t.isEnabled&&m.jsx("div",{className:"voxket-video-loading",children:m.jsx("div",{className:"voxket-spinner"})})]})}function TL({tracks:t,layout:e,className:n="",onLayoutChange:i,onTrackClick:r,maxVisibleTracks:s=9,showPagination:o=!0}){const[a,c]=R.useState(0),[l,d]=R.useState(null),u=R.useMemo(()=>{let w=[...t];e.type==="speaker"&&l&&(w=[l,...t.filter(x=>x.id!==l.id)]);const C=a*s,S=C+s;return w.slice(C,S)},[t,e,l,a,s]),f=Math.ceil(t.length/s),p=R.useMemo(()=>{const w=u.length;switch(e.type){case"grid":const C=Math.ceil(Math.sqrt(w)),S=Math.ceil(w/C);return{display:"grid",gridTemplateColumns:`repeat(${C}, 1fr)`,gridTemplateRows:`repeat(${S}, 1fr)`,gap:"8px"};case"speaker":return{display:"flex",flexDirection:"column",gap:"8px"};case"sidebar":return{display:"flex",gap:"8px"};case"gallery":return{display:"flex",flexWrap:"wrap",gap:"8px",justifyContent:"center"};default:return{}}},[e.type,u.length]),v=w=>{d(w)},h=()=>{d(null)},y=w=>{i==null||i({...e,type:w})},b=["voxket-video-grid",`voxket-video-grid--${e.type}`,`voxket-video-grid--${u.length}-tracks`,n].filter(Boolean).join(" ");return t.length===0?m.jsx("div",{className:"voxket-video-grid-empty",children:m.jsxs("div",{className:"voxket-video-grid-empty-content",children:[m.jsx("div",{className:"voxket-video-grid-empty-icon",children:"📹"}),m.jsx("p",{children:"No video tracks available"})]})}):m.jsxs("div",{className:b,children:[m.jsxs("div",{className:"voxket-video-grid-controls",children:[m.jsx("div",{className:"voxket-video-layout-controls",children:["grid","speaker","sidebar","gallery"].map(w=>m.jsx("button",{className:`voxket-layout-btn ${e.type===w?"voxket-layout-btn--active":""}`,onClick:()=>y(w),title:`Switch to ${w} layout`,children:EL(w)},w))}),m.jsxs("div",{className:"voxket-video-count",children:[t.length," participant",t.length!==1?"s":""]})]}),m.jsx("div",{className:"voxket-video-grid-content",style:p,children:e.type==="speaker"&&l?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"voxket-video-speaker-main",children:m.jsx(ba,{track:l,participantName:`Participant ${l.participantId}`,isPinned:!0,onClick:r,onUnpin:h})}),m.jsx("div",{className:"voxket-video-speaker-sidebar",children:u.filter(w=>w.id!==l.id).map(w=>m.jsx(ba,{track:w,participantName:`Participant ${w.participantId}`,showControls:!1,onClick:r,onPin:v},w.id))})]}):u.map(w=>m.jsx(ba,{track:w,participantName:`Participant ${w.participantId}`,isPinned:(l==null?void 0:l.id)===w.id,onClick:r,onPin:v,onUnpin:h},w.id))}),o&&f>1&&m.jsxs("div",{className:"voxket-video-pagination",children:[m.jsx("button",{className:"voxket-pagination-btn",onClick:()=>c(Math.max(0,a-1)),disabled:a===0,children:"←"}),m.jsxs("span",{className:"voxket-pagination-info",children:["Page ",a+1," of ",f]}),m.jsx("button",{className:"voxket-pagination-btn",onClick:()=>c(Math.min(f-1,a+1)),disabled:a===f-1,children:"→"})]})]})}function EL(t){switch(t){case"grid":return"⊞";case"speaker":return"🎤";case"sidebar":return"⫸";case"gallery":return"⊡";case"picture-in-picture":return"⧉";default:return"⊞"}}function PL({localTrack:t,onToggleCamera:e,onToggleScreenShare:n,onLayoutChange:i,showLayoutControls:r=!0,showCameraControls:s=!0,showScreenShareControls:o=!0,className:a=""}){const c=["voxket-video-controls",a].filter(Boolean).join(" "),l=d=>{i==null||i({type:d,showLocalVideo:!0,aspectRatio:"16:9"})};return m.jsxs("div",{className:c,children:[s&&m.jsxs("div",{className:"voxket-video-controls-section",children:[m.jsx("h4",{className:"voxket-video-controls-title",children:"Camera"}),m.jsxs("button",{className:`voxket-control-btn ${t!=null&&t.isEnabled?"voxket-control-btn--active":""}`,onClick:e,title:t!=null&&t.isEnabled?"Turn off camera":"Turn on camera",children:[m.jsx("span",{className:"voxket-control-icon",children:t!=null&&t.isEnabled?"📹":"📷"}),m.jsx("span",{className:"voxket-control-label",children:t!=null&&t.isEnabled?"Camera On":"Camera Off"})]}),(t==null?void 0:t.dimensions)&&m.jsxs("div",{className:"voxket-video-info",children:[t.dimensions.width," × ",t.dimensions.height]})]}),o&&m.jsxs("div",{className:"voxket-video-controls-section",children:[m.jsx("h4",{className:"voxket-video-controls-title",children:"Screen Share"}),m.jsxs("button",{className:`voxket-control-btn ${t!=null&&t.isScreenShare?"voxket-control-btn--active":""}`,onClick:n,title:t!=null&&t.isScreenShare?"Stop screen sharing":"Start screen sharing",children:[m.jsx("span",{className:"voxket-control-icon",children:t!=null&&t.isScreenShare?"🛑":"🖥️"}),m.jsx("span",{className:"voxket-control-label",children:t!=null&&t.isScreenShare?"Stop Sharing":"Share Screen"})]})]}),r&&m.jsxs("div",{className:"voxket-video-controls-section",children:[m.jsx("h4",{className:"voxket-video-controls-title",children:"Layout"}),m.jsx("div",{className:"voxket-layout-buttons",children:[{type:"grid",icon:"⊞",label:"Grid"},{type:"speaker",icon:"🎤",label:"Speaker"},{type:"sidebar",icon:"⫸",label:"Sidebar"},{type:"gallery",icon:"⊡",label:"Gallery"}].map(({type:d,icon:u,label:f})=>m.jsxs("button",{className:"voxket-layout-control-btn",onClick:()=>l(d),title:`Switch to ${f} layout`,children:[m.jsx("span",{className:"voxket-control-icon",children:u}),m.jsx("span",{className:"voxket-control-label",children:f})]},d))})]}),m.jsxs("div",{className:"voxket-video-controls-section",children:[m.jsx("h4",{className:"voxket-video-controls-title",children:"Video Settings"}),m.jsxs("div",{className:"voxket-video-settings",children:[m.jsxs("div",{className:"voxket-setting-group",children:[m.jsx("label",{className:"voxket-setting-label",children:"Quality"}),m.jsxs("select",{className:"voxket-setting-select",children:[m.jsx("option",{value:"high",children:"High (720p)"}),m.jsx("option",{value:"medium",children:"Medium (480p)"}),m.jsx("option",{value:"low",children:"Low (240p)"})]})]}),m.jsxs("div",{className:"voxket-setting-group",children:[m.jsx("label",{className:"voxket-setting-label",children:"Frame Rate"}),m.jsxs("select",{className:"voxket-setting-select",children:[m.jsx("option",{value:"30",children:"30 fps"}),m.jsx("option",{value:"15",children:"15 fps"}),m.jsx("option",{value:"10",children:"10 fps"})]})]}),m.jsxs("div",{className:"voxket-setting-group",children:[m.jsx("label",{className:"voxket-setting-label",children:"Bandwidth"}),m.jsxs("select",{className:"voxket-setting-select",children:[m.jsx("option",{value:"unlimited",children:"Unlimited"}),m.jsx("option",{value:"1000",children:"1 Mbps"}),m.jsx("option",{value:"500",children:"500 Kbps"}),m.jsx("option",{value:"250",children:"250 Kbps"})]})]})]})]}),m.jsxs("div",{className:"voxket-video-controls-section",children:[m.jsx("h4",{className:"voxket-video-controls-title",children:"Statistics"}),m.jsxs("div",{className:"voxket-video-stats",children:[m.jsxs("div",{className:"voxket-stat-item",children:[m.jsx("span",{className:"voxket-stat-label",children:"Resolution:"}),m.jsx("span",{className:"voxket-stat-value",children:t!=null&&t.dimensions?`${t.dimensions.width}×${t.dimensions.height}`:"N/A"})]}),m.jsxs("div",{className:"voxket-stat-item",children:[m.jsx("span",{className:"voxket-stat-label",children:"Source:"}),m.jsx("span",{className:"voxket-stat-value",children:(t==null?void 0:t.source)||"None"})]}),m.jsxs("div",{className:"voxket-stat-item",children:[m.jsx("span",{className:"voxket-stat-label",children:"Status:"}),m.jsx("span",{className:`voxket-stat-value ${t!=null&&t.isEnabled?"voxket-stat-value--active":"voxket-stat-value--inactive"}`,children:t!=null&&t.isEnabled?"Active":"Inactive"})]})]})]})]})}const xw=({handler:t,loadData:e,data:n,client:i,addLocalMessage:r})=>{const[s,o]=g.useState(null),[a,c]=g.useState(!0),[l,d]=g.useState(!1),[u]=g.useState(Date.now());g.useEffect(()=>{(async()=>{try{if(c(!0),console.log("📋 AssignmentView: Loading assignment data..."),console.log("📋 AssignmentView: Received data from RPC:",n),n&&typeof n=="object"){const y={title:n.title||"Untitled Assignment",description:n.description||"No description provided",estimated_time_of_completion:n.estimated_time_of_completion||"Unknown"};o(y),console.log("📋 AssignmentView: Assignment loaded from RPC data:",y)}}catch(y){console.error("📋 AssignmentView: Error loading assignment:",y),o({title:"Assignment Loading Error",description:"There was an error loading the assignment details. Please try again.",estimated_time_of_completion:"Unknown"})}finally{c(!1)}})()},[n,e]);const f=({message:h,assignment:y})=>{const b=h.toLowerCase().includes("declined"),w=b?"bg-red-50 border-red-200":"bg-green-50 border-green-200",C=b?"text-red-700":"text-green-700",S=b?"❌":"🎉";return m.jsxs("div",{className:`max-w-sm mx-auto ${w} border rounded-lg shadow p-3 flex flex-col items-center`,children:[m.jsx("div",{className:"text-2xl mb-2",children:S}),m.jsx("div",{className:`${C} font-semibold text-sm mb-1`,children:h}),m.jsx("div",{className:"text-xs text-gray-600 text-center mb-1",children:y.title}),m.jsx("div",{className:"text-xs text-gray-500",children:"Thank you for your response!"})]})},p=async()=>{if(!(!s||!t)){d(!0);try{const h={message:"accepted"};console.log("📋 AssignmentView: Assignment accepted:",h),t.didSuccess(h,m.jsx(f,{message:"Assignment accepted!",assignment:s}))}catch(h){console.error("📋 AssignmentView: Error accepting assignment:",h),t.didFail({error:"Failed to accept assignment"})}finally{d(!1)}}},v=async()=>{if(!(!s||!t)){d(!0);try{const h={message:"declined"};console.log("📋 AssignmentView: Assignment declined:",h),t.didSuccess(h,m.jsx(f,{message:"Assignment declined",assignment:s}))}catch(h){console.error("📋 AssignmentView: Error declining assignment:",h),t.didFail({error:"Failed to decline assignment"})}finally{d(!1)}}};return a?m.jsx("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg p-3",children:m.jsxs("div",{className:"flex items-center justify-center py-4",children:[m.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}),m.jsx("span",{className:"ml-2 text-xs text-gray-600",children:"Loading assignment..."})]})}):s?m.jsxs("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg overflow-hidden",children:[m.jsx("div",{className:"bg-gradient-to-r from-blue-600 to-purple-600 text-white p-3",children:m.jsx("div",{className:"flex items-center justify-between",children:m.jsx("h3",{className:"text-xs font-semibold text-white truncate",children:s.title})})}),m.jsxs("div",{className:"p-3",children:[m.jsx("div",{className:"bg-gray-50 rounded p-2 mb-3",children:m.jsx("p",{className:"text-xs text-gray-700 leading-snug",children:s.description})}),m.jsx("div",{className:"mb-3",children:m.jsxs("div",{className:"flex items-center text-xs text-gray-600",children:[m.jsx("span",{className:"text-xs mr-1",children:"📅"}),m.jsxs("span",{children:["Est: ",s.estimated_time_of_completion]})]})}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx("button",{onClick:p,disabled:l,className:"flex-1 bg-green-600 text-white py-2 px-3 rounded text-xs font-medium hover:bg-green-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:l?m.jsxs("span",{className:"flex items-center justify-center",children:[m.jsx("div",{className:"animate-spin rounded-full h-2 w-2 border-b-2 border-white mr-1"}),m.jsx("span",{className:"text-xs",children:"Processing..."})]}):"Accept"}),m.jsx("button",{onClick:v,disabled:l,className:"flex-1 bg-red-600 text-white py-2 px-3 rounded text-xs font-medium hover:bg-red-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Decline"})]})]})]}):m.jsx("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg p-3",children:m.jsxs("div",{className:"text-center py-4",children:[m.jsx("div",{className:"text-red-600 text-sm font-semibold mb-2",children:"⚠️ Assignment Error"}),m.jsx("p",{className:"text-xs text-gray-600 mb-3",children:"Failed to load assignment details."})]})})};function RL(){const[t,e]=g.useState(null),[n,i]=g.useState([]);g.useEffect(()=>{const a=new bo({appId:"your-app-id",appSecret:"your-app-secret",baseUrl:"https://your-voxket-api.com",agentId:"your-agent-id",participantName:"User",modalities:["chat"]});return e(a),a.on("rpc.method.called",c=>{console.log("RPC Method Called:",c)}),a.on("rpc.interaction.completed",c=>{console.log("RPC Interaction Completed:",c)}),()=>{a.disconnect()}},[]);const r=async()=>{if(t)try{await t.registerFrontendRPC("give_assignment",xw,"embedded");const a=t.getRegisteredRpcMethods();i(a),console.log("✅ Assignment RPC registered successfully")}catch(a){console.error("❌ Failed to register assignment RPC:",a)}},s=async()=>{if(!t)return;const a=({handler:c,timeout:l})=>{const[d,u]=g.useState(""),f=[{id:"pro",name:"Pro Plan",price:"$29/month"},{id:"enterprise",name:"Enterprise Plan",price:"$99/month"},{id:"basic",name:"Basic Plan",price:"$9/month"}],p=h=>{u(h)},v=()=>{const h=f.find(y=>y.id===d);c==null||c.didSuccess({selectedProduct:d,productName:h==null?void 0:h.name,price:h==null?void 0:h.price,timestamp:new Date().toISOString()})};return m.jsxs("div",{className:"p-6 bg-white rounded-lg",children:[m.jsx("h3",{className:"text-xl font-bold mb-4",children:"Choose Your Plan"}),m.jsx("p",{className:"text-gray-600 mb-4",children:"Select the plan that best fits your needs:"}),m.jsx("div",{className:"space-y-3 mb-6",children:f.map(h=>m.jsx("div",{onClick:()=>p(h.id),className:`p-4 border rounded-lg cursor-pointer transition-all ${d===h.id?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300"}`,children:m.jsxs("div",{className:"flex justify-between items-center",children:[m.jsxs("div",{children:[m.jsx("h4",{className:"font-medium",children:h.name}),m.jsx("p",{className:"text-gray-600 text-sm",children:h.price})]}),m.jsx("div",{className:`w-4 h-4 rounded-full ${d===h.id?"bg-blue-500":"border-2 border-gray-300"}`})]})},h.id))}),m.jsxs("div",{className:"flex justify-end space-x-3",children:[m.jsx("button",{onClick:()=>c==null?void 0:c.dismissView(),className:"px-4 py-2 border border-gray-300 text-gray-700 rounded hover:bg-gray-50",children:"Cancel"}),m.jsx("button",{onClick:v,disabled:!d,className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",children:"Select Plan"})]}),l&&m.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:["Time remaining: ",l," seconds"]})]})};try{await t.registerFrontendRPC("recommend_product",a,"modal");const c=t.getRegisteredRpcMethods();i(c),console.log("✅ Product Recommendation RPC registered successfully")}catch(c){console.error("❌ Failed to register product recommendation RPC:",c)}},o=async()=>{if(!t)return;const a=({handler:c})=>{const[l,d]=g.useState(0),[u,f]=g.useState(""),p=()=>{c==null||c.didSuccess({rating:l,comment:u,timestamp:new Date().toISOString()})};return m.jsxs("div",{className:"p-4 bg-white rounded-lg",children:[m.jsx("h3",{className:"text-lg font-semibold mb-3",children:"How was your experience?"}),m.jsxs("div",{className:"mb-4",children:[m.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Rate your experience:"}),m.jsx("div",{className:"flex space-x-1",children:[1,2,3,4,5].map(v=>m.jsx("button",{onClick:()=>d(v),className:`text-2xl ${v<=l?"text-yellow-400":"text-gray-300"}`,children:"⭐"},v))})]}),m.jsxs("div",{className:"mb-4",children:[m.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Additional comments:"}),m.jsx("textarea",{value:u,onChange:v=>f(v.target.value),className:"w-full p-2 border border-gray-300 rounded text-sm",rows:3,placeholder:"Tell us more about your experience..."})]}),m.jsxs("div",{className:"flex justify-end space-x-2",children:[m.jsx("button",{onClick:()=>c==null?void 0:c.dismissView(),className:"px-3 py-1 text-sm border border-gray-300 text-gray-700 rounded hover:bg-gray-50",children:"Skip"}),m.jsx("button",{onClick:p,disabled:l===0,className:"px-3 py-1 text-sm bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",children:"Submit"})]})]})};try{await t.registerFrontendRPC("collect_feedback",a,"embedded");const c=t.getRegisteredRpcMethods();i(c),console.log("✅ Feedback RPC registered successfully")}catch(c){console.error("❌ Failed to register feedback RPC:",c)}};return m.jsxs("div",{className:"p-6",children:[m.jsx("h2",{className:"text-2xl font-bold mb-6",children:"Frontend RPC Examples"}),m.jsxs("div",{className:"space-y-4 mb-6",children:[m.jsxs("div",{children:[m.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Register RPC Methods"}),m.jsxs("div",{className:"space-x-2",children:[m.jsx("button",{onClick:r,className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600",children:"Register Assignment RPC"}),m.jsx("button",{onClick:s,className:"px-4 py-2 bg-green-500 text-white rounded hover:bg-green-600",children:"Register Product Recommendation RPC"}),m.jsx("button",{onClick:o,className:"px-4 py-2 bg-purple-500 text-white rounded hover:bg-purple-600",children:"Register Feedback RPC"})]})]}),m.jsxs("div",{children:[m.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Registered Methods"}),n.length>0?m.jsx("ul",{className:"list-disc list-inside space-y-1",children:n.map(a=>m.jsx("li",{className:"text-gray-700",children:m.jsx("code",{className:"bg-gray-100 px-2 py-1 rounded",children:a})},a))}):m.jsx("p",{className:"text-gray-500",children:"No methods registered yet"})]})]}),m.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg",children:[m.jsx("h3",{className:"text-lg font-semibold mb-2",children:"How it works"}),m.jsxs("ol",{className:"list-decimal list-inside space-y-2 text-sm text-gray-700",children:[m.jsxs("li",{children:["Register RPC methods with React components using ",m.jsx("code",{children:"client.registerFrontendRPC()"})]}),m.jsx("li",{children:"When the agent calls an RPC method, the corresponding component will be displayed"}),m.jsx("li",{children:"Users interact with the component, and the response is sent back to the agent"}),m.jsx("li",{children:"Components can be displayed in different modes: embedded, modal, or fullscreen"}),m.jsx("li",{children:"Each component has a timeout and can handle success/failure scenarios"})]})]}),m.jsxs("div",{className:"mt-6 bg-blue-50 p-4 rounded-lg",children:[m.jsx("h3",{className:"text-lg font-semibold mb-2 text-blue-800",children:"Agent Side"}),m.jsx("p",{className:"text-sm text-blue-700 mb-2",children:"On the agent side, you can call these RPC methods like this:"}),m.jsx("pre",{className:"bg-white p-3 rounded text-xs text-gray-800 overflow-x-auto",children:`// Agent calls RPC method
|
|
32
|
+
`,style:{minHeight:"2.5rem",display:i===s?"block":"none"},children:r},i))})}function Uf({statusMessage:e,theme:t}){const n=ye(t);return a.jsxs("div",{className:"z-10 flex items-center space-x-2 mt-2 pb-2",children:[a.jsx("div",{className:n.statusIndicator}),a.jsx("span",{className:`text-xs ${n.text.muted}`,children:e})]})}const zf=({disabled:e,onStartCall:t,onStartChat:n,onStartVideo:s,prompts:o=['"Book a meeting with the marketing team"',`"What's the status of project Alpha?"`,`"Summarize yesterday's sales report"`,'"Find a good Italian restaurant nearby"','"Remind me to call John tomorrow at 10 AM"'],statusMessage:r="Agent is ready",title:i="Choose how to interact",subTitle:l="Ask me anything or give me a task to complete",theme:c="vox",modalities:d=["voice","chat","video"]})=>{const u=ye(c),m=d.includes("voice"),f=d.includes("chat"),p=d.includes("video"),g=[m,f,p].filter(Boolean).length;return console.log("🎯 Welcome component debug:",{modalities:d,hasVoice:m,hasChat:f,hasVideo:p,totalButtons:g,onStartVideo:!!s}),a.jsxs("div",{inert:e,className:"flex p-8 flex-col items-center h-full justify-center w-full",children:[a.jsxs("div",{className:"mt-1 relative flex items-center justify-center mb-8 w-full",style:{minHeight:"120px"},children:[a.jsxs("div",{className:"absolute inset-0 flex items-center justify-center",children:[a.jsx("div",{className:u.pulseRings.ring1}),a.jsx("div",{className:u.pulseRings.ring2,style:{animationDelay:"0.5s"}}),a.jsx("div",{className:u.pulseRings.ring3,style:{animationDelay:"1s"}})]}),a.jsx("div",{className:"relative z-10 flex items-center justify-center",children:m&&f&&p?a.jsxs("div",{className:"flex gap-4 items-center justify-center",children:[a.jsx(Jt,{onClick:t,disabled:e,theme:c}),a.jsx(On,{onClick:n,disabled:e,theme:c}),a.jsx(_n,{onClick:s||t,disabled:e,theme:c})]}):g>1?a.jsxs("div",{className:"flex gap-6 items-center justify-center",children:[m&&a.jsx(Jt,{onClick:t,disabled:e,theme:c}),f&&a.jsx(On,{onClick:n,disabled:e,theme:c}),p&&s&&a.jsx(_n,{onClick:s,disabled:e,theme:c})]}):a.jsx("div",{className:"flex items-center justify-center",children:m?a.jsx(Jt,{onClick:t,disabled:e,theme:c}):f?a.jsx(On,{onClick:n,disabled:e,theme:c}):p&&s?a.jsx(_n,{onClick:s,disabled:e,theme:c}):a.jsx(Jt,{onClick:t,disabled:e,theme:c})})})]}),a.jsxs("div",{className:"text-center flex flex-col items-center gap-y-2 mb-6 w-full",children:[a.jsx("h3",{className:`text-xl font-semibold mb-2 ${u.text.accent}`,children:i}),a.jsx("p",{className:`text-sm leading-relaxed px-4 ${u.text.secondary}`,children:l}),g>1&&a.jsxs("div",{className:"flex gap-6 mt-4 text-xs justify-center",children:[m&&a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[a.jsx(Be.Mic,{className:"w-4 h-4"}),a.jsx("span",{className:u.text.muted,children:"Voice"})]}),f&&a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[a.jsx(Be.Chat,{className:"w-4 h-4"}),a.jsx("span",{className:u.text.muted,children:"Chat"})]}),p&&a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[a.jsx(Be.Videocam,{className:"w-4 h-4"}),a.jsx("span",{className:u.text.muted,children:"Video"})]})]})]}),a.jsx(Zf,{prompts:o,theme:c}),a.jsx(Uf,{statusMessage:r,theme:c})]})};function Fa({room:e,onSessionEnd:t,onSessionStart:n,enableConsoleLogging:s=!0,enableLocalStorage:o=!0,voxketSessionId:r}={}){const[i,l]=h.useState(null),[c,d]=h.useState([]),[u,m]=h.useState(null),[f,p]=h.useState([]),g=h.useCallback((b,S)=>{const w={timestamp:new Date,event:b,data:S,sessionId:i==null?void 0:i.sessionId,participantId:u==null?void 0:u.identity};if(d(C=>[...C,w]),o){const C=JSON.parse(localStorage.getItem("voxket-session-logs")||"[]");C.push(w),localStorage.setItem("voxket-session-logs",JSON.stringify(C))}return w},[i==null?void 0:i.sessionId,u==null?void 0:u.identity,s,o]);h.useEffect(()=>{if(!e)return;const b=()=>{const L=r||`session-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,W=new Date,H={sessionId:L,startTime:W,totalMessages:0,connectionIssues:0,participantCount:f.length,events:[]};l(H),g("SESSION_STARTED",{sessionId:L,startTime:W}),n==null||n(L)},S=()=>{if(i){const L=new Date,W=L.getTime()-i.startTime.getTime(),H={...i,endTime:L,duration:W,events:c};g("SESSION_ENDED",{sessionId:i.sessionId,duration:`${Math.round(W/1e3)}s`,totalMessages:i.totalMessages,connectionIssues:i.connectionIssues}),t==null||t(H),l(null),d([])}},w=L=>{g("CONNECTION_STATE_CHANGED",{state:L}),L===I.ConnectionState.Reconnecting&&i&&(l(W=>W?{...W,connectionIssues:W.connectionIssues+1}:null),g("CONNECTION_ISSUE",{type:"reconnecting"}))},C=L=>{g("TRACK_PUBLISHED",{trackKind:L.kind,trackSource:L.source})},A=L=>{g("TRACK_UNPUBLISHED",{trackKind:L.kind,trackSource:L.source})},j=(L,W)=>{i&&l(H=>H?{...H,totalMessages:H.totalMessages+1}:null),g("DATA_RECEIVED",{participantId:W==null?void 0:W.identity,dataSize:L.length})},k=L=>{g("PARTICIPANT_CONNECTED",{participantId:L.identity,participantName:L.name}),p(W=>[...W,L]),i&&l(W=>W?{...W,participantCount:W.participantCount+1}:null)},D=L=>{g("PARTICIPANT_DISCONNECTED",{participantId:L.identity,participantName:L.name}),p(W=>W.filter(H=>H.identity!==L.identity))};return e.localParticipant&&m(e.localParticipant),e.on(I.RoomEvent.Connected,b),e.on(I.RoomEvent.Disconnected,S),e.on(I.RoomEvent.ConnectionStateChanged,w),e.on(I.RoomEvent.TrackPublished,C),e.on(I.RoomEvent.TrackUnpublished,A),e.on(I.RoomEvent.DataReceived,j),e.on(I.RoomEvent.ParticipantConnected,k),e.on(I.RoomEvent.ParticipantDisconnected,D),()=>{e.off(I.RoomEvent.Connected,b),e.off(I.RoomEvent.Disconnected,S),e.off(I.RoomEvent.ConnectionStateChanged,w),e.off(I.RoomEvent.TrackPublished,C),e.off(I.RoomEvent.TrackUnpublished,A),e.off(I.RoomEvent.DataReceived,j),e.off(I.RoomEvent.ParticipantConnected,k),e.off(I.RoomEvent.ParticipantDisconnected,D)}},[e,i,c,f.length,g,t,n]);const x=h.useCallback(()=>o?JSON.parse(localStorage.getItem("voxket-session-logs")||"[]"):c,[c,o]),v=h.useCallback(()=>{o&&localStorage.removeItem("voxket-session-logs"),d([])},[o]),E=h.useCallback(()=>{const b=x(),S=JSON.stringify(b,null,2),w="data:application/json;charset=utf-8,"+encodeURIComponent(S),C=`voxket-session-logs-${new Date().toISOString().split("T")[0]}.json`,A=document.createElement("a");A.setAttribute("href",w),A.setAttribute("download",C),A.click()},[x]);return{sessionMetrics:i,sessionLogs:c,logEvent:g,getSessionLogs:x,clearSessionLogs:v,exportSessionLogs:E}}class Qs{constructor(){me(this,"listeners",{})}on(t,n){return this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(n),()=>this.off(t,n)}once(t,n){const s=(...o)=>{this.off(t,s),n(...o)};return this.on(t,s)}off(t,n){const s=this.listeners[t];if(!s)return;const o=s.indexOf(n);o>-1&&s.splice(o,1)}removeAllListeners(t){t?delete this.listeners[t]:this.listeners={}}emit(t,...n){const s=this.listeners[t];if(!s)return;const o=[...s];for(const r of o)try{r(...n)}catch(i){console.error(`Error in event listener for ${String(t)}:`,i)}}listenerCount(t){var n;return((n=this.listeners[t])==null?void 0:n.length)??0}eventNames(){return Object.keys(this.listeners)}}class La{constructor(t){me(this,"plugins",new Map);me(this,"installedPlugins",new Set);me(this,"context");this.context={client:t,emit:t.emit.bind(t),on:t.on.bind(t),config:{}}}register(t){if(this.plugins.has(t.name))throw new Error(`Plugin '${t.name}' is already registered`);if(t.dependencies){for(const n of t.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin '${t.name}' depends on '${n}' which is not registered`)}this.plugins.set(t.name,t)}async install(t,n){const s=this.plugins.get(t);if(!s)throw new Error(`Plugin '${t}' is not registered`);if(this.installedPlugins.has(t))throw new Error(`Plugin '${t}' is already installed`);if(s.dependencies)for(const r of s.dependencies)this.installedPlugins.has(r)||await this.install(r);const o={...this.context,config:{...s.config,...n}};s.install&&await s.install(o),this.installedPlugins.add(t),this.setupPluginEvents(s,o)}async uninstall(t){var s;const n=this.plugins.get(t);if(!n)throw new Error(`Plugin '${t}' is not registered`);if(this.installedPlugins.has(t)){for(const[o,r]of this.plugins)if(this.installedPlugins.has(o)&&((s=r.dependencies)!=null&&s.includes(t)))throw new Error(`Cannot uninstall '${t}' because '${o}' depends on it`);n.uninstall&&await n.uninstall(this.context),this.installedPlugins.delete(t)}}isInstalled(t){return this.installedPlugins.has(t)}getInstalledPlugins(){return Array.from(this.installedPlugins)}getAvailablePlugins(){return Array.from(this.plugins.keys())}getPluginInfo(t){return this.plugins.get(t)}setupPluginEvents(t,n){t.onSessionStart&&n.on("session.started",s=>{t.onSessionStart(n,s.id)}),t.onSessionEnd&&n.on("session.ended",s=>{t.onSessionEnd(n,s.id)}),t.onAgentResponse&&n.on("agent.response",s=>{t.onAgentResponse(n,s)})}}function Wf(e){return e}function eo(e,t,n){return{name:e,version:"1.0.0",description:`${t} modality plugin`,install:async s=>{n.onActivate&&await n.onActivate(s)},uninstall:async s=>{n.onDeactivate&&await n.onDeactivate(s)},onAgentResponse:n.onMessage}}const Kf={name:"analytics",version:"1.0.0",description:"Built-in analytics tracking",install:async e=>{console.log("Analytics plugin installed"),e.on("session.started",t=>{console.log("Analytics: Session started",t.id)}),e.on("session.ended",(t,n)=>{console.log("Analytics: Session ended",t.id,n)}),e.on("chat.message.sent",t=>{console.log("Analytics: User message sent",t.content.length)})}},Gf={name:"debug",version:"1.0.0",description:"Debug logging and development tools",install:async e=>{console.log("Debug plugin installed");const t=e.emit;e.emit=(n,...s)=>(console.log(`[Debug] Event: ${String(n)}`,s),t(n,...s))}},Yf={name:"metrics",version:"1.0.0",description:"Advanced metrics collection",install:async e=>{console.log("Metrics plugin installed");const t=new Map;e.on("session.started",n=>{t.set(n.id,{startTime:Date.now(),events:[]})}),e.on("agent.response",n=>{console.log("Metrics: Agent response analyzed",{type:n.type,length:n.content.length,timestamp:n.timestamp})})}},Ba=y.createContext(null);function $a({config:e,children:t,autoConnect:n=!1}){const[s,o]=y.useState(null),[r,i]=y.useState(!1),[l,c]=y.useState(!1),[d,u]=y.useState(null),[m,f]=y.useState(null),[p,g]=y.useState("idle"),[x,v]=y.useState(null),[E,b]=y.useState([]),[S,w]=y.useState([]),[C,A]=y.useState([]);y.useEffect(()=>{const M=new _t(e);return o(M),j(M),n&&k(M),()=>{M.disconnect().catch(console.error)}},[e,n]);const j=M=>{M.on("connection.connecting",()=>{c(!0),u(null)}),M.on("connection.connected",()=>{i(!0),c(!1),u(null)}),M.on("connection.disconnected",()=>{i(!1),c(!1),f(null),g("idle"),b([]),w([]),A([])}),M.on("connection.error",G=>{u(G),c(!1)}),M.on("session.created",G=>{f(G),g(G.state)}),M.on("session.state.changed",G=>{g(G),m&&f({...m,state:G})}),M.on("session.ended",(G,Y)=>{f(null),g("idle"),v(Y),b([]),w([]),A([])}),M.on("participant.joined",G=>{b(Y=>[...Y,G])}),M.on("participant.left",G=>{b(Y=>Y.filter(V=>V.id!==G.id))}),M.on("chat.message.received",G=>{w(Y=>[...Y,G])}),M.on("chat.message.sent",G=>{w(Y=>[...Y,G])}),M.on("transcription.received",G=>{A(Y=>[...Y,G])})},k=async M=>{const G=M||s;if(G)try{await G.connect()}catch(Y){console.error("Failed to connect:",Y)}},z={client:s,isConnected:r,isConnecting:l,connectionError:d,currentSession:m,sessionState:p,sessionMetrics:x,participants:E,chatMessages:S,transcriptions:C,connect:()=>k(),disconnect:async()=>{if(s)try{await s.disconnect()}catch(M){console.error("Failed to disconnect:",M)}},createSession:async(M,G={})=>{if(!s)throw new Error("Client not initialized");const Y={agentId:M,participantName:G.participantName||"User",metadata:G.metadata,modalities:G.modalities||["voice"]};return await s.createSession(Y)},endSession:async()=>s?await s.endSession():null,sendChatMessage:async M=>{if(!s)throw new Error("Client not initialized");await s.sendChatMessage(M)},setMicrophoneEnabled:async M=>{if(!s)throw new Error("Client not initialized");await s.setMicrophoneEnabled(M)},setCameraEnabled:async M=>{if(!s)throw new Error("Client not initialized");await s.setCameraEnabled(M)},startScreenShare:async()=>{if(!s)throw new Error("Client not initialized");await s.startScreenShare()},stopScreenShare:async()=>{if(!s)throw new Error("Client not initialized");await s.stopScreenShare()}};return a.jsx(Ba.Provider,{value:z,children:t})}function Ie(){const e=y.useContext(Ba);if(!e)throw new Error("useVoxket must be used within a VoxketProvider");return e}class qf extends Qs{constructor(n){super();me(this,"room",null);me(this,"registeredMethods",new Map);me(this,"activeInteractions",new Map);me(this,"currentInteraction",null);n&&this.setRoom(n)}setRoom(n){this.room=n}async registerFrontendRPC(n,s,o="embedded"){if(console.log(`RpcManager: Starting registration for method '${n}'`),!this.room)throw console.error(`RpcManager: Cannot register '${n}' - no room instance`),new Error("Room not initialized. Cannot register RPC method.");if(!this.room.localParticipant)throw console.error(`RpcManager: Cannot register '${n}' - no local participant`),new Error("Local participant not available for RPC registration");console.log(`RpcManager: Room state: ${this.room.state}`),console.log(`RpcManager: Local participant: ${this.room.localParticipant.identity}`),console.log(`RpcManager: Registering frontend RPC method: ${n}`);const r={methodName:n,component:s,presentationMode:o};this.registeredMethods.set(n,r);try{this.room.registerRpcMethod(n,async i=>{console.log(`RpcManager: RPC method '${n}' called by ${i.callerIdentity}`),console.log("RpcManager: Payload:",i.payload),this.emit("rpc.method.called",{methodName:n,data:i});let l;console.log(`RpcManager: Current registration for '${n}':`,r);let c=i.responseTimeout||30;try{l=JSON.parse(i.payload)}catch{l=i.payload}try{const d=await this.awaitUserInteraction(n,s,o,l,c);return JSON.stringify(d)}catch(d){throw console.error(`RpcManager: Error in RPC method '${n}':`,d),d}}),this.emit("rpc.method.registered",{methodName:n}),console.log(`RpcManager: Successfully registered RPC method: ${n}`)}catch(i){throw console.error(`RpcManager: Failed to register RPC method '${n}':`,i),i}}async awaitUserInteraction(n,s,o,r,i){return new Promise((l,c)=>{const d=`${n}_${Date.now()}`;console.log(`RpcManager: Starting user interaction for method: ${n}, timeout: ${i} seconds`);const u={didSuccess:(f,p)=>{console.log(`RpcManager: User interaction successful for method: ${n}`,f),this.clearInteraction(d),this.currentInteraction=null;const g={success:!0,message:"User interaction completed successfully",data:f,timestamp:new Date,...p?{successView:p}:{}};this.emit("rpc.interaction.completed",{methodName:n,response:g}),l(g)},didFail:f=>{console.log(`RpcManager: User interaction failed for method: ${n}`,f),this.clearInteraction(d);const p={success:!1,message:"User interaction failed",error:f,timestamp:new Date};this.emit("rpc.interaction.completed",{methodName:n,response:p}),l(p)},dismissView:()=>{var p;console.log(`RpcManager: User dismissed interaction for method: ${n}`),console.log("RpcManager: Current interaction before dismiss:",(p=this.currentInteraction)==null?void 0:p.methodName),this.clearInteraction(d),this.currentInteraction=null,console.log("RpcManager: Current interaction after dismiss:",this.currentInteraction);const f={success:!0,data:{dismissed:!0,reason:"User dismissed the interaction"},message:"User interaction dismissed",timestamp:new Date};this.emit("rpc.interaction.dismissed",{methodName:n,response:f}),this.emit("rpc.interaction.completed",{methodName:n,response:f}),setTimeout(()=>{var g;((g=this.currentInteraction)==null?void 0:g.methodName)===n&&(console.log(`RpcManager: Force clearing interaction for ${n}`),this.currentInteraction=null)},0),l(f)},didTimeout:f=>{console.log(`RpcManager: User interaction timeout for method: ${n}`),this.clearInteraction(d),this.currentInteraction=null;const p={success:!0,message:`User interaction timed out after ${i} seconds, it should be considered as declined, agent don't need to retry`,timestamp:new Date,...f?{timeoutView:f}:{}};this.emit("rpc.interaction.timeout",{methodName:n,response:p}),setTimeout(()=>{var g;((g=this.currentInteraction)==null?void 0:g.methodName)===n&&(console.log(`RpcManager: Force clearing interaction for ${n}`),this.currentInteraction=null)},0),l(p)}},m=setTimeout(()=>{u.didTimeout&&u.didTimeout()},i);this.activeInteractions.set(d,{resolve:f=>l(JSON.parse(f)),reject:c,timeoutId:m}),this.currentInteraction={isVisible:!0,methodName:n,component:s,presentationMode:o,timeout:i,data:r,handler:u},this.emit("rpc.interaction.started",{methodName:n,presentationMode:o}),setTimeout(async()=>{var f;if((f=this.currentInteraction)!=null&&f.handler)try{console.log(`RpcManager: Component created for method: ${n} with data:`,r)}catch(p){console.error("RpcManager: Error loading data into component:",p),u.didFail({error:"Failed to load data into component"})}},100)})}clearInteraction(n){const s=this.activeInteractions.get(n);s&&(console.log(`RpcManager: Clearing interaction: ${n}`),clearTimeout(s.timeoutId),this.activeInteractions.delete(n))}getCurrentInteraction(){return this.currentInteraction}dismissCurrentInteraction(){var n;this.currentInteraction&&(console.log(`RpcManager: Dismissing current interaction: ${this.currentInteraction.methodName}`),(n=this.currentInteraction.handler)==null||n.dismissView(),setTimeout(()=>{this.currentInteraction&&(console.log("RpcManager: Force clearing lingering interaction"),this.currentInteraction=null)},0))}getRegisteredMethods(){return Array.from(this.registeredMethods.keys())}unregisterMethod(n){this.registeredMethods.delete(n),console.log(`RpcManager: Unregistered RPC method: ${n}`)}clear(){for(const[n,s]of this.activeInteractions)clearTimeout(s.timeoutId);this.activeInteractions.clear(),this.registeredMethods.clear(),this.currentInteraction=null,console.log("RpcManager: Cleared all registrations and interactions")}}class ee extends Error{constructor(t,n,s){super(t),this.code=n,this.details=s,this.name="VoxketError"}}class _t extends Qs{constructor(n){super();me(this,"config");me(this,"room",null);me(this,"pluginManager");me(this,"rpcManager");me(this,"isConnected",!1);me(this,"currentSession",null);me(this,"connectionState",I.ConnectionState.Disconnected);me(this,"renderedComponents",new Map);me(this,"textStreamHandlersRegistered",!1);me(this,"currentAgentInfo",null);me(this,"chatMessages",[]);this.config=n,this.pluginManager=new La(this),this.rpcManager=new qf,this.setupEventListeners(),this.initializeClient()}setupEventListeners(){this.on("connection.connected",()=>{var n,s;this.isConnected=!0,(s=(n=this.config).onConnected)==null||s.call(n)}),this.on("connection.disconnected",n=>{var s,o;this.isConnected=!1,(o=(s=this.config).onDisconnected)==null||o.call(s,n)}),this.on("connection.error",n=>{var s,o;(o=(s=this.config).onError)==null||o.call(s,n)}),this.on("chat.message.received",n=>{var s,o;this.addChatMessage(n),(o=(s=this.config).onMessageReceived)==null||o.call(s,n)}),this.on("chat.message.updated",n=>{this.updateChatMessage(n)}),this.on("chat.message.sent",n=>{this.addChatMessage(n)}),this.on("transcription.received",n=>{var s,o;(o=(s=this.config).onTranscriptionReceived)==null||o.call(s,n)}),this.on("session.state.changed",n=>{var s,o;(o=(s=this.config).onSessionStateChanged)==null||o.call(s,n)}),this.on("session.created",n=>{var s,o;(o=(s=this.config).onSessionStart)==null||o.call(s,n.id)}),this.on("session.ended",(n,s)=>{var o,r;(r=(o=this.config).onSessionEnd)==null||r.call(o,s)}),this.on("participant.joined",n=>{var s,o;(o=(s=this.config).onUserJoined)==null||o.call(s,n.id)}),this.on("participant.left",n=>{var s,o;(o=(s=this.config).onUserLeft)==null||o.call(s,n.id)}),this.setupRpcEventForwarding()}setupRpcEventForwarding(){if(!this.rpcManager){console.warn("RpcManager not initialized, skipping event forwarding setup");return}this.rpcManager.on("rpc.method.registered",n=>this.emit("rpc.method.registered",n)),this.rpcManager.on("rpc.method.called",n=>this.emit("rpc.method.called",n)),this.rpcManager.on("rpc.interaction.started",n=>this.emit("rpc.interaction.started",n)),this.rpcManager.on("rpc.interaction.completed",n=>this.emit("rpc.interaction.completed",n)),this.rpcManager.on("rpc.interaction.timeout",n=>this.emit("rpc.interaction.timeout",n)),this.rpcManager.on("rpc.interaction.dismissed",n=>this.emit("rpc.interaction.dismissed",n))}initializeClient(){this.room=new I.Room,this.setupRoomEventListeners()}setupRoomEventListeners(){this.room&&(this.room.on(I.RoomEvent.Connected,()=>{var n,s;this.connectionState=I.ConnectionState.Connected,this.emit("connection.connected"),this.rpcManager.setRoom(this.room),(s=(n=this.currentSession)==null?void 0:n.activeModalities)!=null&&s.includes("voice")&&setTimeout(async()=>{var o;try{(o=this.room)!=null&&o.localParticipant&&(this.room.localParticipant.isMicrophoneEnabled?this.emit("track.unmuted",{source:"microphone",enabled:!0}):(await this.room.localParticipant.setMicrophoneEnabled(!0),this.emit("track.unmuted",{source:"microphone",enabled:!0})))}catch(r){console.warn("VoxketClient: Failed to enable microphone after room connection:",r)}},1e3),this.textStreamHandlersRegistered||this.setupTextStreamHandlers()}),this.room.on(I.RoomEvent.Disconnected,n=>{this.connectionState=I.ConnectionState.Disconnected,this.textStreamHandlersRegistered=!1,this.emit("connection.disconnected",n==null?void 0:n.toString())}),this.room.on(I.RoomEvent.ConnectionStateChanged,n=>{this.connectionState=n,n===I.ConnectionState.Connecting&&this.emit("connection.connecting")}),this.room.on(I.RoomEvent.ParticipantConnected,n=>{const s={id:n.identity,name:n.name||n.identity,isLocal:!1};this.emit("participant.joined",s)}),this.room.on(I.RoomEvent.ParticipantDisconnected,n=>{const s={id:n.identity,name:n.name||n.identity,isLocal:!1};this.emit("participant.left",s)}))}setupTextStreamHandlers(){if(this.room){try{this.room.registerTextStreamHandler("lk.chat",async(n,s)=>{try{const o=await n.readAll(),r={id:`msg_${Date.now()}_${s.identity||"user"}_${Math.random().toString(36).substr(2,9)}`,content:o,timestamp:new Date,sender:{id:s.identity||"user",name:s.identity||"User",type:"participant"},metadata:{topic:"lk.chat"}};this.emit("chat.message.received",r)}catch(o){console.error("VoxketClient: Failed to process lk.chat message:",o)}})}catch(n){console.warn("VoxketClient: lk.chat handler already registered, skipping:",n)}try{this.room.registerTextStreamHandler("lk.transcription",async(n,s)=>{var o,r;try{const i=`msg_${Date.now()}_agent_transcription_${Math.random().toString(36).substr(2,9)}`;let l="";const c=((o=this.currentAgentInfo)==null?void 0:o.name)||s.identity||"AI Assistant",d={id:i,content:"",timestamp:new Date,sender:{id:s.identity||"agent",name:c,type:"agent"},metadata:{topic:"lk.transcription",streaming:!0}};this.emit("chat.message.received",d);for await(const f of n){l+=f;const p=this.convertMarkdownToText(l),g={...d,content:p,metadata:{...d.metadata,streaming:!0}};this.emit("chat.message.updated",g)}const u=this.convertMarkdownToText(l),m={...d,content:u,metadata:{...d.metadata,streaming:!1}};this.emit("chat.message.updated",m)}catch(i){console.error("VoxketClient: Failed to process lk.transcription message:",i);try{const l=await n.readAll(),c=((r=this.currentAgentInfo)==null?void 0:r.name)||s.identity||"AI Assistant",d={id:`msg_${Date.now()}_agent_transcription_${Math.random().toString(36).substr(2,9)}`,content:l,timestamp:new Date,sender:{id:s.identity||"agent",name:c,type:"agent"},metadata:{topic:"lk.transcription"}};this.emit("chat.message.received",d)}catch(l){console.error("VoxketClient: Fallback failed for lk.transcription:",l)}}})}catch(n){console.warn("VoxketClient: lk.transcription handler already registered, skipping:",n)}try{this.room.registerTextStreamHandler("suggested_response",async n=>{const s=await n.readAll();let o=[];try{o=["tes","hello how are you","algebra make me learn that ","what is the meaning of life"]}catch(r){console.warn("VoxketClient: Failed to parse suggested_response:",r,s)}this.emit("suggested.response",o)})}catch(n){console.warn("VoxketClient: suggested_response handler already registered, skipping:",n)}try{this.room.registerTextStreamHandler("agent_state_changed",async(n,s)=>{const o=await n.readAll();let r={};try{r=typeof o=="string"?JSON.parse(o.replace(/'/g,'"')):o}catch(i){console.warn("VoxketClient: Failed to parse agent_state_changed:",i,o)}r.new_state==="speaking"?this.emit("agent.speaking",r):r.new_state==="thinking"&&this.emit("agent.thinking",r)})}catch(n){console.warn("VoxketClient: conversation_item_added handler already registered, skipping:",n)}try{this.room.registerTextStreamHandler("images",async(n,s)=>{try{const o=await n.readAll()}catch(o){console.error("VoxketClient: Error processing images stream:",o)}})}catch(n){console.warn("VoxketClient: images handler already registered, skipping:",n)}try{this.room.registerByteStreamHandler("images",async(n,s)=>{var o,r;try{const i=n.info,l={id:`img_${Date.now()}_${s.identity||"agent"}_${Math.random().toString(36).substr(2,9)}`,content:`�️ ${i.name||"Image"}`,sender:{id:s.identity||"agent",name:s.identity||"Agent",type:s.identity===((r=(o=this.room)==null?void 0:o.localParticipant)==null?void 0:r.identity)?"participant":"agent"},timestamp:new Date,metadata:{type:"attachment",fileName:i.name,fileSize:i.size,mimeType:i.mimeType,streamId:i.id,downloading:!0}};this.emit("chat.message.received",l),n.onProgress&&(n.onProgress=f=>{const p={...l,metadata:{...l.metadata,downloadProgress:f||0}};this.emit("chat.message.updated",p)});const c=[];for await(const f of n)c.push(f);const d=new Blob(c,{type:i.mimeType||"application/octet-stream"}),u=URL.createObjectURL(d),m={...l,metadata:{...l.metadata,downloading:!1,downloadProgress:1,downloadUrl:u,blob:d}};this.emit("chat.message.updated",m)}catch(i){console.error("VoxketClient: Error processing image attachment:",i)}})}catch(n){console.warn("VoxketClient: image handler already registered, skipping:",n)}this.textStreamHandlersRegistered=!0}}async fetchConnectionDetails(n,s,o){const r=n||this.config.agentId||"default-agent",i=s||this.config.participantName||"User",l=o||this.config.modalities||["voice"];try{const c={agent_id:r,participant_name:i,participant_metadata:{user_id:""},modality:l[0]},d=await fetch(`${this.config.baseUrl}/api/live/agent/session`,{method:"POST",headers:{accept:"application/json","X-APP-ID":this.config.appId,"X-APP-SECRET":this.config.appSecret,"Content-Type":"application/json"},body:JSON.stringify(c)});if(!d.ok){let f=`HTTP ${d.status}: Failed to fetch connection details`;try{const p=await d.json();p&&(p.error?f=`API Error: ${p.error}`:p.detail?f=`API Error: ${p.detail}`:p.message&&(f=`API Error: ${p.message}`))}catch{try{const g=await d.text();g&&(f=`API Error: ${g}`)}catch{}}throw new Error(f)}const u=await d.json();let m;return u.agent_info&&(m={id:u.agent_info.id||r,name:u.agent_info.name||"AI Assistant",avatar:u.agent_info.avatar,capabilities:u.agent_info.capabilities||["voice_interaction","text_chat"],metadata:u.agent_info.metadata||{}},this.currentAgentInfo=m),{serverUrl:u.wss_url,participantToken:u.token,voxketSessionId:u.session_id,agentInfo:m}}catch(c){console.error("VoxketClient: fetchConnectionDetails failed:",c);const d=new ee(`Failed to fetch connection details: ${c instanceof Error?c.message:"Unknown error"}`,"CONNECTION_FAILED",c);throw this.emit("connection.error",d),d}}async connect(n,s,o){var r;try{this.emit("connection.connecting");const i=await this.fetchConnectionDetails(n,s,o);return await((r=this.room)==null?void 0:r.connect(i.serverUrl,i.participantToken)),this.isConnected=!0,i}catch(i){console.error("VoxketClient: Connection failed:",i);const l=new ee(`Failed to connect to Voxket services: ${i instanceof Error?i.message:"Unknown error"}`,"CONNECTION_FAILED",i);throw this.emit("connection.error",l),l}}async disconnect(){var n;try{await((n=this.room)==null?void 0:n.disconnect()),this.isConnected=!1,this.currentSession=null,this.currentAgentInfo=null,this.textStreamHandlersRegistered=!1,this.clearChatMessages(),this.room=new I.Room,this.setupRoomEventListeners()}catch(s){const o=new ee("Failed to disconnect properly","NETWORK_ERROR",s);throw this.emit("connection.error",o),o}}async createSession(n){var s,o;try{const r=await this.connect(n.agentId,n.participantName,n.modalities),i={id:r.voxketSessionId,agentId:n.agentId,state:"connecting",startedAt:new Date,metadata:n.metadata||{},activeModalities:n.modalities||["voice"],agentInfo:r.agentInfo||this.currentAgentInfo};if(this.currentSession=i,this.emit("session.created",i),(s=n.modalities)!=null&&s.includes("voice"))try{await new Promise(l=>setTimeout(l,500)),(o=this.room)!=null&&o.localParticipant?(await this.room.localParticipant.setMicrophoneEnabled(!0,void 0,{preConnectBuffer:!0}),this.emit("track.unmuted",{source:"microphone",enabled:!0})):console.warn("VoxketClient: No local participant found, microphone not enabled")}catch(l){console.warn("VoxketClient: Failed to enable microphone, but continuing with session:",l)}return setTimeout(()=>{this.currentSession&&(this.currentSession.state="active",this.emit("session.state.changed","active",this.currentSession.state))},1e3),i}catch(r){throw console.error("VoxketClient: Failed to create session:",r),r instanceof ee?r:r instanceof TypeError&&r.message.includes("fetch")?new ee("Network connection failed","CONNECTION_FAILED",r):r instanceof Error&&r.message.includes("Failed to fetch connection details")?new ee(`API connection failed: ${r.message}`,"CONNECTION_FAILED",r):new ee(`Failed to create session: ${r instanceof Error?r.message:"Unknown error"}`,"SESSION_NOT_FOUND",r)}}async startSession(n,s){const o={agentId:n||this.config.agentId||"default-agent",participantName:(s==null?void 0:s.participantName)||this.config.participantName||"User",modalities:(s==null?void 0:s.modalities)||this.config.modalities||["voice","chat"],metadata:s==null?void 0:s.metadata};return this.createSession(o)}async endSession(){var n,s;if(!this.currentSession)return null;try{const o={sessionId:this.currentSession.id,duration:Date.now()-(((n=this.currentSession.startedAt)==null?void 0:n.getTime())||0),messageCount:0,participantCount:((s=this.room)==null?void 0:s.remoteParticipants.size)||0,audioQuality:{avgBitrate:64e3,avgLatency:150,packetLoss:.01,jitter:.05},videoQuality:{avgBitrate:5e5,avgLatency:150,packetLoss:.01,jitter:.05},networkStats:{totalBytesReceived:0,totalBytesSent:0,connectionType:"webrtc",avgRoundTripTime:150},events:[]};return this.currentSession.endedAt=new Date,this.currentSession.state="disconnected",this.emit("session.ended",this.currentSession,o),await this.disconnect(),o}catch(o){throw new ee("Failed to end session","SESSION_NOT_FOUND",o)}}getCurrentSession(){return this.currentSession}getCurrentAgentInfo(){return this.currentAgentInfo}getChatMessages(){return[...this.chatMessages]}addChatMessage(n){this.chatMessages.some(o=>o.id===n.id)||this.chatMessages.push(n)}updateChatMessage(n){const s=this.chatMessages.findIndex(o=>o.id===n.id);s!==-1&&(this.chatMessages[s]=n)}clearChatMessages(){this.chatMessages=[],this.dismissCurrentInteraction(),this.renderedComponents.clear(),this.forceCleanupFullscreenOverlays(),this.emit("chat.history.cleared")}renderUI(n={}){var c,d,u;const s=this.resolveTarget(n.target||"body"),o=this.getTargetKey(s),r=this.renderedComponents.get(o);r&&r.target===s||this.removeUI(s);const i=(r==null?void 0:r.root)||hl.createRoot(s),l={agentId:n.agentId||this.config.agentId||"default-agent",participantName:n.participantName||this.config.participantName||"User",baseUrl:this.config.baseUrl,appSecret:this.config.appSecret,appId:this.config.appId,className:n.className,theme:typeof n.theme=="string"?n.theme:void 0,modalities:n.modality||this.config.modalities||["voice"],suportsChatInput:((c=n.modality)==null?void 0:c.includes("chat"))!==!1,suportsVideoInput:((d=n.modality)==null?void 0:d.includes("video"))===!0,suportsScreenShare:((u=n.modality)==null?void 0:u.includes("screen_share"))===!0,autoStart:n.autoStart,displayType:n.displayType||"widget",popupPosition:n.popupPosition||"bottom-right",popupTriggerText:n.popupTriggerText||"Open Chat",width:n.width,height:n.height,onDisplayTypeChange:n.onDisplayTypeChange,prompts:n.prompts,statusMessage:n.statusMessage,welcomeTitle:n.welcomeTitle,welcomeSubTitle:n.welcomeSubTitle,loadingText:n.loadingText,voxketClient:this};if(!i||typeof i.render!="function")throw new Error("Invalid React root. Make sure React 18+ is properly installed and configured.");try{i.render(y.createElement($a,{config:this.config,autoConnect:n.autoStart||!1,children:y.createElement(Oa,l)}))}catch(m){throw console.error("Error rendering Voxket widget:",m),new Error(`Failed to render Voxket widget: ${m instanceof Error?m.message:"Unknown error"}`)}this.renderedComponents.set(o,{root:i,target:s})}removeUI(n){const s=n?this.resolveTarget(n):null;if(s){const o=this.getTargetKey(s),r=this.renderedComponents.get(o);r&&(r.root.unmount(),this.renderedComponents.delete(o),s.querySelectorAll('[id*="voxket"], [class*="voxket"], .fixed.inset-0.z-50').forEach(l=>{try{l.remove()}catch(c){console.warn("Failed to remove element:",c)}}),s===document.body&&s.querySelectorAll(".fixed.z-50, .fixed.inset-0").forEach(c=>{if(c.classList.contains("bg-black")&&c.classList.contains("backdrop-blur-sm"))try{c.remove()}catch(d){console.warn("Failed to remove fixed element:",d)}}))}}removeAllUI(){for(const[n,s]of this.renderedComponents)s.root.unmount();this.renderedComponents.clear(),this.forceCleanupFullscreenOverlays()}forceCleanupFullscreenOverlays(){document.body.querySelectorAll(".fixed.inset-0.z-50").forEach(s=>{if(s.classList.contains("bg-black")&&(s.classList.contains("backdrop-blur-sm")||s.classList.contains("bg-opacity-30")))try{s.remove()}catch(o){console.warn("Failed to remove overlay:",o)}})}resolveTarget(n){if(typeof n=="string"){const s=document.querySelector(n);if(!s)throw new Error(`Target element not found: ${n}`);return s}return n}getTargetKey(n){return n.id?n.id:n.className?n.tagName+"_"+n.className.replace(/\s+/g,"_"):n.tagName+"_"+n.outerHTML.length%1e3}async sendMessage(n,s){var o;if(!this.currentSession)throw console.error("VoxketClient: No active session found"),new ee("No active session","SESSION_NOT_FOUND");if(!this.room)throw console.error("VoxketClient: No room instance found"),new ee("No room connection","CONNECTION_FAILED");if(!this.room.localParticipant)throw console.error("VoxketClient: No local participant found"),new ee("No local participant","CONNECTION_FAILED");this.dismissCurrentInteraction();try{const r={id:`msg_${Date.now()}`,content:n,sender:{id:"user",name:this.config.participantName||"User",type:"participant"},timestamp:new Date,metadata:s||{}},i=await((o=this.room)==null?void 0:o.localParticipant.sendText(n,{topic:"lk.chat",destinationIdentities:[]}));this.emit("chat.message.sent",r)}catch(r){throw console.error("VoxketClient: Failed to send chat message:",r),new ee("Failed to send message","NETWORK_ERROR",r)}}async sendChatMessage(n,s){return this.sendMessage(n,s)}async sendAttachments(n,s){if(!this.currentSession)throw console.error("VoxketClient: No active session found"),new ee("No active session","SESSION_NOT_FOUND");if(!this.room)throw console.error("VoxketClient: No room instance found"),new ee("No room connection","CONNECTION_FAILED");if(!this.room.localParticipant)throw console.error("VoxketClient: No local participant found"),new ee("No local participant","CONNECTION_FAILED");if(!n||n.length===0)throw new ee("No files provided","INVALID_PARAMETER");this.dismissCurrentInteraction();const o=n.filter(r=>r.type.startsWith("image/"));if(o.length===0)throw new ee("Only image files are allowed","INVALID_PARAMETER");o.length!==n.length&&console.warn("VoxketClient: Some non-image files were filtered out");try{const r=o.map(async(i,l)=>{const d={id:`att_${Date.now()}_${l}`,content:`📎 ${i.name}`,sender:{id:"user",name:this.config.participantName||"User",type:"participant"},timestamp:new Date,metadata:{...s,type:"attachment",fileName:i.name,fileSize:i.size,mimeType:i.type,uploading:!0}};this.emit("chat.message.sent",d);const u=await this.room.localParticipant.sendFile(i,{mimeType:i.type,topic:"images",onProgress:f=>{const p={...d,metadata:{...d.metadata,uploadProgress:f}};this.emit("chat.message.updated",p)}});try{const f=new FileReader,p=new Promise((v,E)=>{f.onload=()=>{typeof f.result=="string"?v(f.result):E(new Error("Failed to convert to base64"))},f.onerror=E});f.readAsDataURL(i);const x={type:"image",data:await p,filename:i.name,mimeType:i.type,size:i.size};await this.room.localParticipant.sendText(JSON.stringify(x),{topic:"images",destinationIdentities:[]})}catch(f){console.warn("VoxketClient: Failed to send image data to agent:",f);try{const p=`I've shared an image: ${i.name}`;await this.room.localParticipant.sendText(p,{topic:"lk.chat",destinationIdentities:[]})}catch(p){console.warn("VoxketClient: Failed to send image notification to agent:",p)}}const m={...d,metadata:{...d.metadata,uploading:!1,uploadProgress:1,streamId:u.id}};return this.emit("chat.message.updated",m),u});await Promise.all(r)}catch(r){throw console.error("VoxketClient: Failed to send attachments:",r),new ee("Failed to send attachments","NETWORK_ERROR",r)}}async sendAttachment(n,s){return this.sendAttachments([n],s)}toggleMicrophone(n){return this.setMicrophoneEnabled(n!==!1)}async setMicrophoneEnabled(n){var s,o;try{const r=(s=this.room)==null?void 0:s.localParticipant.isMicrophoneEnabled,i=n??!r;await((o=this.room)==null?void 0:o.localParticipant.setMicrophoneEnabled(i)),i?this.emit("track.unmuted",{source:"microphone",enabled:!0}):this.emit("track.muted",{source:"microphone",enabled:!1})}catch(r){throw console.error("VoxketClient: Failed to toggle microphone:",r),new ee("Failed to toggle microphone","PERMISSION_DENIED",r)}}toggleCamera(n){return this.setCameraEnabled(n!==!1)}async setCameraEnabled(n){var s,o;try{const r=(s=this.room)==null?void 0:s.localParticipant.isCameraEnabled,i=n??!r;await((o=this.room)==null?void 0:o.localParticipant.setCameraEnabled(i)),i?this.emit("track.unmuted",{source:"camera",enabled:!0}):this.emit("track.muted",{source:"camera",enabled:!1})}catch(r){throw console.error("VoxketClient: Failed to toggle camera:",r),new ee("Failed to toggle camera","PERMISSION_DENIED",r)}}async enableCamera(){return this.setCameraEnabled(!0)}async disableCamera(){return this.setCameraEnabled(!1)}async startScreenShare(){var n;try{await((n=this.room)==null?void 0:n.localParticipant.setScreenShareEnabled(!0))}catch(s){throw new ee("Failed to start screen share","PERMISSION_DENIED",s)}}async stopScreenShare(){var n;try{await((n=this.room)==null?void 0:n.localParticipant.setScreenShareEnabled(!1))}catch(s){throw new ee("Failed to stop screen share","PERMISSION_DENIED",s)}}async getAudioInputDevices(){try{return(await navigator.mediaDevices.enumerateDevices()).filter(s=>s.kind==="audioinput")}catch(n){throw new ee("Failed to get audio input devices","DEVICE_ERROR",n)}}async getVideoInputDevices(){try{return(await navigator.mediaDevices.enumerateDevices()).filter(s=>s.kind==="videoinput")}catch(n){throw new ee("Failed to get video input devices","DEVICE_ERROR",n)}}async setAudioInputDevice(n){var s;try{if(!((s=this.room)!=null&&s.localParticipant))throw new Error("Not connected to room")}catch(o){throw new ee("Failed to set audio input device","DEVICE_ERROR",o)}}async setVideoInputDevice(n){var s;try{if(!((s=this.room)!=null&&s.localParticipant))throw new Error("Not connected to room")}catch(o){throw new ee("Failed to set video input device","DEVICE_ERROR",o)}}getLocalParticipant(){var n;return((n=this.room)==null?void 0:n.localParticipant)??null}getRemoteParticipants(){var n;return Array.from(((n=this.room)==null?void 0:n.remoteParticipants.values())??[])}getPublishPermissions(){const n=this.getLocalParticipant();if(!n)return{camera:!1,microphone:!1,screenShare:!1,data:!1};const s=n.permissions;if(!s)return{camera:!0,microphone:!0,screenShare:!0,data:!0};const o=r=>!!s.canPublish&&(s.canPublishSources.length===0||s.canPublishSources.includes(r));return{camera:o(1),microphone:o(2),screenShare:o(3),data:s.canPublishData??!1}}canPublishSource(n){return this.getPublishPermissions()[n]}getRoom(){return this.room}getConnectionState(){return this.connectionState}get connected(){return this.isConnected&&this.connectionState===I.ConnectionState.Connected}getMicrophoneTrack(){const n=this.getLocalParticipant();if(!n)return null;for(const[,s]of n.trackPublications)if(s.source===I.Track.Source.Microphone)return s.track;return null}getCameraTrack(){const n=this.getLocalParticipant();if(!n)return null;for(const[,s]of n.trackPublications)if(s.source===I.Track.Source.Camera)return s.track;return null}getScreenShareTrack(){const n=this.getLocalParticipant();if(!n)return null;for(const[,s]of n.trackPublications)if(s.source===I.Track.Source.ScreenShare)return s.track;return null}get isMicrophoneEnabled(){const n=this.getMicrophoneTrack();return n?!n.isMuted:!1}get isCameraEnabled(){const n=this.getCameraTrack();return n?!n.isMuted:!1}get isScreenShareEnabled(){const n=this.getScreenShareTrack();return n?!n.isMuted:!1}registerPlugin(n){this.pluginManager.register(n)}getPluginManager(){return this.pluginManager}getParticipants(){if(!this.room)return[];const n=[];return this.room.localParticipant&&n.push({id:this.room.localParticipant.identity,name:this.room.localParticipant.name||this.room.localParticipant.identity,isLocal:!0}),this.room.remoteParticipants.forEach(s=>{n.push({id:s.identity,name:s.name||s.identity,isLocal:!1})}),n}getSessionMetrics(){var n,s;return this.currentSession?{sessionId:this.currentSession.id,duration:Date.now()-(((n=this.currentSession.startedAt)==null?void 0:n.getTime())||0),messageCount:0,participantCount:((s=this.room)==null?void 0:s.remoteParticipants.size)||0,audioQuality:{avgBitrate:64e3,avgLatency:150,packetLoss:.01,jitter:.05},videoQuality:{avgBitrate:5e5,avgLatency:150,packetLoss:.01,jitter:.05},networkStats:{totalBytesReceived:0,totalBytesSent:0,connectionType:"webrtc",avgRoundTripTime:150},events:[]}:null}updateConfig(n){this.config={...this.config,...n}}async startRecording(){var n;try{this.emit("recording.started",{sessionId:(n=this.currentSession)==null?void 0:n.id,timestamp:new Date})}catch(s){throw new ee("Failed to start recording","RECORDING_ERROR",s)}}async stopRecording(){var n;try{this.emit("recording.stopped",{sessionId:(n=this.currentSession)==null?void 0:n.id,timestamp:new Date})}catch(s){throw new ee("Failed to stop recording","RECORDING_ERROR",s)}}async registerFrontendRPC(n,s,o="embedded"){return this.rpcManager.registerFrontendRPC(n,s,o)}getCurrentInteraction(){return this.rpcManager.getCurrentInteraction()}dismissCurrentInteraction(){this.rpcManager.dismissCurrentInteraction()}getRegisteredRpcMethods(){return this.rpcManager.getRegisteredMethods()}unregisterRpcMethod(n){this.rpcManager.unregisterMethod(n)}registerEventListener(n,s){return this.on(n,s)}registerEventEmitter(n,s){if(!this.room)throw new Error("Room not available");try{this.room.registerTextStreamHandler(n,async o=>{try{const r=await o.readAll();s(r)}catch(r){console.error(`Error processing event for topic '${n}':`,r)}})}catch(o){console.warn(`VoxketClient: Handler for topic '${n}' may already be registered:`,o)}}convertMarkdownToText(n){if(!n)return"";let s=n;return s=s.replace(/\*\*(.*?)\*\*/g,"$1"),s=s.replace(/__(.*?)__/g,"$1"),s=s.replace(/\*(.*?)\*/g,"$1"),s=s.replace(/_(.*?)_/g,"$1"),s=s.replace(/~~(.*?)~~/g,"$1"),s=s.replace(/`([^`]+)`/g,"$1"),s=s.replace(/```[\s\S]*?```/g,""),s=s.replace(/^#{1,6}\s+/gm,""),s=s.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1"),s.trim()}}const Xf=Q.create(Tf),Jf=Q.create($f),Qf=Q.create(Hf),e0=Q.create(zf);function t0({onClick:e,text:t="Open Chat",position:n="bottom-right",theme:s}){const o={"top-left":"top-4 left-4","top-right":"top-4 right-4","bottom-left":"bottom-4 left-4","bottom-right":"bottom-4 right-4"},r=ye(s);return a.jsx(Q.button,{onClick:e,className:`fixed ${o[n]} z-50 px-4 py-2 rounded-full shadow-lg ${r.popupTrigger} transition-all duration-200 hover:scale-105`,initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},children:t})}function Li({children:e,theme:t,displayType:n="widget",onClose:s,popupPosition:o="bottom-right",onExpand:r}){const i=ye(t);if(n==="fullscreen")return a.jsx("div",{className:"fixed inset-0 z-50 bg-black bg-opacity-30 backdrop-blur-sm flex items-center justify-center p-8",children:a.jsxs("div",{className:"w-full h-full max-w-6xl max-h-[90vh] rounded-2xl relative bg-transparent",children:[s&&a.jsx("button",{onClick:l=>{l.preventDefault(),l.stopPropagation(),s()},className:"absolute top-4 cursor-pointer right-4 z-[100] w-12 h-12 rounded-full bg-gray-900 bg-opacity-90 text-white flex items-center justify-center hover:bg-gray-800 transition-all duration-200 shadow-lg border border-gray-700 backdrop-blur-sm",title:"Exit Fullscreen",type:"button",children:a.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}),a.jsxs("div",{id:"voice-card",className:`${i.card} w-full h-full flex flex-col rounded-xl shadow-2xl`,style:{minHeight:"600px"},children:[a.jsx("div",{className:i.cardTopGradient}),a.jsx("div",{className:i.cardPurpleBlur}),a.jsx("div",{className:i.cardPinkBlur}),a.jsx("div",{className:" flex flex-col h-full",children:e}),a.jsx("div",{className:i.cardPulse1}),a.jsx("div",{className:i.cardPulse2,style:{animationDelay:"1s"}})]})]})});if(n==="popup"){const l={"top-left":"top-4 left-4","top-right":"top-4 right-4","bottom-left":"bottom-4 left-4","bottom-right":"bottom-4 right-4"};return a.jsx("div",{className:"fixed rounded-2xl inset-0 z-50 pointer-events-none",children:a.jsxs("div",{className:`fixed rounded-2xl ${l[o]} pointer-events-auto`,children:[s&&a.jsx("button",{onClick:s,className:"absolute -top-2 -right-2 z-10 w-8 h-8 rounded-full bg-gray-900 bg-opacity-90 text-white flex items-center justify-center hover:bg-gray-800 transition-all duration-200 text-sm shadow-lg border border-gray-700",children:"×"}),a.jsxs("div",{id:"voice-card",className:`${i.card} rounded-2xl flex flex-col`,style:{width:"300px",height:"450px"},children:[a.jsx("div",{className:i.cardPurpleBlur}),a.jsx("div",{className:i.cardPinkBlur}),a.jsx("div",{className:" flex flex-col h-full",children:e}),a.jsx("div",{className:i.cardPulse1}),a.jsx("div",{className:i.cardPulse2,style:{animationDelay:"1s"}})]})]})})}return a.jsxs("div",{id:"voice-card",className:`${i.card}`,children:[r&&a.jsx("button",{onClick:r,className:"absolute top-4 right-4 z-20 w-10 h-10 rounded-full bg-gray-900 bg-opacity-90 text-white flex items-center justify-center hover:bg-gray-800 transition-all duration-200 shadow-lg border border-gray-700 backdrop-blur-sm",title:"Enter Fullscreen",children:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"})})}),a.jsx("div",{className:i.cardTopGradient}),a.jsx("div",{className:i.cardPurpleBlur}),a.jsx("div",{className:i.cardPinkBlur}),e,a.jsx("div",{className:i.cardPulse1}),a.jsx("div",{className:i.cardPulse2,style:{animationDelay:"1s"}})]})}function Oa(e){if(typeof window>"u")return null;console.log("🎯 Widget component rendering with props:",{displayType:e.displayType,popupPosition:e.popupPosition,theme:e.theme});const{agentId:t,participantName:n,baseUrl:s,appSecret:o,appId:r,prompts:i,statusMessage:l,welcomeTitle:c,welcomeSubTitle:d,className:u,width:m,height:f,loadingText:p,suportsChatInput:g=!0,suportsVideoInput:x=!0,suportsScreenShare:v=!0,theme:E="vox",onSessionStart:b,onSessionEnd:S,enableSessionLogging:w=!0,onSessionLogsUpdate:C,onSessionMetricsUpdate:A,modalities:j=["voice"],displayType:k="widget",popupPosition:D="bottom-right",popupTriggerText:L="Open Chat",onPopupToggle:W,voxketClient:H,onDisplayTypeChange:Ce}=e,[ne,te]=h.useState(()=>H?!!H.getCurrentSession():!1),[se,z]=h.useState(!1),[M,G]=h.useState(t||""),[Y,V]=h.useState(n||"User"),[q,T]=h.useState(()=>H?H.getCurrentSession():null),[F,Z]=h.useState(()=>{var J,He,Me;if(H){const ce=H.getCurrentSession();if((J=ce==null?void 0:ce.activeModalities)!=null&&J.includes("chat"))return"chat";if((He=ce==null?void 0:ce.activeModalities)!=null&&He.includes("voice"))return"voice";if((Me=ce==null?void 0:ce.activeModalities)!=null&&Me.includes("video"))return"video"}return"welcome"}),[B,R]=h.useState(!1);h.useEffect(()=>{console.log("🎯 Widget displayType prop changed to:",k)},[k]),h.useEffect(()=>{console.log("📊 Session state changed:",{currentMode:F,sessionStarted:ne,loading:se,currentSession:q==null?void 0:q.id,isPopupOpen:B})},[F,ne,se,q,B]);const _=h.useMemo(()=>{if(H)return console.log("🔄 Using passed VoxketClient to preserve session state"),H;console.log("🆕 Creating new VoxketClient instance");const J={appId:r,appSecret:o,baseUrl:s,agentId:M,participantName:Y||"User",modalities:j};return new _t(J)},[H,r,o,s,M,Y,j]),K=j,O=h.useMemo(()=>_.getRoom()||new I.Room,[_]),re={suportsChatInput:g,suportsVideoInput:x,suportsScreenShare:v},{sessionMetrics:oe,sessionLogs:he,logEvent:ve}=Fa({room:O,onSessionStart:b,onSessionEnd:S,enableConsoleLogging:w,enableLocalStorage:w,voxketSessionId:q==null?void 0:q.id});h.useEffect(()=>{C&&C(he)},[he,C]),h.useEffect(()=>{A&&oe&&A(oe)},[oe,A]),h.useEffect(()=>{const J=Me=>{console.log("🔴 Room disconnected:",Me),z(!1),te(!1),T(null),Z("welcome")},He=Me=>{console.log("📹 Media devices error:",Me),Xt({title:"Allow access to your microphone/camera",description:`${Me.name}: ${Me.message}`})};return O.on(I.RoomEvent.MediaDevicesError,He),O.on(I.RoomEvent.Disconnected,J),()=>{O.off(I.RoomEvent.Disconnected,J),O.off(I.RoomEvent.MediaDevicesError,He)}},[O]);const De=async()=>{try{console.log("🎤 Starting voice session...",{agentId:M,participantName:Y}),console.log("🎤 Pre-start state:",{currentMode:F,sessionStarted:ne,loading:se}),z(!0),te(!0),Z("voice"),console.log("🎤 State after mode change:",{currentMode:"voice",sessionStarted:!0,loading:!0}),ve("USER_STARTED_VOICE_SESSION",{agentId:M,participantName:Y});const J=await _.startSession(M,{participantName:Y||"User",modalities:["voice",...x?["video"]:[]]});console.log("✅ Voice session started successfully:",J.id),T(J),z(!1),b&&b(J.id)}catch(J){console.error("❌ Failed to start voice session:",J),Xt({title:"Failed to start voice session",description:J instanceof Error?J.message:"Unknown error occurred"}),z(!1),te(!1),Z("welcome")}},Zt=async()=>{try{z(!0),te(!0),Z("chat"),ve("USER_STARTED_CHAT_SESSION",{agentId:M,participantName:Y});const J=await _.startSession(M,{participantName:Y||"User",modalities:["chat"]});T(J),z(!1),b&&b(J.id)}catch(J){console.error("Failed to start chat session:",J),Xt({title:"Failed to start chat session",description:J instanceof Error?J.message:"Unknown error occurred"}),z(!1),te(!1),Z("welcome")}},nl=async()=>{try{console.log("📺 Starting video session...",{agentId:M,participantName:Y}),console.log("📺 Pre-start state:",{currentMode:F,sessionStarted:ne,loading:se}),z(!0),te(!0),Z("video"),console.log("📺 State after mode change:",{currentMode:"video",sessionStarted:!0,loading:!0}),ve("USER_STARTED_VIDEO_SESSION",{agentId:M,participantName:Y});const J=await _.startSession(M,{participantName:Y||"User",modalities:["video","voice"]});console.log("✅ Video session started successfully:",J.id),T(J),z(!1),b&&b(J.id)}catch(J){console.error("❌ Failed to start video session:",J),Xt({title:"Failed to start video session",description:J instanceof Error?J.message:"Unknown error occurred"}),z(!1),te(!1),Z("welcome")}},St=()=>{Z("welcome"),Ce&&Ce(e.displayType||"widget"),q&&ne&&(te(!1),T(null),_.disconnect()),k==="popup"&&!B&&R(!0)},Ct=()=>{const J=!B;R(J),W&&W(J),!J&&!(q&&ne)&&(Z("welcome"),te(!1),T(null))},sl=()=>{console.log("🔄 Closing fullscreen, switching to widget display type"),e.onDisplayTypeChange?e.onDisplayTypeChange("widget"):console.warn("⚠️ No onDisplayTypeChange callback provided")},ol=()=>{e.onDisplayTypeChange&&e.onDisplayTypeChange("fullscreen")};h.useEffect(()=>{var J,He,Me;if(H&&_){console.log("🔄 Syncing widget state with existing client session state");const ce=_.getCurrentSession(),il=_.connected;console.log("🔍 Existing session state:",{hasSession:!!ce,sessionId:ce==null?void 0:ce.id,isConnected:il,activeModalities:ce==null?void 0:ce.activeModalities}),ce&&(console.log("✅ Restoring session state from existing client"),T(ce),te(!0),z(!1),(J=ce.activeModalities)!=null&&J.includes("chat")?Z("chat"):(He=ce.activeModalities)!=null&&He.includes("voice")?Z("voice"):(Me=ce.activeModalities)!=null&&Me.includes("video")&&Z("video"))}},[H,_]),h.useEffect(()=>()=>{console.log("🧹 Cleaning up widget component"),H?console.log("🔄 Widget cleanup: preserving passed client instance"):(console.log("🧹 Widget cleanup: disconnecting self-created client"),_.disconnect())},[_,H]);let xn="w-96",yn="h-[25rem]",bn={};if(m&&(m.startsWith("w-")?xn=m:(bn.width=m,xn="")),f&&(f.startsWith("h-")?yn=f:(bn.height=f,yn="")),k==="popup"&&!B)return console.log("🟡 Showing popup trigger button"),a.jsx(t0,{onClick:Ct,text:L,position:D,theme:E});console.log("🟢 Rendering widget content, displayType:",k,"isPopupOpen:",B,"currentMode:",F,"sessionStarted:",ne,"loading:",se);let vn=`voxket-widget-root theme-${E}`,Ut={scrollMargin:0,scrollPadding:0,contain:"layout style paint"};k==="widget"?(vn+=` flex items-center justify-center min-h-fit ${xn} ${yn} ${u}`,Ut={...Ut,...bn}):(vn=`${u||""}`,Ut={});const io=a.jsx(a.Fragment,{children:a.jsxs(ut,{mode:"wait",children:[F==="welcome"&&!se&&a.jsx(e0,{agentId:M,participantName:Y||"",onAgentIdChange:G,onParticipantNameChange:V,onStartCall:De,onStartChat:Zt,onStartVideo:nl,disabled:ne||se,prompts:i,statusMessage:l,title:c,subTitle:d,theme:E,modalities:K,initial:{opacity:0,y:0},animate:{opacity:1,y:0},exit:{opacity:0,y:40},transition:{duration:.3,ease:"easeInOut"}},"welcome"),F==="voice"&&a.jsxs(ue.RoomContext.Provider,{value:O,children:[a.jsx(ue.RoomAudioRenderer,{}),a.jsx(ue.StartAudio,{label:"Start Audio"}),a.jsx(Xf,{loadingText:p,participantName:Y||"User",capabilities:re,sessionStarted:ne,disabled:!ne,theme:E,client:_,displayType:k,onBack:k==="popup"?Ct:St,initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.3,ease:"easeInOut"}},"session-view")]}),F==="chat"&&a.jsx(Jf,{client:_,theme:E,displayType:k,onBack:k==="popup"?Ct:St,onEndChat:St,disabled:!ne,initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.3,ease:"easeInOut"}},"chat-view"),F==="video"&&a.jsxs(ue.RoomContext.Provider,{value:O,children:[a.jsx(ue.RoomAudioRenderer,{}),a.jsx(ue.StartAudio,{label:"Start Audio"}),a.jsx(Qf,{client:_,theme:E,displayType:k,onBack:k==="popup"?Ct:St,onEndCall:St,disabled:!ne,initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.3,ease:"easeInOut"}},"video-view")]})]})});return k==="fullscreen"||k==="popup"?(console.log("📱 Rendering fullscreen/popup mode, displayType:",k),a.jsx(Li,{theme:E,displayType:k,popupPosition:D,onClose:k==="fullscreen"?sl:Ct,children:io})):(console.log("📦 Rendering widget mode"),a.jsx("div",{className:vn,style:Ut,children:a.jsx(Li,{theme:E,displayType:k,popupPosition:D,onExpand:ol,children:io})}))}class _a extends h.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("VoxketWidget Error:",t,n)}render(){if(this.state.hasError){if(this.props.fallback){const t=this.props.fallback;return h.createElement(t,{error:this.state.error})}return h.createElement("div",{style:{padding:"20px",border:"1px solid #ff4444",borderRadius:"8px",background:"#fff5f5",color:"#cc0000"}},"VoxketWidget encountered an error. Please check the console for details.")}return this.props.children}}function n0({logs:e,onClear:t,onExport:n}){const[s,o]=y.useState(!1),[r,i]=y.useState(""),l=e.filter(c=>!r||c.event.toLowerCase().includes(r.toLowerCase()));return s?a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-4xl w-full max-h-[80vh] flex flex-col m-4",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[a.jsxs("h2",{className:"text-lg font-semibold",children:["Session Logs (",e.length,")"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"text",placeholder:"Filter events...",value:r,onChange:c=>i(c.target.value),className:"px-3 py-1 border rounded text-sm"}),a.jsx("button",{onClick:t,className:"px-3 py-1 bg-red-600 text-white rounded text-sm hover:bg-red-700",children:"Clear"}),a.jsx("button",{onClick:n,className:"px-3 py-1 bg-green-600 text-white rounded text-sm hover:bg-green-700",children:"Export"}),a.jsx("button",{onClick:()=>o(!1),className:"px-3 py-1 bg-gray-600 text-white rounded text-sm hover:bg-gray-700",children:"Close"})]})]}),a.jsx("div",{className:"flex-1 overflow-auto p-4",children:l.length===0?a.jsx("p",{className:"text-gray-500 text-center py-8",children:"No logs found"}):a.jsx("div",{className:"space-y-2",children:l.map((c,d)=>a.jsxs("div",{className:"border rounded p-3 text-sm",children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:"font-semibold text-blue-600",children:c.event}),a.jsx("span",{className:"text-gray-500 text-xs",children:new Date(c.timestamp).toLocaleTimeString()})]}),c.sessionId&&a.jsxs("div",{className:"text-xs text-gray-600 mb-1",children:["Session: ",c.sessionId]}),c.data&&a.jsx("div",{className:"bg-gray-50 p-2 rounded text-xs",children:a.jsx("pre",{className:"whitespace-pre-wrap overflow-auto",children:JSON.stringify(c.data,null,2)})})]},d))})})]})}):a.jsxs("button",{onClick:()=>o(!0),className:"fixed bottom-4 right-4 bg-blue-600 text-white px-4 py-2 rounded-lg shadow-lg hover:bg-blue-700 transition-colors text-sm z-50",children:["Session Logs (",e.length,")"]})}function s0({metrics:e}){return e?a.jsxs("div",{className:"bg-gray-100 p-4 rounded-lg",children:[a.jsx("h3",{className:"font-semibold mb-2",children:"Current Session"}),a.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-gray-600",children:"Session ID:"}),a.jsx("div",{className:"font-mono text-xs",children:e.sessionId})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-gray-600",children:"Start Time:"}),a.jsx("div",{children:new Date(e.startTime).toLocaleString()})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-gray-600",children:"Messages:"}),a.jsx("div",{children:e.totalMessages})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-gray-600",children:"Participants:"}),a.jsx("div",{children:e.participantCount})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-gray-600",children:"Connection Issues:"}),a.jsx("div",{children:e.connectionIssues})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-gray-600",children:"Duration:"}),a.jsxs("div",{children:[Math.round((Date.now()-new Date(e.startTime).getTime())/1e3),"s"]})]})]})]}):null}function nt(){const{currentSession:e,sessionState:t,sessionMetrics:n,createSession:s,endSession:o}=Ie(),r=y.useCallback(async(l,c)=>await s(l,c),[s]),i=y.useCallback(async()=>await o(),[o]);return{session:e,state:t,metrics:n,isActive:e!==null&&t!=="disconnected",isConnecting:t==="connecting",isConnected:t==="connected"||t==="active",start:r,stop:i}}function Ha(){const{sessionMetrics:e,currentSession:t}=Ie();return{metrics:e,sessionId:t==null?void 0:t.id,duration:e==null?void 0:e.duration,participantCount:e==null?void 0:e.participantCount,messageCount:e==null?void 0:e.messageCount,audioQuality:e==null?void 0:e.audioQuality,networkStats:e==null?void 0:e.networkStats}}function Za(){const{setMicrophoneEnabled:e,client:t}=Ie(),[n,s]=y.useState(!1),[o,r]=y.useState(!1),i=y.useCallback(async()=>{if(!o){r(!0);try{const d=!n;await e(d),s(d)}catch(d){console.error("Failed to toggle microphone:",d)}finally{r(!1)}}},[n,o,e]),l=y.useCallback(async()=>{if(!(n||o)){r(!0);try{await e(!0),s(!0)}catch(d){console.error("Failed to enable microphone:",d)}finally{r(!1)}}},[n,o,e]),c=y.useCallback(async()=>{if(!(!n||o)){r(!0);try{await e(!1),s(!1)}catch(d){console.error("Failed to disable microphone:",d)}finally{r(!1)}}},[n,o,e]);return{isEnabled:n,isLoading:o,toggle:i,enable:l,disable:c}}function Ua(){const{setCameraEnabled:e}=Ie(),[t,n]=y.useState(!1),[s,o]=y.useState(!1),r=y.useCallback(async()=>{if(!s){o(!0);try{const c=!t;await e(c),n(c)}catch(c){console.error("Failed to toggle camera:",c)}finally{o(!1)}}},[t,s,e]),i=y.useCallback(async()=>{if(!(t||s)){o(!0);try{await e(!0),n(!0)}catch(c){console.error("Failed to enable camera:",c)}finally{o(!1)}}},[t,s,e]),l=y.useCallback(async()=>{if(!(!t||s)){o(!0);try{await e(!1),n(!1)}catch(c){console.error("Failed to disable camera:",c)}finally{o(!1)}}},[t,s,e]);return{isEnabled:t,isLoading:s,toggle:r,enable:i,disable:l}}function za(){const{startScreenShare:e,stopScreenShare:t}=Ie(),[n,s]=y.useState(!1),[o,r]=y.useState(!1),i=y.useCallback(async()=>{if(!(n||o)){r(!0);try{await e(),s(!0)}catch(d){console.error("Failed to start screen share:",d)}finally{r(!1)}}},[n,o,e]),l=y.useCallback(async()=>{if(!(!n||o)){r(!0);try{await t(),s(!1)}catch(d){console.error("Failed to stop screen share:",d)}finally{r(!1)}}},[n,o,t]),c=y.useCallback(async()=>{n?await l():await i()},[n,i,l]);return{isSharing:n,isLoading:o,start:i,stop:l,toggle:c}}function o0(){const{client:e}=Ie(),[t,n]=y.useState({tracks:[],layout:{type:"grid",showLocalVideo:!0,aspectRatio:"16:9"},isRecording:!1}),s=y.useMemo(()=>t.tracks.find(x=>x.isLocal),[t.tracks]),o=y.useMemo(()=>t.tracks.filter(x=>!x.isLocal),[t.tracks]),r=y.useCallback(async()=>{try{s!=null&&s.isEnabled?await(e==null?void 0:e.disableCamera()):await(e==null?void 0:e.enableCamera())}catch(x){throw console.error("Failed to toggle camera:",x),x}},[e,s]),i=y.useCallback(async()=>{try{t.tracks.find(v=>v.isScreenShare)?await(e==null?void 0:e.stopScreenShare()):await(e==null?void 0:e.startScreenShare())}catch(x){throw console.error("Failed to toggle screen share:",x),x}},[e,t.tracks]),l=y.useCallback(x=>{n(v=>({...v,layout:x}))},[]),c=y.useCallback(x=>{n(v=>({...v,pinnedTrack:x}))},[]),d=y.useCallback(()=>{n(x=>({...x,pinnedTrack:void 0}))},[]),u=y.useCallback(async()=>{try{await(e==null?void 0:e.startRecording()),n(x=>({...x,isRecording:!0}))}catch(x){throw console.error("Failed to start recording:",x),x}},[e]),m=y.useCallback(async()=>{try{await(e==null?void 0:e.stopRecording()),n(x=>({...x,isRecording:!1}))}catch(x){throw console.error("Failed to stop recording:",x),x}},[e]),f=y.useCallback(x=>t.tracks.find(v=>v.id===x),[t.tracks]),p=y.useCallback(x=>t.tracks.filter(v=>v.participantId===x),[t.tracks]),g=y.useCallback(x=>x.isEnabled&&t.tracks.includes(x),[t.tracks]);return y.useEffect(()=>{if(!e)return;const x=b=>{n(S=>({...S,tracks:[...S.tracks.filter(w=>w.id!==b.id),b]}))},v=b=>{n(S=>{var w;return{...S,tracks:S.tracks.filter(C=>C.id!==b),pinnedTrack:((w=S.pinnedTrack)==null?void 0:w.id)===b?void 0:S.pinnedTrack}})},E=b=>{n(S=>({...S,tracks:S.tracks.map(w=>w.id===b.id?b:w)}))};return e.on("videoTrackAdded",x),e.on("videoTrackRemoved",v),e.on("videoTrackUpdated",E),()=>{e.off("videoTrackAdded",x),e.off("videoTrackRemoved",v),e.off("videoTrackUpdated",E)}},[e]),{tracks:t.tracks,localTrack:s,remoteTraracks:o,pinnedTrack:t.pinnedTrack,layout:t.layout,isRecording:t.isRecording,toggleCamera:r,toggleScreenShare:i,setLayout:l,pinTrack:c,unpinTrack:d,startRecording:u,stopRecording:m,getTrackById:f,getTracksByParticipant:p,isTrackActive:g}}function gn(){const{chatMessages:e,sendChatMessage:t,currentSession:n}=Ie(),[s,o]=y.useState(!1),r=y.useCallback(async d=>{if(!(!d.trim()||s||!n)){o(!0);try{await t(d.trim())}catch(u){throw console.error("Failed to send chat message:",u),u}finally{o(!1)}}},[t,s,n]),{userMessages:i,agentMessages:l,allMessages:c}=y.useMemo(()=>{const d=e.filter(m=>m.sender.type==="participant"),u=e.filter(m=>m.sender.type==="agent");return{userMessages:d,agentMessages:u,allMessages:e}},[e]);return{messages:c,userMessages:i,agentMessages:l,messageCount:c.length,isSending:s,canSend:!!n&&!s,send:r}}function i0(){const{send:e,isSending:t,canSend:n}=gn(),[s,o]=y.useState(""),r=y.useCallback(async()=>{if(!(!s.trim()||!n))try{await e(s),o("")}catch(l){throw l}},[s,e,n]),i=y.useCallback(l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),r())},[r]);return{value:s,setValue:o,send:r,handleKeyPress:i,isSending:t,canSend:n&&s.trim().length>0}}function to(){const{isConnected:e,isConnecting:t,connectionError:n,connect:s,disconnect:o}=Ie(),r=y.useCallback(async()=>{if(!(e||t))try{await s()}catch(l){throw console.error("Failed to connect:",l),l}},[s,e,t]),i=y.useCallback(async()=>{if(e)try{await o()}catch(l){throw console.error("Failed to disconnect:",l),l}},[o,e]);return{isConnected:e,isConnecting:t,isDisconnected:!e&&!t,error:n,hasError:!!n,connect:r,disconnect:i}}function Wa(){const{participants:e}=Ie();return{participants:e,count:e.length,localParticipant:e.find(t=>t.isLocal),remoteParticipants:e.filter(t=>!t.isLocal)}}const Ka=y.createContext({}),Ht=()=>y.useContext(Ka);function Ga({children:e,...t}){return a.jsx(Ka.Provider,{value:t,children:e})}function sn({name:e,children:t,fallback:n,className:s}){return a.jsx("div",{className:`voxket-slot voxket-slot--${e} ${s||""}`,children:t||n})}function Ya(e,t={}){return Object.assign(e,t)}function qa({showMicrophoneControl:e=!0,showCameraControl:t=!0,showScreenShareControl:n=!0,showSessionActions:s=!0,customControls:o,className:r=""}){const i=nt(),l=Za(),c=Ua(),d=za(),u=Ht(),m=["voxket-session-controls",`voxket-session-controls--${u.variant||"default"}`,`voxket-session-controls--${u.size||"md"}`,i.isActive?"voxket-session-controls--active":"voxket-session-controls--inactive",r].filter(Boolean).join(" ");return!i.isActive&&!s?a.jsx("div",{className:m,children:a.jsx("div",{className:"voxket-controls-inactive",children:a.jsx("p",{children:"Controls available during active session"})})}):a.jsxs("div",{className:m,children:[s&&a.jsx("div",{className:"voxket-session-actions",children:i.isActive?a.jsx("button",{onClick:i.stop,className:"voxket-button voxket-button--danger",children:"End Session"}):a.jsx(r0,{})}),i.isActive&&a.jsxs("div",{className:"voxket-media-controls",children:[e&&a.jsxs("button",{onClick:l.toggle,disabled:l.isLoading,className:`voxket-button voxket-button--media ${l.isEnabled?"voxket-button--active":""}`,title:l.isEnabled?"Mute microphone":"Unmute microphone",children:[a.jsx("span",{className:"voxket-icon",children:"🎤"}),l.isLoading?"Loading...":l.isEnabled?"Mute":"Unmute"]}),t&&a.jsxs("button",{onClick:c.toggle,disabled:c.isLoading,className:`voxket-button voxket-button--media ${c.isEnabled?"voxket-button--active":""}`,title:c.isEnabled?"Stop camera":"Start camera",children:[a.jsx("span",{className:"voxket-icon",children:"📹"}),c.isLoading?"Loading...":c.isEnabled?"Stop Video":"Start Video"]}),n&&a.jsxs("button",{onClick:d.toggle,disabled:d.isLoading,className:`voxket-button voxket-button--media ${d.isSharing?"voxket-button--active":""}`,title:d.isSharing?"Stop screen share":"Start screen share",children:[a.jsx("span",{className:"voxket-icon",children:"🖥️"}),d.isLoading?"Loading...":d.isSharing?"Stop Share":"Share Screen"]})]}),o&&a.jsx("div",{className:"voxket-custom-controls",children:o})]})}function r0(){nt();const[e,t]=y.useState(!1),n=async()=>{t(!0);try{console.log("Start session - agentId needed")}catch(s){console.error("Failed to start session:",s)}finally{t(!1)}};return a.jsx("button",{onClick:n,disabled:e,className:"voxket-button voxket-button--primary",children:e?"Starting...":"Start Session"})}function no({showConnectionStatus:e=!0,showSessionInfo:t=!0,showAgentInfo:n=!0,className:s=""}){const o=nt(),r=to(),i=Ht(),l=["voxket-session-header",`voxket-session-header--${i.variant||"default"}`,`voxket-session-header--${i.size||"md"}`,s].filter(Boolean).join(" ");return a.jsxs("div",{className:l,children:[e&&a.jsxs("div",{className:"voxket-connection-status",children:[a.jsx("div",{className:`voxket-status-indicator ${r.isConnected?"connected":"disconnected"}`}),a.jsx("span",{className:"voxket-status-text",children:r.isConnecting?"Connecting...":r.isConnected?"Connected":"Disconnected"})]}),t&&o.session&&a.jsxs("div",{className:"voxket-session-info",children:[a.jsxs("div",{className:"voxket-session-id",children:["Session: ",o.session.id.slice(-8)]}),a.jsxs("div",{className:"voxket-session-state",children:["State: ",o.state]})]}),n&&o.session&&a.jsxs("div",{className:"voxket-agent-info",children:[a.jsxs("div",{className:"voxket-agent-id",children:["Agent: ",o.session.agentId]}),a.jsxs("div",{className:"voxket-modalities",children:["Modalities: ",o.session.activeModalities.join(", ")]})]}),r.error&&a.jsxs("div",{className:"voxket-error-message",children:["Error: ",r.error.message]})]})}function so({showChat:e=!0,showTranscriptions:t=!1,customContent:n,className:s=""}){const o=nt(),r=gn(),i=Ht(),l=["voxket-session-content",`voxket-session-content--${i.variant||"default"}`,`voxket-session-content--${i.size||"md"}`,s].filter(Boolean).join(" ");return o.isActive?a.jsx("div",{className:l,children:n||a.jsxs(a.Fragment,{children:[e&&a.jsxs("div",{className:"voxket-chat-container",children:[a.jsxs("div",{className:"voxket-chat-messages",children:[r.messages.map(c=>a.jsxs("div",{className:`voxket-message voxket-message--${c.sender.type}`,children:[a.jsxs("div",{className:"voxket-message-header",children:[a.jsx("span",{className:"voxket-message-sender",children:c.sender.name}),a.jsx("span",{className:"voxket-message-time",children:c.timestamp.toLocaleTimeString()})]}),a.jsx("div",{className:"voxket-message-content",children:c.content})]},c.id)),r.messages.length===0&&a.jsx("div",{className:"voxket-empty-messages",children:a.jsx("p",{children:"No messages yet. Start the conversation!"})})]}),a.jsx(a0,{})]}),t&&a.jsx("div",{className:"voxket-transcriptions",children:a.jsx("div",{className:"voxket-transcription-placeholder",children:a.jsx("p",{children:"Voice transcriptions will appear here"})})})]})}):a.jsx("div",{className:l,children:a.jsx("div",{className:"voxket-inactive-state",children:a.jsxs("div",{className:"voxket-inactive-message",children:[a.jsx("h3",{children:"Start a conversation"}),a.jsx("p",{children:"Begin a session to start chatting with the AI agent"})]})})})}function a0(){const e=gn(),[t,n]=y.useState(""),s=async()=>{if(!(!t.trim()||!e.canSend))try{await e.send(t),n("")}catch(r){console.error("Failed to send message:",r)}},o=r=>{r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),s())};return a.jsxs("div",{className:"voxket-chat-input",children:[a.jsx("input",{type:"text",value:t,onChange:r=>n(r.target.value),onKeyPress:o,placeholder:"Type your message...",disabled:!e.canSend,className:"voxket-input"}),a.jsx("button",{onClick:s,disabled:!e.canSend||!t.trim(),className:"voxket-send-button",children:e.isSending?"Sending...":"Send"})]})}function oo({showMetrics:e=!0,showParticipants:t=!0,showStatus:n=!0,customFooter:s,className:o=""}){const r=nt(),i=Ha(),l=Wa(),c=Ht(),d=["voxket-session-footer",`voxket-session-footer--${c.variant||"default"}`,`voxket-session-footer--${c.size||"md"}`,o].filter(Boolean).join(" ");return r.isActive?a.jsx("div",{className:d,children:s||a.jsxs(a.Fragment,{children:[n&&a.jsxs("div",{className:"voxket-session-status",children:[a.jsx("div",{className:"voxket-status-indicator voxket-status-indicator--active"}),a.jsx("span",{className:"voxket-status-text",children:"Session Active"})]}),e&&i.metrics&&a.jsxs("div",{className:"voxket-session-metrics",children:[a.jsxs("div",{className:"voxket-metric",children:[a.jsx("span",{className:"voxket-metric-label",children:"Duration:"}),a.jsx("span",{className:"voxket-metric-value",children:l0(i.duration||0)})]}),a.jsxs("div",{className:"voxket-metric",children:[a.jsx("span",{className:"voxket-metric-label",children:"Messages:"}),a.jsx("span",{className:"voxket-metric-value",children:i.metrics.messageCount})]})]}),t&&a.jsxs("div",{className:"voxket-participants-info",children:[a.jsxs("span",{className:"voxket-participants-count",children:[l.count," participant",l.count!==1?"s":""]}),l.remoteParticipants.length>0&&a.jsx("div",{className:"voxket-participant-list",children:l.remoteParticipants.map(u=>a.jsx("span",{className:"voxket-participant-name",children:u.name},u.id))})]})]})}):a.jsx("div",{className:d,children:a.jsx("div",{className:"voxket-footer-inactive",children:a.jsx("span",{className:"voxket-status-text",children:"Ready to start session"})})})}function l0(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),s=Math.floor(n/60);return s>0?`${s}:${(n%60).toString().padStart(2,"0")}:${(t%60).toString().padStart(2,"0")}`:`${n}:${(t%60).toString().padStart(2,"0")}`}function c0({agentId:e,sessionConfig:t,autoStart:n=!1,onSessionStart:s,onSessionEnd:o,variant:r="default",size:i="md",theme:l,className:c="",children:d}){var p;const u=nt(),m=to();y.useEffect(()=>{n&&e&&m.isConnected&&!u.isActive&&u.start(e,t).catch(console.error)},[n,e,m.isConnected,u.isActive]),y.useEffect(()=>{var g;(g=u.session)!=null&&g.id&&s&&s(u.session.id)},[(p=u.session)==null?void 0:p.id,s]),y.useEffect(()=>()=>{u.isActive&&o&&u.stop().then(o).catch(console.error)},[]);const f=["voxket-session",`voxket-session--${r}`,`voxket-session--${i}`,u.isActive?"voxket-session--active":"voxket-session--inactive",c].filter(Boolean).join(" ");return a.jsx(Ga,{variant:r,size:i,theme:l,className:c,children:a.jsx("div",{className:f,children:d||a.jsxs(a.Fragment,{children:[a.jsx(sn,{name:"header",fallback:a.jsx(no,{})}),a.jsx(sn,{name:"content",fallback:a.jsx(so,{})}),a.jsx(sn,{name:"footer",fallback:a.jsx(oo,{})})]})})})}const Xa=Ya(c0,{Header:no,Content:so,Footer:oo,Controls:qa}),tt={name:"default",colors:{primary:"#3B82F6",secondary:"#6B7280",accent:"#8B5CF6",background:"#FFFFFF",surface:"#F9FAFB",text:{primary:"#111827",secondary:"#6B7280",muted:"#9CA3AF",inverse:"#FFFFFF"},status:{success:"#10B981",warning:"#F59E0B",error:"#EF4444",info:"#3B82F6"},border:"#E5E7EB",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1)"},typography:{fontFamily:"system-ui, -apple-system, sans-serif",fontSize:{xs:"0.75rem",sm:"0.875rem",md:"1rem",lg:"1.125rem",xl:"1.25rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700},lineHeight:{tight:1.25,normal:1.5,relaxed:1.75}},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},borderRadius:{none:"0",sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1)"}},ms={...tt,name:"dark",colors:{primary:"#60A5FA",secondary:"#9CA3AF",accent:"#A78BFA",background:"#111827",surface:"#1F2937",text:{primary:"#F9FAFB",secondary:"#D1D5DB",muted:"#9CA3AF",inverse:"#111827"},status:{success:"#34D399",warning:"#FBBF24",error:"#F87171",info:"#60A5FA"},border:"#374151",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.3)"}},fs={...tt,name:"enterprise",colors:{primary:"#1E40AF",secondary:"#64748B",accent:"#7C3AED",background:"#FFFFFF",surface:"#F8FAFC",text:{primary:"#0F172A",secondary:"#475569",muted:"#94A3B8",inverse:"#FFFFFF"},status:{success:"#059669",warning:"#D97706",error:"#DC2626",info:"#1E40AF"},border:"#CBD5E1",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1)"},borderRadius:{none:"0",sm:"0.125rem",md:"0.25rem",lg:"0.375rem",full:"9999px"}},Ja=y.createContext(null),Qa=()=>{const e=y.useContext(Ja);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e};function d0({theme:e="default",themes:t={},children:n,cssVariables:s=!0,className:o=""}){const[r,i]=y.useState(()=>{const f={default:tt,dark:ms,enterprise:fs,...t};return typeof e=="string"?f[e]||tt:e}),[l,c]=y.useState(()=>({default:tt,dark:ms,enterprise:fs,...t})),d=f=>{if(typeof f=="string"){const p=l[f];p&&i(p)}else i(f)},u=f=>{c(p=>({...p,[f.name]:f}))};y.useEffect(()=>{if(s&&typeof document<"u"){const f=document.documentElement;Object.entries(el(r)).forEach(([p,g])=>{f.style.setProperty(`--voxket-${p}`,g)})}},[r,s]);const m={theme:r,setTheme:d,themes:l,registerTheme:u};return a.jsx(Ja.Provider,{value:m,children:a.jsx("div",{className:`voxket-theme voxket-theme--${r.name} ${o}`,children:n})})}function el(e){const t={},n=(s,o="")=>{for(const[r,i]of Object.entries(s)){const l=o?`${o}-${r}`:r;typeof i=="object"&&i!==null&&!Array.isArray(i)?n(i,l):t[l]=String(i)}};return n(e),t}function u0(e=tt,t){return{...e,...t,colors:{...e.colors,...t.colors},typography:{...e.typography,...t.typography},spacing:{...e.spacing,...t.spacing},borderRadius:{...e.borderRadius,...t.borderRadius},shadows:{...e.shadows,...t.shadows}}}function h0(e){var n;const{theme:t}=Qa();return((n=t.components)==null?void 0:n[e])||{}}const m0=eo("voice-modality","voice",{onActivate:async e=>{const t=e.config;t.enableTranscription&&f0(e),t.enableVoiceActivation&&p0(e,t),console.log("Voice modality activated",t)},onDeactivate:async e=>{console.log("Voice modality deactivated")},onMessage:async(e,t)=>{t.type==="audio"&&g0(e,t)}});function f0(e,t){e.on("participant.speaking.started",n=>{console.log("Transcription: Started for",n.name)}),e.on("participant.speaking.stopped",n=>{console.log("Transcription: Stopped for",n.name)})}function p0(e,t){const n=t.silenceThreshold||-50;console.log("Voice activation setup with threshold:",n)}function g0(e,t){console.log("Playing audio response:",t.content)}const x0=eo("chat-modality","chat",{onActivate:async e=>{const t=e.config;t.enableRichText&&y0(),t.enableFileUpload&&b0(e),t.enableCustomComponents&&v0(),console.log("Chat modality activated",t)},onDeactivate:async e=>{console.log("Chat modality deactivated")},onMessage:async(e,t)=>{const n=e.config;t.type==="ui_component"?w0(e,t):t.type==="text"&&n.enableRichText&&S0(e,t)}});function y0(e){console.log("Rich text support enabled")}function b0(e){console.log("File upload enabled"),e.on("chat.file.uploaded",t=>{console.log("File uploaded:",t.name)})}function v0(e){console.log("Custom components enabled");const t=new Map;t.set("quick-actions",C0),t.set("form",k0),t.set("card",j0),t.set("chart",E0)}function w0(e,t){const{componentType:n,props:s}=t.metadata;console.log("Rendering custom component:",n,s),e.emit("chat.component.render",{type:n,props:s,timestamp:new Date})}function S0(e,t){console.log("Processing rich text message:",t.content)}function C0(e){return{type:"quick-actions",actions:e.actions||[],layout:e.layout||"horizontal"}}function k0(e){return{type:"form",fields:e.fields||[],submitAction:e.submitAction,validation:e.validation}}function j0(e){return{type:"card",title:e.title,content:e.content,actions:e.actions,variant:e.variant||"default"}}function E0(e){return{type:"chart",chartType:e.chartType||"line",data:e.data,options:e.options}}function on({track:e,participantName:t,showControls:n=!0,showName:s=!0,showMuteIndicator:o=!0,isPinned:r=!1,className:i="",onClick:l,onPin:c,onUnpin:d}){const u=y.useRef(null),[m,f]=y.useState(!1);y.useEffect(()=>{if(!u.current||!e.isEnabled)return;const v=u.current;return v.srcObject=null,()=>{v.srcObject&&(v.srcObject=null)}},[e]);const p=()=>{l==null||l(e)},g=v=>{v.stopPropagation(),r?d==null||d(e):c==null||c(e)},x=["voxket-video-tile",e.isLocal?"voxket-video-tile--local":"voxket-video-tile--remote",e.isScreenShare?"voxket-video-tile--screen-share":"voxket-video-tile--camera",r?"voxket-video-tile--pinned":"",e.isEnabled?"":"voxket-video-tile--disabled",m?"voxket-video-tile--hovered":"",i].filter(Boolean).join(" ");return a.jsxs("div",{className:x,onClick:p,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),style:{aspectRatio:e.dimensions?`${e.dimensions.width} / ${e.dimensions.height}`:"16 / 9"},children:[a.jsx("video",{ref:u,className:"voxket-video-element",autoPlay:!0,playsInline:!0,muted:e.isLocal}),!e.isEnabled&&a.jsxs("div",{className:"voxket-video-placeholder",children:[a.jsx("div",{className:"voxket-video-placeholder-icon",children:e.isScreenShare?"🖥️":"📹"}),a.jsx("p",{className:"voxket-video-placeholder-text",children:e.isScreenShare?"Screen sharing paused":"Camera off"})]}),a.jsxs("div",{className:"voxket-video-overlay",children:[s&&t&&a.jsxs("div",{className:"voxket-video-name",children:[t,e.isLocal&&" (You)"]}),o&&!e.isEnabled&&a.jsx("div",{className:"voxket-video-mute-indicator",children:"🔇"}),n&&(m||r)&&a.jsxs("div",{className:"voxket-video-controls",children:[a.jsx("button",{className:`voxket-video-control-btn ${r?"voxket-video-control-btn--active":""}`,onClick:g,title:r?"Unpin video":"Pin video",children:"📌"}),e.isScreenShare&&a.jsx("div",{className:"voxket-video-indicator",children:"🖥️"}),e.source&&a.jsx("div",{className:"voxket-video-source",children:e.source})]})]}),!e.isEnabled&&a.jsx("div",{className:"voxket-video-loading",children:a.jsx("div",{className:"voxket-spinner"})})]})}function A0({tracks:e,layout:t,className:n="",onLayoutChange:s,onTrackClick:o,maxVisibleTracks:r=9,showPagination:i=!0}){const[l,c]=y.useState(0),[d,u]=y.useState(null),m=y.useMemo(()=>{let b=[...e];t.type==="speaker"&&d&&(b=[d,...e.filter(C=>C.id!==d.id)]);const S=l*r,w=S+r;return b.slice(S,w)},[e,t,d,l,r]),f=Math.ceil(e.length/r),p=y.useMemo(()=>{const b=m.length;switch(t.type){case"grid":const S=Math.ceil(Math.sqrt(b)),w=Math.ceil(b/S);return{display:"grid",gridTemplateColumns:`repeat(${S}, 1fr)`,gridTemplateRows:`repeat(${w}, 1fr)`,gap:"8px"};case"speaker":return{display:"flex",flexDirection:"column",gap:"8px"};case"sidebar":return{display:"flex",gap:"8px"};case"gallery":return{display:"flex",flexWrap:"wrap",gap:"8px",justifyContent:"center"};default:return{}}},[t.type,m.length]),g=b=>{u(b)},x=()=>{u(null)},v=b=>{s==null||s({...t,type:b})},E=["voxket-video-grid",`voxket-video-grid--${t.type}`,`voxket-video-grid--${m.length}-tracks`,n].filter(Boolean).join(" ");return e.length===0?a.jsx("div",{className:"voxket-video-grid-empty",children:a.jsxs("div",{className:"voxket-video-grid-empty-content",children:[a.jsx("div",{className:"voxket-video-grid-empty-icon",children:"📹"}),a.jsx("p",{children:"No video tracks available"})]})}):a.jsxs("div",{className:E,children:[a.jsxs("div",{className:"voxket-video-grid-controls",children:[a.jsx("div",{className:"voxket-video-layout-controls",children:["grid","speaker","sidebar","gallery"].map(b=>a.jsx("button",{className:`voxket-layout-btn ${t.type===b?"voxket-layout-btn--active":""}`,onClick:()=>v(b),title:`Switch to ${b} layout`,children:M0(b)},b))}),a.jsxs("div",{className:"voxket-video-count",children:[e.length," participant",e.length!==1?"s":""]})]}),a.jsx("div",{className:"voxket-video-grid-content",style:p,children:t.type==="speaker"&&d?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"voxket-video-speaker-main",children:a.jsx(on,{track:d,participantName:`Participant ${d.participantId}`,isPinned:!0,onClick:o,onUnpin:x})}),a.jsx("div",{className:"voxket-video-speaker-sidebar",children:m.filter(b=>b.id!==d.id).map(b=>a.jsx(on,{track:b,participantName:`Participant ${b.participantId}`,showControls:!1,onClick:o,onPin:g},b.id))})]}):m.map(b=>a.jsx(on,{track:b,participantName:`Participant ${b.participantId}`,isPinned:(d==null?void 0:d.id)===b.id,onClick:o,onPin:g,onUnpin:x},b.id))}),i&&f>1&&a.jsxs("div",{className:"voxket-video-pagination",children:[a.jsx("button",{className:"voxket-pagination-btn",onClick:()=>c(Math.max(0,l-1)),disabled:l===0,children:"←"}),a.jsxs("span",{className:"voxket-pagination-info",children:["Page ",l+1," of ",f]}),a.jsx("button",{className:"voxket-pagination-btn",onClick:()=>c(Math.min(f-1,l+1)),disabled:l===f-1,children:"→"})]})]})}function M0(e){switch(e){case"grid":return"⊞";case"speaker":return"🎤";case"sidebar":return"⫸";case"gallery":return"⊡";case"picture-in-picture":return"⧉";default:return"⊞"}}function T0({localTrack:e,onToggleCamera:t,onToggleScreenShare:n,onLayoutChange:s,showLayoutControls:o=!0,showCameraControls:r=!0,showScreenShareControls:i=!0,className:l=""}){const c=["voxket-video-controls",l].filter(Boolean).join(" "),d=u=>{s==null||s({type:u,showLocalVideo:!0,aspectRatio:"16:9"})};return a.jsxs("div",{className:c,children:[r&&a.jsxs("div",{className:"voxket-video-controls-section",children:[a.jsx("h4",{className:"voxket-video-controls-title",children:"Camera"}),a.jsxs("button",{className:`voxket-control-btn ${e!=null&&e.isEnabled?"voxket-control-btn--active":""}`,onClick:t,title:e!=null&&e.isEnabled?"Turn off camera":"Turn on camera",children:[a.jsx("span",{className:"voxket-control-icon",children:e!=null&&e.isEnabled?"📹":"📷"}),a.jsx("span",{className:"voxket-control-label",children:e!=null&&e.isEnabled?"Camera On":"Camera Off"})]}),(e==null?void 0:e.dimensions)&&a.jsxs("div",{className:"voxket-video-info",children:[e.dimensions.width," × ",e.dimensions.height]})]}),i&&a.jsxs("div",{className:"voxket-video-controls-section",children:[a.jsx("h4",{className:"voxket-video-controls-title",children:"Screen Share"}),a.jsxs("button",{className:`voxket-control-btn ${e!=null&&e.isScreenShare?"voxket-control-btn--active":""}`,onClick:n,title:e!=null&&e.isScreenShare?"Stop screen sharing":"Start screen sharing",children:[a.jsx("span",{className:"voxket-control-icon",children:e!=null&&e.isScreenShare?"🛑":"🖥️"}),a.jsx("span",{className:"voxket-control-label",children:e!=null&&e.isScreenShare?"Stop Sharing":"Share Screen"})]})]}),o&&a.jsxs("div",{className:"voxket-video-controls-section",children:[a.jsx("h4",{className:"voxket-video-controls-title",children:"Layout"}),a.jsx("div",{className:"voxket-layout-buttons",children:[{type:"grid",icon:"⊞",label:"Grid"},{type:"speaker",icon:"🎤",label:"Speaker"},{type:"sidebar",icon:"⫸",label:"Sidebar"},{type:"gallery",icon:"⊡",label:"Gallery"}].map(({type:u,icon:m,label:f})=>a.jsxs("button",{className:"voxket-layout-control-btn",onClick:()=>d(u),title:`Switch to ${f} layout`,children:[a.jsx("span",{className:"voxket-control-icon",children:m}),a.jsx("span",{className:"voxket-control-label",children:f})]},u))})]}),a.jsxs("div",{className:"voxket-video-controls-section",children:[a.jsx("h4",{className:"voxket-video-controls-title",children:"Video Settings"}),a.jsxs("div",{className:"voxket-video-settings",children:[a.jsxs("div",{className:"voxket-setting-group",children:[a.jsx("label",{className:"voxket-setting-label",children:"Quality"}),a.jsxs("select",{className:"voxket-setting-select",children:[a.jsx("option",{value:"high",children:"High (720p)"}),a.jsx("option",{value:"medium",children:"Medium (480p)"}),a.jsx("option",{value:"low",children:"Low (240p)"})]})]}),a.jsxs("div",{className:"voxket-setting-group",children:[a.jsx("label",{className:"voxket-setting-label",children:"Frame Rate"}),a.jsxs("select",{className:"voxket-setting-select",children:[a.jsx("option",{value:"30",children:"30 fps"}),a.jsx("option",{value:"15",children:"15 fps"}),a.jsx("option",{value:"10",children:"10 fps"})]})]}),a.jsxs("div",{className:"voxket-setting-group",children:[a.jsx("label",{className:"voxket-setting-label",children:"Bandwidth"}),a.jsxs("select",{className:"voxket-setting-select",children:[a.jsx("option",{value:"unlimited",children:"Unlimited"}),a.jsx("option",{value:"1000",children:"1 Mbps"}),a.jsx("option",{value:"500",children:"500 Kbps"}),a.jsx("option",{value:"250",children:"250 Kbps"})]})]})]})]}),a.jsxs("div",{className:"voxket-video-controls-section",children:[a.jsx("h4",{className:"voxket-video-controls-title",children:"Statistics"}),a.jsxs("div",{className:"voxket-video-stats",children:[a.jsxs("div",{className:"voxket-stat-item",children:[a.jsx("span",{className:"voxket-stat-label",children:"Resolution:"}),a.jsx("span",{className:"voxket-stat-value",children:e!=null&&e.dimensions?`${e.dimensions.width}×${e.dimensions.height}`:"N/A"})]}),a.jsxs("div",{className:"voxket-stat-item",children:[a.jsx("span",{className:"voxket-stat-label",children:"Source:"}),a.jsx("span",{className:"voxket-stat-value",children:(e==null?void 0:e.source)||"None"})]}),a.jsxs("div",{className:"voxket-stat-item",children:[a.jsx("span",{className:"voxket-stat-label",children:"Status:"}),a.jsx("span",{className:`voxket-stat-value ${e!=null&&e.isEnabled?"voxket-stat-value--active":"voxket-stat-value--inactive"}`,children:e!=null&&e.isEnabled?"Active":"Inactive"})]})]})]})]})}const tl=({handler:e,loadData:t,data:n,client:s,addLocalMessage:o})=>{const[r,i]=h.useState(null),[l,c]=h.useState(!0),[d,u]=h.useState(!1),[m]=h.useState(Date.now());h.useEffect(()=>{(async()=>{try{if(c(!0),console.log("📋 AssignmentView: Loading assignment data..."),console.log("📋 AssignmentView: Received data from RPC:",n),n&&typeof n=="object"){const v={title:n.title||"Untitled Assignment",description:n.description||"No description provided",estimated_time_of_completion:n.estimated_time_of_completion||"Unknown"};i(v),console.log("📋 AssignmentView: Assignment loaded from RPC data:",v)}}catch(v){console.error("📋 AssignmentView: Error loading assignment:",v),i({title:"Assignment Loading Error",description:"There was an error loading the assignment details. Please try again.",estimated_time_of_completion:"Unknown"})}finally{c(!1)}})()},[n,t]);const f=({message:x,assignment:v})=>{const E=x.toLowerCase().includes("declined"),b=E?"bg-red-50 border-red-200":"bg-green-50 border-green-200",S=E?"text-red-700":"text-green-700",w=E?"❌":"🎉";return a.jsxs("div",{className:`max-w-sm mx-auto ${b} border rounded-lg shadow p-3 flex flex-col items-center`,children:[a.jsx("div",{className:"text-2xl mb-2",children:w}),a.jsx("div",{className:`${S} font-semibold text-sm mb-1`,children:x}),a.jsx("div",{className:"text-xs text-gray-600 text-center mb-1",children:v.title}),a.jsx("div",{className:"text-xs text-gray-500",children:"Thank you for your response!"})]})},p=async()=>{if(!(!r||!e)){u(!0);try{const x={message:"accepted"};console.log("📋 AssignmentView: Assignment accepted:",x),e.didSuccess(x,a.jsx(f,{message:"Assignment accepted!",assignment:r}))}catch(x){console.error("📋 AssignmentView: Error accepting assignment:",x),e.didFail({error:"Failed to accept assignment"})}finally{u(!1)}}},g=async()=>{if(!(!r||!e)){u(!0);try{const x={message:"declined"};console.log("📋 AssignmentView: Assignment declined:",x),e.didSuccess(x,a.jsx(f,{message:"Assignment declined",assignment:r}))}catch(x){console.error("📋 AssignmentView: Error declining assignment:",x),e.didFail({error:"Failed to decline assignment"})}finally{u(!1)}}};return l?a.jsx("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg p-3",children:a.jsxs("div",{className:"flex items-center justify-center py-4",children:[a.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}),a.jsx("span",{className:"ml-2 text-xs text-gray-600",children:"Loading assignment..."})]})}):r?a.jsxs("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg overflow-hidden",children:[a.jsx("div",{className:"bg-gradient-to-r from-blue-600 to-purple-600 text-white p-3",children:a.jsx("div",{className:"flex items-center justify-between",children:a.jsx("h3",{className:"text-xs font-semibold text-white truncate",children:r.title})})}),a.jsxs("div",{className:"p-3",children:[a.jsx("div",{className:"bg-gray-50 rounded p-2 mb-3",children:a.jsx("p",{className:"text-xs text-gray-700 leading-snug",children:r.description})}),a.jsx("div",{className:"mb-3",children:a.jsxs("div",{className:"flex items-center text-xs text-gray-600",children:[a.jsx("span",{className:"text-xs mr-1",children:"📅"}),a.jsxs("span",{children:["Est: ",r.estimated_time_of_completion]})]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:p,disabled:d,className:"flex-1 bg-green-600 text-white py-2 px-3 rounded text-xs font-medium hover:bg-green-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:d?a.jsxs("span",{className:"flex items-center justify-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-2 w-2 border-b-2 border-white mr-1"}),a.jsx("span",{className:"text-xs",children:"Processing..."})]}):"Accept"}),a.jsx("button",{onClick:g,disabled:d,className:"flex-1 bg-red-600 text-white py-2 px-3 rounded text-xs font-medium hover:bg-red-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Decline"})]})]})]}):a.jsx("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg p-3",children:a.jsxs("div",{className:"text-center py-4",children:[a.jsx("div",{className:"text-red-600 text-sm font-semibold mb-2",children:"⚠️ Assignment Error"}),a.jsx("p",{className:"text-xs text-gray-600 mb-3",children:"Failed to load assignment details."})]})})};function V0(){const[e,t]=h.useState(null),[n,s]=h.useState([]);h.useEffect(()=>{const l=new _t({appId:"your-app-id",appSecret:"your-app-secret",baseUrl:"https://your-voxket-api.com",agentId:"your-agent-id",participantName:"User",modalities:["chat"]});return t(l),l.on("rpc.method.called",c=>{console.log("RPC Method Called:",c)}),l.on("rpc.interaction.completed",c=>{console.log("RPC Interaction Completed:",c)}),()=>{l.disconnect()}},[]);const o=async()=>{if(e)try{await e.registerFrontendRPC("give_assignment",tl,"embedded");const l=e.getRegisteredRpcMethods();s(l),console.log("✅ Assignment RPC registered successfully")}catch(l){console.error("❌ Failed to register assignment RPC:",l)}},r=async()=>{if(!e)return;const l=({handler:c,timeout:d})=>{const[u,m]=h.useState(""),f=[{id:"pro",name:"Pro Plan",price:"$29/month"},{id:"enterprise",name:"Enterprise Plan",price:"$99/month"},{id:"basic",name:"Basic Plan",price:"$9/month"}],p=x=>{m(x)},g=()=>{const x=f.find(v=>v.id===u);c==null||c.didSuccess({selectedProduct:u,productName:x==null?void 0:x.name,price:x==null?void 0:x.price,timestamp:new Date().toISOString()})};return a.jsxs("div",{className:"p-6 bg-white rounded-lg",children:[a.jsx("h3",{className:"text-xl font-bold mb-4",children:"Choose Your Plan"}),a.jsx("p",{className:"text-gray-600 mb-4",children:"Select the plan that best fits your needs:"}),a.jsx("div",{className:"space-y-3 mb-6",children:f.map(x=>a.jsx("div",{onClick:()=>p(x.id),className:`p-4 border rounded-lg cursor-pointer transition-all ${u===x.id?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300"}`,children:a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"font-medium",children:x.name}),a.jsx("p",{className:"text-gray-600 text-sm",children:x.price})]}),a.jsx("div",{className:`w-4 h-4 rounded-full ${u===x.id?"bg-blue-500":"border-2 border-gray-300"}`})]})},x.id))}),a.jsxs("div",{className:"flex justify-end space-x-3",children:[a.jsx("button",{onClick:()=>c==null?void 0:c.dismissView(),className:"px-4 py-2 border border-gray-300 text-gray-700 rounded hover:bg-gray-50",children:"Cancel"}),a.jsx("button",{onClick:g,disabled:!u,className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",children:"Select Plan"})]}),d&&a.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:["Time remaining: ",d," seconds"]})]})};try{await e.registerFrontendRPC("recommend_product",l,"modal");const c=e.getRegisteredRpcMethods();s(c),console.log("✅ Product Recommendation RPC registered successfully")}catch(c){console.error("❌ Failed to register product recommendation RPC:",c)}},i=async()=>{if(!e)return;const l=({handler:c})=>{const[d,u]=h.useState(0),[m,f]=h.useState(""),p=()=>{c==null||c.didSuccess({rating:d,comment:m,timestamp:new Date().toISOString()})};return a.jsxs("div",{className:"p-4 bg-white rounded-lg",children:[a.jsx("h3",{className:"text-lg font-semibold mb-3",children:"How was your experience?"}),a.jsxs("div",{className:"mb-4",children:[a.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Rate your experience:"}),a.jsx("div",{className:"flex space-x-1",children:[1,2,3,4,5].map(g=>a.jsx("button",{onClick:()=>u(g),className:`text-2xl ${g<=d?"text-yellow-400":"text-gray-300"}`,children:"⭐"},g))})]}),a.jsxs("div",{className:"mb-4",children:[a.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Additional comments:"}),a.jsx("textarea",{value:m,onChange:g=>f(g.target.value),className:"w-full p-2 border border-gray-300 rounded text-sm",rows:3,placeholder:"Tell us more about your experience..."})]}),a.jsxs("div",{className:"flex justify-end space-x-2",children:[a.jsx("button",{onClick:()=>c==null?void 0:c.dismissView(),className:"px-3 py-1 text-sm border border-gray-300 text-gray-700 rounded hover:bg-gray-50",children:"Skip"}),a.jsx("button",{onClick:p,disabled:d===0,className:"px-3 py-1 text-sm bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",children:"Submit"})]})]})};try{await e.registerFrontendRPC("collect_feedback",l,"embedded");const c=e.getRegisteredRpcMethods();s(c),console.log("✅ Feedback RPC registered successfully")}catch(c){console.error("❌ Failed to register feedback RPC:",c)}};return a.jsxs("div",{className:"p-6",children:[a.jsx("h2",{className:"text-2xl font-bold mb-6",children:"Frontend RPC Examples"}),a.jsxs("div",{className:"space-y-4 mb-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Register RPC Methods"}),a.jsxs("div",{className:"space-x-2",children:[a.jsx("button",{onClick:o,className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600",children:"Register Assignment RPC"}),a.jsx("button",{onClick:r,className:"px-4 py-2 bg-green-500 text-white rounded hover:bg-green-600",children:"Register Product Recommendation RPC"}),a.jsx("button",{onClick:i,className:"px-4 py-2 bg-purple-500 text-white rounded hover:bg-purple-600",children:"Register Feedback RPC"})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Registered Methods"}),n.length>0?a.jsx("ul",{className:"list-disc list-inside space-y-1",children:n.map(l=>a.jsx("li",{className:"text-gray-700",children:a.jsx("code",{className:"bg-gray-100 px-2 py-1 rounded",children:l})},l))}):a.jsx("p",{className:"text-gray-500",children:"No methods registered yet"})]})]}),a.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg",children:[a.jsx("h3",{className:"text-lg font-semibold mb-2",children:"How it works"}),a.jsxs("ol",{className:"list-decimal list-inside space-y-2 text-sm text-gray-700",children:[a.jsxs("li",{children:["Register RPC methods with React components using ",a.jsx("code",{children:"client.registerFrontendRPC()"})]}),a.jsx("li",{children:"When the agent calls an RPC method, the corresponding component will be displayed"}),a.jsx("li",{children:"Users interact with the component, and the response is sent back to the agent"}),a.jsx("li",{children:"Components can be displayed in different modes: embedded, modal, or fullscreen"}),a.jsx("li",{children:"Each component has a timeout and can handle success/failure scenarios"})]})]}),a.jsxs("div",{className:"mt-6 bg-blue-50 p-4 rounded-lg",children:[a.jsx("h3",{className:"text-lg font-semibold mb-2 text-blue-800",children:"Agent Side"}),a.jsx("p",{className:"text-sm text-blue-700 mb-2",children:"On the agent side, you can call these RPC methods like this:"}),a.jsx("pre",{className:"bg-white p-3 rounded text-xs text-gray-800 overflow-x-auto",children:`// Agent calls RPC method
|
|
319
33
|
const response = await participant.performRpc({
|
|
320
34
|
method: 'give_assignment',
|
|
321
35
|
data: JSON.stringify({
|
|
@@ -326,4 +40,4 @@ const response = await participant.performRpc({
|
|
|
326
40
|
})
|
|
327
41
|
});
|
|
328
42
|
|
|
329
|
-
console.log('User response:', response);`})]})]})}const
|
|
43
|
+
console.log('User response:', response);`})]})]})}const N0={async checkAvailableRpcs(e){const t=e.getRegisteredRpcMethods();return console.log("🔍 Agent: Available RPC methods:",t),t},async triggerAssignment(e,t){const n={title:"Complete Q4 Sales Analysis Report",description:"Please analyze the Q4 sales data and create a comprehensive report with insights, trends, and recommendations for the upcoming quarter. Include visualizations and executive summary.",estimated_time_of_completion:"2-3 hours"};try{console.log("🤖 Agent: Triggering give_assignment RPC with data:",n);const s=await e.localParticipant.performRpc(t,"give_assignment",JSON.stringify(n),{responseTimeout:12e4}),o=JSON.parse(s);return console.log("✅ Agent: Received user response:",o),await this.processAssignmentResponse(o),o}catch(s){throw console.error("❌ Agent: RPC failed:",s),s}},async processAssignmentResponse(e){console.log("🧠 Agent: Processing assignment response...");const t=e.status,n=e.assignmentId,s=e.timeSpent;return t==="accepted"?(console.log("🎉 Agent: User accepted the assignment!"),console.log(`� Assignment ID: ${n}`),console.log(`⏱️ Time to respond: ${s}ms`),console.log("💬 Agent: Sending follow-up:","Great! I've recorded that you've accepted the assignment. You'll receive the detailed requirements and access to the data shortly. Let me know if you need any clarification!")):t==="declined"?(console.log("❌ Agent: User declined the assignment"),console.log("💬 Agent: Sending follow-up:","No problem! Is there anything specific about this assignment that doesn't work for you? I can suggest alternatives or modify the requirements.")):t==="completed"&&(console.log("✅ Agent: User completed the assignment"),console.log("💬 Agent: Sending follow-up:","Excellent work! Could you please share the completed report? I'm excited to review your analysis and insights.")),{status:t,assignmentId:n,timeSpent:s,processed:!0,followupAction:t==="accepted"?"send_requirements":t==="declined"?"offer_alternatives":"request_deliverables"}},getAssignmentExamples(){return{marketing:{title:"Create Social Media Campaign",description:"Design and plan a social media campaign for our new product launch. Include content calendar, post designs, and engagement strategy.",estimated_time_of_completion:"4-5 hours"},technical:{title:"API Integration Documentation",description:"Create comprehensive documentation for our new API endpoints, including examples, error codes, and best practices for developers.",estimated_time_of_completion:"6-8 hours"},research:{title:"Market Research Analysis",description:"Research and analyze competitor pricing strategies in our target market. Provide recommendations for our pricing model.",estimated_time_of_completion:"3-4 hours"},quick:{title:"Customer Feedback Summary",description:"Review this week's customer feedback and create a summary of key themes and actionable insights.",estimated_time_of_completion:"30-45 minutes"}}}},P0=e=>typeof window>"u"?null:h.createElement(_a,{children:h.createElement(Oa,e)});exports.AssignmentView=tl;exports.CompoundProvider=Ga;exports.InteractiveComponent=pt;exports.PluginManager=La;exports.RpcExamples=V0;exports.SessionContainer=Xa;exports.SessionContent=so;exports.SessionControls=qa;exports.SessionFooter=oo;exports.SessionHeader=no;exports.SessionLogViewer=n0;exports.SessionMetricsComponent=s0;exports.Slot=sn;exports.ThemeProvider=d0;exports.VideoControls=T0;exports.VideoGrid=A0;exports.VideoTile=on;exports.VoxketClient=_t;exports.VoxketErrorBoundary=_a;exports.VoxketEventEmitter=Qs;exports.VoxketProvider=$a;exports.VoxketSDK=_t;exports.VoxketSessionComponent=Xa;exports.agentRpcExample=N0;exports.analyticsPlugin=Kf;exports.chatModalityPlugin=x0;exports.createCustomTheme=u0;exports.createModalityPlugin=eo;exports.createPlugin=Wf;exports.darkTheme=ms;exports.debugPlugin=Gf;exports.default=P0;exports.defaultTheme=tt;exports.enterpriseTheme=fs;exports.flattenTheme=el;exports.metricsPlugin=Yf;exports.useComponentTheme=h0;exports.useCompoundContext=Ht;exports.useSessionLogging=Fa;exports.useTheme=Qa;exports.useVoxket=Ie;exports.useVoxketCamera=Ua;exports.useVoxketChat=gn;exports.useVoxketChatInput=i0;exports.useVoxketConnection=to;exports.useVoxketMetrics=Ha;exports.useVoxketMicrophone=Za;exports.useVoxketParticipants=Wa;exports.useVoxketScreenShare=za;exports.useVoxketSession=nt;exports.useVoxketVideo=o0;exports.voiceModalityPlugin=m0;exports.withCompoundComponent=Ya;
|