@heybello/bello-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -0
- package/dist/api.d.ts +3 -0
- package/dist/bello-embed.es.js +36605 -0
- package/dist/bello-embed.es.js.map +1 -0
- package/dist/bello-embed.iife.js +52 -0
- package/dist/bello-embed.iife.js.map +1 -0
- package/dist/bello-embed.umd.cjs +52 -0
- package/dist/bello-embed.umd.cjs.map +1 -0
- package/dist/embed-runtime.d.ts +6 -0
- package/dist/embed.d.ts +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/mountShadow.d.ts +2 -0
- package/dist/polyfills.d.ts +6 -0
- package/dist/react-wrapper.d.ts +2 -0
- package/dist/react.cjs +807 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.es.js +786 -0
- package/dist/react.es.js.map +1 -0
- package/dist/types.d.ts +34 -0
- package/dist/vite.svg +1 -0
- package/dist/widget/BelloWidget.d.ts +9 -0
- package/dist/widget/ChatEntry.d.ts +4 -0
- package/dist/widget/ChatInput.d.ts +4 -0
- package/dist/widget/transcriptionToChatMessage.d.ts +7 -0
- package/dist/widget/transcriptionUtils.d.ts +9 -0
- package/dist/widget/useChatAndTranscription.d.ts +13 -0
- package/dist/widget/useLiveKit.d.ts +15 -0
- package/package.json +71 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
(function(us){typeof define=="function"&&define.amd?define(us):us()})((function(){"use strict";var SC,TC;var us={exports:{}},wr={};var ng;function kw(){if(ng)return wr;ng=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(a,r,c){var l=null;if(c!==void 0&&(l=""+c),r.key!==void 0&&(l=""+r.key),"key"in r){c={};for(var u in r)u!=="key"&&(c[u]=r[u])}else c=r;return r=c.ref,{$$typeof:t,type:a,key:l,ref:r!==void 0?r:null,props:c}}return wr.Fragment=e,wr.jsx=n,wr.jsxs=n,wr}var ig;function Ew(){return ig||(ig=1,us.exports=kw()),us.exports}var oe=Ew(),Au={exports:{}},Rr={},Mu={exports:{}},Du={};var ag;function ww(){return ag||(ag=1,(function(t){function e(H,ne){var ce=H.length;H.push(ne);e:for(;0<ce;){var Ce=ce-1>>>1,Re=H[Ce];if(0<r(Re,ne))H[Ce]=ne,H[ce]=Re,ce=Ce;else break e}}function n(H){return H.length===0?null:H[0]}function a(H){if(H.length===0)return null;var ne=H[0],ce=H.pop();if(ce!==ne){H[0]=ce;e:for(var Ce=0,Re=H.length,D=Re>>>1;Ce<D;){var Z=2*(Ce+1)-1,re=H[Z],le=Z+1,ye=H[le];if(0>r(re,ce))le<Re&&0>r(ye,re)?(H[Ce]=ye,H[le]=ce,Ce=le):(H[Ce]=re,H[Z]=ce,Ce=Z);else if(le<Re&&0>r(ye,ce))H[Ce]=ye,H[le]=ce,Ce=le;else break e}}return ne}function r(H,ne){var ce=H.sortIndex-ne.sortIndex;return ce!==0?ce:H.id-ne.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;t.unstable_now=function(){return c.now()}}else{var l=Date,u=l.now();t.unstable_now=function(){return l.now()-u}}var f=[],h=[],p=1,v=null,y=3,S=!1,w=!1,T=!1,x=!1,R=typeof setTimeout=="function"?setTimeout:null,P=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate!="undefined"?setImmediate:null;function E(H){for(var ne=n(h);ne!==null;){if(ne.callback===null)a(h);else if(ne.startTime<=H)a(h),ne.sortIndex=ne.expirationTime,e(f,ne);else break;ne=n(h)}}function k(H){if(T=!1,E(H),!w)if(n(f)!==null)w=!0,_||(_=!0,ie());else{var ne=n(h);ne!==null&&qe(k,ne.startTime-H)}}var _=!1,N=-1,U=5,G=-1;function V(){return x?!0:!(t.unstable_now()-G<U)}function Y(){if(x=!1,_){var H=t.unstable_now();G=H;var ne=!0;try{e:{w=!1,T&&(T=!1,P(N),N=-1),S=!0;var ce=y;try{t:{for(E(H),v=n(f);v!==null&&!(v.expirationTime>H&&V());){var Ce=v.callback;if(typeof Ce=="function"){v.callback=null,y=v.priorityLevel;var Re=Ce(v.expirationTime<=H);if(H=t.unstable_now(),typeof Re=="function"){v.callback=Re,E(H),ne=!0;break t}v===n(f)&&a(f),E(H)}else a(f);v=n(f)}if(v!==null)ne=!0;else{var D=n(h);D!==null&&qe(k,D.startTime-H),ne=!1}}break e}finally{v=null,y=ce,S=!1}ne=void 0}}finally{ne?ie():_=!1}}}var ie;if(typeof L=="function")ie=function(){L(Y)};else if(typeof MessageChannel!="undefined"){var he=new MessageChannel,be=he.port2;he.port1.onmessage=Y,ie=function(){be.postMessage(null)}}else ie=function(){R(Y,0)};function qe(H,ne){N=R(function(){H(t.unstable_now())},ne)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(H){H.callback=null},t.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<H?Math.floor(1e3/H):5},t.unstable_getCurrentPriorityLevel=function(){return y},t.unstable_next=function(H){switch(y){case 1:case 2:case 3:var ne=3;break;default:ne=y}var ce=y;y=ne;try{return H()}finally{y=ce}},t.unstable_requestPaint=function(){x=!0},t.unstable_runWithPriority=function(H,ne){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var ce=y;y=H;try{return ne()}finally{y=ce}},t.unstable_scheduleCallback=function(H,ne,ce){var Ce=t.unstable_now();switch(typeof ce=="object"&&ce!==null?(ce=ce.delay,ce=typeof ce=="number"&&0<ce?Ce+ce:Ce):ce=Ce,H){case 1:var Re=-1;break;case 2:Re=250;break;case 5:Re=1073741823;break;case 4:Re=1e4;break;default:Re=5e3}return Re=ce+Re,H={id:p++,callback:ne,priorityLevel:H,startTime:ce,expirationTime:Re,sortIndex:-1},ce>Ce?(H.sortIndex=ce,e(h,H),n(f)===null&&H===n(h)&&(T?(P(N),N=-1):T=!0,qe(k,ce-Ce))):(H.sortIndex=Re,e(f,H),w||S||(w=!0,_||(_=!0,ie()))),H},t.unstable_shouldYield=V,t.unstable_wrapCallback=function(H){var ne=y;return function(){var ce=y;y=ne;try{return H.apply(this,arguments)}finally{y=ce}}}})(Du)),Du}var sg;function Rw(){return sg||(sg=1,Mu.exports=ww()),Mu.exports}var Ou={exports:{}},Te={};var rg;function _w(){if(rg)return Te;rg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),y=Symbol.iterator;function S(D){return D===null||typeof D!="object"?null:(D=y&&D[y]||D["@@iterator"],typeof D=="function"?D:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,x={};function R(D,Z,re){this.props=D,this.context=Z,this.refs=x,this.updater=re||w}R.prototype.isReactComponent={},R.prototype.setState=function(D,Z){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,Z,"setState")},R.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function P(){}P.prototype=R.prototype;function L(D,Z,re){this.props=D,this.context=Z,this.refs=x,this.updater=re||w}var E=L.prototype=new P;E.constructor=L,T(E,R.prototype),E.isPureReactComponent=!0;var k=Array.isArray;function _(){}var N={H:null,A:null,T:null,S:null},U=Object.prototype.hasOwnProperty;function G(D,Z,re){var le=re.ref;return{$$typeof:t,type:D,key:Z,ref:le!==void 0?le:null,props:re}}function V(D,Z){return G(D.type,Z,D.props)}function Y(D){return typeof D=="object"&&D!==null&&D.$$typeof===t}function ie(D){var Z={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(re){return Z[re]})}var he=/\/+/g;function be(D,Z){return typeof D=="object"&&D!==null&&D.key!=null?ie(""+D.key):Z.toString(36)}function qe(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(_,_):(D.status="pending",D.then(function(Z){D.status==="pending"&&(D.status="fulfilled",D.value=Z)},function(Z){D.status==="pending"&&(D.status="rejected",D.reason=Z)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function H(D,Z,re,le,ye){var Se=typeof D;(Se==="undefined"||Se==="boolean")&&(D=null);var ve=!1;if(D===null)ve=!0;else switch(Se){case"bigint":case"string":case"number":ve=!0;break;case"object":switch(D.$$typeof){case t:case e:ve=!0;break;case p:return ve=D._init,H(ve(D._payload),Z,re,le,ye)}}if(ve)return ye=ye(D),ve=le===""?"."+be(D,0):le,k(ye)?(re="",ve!=null&&(re=ve.replace(he,"$&/")+"/"),H(ye,Z,re,"",function(sa){return sa})):ye!=null&&(Y(ye)&&(ye=V(ye,re+(ye.key==null||D&&D.key===ye.key?"":(""+ye.key).replace(he,"$&/")+"/")+ve)),Z.push(ye)),1;ve=0;var tt=le===""?".":le+":";if(k(D))for(var Qe=0;Qe<D.length;Qe++)le=D[Qe],Se=tt+be(le,Qe),ve+=H(le,Z,re,Se,ye);else if(Qe=S(D),typeof Qe=="function")for(D=Qe.call(D),Qe=0;!(le=D.next()).done;)le=le.value,Se=tt+be(le,Qe++),ve+=H(le,Z,re,Se,ye);else if(Se==="object"){if(typeof D.then=="function")return H(qe(D),Z,re,le,ye);throw Z=String(D),Error("Objects are not valid as a React child (found: "+(Z==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":Z)+"). If you meant to render a collection of children, use an array instead.")}return ve}function ne(D,Z,re){if(D==null)return D;var le=[],ye=0;return H(D,le,"","",function(Se){return Z.call(re,Se,ye++)}),le}function ce(D){if(D._status===-1){var Z=D._result;Z=Z(),Z.then(function(re){(D._status===0||D._status===-1)&&(D._status=1,D._result=re)},function(re){(D._status===0||D._status===-1)&&(D._status=2,D._result=re)}),D._status===-1&&(D._status=0,D._result=Z)}if(D._status===1)return D._result.default;throw D._result}var Ce=typeof reportError=="function"?reportError:function(D){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Z=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof D=="object"&&D!==null&&typeof D.message=="string"?String(D.message):String(D),error:D});if(!window.dispatchEvent(Z))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",D);return}console.error(D)},Re={map:ne,forEach:function(D,Z,re){ne(D,function(){Z.apply(this,arguments)},re)},count:function(D){var Z=0;return ne(D,function(){Z++}),Z},toArray:function(D){return ne(D,function(Z){return Z})||[]},only:function(D){if(!Y(D))throw Error("React.Children.only expected to receive a single React element child.");return D}};return Te.Activity=v,Te.Children=Re,Te.Component=R,Te.Fragment=n,Te.Profiler=r,Te.PureComponent=L,Te.StrictMode=a,Te.Suspense=f,Te.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,Te.__COMPILER_RUNTIME={__proto__:null,c:function(D){return N.H.useMemoCache(D)}},Te.cache=function(D){return function(){return D.apply(null,arguments)}},Te.cacheSignal=function(){return null},Te.cloneElement=function(D,Z,re){if(D==null)throw Error("The argument must be a React element, but you passed "+D+".");var le=T({},D.props),ye=D.key;if(Z!=null)for(Se in Z.key!==void 0&&(ye=""+Z.key),Z)!U.call(Z,Se)||Se==="key"||Se==="__self"||Se==="__source"||Se==="ref"&&Z.ref===void 0||(le[Se]=Z[Se]);var Se=arguments.length-2;if(Se===1)le.children=re;else if(1<Se){for(var ve=Array(Se),tt=0;tt<Se;tt++)ve[tt]=arguments[tt+2];le.children=ve}return G(D.type,ye,le)},Te.createContext=function(D){return D={$$typeof:l,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null},D.Provider=D,D.Consumer={$$typeof:c,_context:D},D},Te.createElement=function(D,Z,re){var le,ye={},Se=null;if(Z!=null)for(le in Z.key!==void 0&&(Se=""+Z.key),Z)U.call(Z,le)&&le!=="key"&&le!=="__self"&&le!=="__source"&&(ye[le]=Z[le]);var ve=arguments.length-2;if(ve===1)ye.children=re;else if(1<ve){for(var tt=Array(ve),Qe=0;Qe<ve;Qe++)tt[Qe]=arguments[Qe+2];ye.children=tt}if(D&&D.defaultProps)for(le in ve=D.defaultProps,ve)ye[le]===void 0&&(ye[le]=ve[le]);return G(D,Se,ye)},Te.createRef=function(){return{current:null}},Te.forwardRef=function(D){return{$$typeof:u,render:D}},Te.isValidElement=Y,Te.lazy=function(D){return{$$typeof:p,_payload:{_status:-1,_result:D},_init:ce}},Te.memo=function(D,Z){return{$$typeof:h,type:D,compare:Z===void 0?null:Z}},Te.startTransition=function(D){var Z=N.T,re={};N.T=re;try{var le=D(),ye=N.S;ye!==null&&ye(re,le),typeof le=="object"&&le!==null&&typeof le.then=="function"&&le.then(_,Ce)}catch(Se){Ce(Se)}finally{Z!==null&&re.types!==null&&(Z.types=re.types),N.T=Z}},Te.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},Te.use=function(D){return N.H.use(D)},Te.useActionState=function(D,Z,re){return N.H.useActionState(D,Z,re)},Te.useCallback=function(D,Z){return N.H.useCallback(D,Z)},Te.useContext=function(D){return N.H.useContext(D)},Te.useDebugValue=function(){},Te.useDeferredValue=function(D,Z){return N.H.useDeferredValue(D,Z)},Te.useEffect=function(D,Z){return N.H.useEffect(D,Z)},Te.useEffectEvent=function(D){return N.H.useEffectEvent(D)},Te.useId=function(){return N.H.useId()},Te.useImperativeHandle=function(D,Z,re){return N.H.useImperativeHandle(D,Z,re)},Te.useInsertionEffect=function(D,Z){return N.H.useInsertionEffect(D,Z)},Te.useLayoutEffect=function(D,Z){return N.H.useLayoutEffect(D,Z)},Te.useMemo=function(D,Z){return N.H.useMemo(D,Z)},Te.useOptimistic=function(D,Z){return N.H.useOptimistic(D,Z)},Te.useReducer=function(D,Z,re){return N.H.useReducer(D,Z,re)},Te.useRef=function(D){return N.H.useRef(D)},Te.useState=function(D){return N.H.useState(D)},Te.useSyncExternalStore=function(D,Z,re){return N.H.useSyncExternalStore(D,Z,re)},Te.useTransition=function(){return N.H.useTransition()},Te.version="19.2.3",Te}var og;function ac(){return og||(og=1,Ou.exports=_w()),Ou.exports}var Pu={exports:{}},Ut={};var cg;function xw(){if(cg)return Ut;cg=1;var t=ac();function e(f){var h="https://react.dev/errors/"+f;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)h+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+f+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var a={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},r=Symbol.for("react.portal");function c(f,h,p){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:r,key:v==null?null:""+v,children:f,containerInfo:h,implementation:p}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(f,h){if(f==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Ut.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,Ut.createPortal=function(f,h){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(e(299));return c(f,h,null,p)},Ut.flushSync=function(f){var h=l.T,p=a.p;try{if(l.T=null,a.p=2,f)return f()}finally{l.T=h,a.p=p,a.d.f()}},Ut.preconnect=function(f,h){typeof f=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,a.d.C(f,h))},Ut.prefetchDNS=function(f){typeof f=="string"&&a.d.D(f)},Ut.preinit=function(f,h){if(typeof f=="string"&&h&&typeof h.as=="string"){var p=h.as,v=u(p,h.crossOrigin),y=typeof h.integrity=="string"?h.integrity:void 0,S=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;p==="style"?a.d.S(f,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:v,integrity:y,fetchPriority:S}):p==="script"&&a.d.X(f,{crossOrigin:v,integrity:y,fetchPriority:S,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Ut.preinitModule=function(f,h){if(typeof f=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var p=u(h.as,h.crossOrigin);a.d.M(f,{crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&a.d.M(f)},Ut.preload=function(f,h){if(typeof f=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var p=h.as,v=u(p,h.crossOrigin);a.d.L(f,p,{crossOrigin:v,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Ut.preloadModule=function(f,h){if(typeof f=="string")if(h){var p=u(h.as,h.crossOrigin);a.d.m(f,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else a.d.m(f)},Ut.requestFormReset=function(f){a.d.r(f)},Ut.unstable_batchedUpdates=function(f,h){return f(h)},Ut.useFormState=function(f,h,p){return l.H.useFormState(f,h,p)},Ut.useFormStatus=function(){return l.H.useHostTransitionStatus()},Ut.version="19.2.3",Ut}var lg;function Aw(){if(lg)return Pu.exports;lg=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Pu.exports=xw(),Pu.exports}var ug;function Mw(){if(ug)return Rr;ug=1;var t=Rw(),e=ac(),n=Aw();function a(i){var s="https://react.dev/errors/"+i;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var o=2;o<arguments.length;o++)s+="&args[]="+encodeURIComponent(arguments[o])}return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function c(i){var s=i,o=i;if(i.alternate)for(;s.return;)s=s.return;else{i=s;do s=i,(s.flags&4098)!==0&&(o=s.return),i=s.return;while(i)}return s.tag===3?o:null}function l(i){if(i.tag===13){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function u(i){if(i.tag===31){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function f(i){if(c(i)!==i)throw Error(a(188))}function h(i){var s=i.alternate;if(!s){if(s=c(i),s===null)throw Error(a(188));return s!==i?null:i}for(var o=i,d=s;;){var m=o.return;if(m===null)break;var g=m.alternate;if(g===null){if(d=m.return,d!==null){o=d;continue}break}if(m.child===g.child){for(g=m.child;g;){if(g===o)return f(m),i;if(g===d)return f(m),s;g=g.sibling}throw Error(a(188))}if(o.return!==d.return)o=m,d=g;else{for(var b=!1,C=m.child;C;){if(C===o){b=!0,o=m,d=g;break}if(C===d){b=!0,d=m,o=g;break}C=C.sibling}if(!b){for(C=g.child;C;){if(C===o){b=!0,o=g,d=m;break}if(C===d){b=!0,d=g,o=m;break}C=C.sibling}if(!b)throw Error(a(189))}}if(o.alternate!==d)throw Error(a(190))}if(o.tag!==3)throw Error(a(188));return o.stateNode.current===o?i:s}function p(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i;for(i=i.child;i!==null;){if(s=p(i),s!==null)return s;i=i.sibling}return null}var v=Object.assign,y=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),L=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),G=Symbol.for("react.activity"),V=Symbol.for("react.memo_cache_sentinel"),Y=Symbol.iterator;function ie(i){return i===null||typeof i!="object"?null:(i=Y&&i[Y]||i["@@iterator"],typeof i=="function"?i:null)}var he=Symbol.for("react.client.reference");function be(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===he?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case T:return"Fragment";case R:return"Profiler";case x:return"StrictMode";case k:return"Suspense";case _:return"SuspenseList";case G:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case w:return"Portal";case L:return i.displayName||"Context";case P:return(i._context.displayName||"Context")+".Consumer";case E:var s=i.render;return i=i.displayName,i||(i=s.displayName||s.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case N:return s=i.displayName||null,s!==null?s:be(i.type)||"Memo";case U:s=i._payload,i=i._init;try{return be(i(s))}catch{}}return null}var qe=Array.isArray,H=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ce={pending:!1,data:null,method:null,action:null},Ce=[],Re=-1;function D(i){return{current:i}}function Z(i){0>Re||(i.current=Ce[Re],Ce[Re]=null,Re--)}function re(i,s){Re++,Ce[Re]=i.current,i.current=s}var le=D(null),ye=D(null),Se=D(null),ve=D(null);function tt(i,s){switch(re(Se,s),re(ye,i),re(le,null),s.nodeType){case 9:case 11:i=(i=s.documentElement)&&(i=i.namespaceURI)?K1(i):0;break;default:if(i=s.tagName,s=s.namespaceURI)s=K1(s),i=Y1(s,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}Z(le),re(le,i)}function Qe(){Z(le),Z(ye),Z(Se)}function sa(i){i.memoizedState!==null&&re(ve,i);var s=le.current,o=Y1(s,i.type);s!==o&&(re(ye,i),re(le,o))}function dl(i){ye.current===i&&(Z(le),Z(ye)),ve.current===i&&(Z(ve),ec._currentValue=ce)}var Bh,CC;function Ga(i){if(Bh===void 0)try{throw Error()}catch(o){var s=o.stack.trim().match(/\n( *(at )?)/);Bh=s&&s[1]||"",CC=-1<o.stack.indexOf(`
|
|
2
|
+
at`)?" (<anonymous>)":-1<o.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
+
`+Bh+i+CC}var jh=!1;function Vh(i,s){if(!i||jh)return"";jh=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var d={DetermineComponentFrameRoot:function(){try{if(s){var $=function(){throw Error()};if(Object.defineProperty($.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct($,[])}catch(K){var F=K}Reflect.construct(i,[],$)}else{try{$.call()}catch(K){F=K}i.call($.prototype)}}else{try{throw Error()}catch(K){F=K}($=i())&&typeof $.catch=="function"&&$.catch(function(){})}}catch(K){if(K&&F&&typeof K.stack=="string")return[K.stack,F.stack]}return[null,null]}};d.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var m=Object.getOwnPropertyDescriptor(d.DetermineComponentFrameRoot,"name");m&&m.configurable&&Object.defineProperty(d.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=d.DetermineComponentFrameRoot(),b=g[0],C=g[1];if(b&&C){var M=b.split(`
|
|
4
|
+
`),z=C.split(`
|
|
5
|
+
`);for(m=d=0;d<M.length&&!M[d].includes("DetermineComponentFrameRoot");)d++;for(;m<z.length&&!z[m].includes("DetermineComponentFrameRoot");)m++;if(d===M.length||m===z.length)for(d=M.length-1,m=z.length-1;1<=d&&0<=m&&M[d]!==z[m];)m--;for(;1<=d&&0<=m;d--,m--)if(M[d]!==z[m]){if(d!==1||m!==1)do if(d--,m--,0>m||M[d]!==z[m]){var J=`
|
|
6
|
+
`+M[d].replace(" at new "," at ");return i.displayName&&J.includes("<anonymous>")&&(J=J.replace("<anonymous>",i.displayName)),J}while(1<=d&&0<=m);break}}}finally{jh=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ga(o):""}function uI(i,s){switch(i.tag){case 26:case 27:case 5:return Ga(i.type);case 16:return Ga("Lazy");case 13:return i.child!==s&&s!==null?Ga("Suspense Fallback"):Ga("Suspense");case 19:return Ga("SuspenseList");case 0:case 15:return Vh(i.type,!1);case 11:return Vh(i.type.render,!1);case 1:return Vh(i.type,!0);case 31:return Ga("Activity");default:return""}}function kC(i){try{var s="",o=null;do s+=uI(i,o),o=i,i=i.return;while(i);return s}catch(d){return`
|
|
7
|
+
Error generating stack: `+d.message+`
|
|
8
|
+
`+d.stack}}var zh=Object.prototype.hasOwnProperty,Fh=t.unstable_scheduleCallback,qh=t.unstable_cancelCallback,dI=t.unstable_shouldYield,fI=t.unstable_requestPaint,on=t.unstable_now,hI=t.unstable_getCurrentPriorityLevel,EC=t.unstable_ImmediatePriority,wC=t.unstable_UserBlockingPriority,fl=t.unstable_NormalPriority,mI=t.unstable_LowPriority,RC=t.unstable_IdlePriority,pI=t.log,gI=t.unstable_setDisableYieldValue,fo=null,cn=null;function ra(i){if(typeof pI=="function"&&gI(i),cn&&typeof cn.setStrictMode=="function")try{cn.setStrictMode(fo,i)}catch{}}var ln=Math.clz32?Math.clz32:bI,vI=Math.log,yI=Math.LN2;function bI(i){return i>>>=0,i===0?32:31-(vI(i)/yI|0)|0}var hl=256,ml=262144,pl=4194304;function Ka(i){var s=i&42;if(s!==0)return s;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function gl(i,s,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,g=i.suspendedLanes,b=i.pingedLanes;i=i.warmLanes;var C=d&134217727;return C!==0?(d=C&~g,d!==0?m=Ka(d):(b&=C,b!==0?m=Ka(b):o||(o=C&~i,o!==0&&(m=Ka(o))))):(C=d&~g,C!==0?m=Ka(C):b!==0?m=Ka(b):o||(o=d&~i,o!==0&&(m=Ka(o)))),m===0?0:s!==0&&s!==m&&(s&g)===0&&(g=m&-m,o=s&-s,g>=o||g===32&&(o&4194048)!==0)?s:m}function ho(i,s){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&s)===0}function SI(i,s){switch(i){case 1:case 2:case 4:case 8:case 64:return s+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function _C(){var i=pl;return pl<<=1,(pl&62914560)===0&&(pl=4194304),i}function Hh(i){for(var s=[],o=0;31>o;o++)s.push(i);return s}function mo(i,s){i.pendingLanes|=s,s!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function TI(i,s,o,d,m,g){var b=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var C=i.entanglements,M=i.expirationTimes,z=i.hiddenUpdates;for(o=b&~o;0<o;){var J=31-ln(o),$=1<<J;C[J]=0,M[J]=-1;var F=z[J];if(F!==null)for(z[J]=null,J=0;J<F.length;J++){var K=F[J];K!==null&&(K.lane&=-536870913)}o&=~$}d!==0&&xC(i,d,0),g!==0&&m===0&&i.tag!==0&&(i.suspendedLanes|=g&~(b&~s))}function xC(i,s,o){i.pendingLanes|=s,i.suspendedLanes&=~s;var d=31-ln(s);i.entangledLanes|=s,i.entanglements[d]=i.entanglements[d]|1073741824|o&261930}function AC(i,s){var o=i.entangledLanes|=s;for(i=i.entanglements;o;){var d=31-ln(o),m=1<<d;m&s|i[d]&s&&(i[d]|=s),o&=~m}}function MC(i,s){var o=s&-s;return o=(o&42)!==0?1:Gh(o),(o&(i.suspendedLanes|s))!==0?0:o}function Gh(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function Kh(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function DC(){var i=ne.p;return i!==0?i:(i=window.event,i===void 0?32:gw(i.type))}function OC(i,s){var o=ne.p;try{return ne.p=i,s()}finally{ne.p=o}}var oa=Math.random().toString(36).slice(2),Ot="__reactFiber$"+oa,Jt="__reactProps$"+oa,zs="__reactContainer$"+oa,Yh="__reactEvents$"+oa,CI="__reactListeners$"+oa,kI="__reactHandles$"+oa,PC="__reactResources$"+oa,po="__reactMarker$"+oa;function Xh(i){delete i[Ot],delete i[Jt],delete i[Yh],delete i[CI],delete i[kI]}function Fs(i){var s=i[Ot];if(s)return s;for(var o=i.parentNode;o;){if(s=o[zs]||o[Ot]){if(o=s.alternate,s.child!==null||o!==null&&o.child!==null)for(i=ew(i);i!==null;){if(o=i[Ot])return o;i=ew(i)}return s}i=o,o=i.parentNode}return null}function qs(i){if(i=i[Ot]||i[zs]){var s=i.tag;if(s===5||s===6||s===13||s===31||s===26||s===27||s===3)return i}return null}function go(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i.stateNode;throw Error(a(33))}function Hs(i){var s=i[PC];return s||(s=i[PC]={hoistableStyles:new Map,hoistableScripts:new Map}),s}function _t(i){i[po]=!0}var NC=new Set,LC={};function Ya(i,s){Gs(i,s),Gs(i+"Capture",s)}function Gs(i,s){for(LC[i]=s,i=0;i<s.length;i++)NC.add(s[i])}var EI=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),IC={},UC={};function wI(i){return zh.call(UC,i)?!0:zh.call(IC,i)?!1:EI.test(i)?UC[i]=!0:(IC[i]=!0,!1)}function vl(i,s,o){if(wI(s))if(o===null)i.removeAttribute(s);else{switch(typeof o){case"undefined":case"function":case"symbol":i.removeAttribute(s);return;case"boolean":var d=s.toLowerCase().slice(0,5);if(d!=="data-"&&d!=="aria-"){i.removeAttribute(s);return}}i.setAttribute(s,""+o)}}function yl(i,s,o){if(o===null)i.removeAttribute(s);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(s);return}i.setAttribute(s,""+o)}}function yi(i,s,o,d){if(d===null)i.removeAttribute(o);else{switch(typeof d){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(o);return}i.setAttributeNS(s,o,""+d)}}function En(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function BC(i){var s=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function RI(i,s,o){var d=Object.getOwnPropertyDescriptor(i.constructor.prototype,s);if(!i.hasOwnProperty(s)&&typeof d!="undefined"&&typeof d.get=="function"&&typeof d.set=="function"){var m=d.get,g=d.set;return Object.defineProperty(i,s,{configurable:!0,get:function(){return m.call(this)},set:function(b){o=""+b,g.call(this,b)}}),Object.defineProperty(i,s,{enumerable:d.enumerable}),{getValue:function(){return o},setValue:function(b){o=""+b},stopTracking:function(){i._valueTracker=null,delete i[s]}}}}function Qh(i){if(!i._valueTracker){var s=BC(i)?"checked":"value";i._valueTracker=RI(i,s,""+i[s])}}function jC(i){if(!i)return!1;var s=i._valueTracker;if(!s)return!0;var o=s.getValue(),d="";return i&&(d=BC(i)?i.checked?"true":"false":i.value),i=d,i!==o?(s.setValue(i),!0):!1}function bl(i){if(i=i||(typeof document!="undefined"?document:void 0),typeof i=="undefined")return null;try{return i.activeElement||i.body}catch{return i.body}}var _I=/[\n"\\]/g;function wn(i){return i.replace(_I,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function Jh(i,s,o,d,m,g,b,C){i.name="",b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?i.type=b:i.removeAttribute("type"),s!=null?b==="number"?(s===0&&i.value===""||i.value!=s)&&(i.value=""+En(s)):i.value!==""+En(s)&&(i.value=""+En(s)):b!=="submit"&&b!=="reset"||i.removeAttribute("value"),s!=null?Zh(i,b,En(s)):o!=null?Zh(i,b,En(o)):d!=null&&i.removeAttribute("value"),m==null&&g!=null&&(i.defaultChecked=!!g),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?i.name=""+En(C):i.removeAttribute("name")}function VC(i,s,o,d,m,g,b,C){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(i.type=g),s!=null||o!=null){if(!(g!=="submit"&&g!=="reset"||s!=null)){Qh(i);return}o=o!=null?""+En(o):"",s=s!=null?""+En(s):o,C||s===i.value||(i.value=s),i.defaultValue=s}d=d!=null?d:m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=C?i.checked:!!d,i.defaultChecked=!!d,b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(i.name=b),Qh(i)}function Zh(i,s,o){s==="number"&&bl(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Ks(i,s,o,d){if(i=i.options,s){s={};for(var m=0;m<o.length;m++)s["$"+o[m]]=!0;for(o=0;o<i.length;o++)m=s.hasOwnProperty("$"+i[o].value),i[o].selected!==m&&(i[o].selected=m),m&&d&&(i[o].defaultSelected=!0)}else{for(o=""+En(o),s=null,m=0;m<i.length;m++){if(i[m].value===o){i[m].selected=!0,d&&(i[m].defaultSelected=!0);return}s!==null||i[m].disabled||(s=i[m])}s!==null&&(s.selected=!0)}}function zC(i,s,o){if(s!=null&&(s=""+En(s),s!==i.value&&(i.value=s),o==null)){i.defaultValue!==s&&(i.defaultValue=s);return}i.defaultValue=o!=null?""+En(o):""}function FC(i,s,o,d){if(s==null){if(d!=null){if(o!=null)throw Error(a(92));if(qe(d)){if(1<d.length)throw Error(a(93));d=d[0]}o=d}o==null&&(o=""),s=o}o=En(s),i.defaultValue=o,d=i.textContent,d===o&&d!==""&&d!==null&&(i.value=d),Qh(i)}function Ys(i,s){if(s){var o=i.firstChild;if(o&&o===i.lastChild&&o.nodeType===3){o.nodeValue=s;return}}i.textContent=s}var xI=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function qC(i,s,o){var d=s.indexOf("--")===0;o==null||typeof o=="boolean"||o===""?d?i.setProperty(s,""):s==="float"?i.cssFloat="":i[s]="":d?i.setProperty(s,o):typeof o!="number"||o===0||xI.has(s)?s==="float"?i.cssFloat=o:i[s]=(""+o).trim():i[s]=o+"px"}function HC(i,s,o){if(s!=null&&typeof s!="object")throw Error(a(62));if(i=i.style,o!=null){for(var d in o)!o.hasOwnProperty(d)||s!=null&&s.hasOwnProperty(d)||(d.indexOf("--")===0?i.setProperty(d,""):d==="float"?i.cssFloat="":i[d]="");for(var m in s)d=s[m],s.hasOwnProperty(m)&&o[m]!==d&&qC(i,m,d)}else for(var g in s)s.hasOwnProperty(g)&&qC(i,g,s[g])}function Wh(i){if(i.indexOf("-")===-1)return!1;switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var AI=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),MI=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Sl(i){return MI.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function bi(){}var $h=null;function em(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Xs=null,Qs=null;function GC(i){var s=qs(i);if(s&&(i=s.stateNode)){var o=i[Jt]||null;e:switch(i=s.stateNode,s.type){case"input":if(Jh(i,o.value,o.defaultValue,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name),s=o.name,o.type==="radio"&&s!=null){for(o=i;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll('input[name="'+wn(""+s)+'"][type="radio"]'),s=0;s<o.length;s++){var d=o[s];if(d!==i&&d.form===i.form){var m=d[Jt]||null;if(!m)throw Error(a(90));Jh(d,m.value,m.defaultValue,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name)}}for(s=0;s<o.length;s++)d=o[s],d.form===i.form&&jC(d)}break e;case"textarea":zC(i,o.value,o.defaultValue);break e;case"select":s=o.value,s!=null&&Ks(i,!!o.multiple,s,!1)}}}var tm=!1;function KC(i,s,o){if(tm)return i(s,o);tm=!0;try{var d=i(s);return d}finally{if(tm=!1,(Xs!==null||Qs!==null)&&(ou(),Xs&&(s=Xs,i=Qs,Qs=Xs=null,GC(s),i)))for(s=0;s<i.length;s++)GC(i[s])}}function vo(i,s){var o=i.stateNode;if(o===null)return null;var d=o[Jt]||null;if(d===null)return null;o=d[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(d=!d.disabled)||(i=i.type,d=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!d;break e;default:i=!1}if(i)return null;if(o&&typeof o!="function")throw Error(a(231,s,typeof o));return o}var Si=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),nm=!1;if(Si)try{var yo={};Object.defineProperty(yo,"passive",{get:function(){nm=!0}}),window.addEventListener("test",yo,yo),window.removeEventListener("test",yo,yo)}catch{nm=!1}var ca=null,im=null,Tl=null;function YC(){if(Tl)return Tl;var i,s=im,o=s.length,d,m="value"in ca?ca.value:ca.textContent,g=m.length;for(i=0;i<o&&s[i]===m[i];i++);var b=o-i;for(d=1;d<=b&&s[o-d]===m[g-d];d++);return Tl=m.slice(i,1<d?1-d:void 0)}function Cl(i){var s=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&s===13&&(i=13)):i=s,i===10&&(i=13),32<=i||i===13?i:0}function kl(){return!0}function XC(){return!1}function Zt(i){function s(o,d,m,g,b){this._reactName=o,this._targetInst=m,this.type=d,this.nativeEvent=g,this.target=b,this.currentTarget=null;for(var C in i)i.hasOwnProperty(C)&&(o=i[C],this[C]=o?o(g):g[C]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?kl:XC,this.isPropagationStopped=XC,this}return v(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var o=this.nativeEvent;o&&(o.preventDefault?o.preventDefault():typeof o.returnValue!="unknown"&&(o.returnValue=!1),this.isDefaultPrevented=kl)},stopPropagation:function(){var o=this.nativeEvent;o&&(o.stopPropagation?o.stopPropagation():typeof o.cancelBubble!="unknown"&&(o.cancelBubble=!0),this.isPropagationStopped=kl)},persist:function(){},isPersistent:kl}),s}var Xa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},El=Zt(Xa),bo=v({},Xa,{view:0,detail:0}),DI=Zt(bo),am,sm,So,wl=v({},bo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:om,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==So&&(So&&i.type==="mousemove"?(am=i.screenX-So.screenX,sm=i.screenY-So.screenY):sm=am=0,So=i),am)},movementY:function(i){return"movementY"in i?i.movementY:sm}}),QC=Zt(wl),OI=v({},wl,{dataTransfer:0}),PI=Zt(OI),NI=v({},bo,{relatedTarget:0}),rm=Zt(NI),LI=v({},Xa,{animationName:0,elapsedTime:0,pseudoElement:0}),II=Zt(LI),UI=v({},Xa,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),BI=Zt(UI),jI=v({},Xa,{data:0}),JC=Zt(jI),VI={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},zI={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},FI={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function qI(i){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(i):(i=FI[i])?!!s[i]:!1}function om(){return qI}var HI=v({},bo,{key:function(i){if(i.key){var s=VI[i.key]||i.key;if(s!=="Unidentified")return s}return i.type==="keypress"?(i=Cl(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?zI[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:om,charCode:function(i){return i.type==="keypress"?Cl(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Cl(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),GI=Zt(HI),KI=v({},wl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ZC=Zt(KI),YI=v({},bo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:om}),XI=Zt(YI),QI=v({},Xa,{propertyName:0,elapsedTime:0,pseudoElement:0}),JI=Zt(QI),ZI=v({},wl,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),WI=Zt(ZI),$I=v({},Xa,{newState:0,oldState:0}),eU=Zt($I),tU=[9,13,27,32],cm=Si&&"CompositionEvent"in window,To=null;Si&&"documentMode"in document&&(To=document.documentMode);var nU=Si&&"TextEvent"in window&&!To,WC=Si&&(!cm||To&&8<To&&11>=To),$C=" ",ek=!1;function tk(i,s){switch(i){case"keyup":return tU.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function nk(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Js=!1;function iU(i,s){switch(i){case"compositionend":return nk(s);case"keypress":return s.which!==32?null:(ek=!0,$C);case"textInput":return i=s.data,i===$C&&ek?null:i;default:return null}}function aU(i,s){if(Js)return i==="compositionend"||!cm&&tk(i,s)?(i=YC(),Tl=im=ca=null,Js=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return WC&&s.locale!=="ko"?null:s.data;default:return null}}var sU={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function ik(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s==="input"?!!sU[i.type]:s==="textarea"}function ak(i,s,o,d){Xs?Qs?Qs.push(d):Qs=[d]:Xs=d,s=mu(s,"onChange"),0<s.length&&(o=new El("onChange","change",null,o,d),i.push({event:o,listeners:s}))}var Co=null,ko=null;function rU(i){V1(i,0)}function Rl(i){var s=go(i);if(jC(s))return i}function sk(i,s){if(i==="change")return s}var rk=!1;if(Si){var lm;if(Si){var um="oninput"in document;if(!um){var ok=document.createElement("div");ok.setAttribute("oninput","return;"),um=typeof ok.oninput=="function"}lm=um}else lm=!1;rk=lm&&(!document.documentMode||9<document.documentMode)}function ck(){Co&&(Co.detachEvent("onpropertychange",lk),ko=Co=null)}function lk(i){if(i.propertyName==="value"&&Rl(ko)){var s=[];ak(s,ko,i,em(i)),KC(rU,s)}}function oU(i,s,o){i==="focusin"?(ck(),Co=s,ko=o,Co.attachEvent("onpropertychange",lk)):i==="focusout"&&ck()}function cU(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Rl(ko)}function lU(i,s){if(i==="click")return Rl(s)}function uU(i,s){if(i==="input"||i==="change")return Rl(s)}function dU(i,s){return i===s&&(i!==0||1/i===1/s)||i!==i&&s!==s}var un=typeof Object.is=="function"?Object.is:dU;function Eo(i,s){if(un(i,s))return!0;if(typeof i!="object"||i===null||typeof s!="object"||s===null)return!1;var o=Object.keys(i),d=Object.keys(s);if(o.length!==d.length)return!1;for(d=0;d<o.length;d++){var m=o[d];if(!zh.call(s,m)||!un(i[m],s[m]))return!1}return!0}function uk(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function dk(i,s){var o=uk(i);i=0;for(var d;o;){if(o.nodeType===3){if(d=i+o.textContent.length,i<=s&&d>=s)return{node:o,offset:s-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=uk(o)}}function fk(i,s){return i&&s?i===s?!0:i&&i.nodeType===3?!1:s&&s.nodeType===3?fk(i,s.parentNode):"contains"in i?i.contains(s):i.compareDocumentPosition?!!(i.compareDocumentPosition(s)&16):!1:!1}function hk(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var s=bl(i.document);s instanceof i.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)i=s.contentWindow;else break;s=bl(i.document)}return s}function dm(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s&&(s==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||s==="textarea"||i.contentEditable==="true")}var fU=Si&&"documentMode"in document&&11>=document.documentMode,Zs=null,fm=null,wo=null,hm=!1;function mk(i,s,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;hm||Zs==null||Zs!==bl(d)||(d=Zs,"selectionStart"in d&&dm(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),wo&&Eo(wo,d)||(wo=d,d=mu(fm,"onSelect"),0<d.length&&(s=new El("onSelect","select",null,s,o),i.push({event:s,listeners:d}),s.target=Zs)))}function Qa(i,s){var o={};return o[i.toLowerCase()]=s.toLowerCase(),o["Webkit"+i]="webkit"+s,o["Moz"+i]="moz"+s,o}var Ws={animationend:Qa("Animation","AnimationEnd"),animationiteration:Qa("Animation","AnimationIteration"),animationstart:Qa("Animation","AnimationStart"),transitionrun:Qa("Transition","TransitionRun"),transitionstart:Qa("Transition","TransitionStart"),transitioncancel:Qa("Transition","TransitionCancel"),transitionend:Qa("Transition","TransitionEnd")},mm={},pk={};Si&&(pk=document.createElement("div").style,"AnimationEvent"in window||(delete Ws.animationend.animation,delete Ws.animationiteration.animation,delete Ws.animationstart.animation),"TransitionEvent"in window||delete Ws.transitionend.transition);function Ja(i){if(mm[i])return mm[i];if(!Ws[i])return i;var s=Ws[i],o;for(o in s)if(s.hasOwnProperty(o)&&o in pk)return mm[i]=s[o];return i}var gk=Ja("animationend"),vk=Ja("animationiteration"),yk=Ja("animationstart"),hU=Ja("transitionrun"),mU=Ja("transitionstart"),pU=Ja("transitioncancel"),bk=Ja("transitionend"),Sk=new Map,pm="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");pm.push("scrollEnd");function Hn(i,s){Sk.set(i,s),Ya(s,[i])}var _l=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var s=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(s))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Rn=[],$s=0,gm=0;function xl(){for(var i=$s,s=gm=$s=0;s<i;){var o=Rn[s];Rn[s++]=null;var d=Rn[s];Rn[s++]=null;var m=Rn[s];Rn[s++]=null;var g=Rn[s];if(Rn[s++]=null,d!==null&&m!==null){var b=d.pending;b===null?m.next=m:(m.next=b.next,b.next=m),d.pending=m}g!==0&&Tk(o,m,g)}}function Al(i,s,o,d){Rn[$s++]=i,Rn[$s++]=s,Rn[$s++]=o,Rn[$s++]=d,gm|=d,i.lanes|=d,i=i.alternate,i!==null&&(i.lanes|=d)}function vm(i,s,o,d){return Al(i,s,o,d),Ml(i)}function Za(i,s){return Al(i,null,null,s),Ml(i)}function Tk(i,s,o){i.lanes|=o;var d=i.alternate;d!==null&&(d.lanes|=o);for(var m=!1,g=i.return;g!==null;)g.childLanes|=o,d=g.alternate,d!==null&&(d.childLanes|=o),g.tag===22&&(i=g.stateNode,i===null||i._visibility&1||(m=!0)),i=g,g=g.return;return i.tag===3?(g=i.stateNode,m&&s!==null&&(m=31-ln(o),i=g.hiddenUpdates,d=i[m],d===null?i[m]=[s]:d.push(s),s.lane=o|536870912),g):null}function Ml(i){if(50<Yo)throw Yo=0,Rp=null,Error(a(185));for(var s=i.return;s!==null;)i=s,s=i.return;return i.tag===3?i.stateNode:null}var er={};function gU(i,s,o,d){this.tag=i,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=d,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function dn(i,s,o,d){return new gU(i,s,o,d)}function ym(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Ti(i,s){var o=i.alternate;return o===null?(o=dn(i.tag,s,i.key,i.mode),o.elementType=i.elementType,o.type=i.type,o.stateNode=i.stateNode,o.alternate=i,i.alternate=o):(o.pendingProps=s,o.type=i.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=i.flags&65011712,o.childLanes=i.childLanes,o.lanes=i.lanes,o.child=i.child,o.memoizedProps=i.memoizedProps,o.memoizedState=i.memoizedState,o.updateQueue=i.updateQueue,s=i.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=i.sibling,o.index=i.index,o.ref=i.ref,o.refCleanup=i.refCleanup,o}function Ck(i,s){i.flags&=65011714;var o=i.alternate;return o===null?(i.childLanes=0,i.lanes=s,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,s=o.dependencies,i.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),i}function Dl(i,s,o,d,m,g){var b=0;if(d=i,typeof i=="function")ym(i)&&(b=1);else if(typeof i=="string")b=T5(i,o,le.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case G:return i=dn(31,o,s,m),i.elementType=G,i.lanes=g,i;case T:return Wa(o.children,m,g,s);case x:b=8,m|=24;break;case R:return i=dn(12,o,s,m|2),i.elementType=R,i.lanes=g,i;case k:return i=dn(13,o,s,m),i.elementType=k,i.lanes=g,i;case _:return i=dn(19,o,s,m),i.elementType=_,i.lanes=g,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case L:b=10;break e;case P:b=9;break e;case E:b=11;break e;case N:b=14;break e;case U:b=16,d=null;break e}b=29,o=Error(a(130,i===null?"null":typeof i,"")),d=null}return s=dn(b,o,s,m),s.elementType=i,s.type=d,s.lanes=g,s}function Wa(i,s,o,d){return i=dn(7,i,d,s),i.lanes=o,i}function bm(i,s,o){return i=dn(6,i,null,s),i.lanes=o,i}function kk(i){var s=dn(18,null,null,0);return s.stateNode=i,s}function Sm(i,s,o){return s=dn(4,i.children!==null?i.children:[],i.key,s),s.lanes=o,s.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},s}var Ek=new WeakMap;function _n(i,s){if(typeof i=="object"&&i!==null){var o=Ek.get(i);return o!==void 0?o:(s={value:i,source:s,stack:kC(s)},Ek.set(i,s),s)}return{value:i,source:s,stack:kC(s)}}var tr=[],nr=0,Ol=null,Ro=0,xn=[],An=0,la=null,ai=1,si="";function Ci(i,s){tr[nr++]=Ro,tr[nr++]=Ol,Ol=i,Ro=s}function wk(i,s,o){xn[An++]=ai,xn[An++]=si,xn[An++]=la,la=i;var d=ai;i=si;var m=32-ln(d)-1;d&=~(1<<m),o+=1;var g=32-ln(s)+m;if(30<g){var b=m-m%5;g=(d&(1<<b)-1).toString(32),d>>=b,m-=b,ai=1<<32-ln(s)+m|o<<m|d,si=g+i}else ai=1<<g|o<<m|d,si=i}function Tm(i){i.return!==null&&(Ci(i,1),wk(i,1,0))}function Cm(i){for(;i===Ol;)Ol=tr[--nr],tr[nr]=null,Ro=tr[--nr],tr[nr]=null;for(;i===la;)la=xn[--An],xn[An]=null,si=xn[--An],xn[An]=null,ai=xn[--An],xn[An]=null}function Rk(i,s){xn[An++]=ai,xn[An++]=si,xn[An++]=la,ai=s.id,si=s.overflow,la=i}var Pt=null,We=null,Le=!1,ua=null,Mn=!1,km=Error(a(519));function da(i){var s=Error(a(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw _o(_n(s,i)),km}function _k(i){var s=i.stateNode,o=i.type,d=i.memoizedProps;switch(s[Ot]=i,s[Jt]=d,o){case"dialog":De("cancel",s),De("close",s);break;case"iframe":case"object":case"embed":De("load",s);break;case"video":case"audio":for(o=0;o<Qo.length;o++)De(Qo[o],s);break;case"source":De("error",s);break;case"img":case"image":case"link":De("error",s),De("load",s);break;case"details":De("toggle",s);break;case"input":De("invalid",s),VC(s,d.value,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name,!0);break;case"select":De("invalid",s);break;case"textarea":De("invalid",s),FC(s,d.value,d.defaultValue,d.children)}o=d.children,typeof o!="string"&&typeof o!="number"&&typeof o!="bigint"||s.textContent===""+o||d.suppressHydrationWarning===!0||H1(s.textContent,o)?(d.popover!=null&&(De("beforetoggle",s),De("toggle",s)),d.onScroll!=null&&De("scroll",s),d.onScrollEnd!=null&&De("scrollend",s),d.onClick!=null&&(s.onclick=bi),s=!0):s=!1,s||da(i,!0)}function xk(i){for(Pt=i.return;Pt;)switch(Pt.tag){case 5:case 31:case 13:Mn=!1;return;case 27:case 3:Mn=!0;return;default:Pt=Pt.return}}function ir(i){if(i!==Pt)return!1;if(!Le)return xk(i),Le=!0,!1;var s=i.tag,o;if((o=s!==3&&s!==27)&&((o=s===5)&&(o=i.type,o=!(o!=="form"&&o!=="button")||zp(i.type,i.memoizedProps)),o=!o),o&&We&&da(i),xk(i),s===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(a(317));We=$1(i)}else if(s===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(a(317));We=$1(i)}else s===27?(s=We,wa(i.type)?(i=Kp,Kp=null,We=i):We=s):We=Pt?On(i.stateNode.nextSibling):null;return!0}function $a(){We=Pt=null,Le=!1}function Em(){var i=ua;return i!==null&&(tn===null?tn=i:tn.push.apply(tn,i),ua=null),i}function _o(i){ua===null?ua=[i]:ua.push(i)}var wm=D(null),es=null,ki=null;function fa(i,s,o){re(wm,s._currentValue),s._currentValue=o}function Ei(i){i._currentValue=wm.current,Z(wm)}function Rm(i,s,o){for(;i!==null;){var d=i.alternate;if((i.childLanes&s)!==s?(i.childLanes|=s,d!==null&&(d.childLanes|=s)):d!==null&&(d.childLanes&s)!==s&&(d.childLanes|=s),i===o)break;i=i.return}}function _m(i,s,o,d){var m=i.child;for(m!==null&&(m.return=i);m!==null;){var g=m.dependencies;if(g!==null){var b=m.child;g=g.firstContext;e:for(;g!==null;){var C=g;g=m;for(var M=0;M<s.length;M++)if(C.context===s[M]){g.lanes|=o,C=g.alternate,C!==null&&(C.lanes|=o),Rm(g.return,o,i),d||(b=null);break e}g=C.next}}else if(m.tag===18){if(b=m.return,b===null)throw Error(a(341));b.lanes|=o,g=b.alternate,g!==null&&(g.lanes|=o),Rm(b,o,i),b=null}else b=m.child;if(b!==null)b.return=m;else for(b=m;b!==null;){if(b===i){b=null;break}if(m=b.sibling,m!==null){m.return=b.return,b=m;break}b=b.return}m=b}}function ar(i,s,o,d){i=null;for(var m=s,g=!1;m!==null;){if(!g){if((m.flags&524288)!==0)g=!0;else if((m.flags&262144)!==0)break}if(m.tag===10){var b=m.alternate;if(b===null)throw Error(a(387));if(b=b.memoizedProps,b!==null){var C=m.type;un(m.pendingProps.value,b.value)||(i!==null?i.push(C):i=[C])}}else if(m===ve.current){if(b=m.alternate,b===null)throw Error(a(387));b.memoizedState.memoizedState!==m.memoizedState.memoizedState&&(i!==null?i.push(ec):i=[ec])}m=m.return}i!==null&&_m(s,i,o,d),s.flags|=262144}function Pl(i){for(i=i.firstContext;i!==null;){if(!un(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function ts(i){es=i,ki=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Nt(i){return Ak(es,i)}function Nl(i,s){return es===null&&ts(i),Ak(i,s)}function Ak(i,s){var o=s._currentValue;if(s={context:s,memoizedValue:o,next:null},ki===null){if(i===null)throw Error(a(308));ki=s,i.dependencies={lanes:0,firstContext:s},i.flags|=524288}else ki=ki.next=s;return o}var vU=typeof AbortController!="undefined"?AbortController:function(){var i=[],s=this.signal={aborted:!1,addEventListener:function(o,d){i.push(d)}};this.abort=function(){s.aborted=!0,i.forEach(function(o){return o()})}},yU=t.unstable_scheduleCallback,bU=t.unstable_NormalPriority,vt={$$typeof:L,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function xm(){return{controller:new vU,data:new Map,refCount:0}}function xo(i){i.refCount--,i.refCount===0&&yU(bU,function(){i.controller.abort()})}var Ao=null,Am=0,sr=0,rr=null;function SU(i,s){if(Ao===null){var o=Ao=[];Am=0,sr=Op(),rr={status:"pending",value:void 0,then:function(d){o.push(d)}}}return Am++,s.then(Mk,Mk),s}function Mk(){if(--Am===0&&Ao!==null){rr!==null&&(rr.status="fulfilled");var i=Ao;Ao=null,sr=0,rr=null;for(var s=0;s<i.length;s++)(0,i[s])()}}function TU(i,s){var o=[],d={status:"pending",value:null,reason:null,then:function(m){o.push(m)}};return i.then(function(){d.status="fulfilled",d.value=s;for(var m=0;m<o.length;m++)(0,o[m])(s)},function(m){for(d.status="rejected",d.reason=m,m=0;m<o.length;m++)(0,o[m])(void 0)}),d}var Dk=H.S;H.S=function(i,s){m1=on(),typeof s=="object"&&s!==null&&typeof s.then=="function"&&SU(i,s),Dk!==null&&Dk(i,s)};var ns=D(null);function Mm(){var i=ns.current;return i!==null?i:Je.pooledCache}function Ll(i,s){s===null?re(ns,ns.current):re(ns,s.pool)}function Ok(){var i=Mm();return i===null?null:{parent:vt._currentValue,pool:i}}var or=Error(a(460)),Dm=Error(a(474)),Il=Error(a(542)),Ul={then:function(){}};function Pk(i){return i=i.status,i==="fulfilled"||i==="rejected"}function Nk(i,s,o){switch(o=i[o],o===void 0?i.push(s):o!==s&&(s.then(bi,bi),s=o),s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,Ik(i),i;default:if(typeof s.status=="string")s.then(bi,bi);else{if(i=Je,i!==null&&100<i.shellSuspendCounter)throw Error(a(482));i=s,i.status="pending",i.then(function(d){if(s.status==="pending"){var m=s;m.status="fulfilled",m.value=d}},function(d){if(s.status==="pending"){var m=s;m.status="rejected",m.reason=d}})}switch(s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,Ik(i),i}throw as=s,or}}function is(i){try{var s=i._init;return s(i._payload)}catch(o){throw o!==null&&typeof o=="object"&&typeof o.then=="function"?(as=o,or):o}}var as=null;function Lk(){if(as===null)throw Error(a(459));var i=as;return as=null,i}function Ik(i){if(i===or||i===Il)throw Error(a(483))}var cr=null,Mo=0;function Bl(i){var s=Mo;return Mo+=1,cr===null&&(cr=[]),Nk(cr,i,s)}function Do(i,s){s=s.props.ref,i.ref=s!==void 0?s:null}function jl(i,s){throw s.$$typeof===y?Error(a(525)):(i=Object.prototype.toString.call(s),Error(a(31,i==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":i)))}function Uk(i){function s(I,O){if(i){var B=I.deletions;B===null?(I.deletions=[O],I.flags|=16):B.push(O)}}function o(I,O){if(!i)return null;for(;O!==null;)s(I,O),O=O.sibling;return null}function d(I){for(var O=new Map;I!==null;)I.key!==null?O.set(I.key,I):O.set(I.index,I),I=I.sibling;return O}function m(I,O){return I=Ti(I,O),I.index=0,I.sibling=null,I}function g(I,O,B){return I.index=B,i?(B=I.alternate,B!==null?(B=B.index,B<O?(I.flags|=67108866,O):B):(I.flags|=67108866,O)):(I.flags|=1048576,O)}function b(I){return i&&I.alternate===null&&(I.flags|=67108866),I}function C(I,O,B,W){return O===null||O.tag!==6?(O=bm(B,I.mode,W),O.return=I,O):(O=m(O,B),O.return=I,O)}function M(I,O,B,W){var me=B.type;return me===T?J(I,O,B.props.children,W,B.key):O!==null&&(O.elementType===me||typeof me=="object"&&me!==null&&me.$$typeof===U&&is(me)===O.type)?(O=m(O,B.props),Do(O,B),O.return=I,O):(O=Dl(B.type,B.key,B.props,null,I.mode,W),Do(O,B),O.return=I,O)}function z(I,O,B,W){return O===null||O.tag!==4||O.stateNode.containerInfo!==B.containerInfo||O.stateNode.implementation!==B.implementation?(O=Sm(B,I.mode,W),O.return=I,O):(O=m(O,B.children||[]),O.return=I,O)}function J(I,O,B,W,me){return O===null||O.tag!==7?(O=Wa(B,I.mode,W,me),O.return=I,O):(O=m(O,B),O.return=I,O)}function $(I,O,B){if(typeof O=="string"&&O!==""||typeof O=="number"||typeof O=="bigint")return O=bm(""+O,I.mode,B),O.return=I,O;if(typeof O=="object"&&O!==null){switch(O.$$typeof){case S:return B=Dl(O.type,O.key,O.props,null,I.mode,B),Do(B,O),B.return=I,B;case w:return O=Sm(O,I.mode,B),O.return=I,O;case U:return O=is(O),$(I,O,B)}if(qe(O)||ie(O))return O=Wa(O,I.mode,B,null),O.return=I,O;if(typeof O.then=="function")return $(I,Bl(O),B);if(O.$$typeof===L)return $(I,Nl(I,O),B);jl(I,O)}return null}function F(I,O,B,W){var me=O!==null?O.key:null;if(typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint")return me!==null?null:C(I,O,""+B,W);if(typeof B=="object"&&B!==null){switch(B.$$typeof){case S:return B.key===me?M(I,O,B,W):null;case w:return B.key===me?z(I,O,B,W):null;case U:return B=is(B),F(I,O,B,W)}if(qe(B)||ie(B))return me!==null?null:J(I,O,B,W,null);if(typeof B.then=="function")return F(I,O,Bl(B),W);if(B.$$typeof===L)return F(I,O,Nl(I,B),W);jl(I,B)}return null}function K(I,O,B,W,me){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return I=I.get(B)||null,C(O,I,""+W,me);if(typeof W=="object"&&W!==null){switch(W.$$typeof){case S:return I=I.get(W.key===null?B:W.key)||null,M(O,I,W,me);case w:return I=I.get(W.key===null?B:W.key)||null,z(O,I,W,me);case U:return W=is(W),K(I,O,B,W,me)}if(qe(W)||ie(W))return I=I.get(B)||null,J(O,I,W,me,null);if(typeof W.then=="function")return K(I,O,B,Bl(W),me);if(W.$$typeof===L)return K(I,O,B,Nl(O,W),me);jl(O,W)}return null}function ue(I,O,B,W){for(var me=null,Ue=null,fe=O,we=O=0,Pe=null;fe!==null&&we<B.length;we++){fe.index>we?(Pe=fe,fe=null):Pe=fe.sibling;var Be=F(I,fe,B[we],W);if(Be===null){fe===null&&(fe=Pe);break}i&&fe&&Be.alternate===null&&s(I,fe),O=g(Be,O,we),Ue===null?me=Be:Ue.sibling=Be,Ue=Be,fe=Pe}if(we===B.length)return o(I,fe),Le&&Ci(I,we),me;if(fe===null){for(;we<B.length;we++)fe=$(I,B[we],W),fe!==null&&(O=g(fe,O,we),Ue===null?me=fe:Ue.sibling=fe,Ue=fe);return Le&&Ci(I,we),me}for(fe=d(fe);we<B.length;we++)Pe=K(fe,I,we,B[we],W),Pe!==null&&(i&&Pe.alternate!==null&&fe.delete(Pe.key===null?we:Pe.key),O=g(Pe,O,we),Ue===null?me=Pe:Ue.sibling=Pe,Ue=Pe);return i&&fe.forEach(function(Ma){return s(I,Ma)}),Le&&Ci(I,we),me}function ge(I,O,B,W){if(B==null)throw Error(a(151));for(var me=null,Ue=null,fe=O,we=O=0,Pe=null,Be=B.next();fe!==null&&!Be.done;we++,Be=B.next()){fe.index>we?(Pe=fe,fe=null):Pe=fe.sibling;var Ma=F(I,fe,Be.value,W);if(Ma===null){fe===null&&(fe=Pe);break}i&&fe&&Ma.alternate===null&&s(I,fe),O=g(Ma,O,we),Ue===null?me=Ma:Ue.sibling=Ma,Ue=Ma,fe=Pe}if(Be.done)return o(I,fe),Le&&Ci(I,we),me;if(fe===null){for(;!Be.done;we++,Be=B.next())Be=$(I,Be.value,W),Be!==null&&(O=g(Be,O,we),Ue===null?me=Be:Ue.sibling=Be,Ue=Be);return Le&&Ci(I,we),me}for(fe=d(fe);!Be.done;we++,Be=B.next())Be=K(fe,I,we,Be.value,W),Be!==null&&(i&&Be.alternate!==null&&fe.delete(Be.key===null?we:Be.key),O=g(Be,O,we),Ue===null?me=Be:Ue.sibling=Be,Ue=Be);return i&&fe.forEach(function(O5){return s(I,O5)}),Le&&Ci(I,we),me}function Ke(I,O,B,W){if(typeof B=="object"&&B!==null&&B.type===T&&B.key===null&&(B=B.props.children),typeof B=="object"&&B!==null){switch(B.$$typeof){case S:e:{for(var me=B.key;O!==null;){if(O.key===me){if(me=B.type,me===T){if(O.tag===7){o(I,O.sibling),W=m(O,B.props.children),W.return=I,I=W;break e}}else if(O.elementType===me||typeof me=="object"&&me!==null&&me.$$typeof===U&&is(me)===O.type){o(I,O.sibling),W=m(O,B.props),Do(W,B),W.return=I,I=W;break e}o(I,O);break}else s(I,O);O=O.sibling}B.type===T?(W=Wa(B.props.children,I.mode,W,B.key),W.return=I,I=W):(W=Dl(B.type,B.key,B.props,null,I.mode,W),Do(W,B),W.return=I,I=W)}return b(I);case w:e:{for(me=B.key;O!==null;){if(O.key===me)if(O.tag===4&&O.stateNode.containerInfo===B.containerInfo&&O.stateNode.implementation===B.implementation){o(I,O.sibling),W=m(O,B.children||[]),W.return=I,I=W;break e}else{o(I,O);break}else s(I,O);O=O.sibling}W=Sm(B,I.mode,W),W.return=I,I=W}return b(I);case U:return B=is(B),Ke(I,O,B,W)}if(qe(B))return ue(I,O,B,W);if(ie(B)){if(me=ie(B),typeof me!="function")throw Error(a(150));return B=me.call(B),ge(I,O,B,W)}if(typeof B.then=="function")return Ke(I,O,Bl(B),W);if(B.$$typeof===L)return Ke(I,O,Nl(I,B),W);jl(I,B)}return typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint"?(B=""+B,O!==null&&O.tag===6?(o(I,O.sibling),W=m(O,B),W.return=I,I=W):(o(I,O),W=bm(B,I.mode,W),W.return=I,I=W),b(I)):o(I,O)}return function(I,O,B,W){try{Mo=0;var me=Ke(I,O,B,W);return cr=null,me}catch(fe){if(fe===or||fe===Il)throw fe;var Ue=dn(29,fe,null,I.mode);return Ue.lanes=W,Ue.return=I,Ue}}}var ss=Uk(!0),Bk=Uk(!1),ha=!1;function Om(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Pm(i,s){i=i.updateQueue,s.updateQueue===i&&(s.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ma(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function pa(i,s,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(je&2)!==0){var m=d.pending;return m===null?s.next=s:(s.next=m.next,m.next=s),d.pending=s,s=Ml(i),Tk(i,null,o),s}return Al(i,d,s,o),Ml(i)}function Oo(i,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194048)!==0)){var d=s.lanes;d&=i.pendingLanes,o|=d,s.lanes=o,AC(i,o)}}function Nm(i,s){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,g=null;if(o=o.firstBaseUpdate,o!==null){do{var b={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};g===null?m=g=b:g=g.next=b,o=o.next}while(o!==null);g===null?m=g=s:g=g.next=s}else m=g=s;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:g,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=s:i.next=s,o.lastBaseUpdate=s}var Lm=!1;function Po(){if(Lm){var i=rr;if(i!==null)throw i}}function No(i,s,o,d){Lm=!1;var m=i.updateQueue;ha=!1;var g=m.firstBaseUpdate,b=m.lastBaseUpdate,C=m.shared.pending;if(C!==null){m.shared.pending=null;var M=C,z=M.next;M.next=null,b===null?g=z:b.next=z,b=M;var J=i.alternate;J!==null&&(J=J.updateQueue,C=J.lastBaseUpdate,C!==b&&(C===null?J.firstBaseUpdate=z:C.next=z,J.lastBaseUpdate=M))}if(g!==null){var $=m.baseState;b=0,J=z=M=null,C=g;do{var F=C.lane&-536870913,K=F!==C.lane;if(K?(Oe&F)===F:(d&F)===F){F!==0&&F===sr&&(Lm=!0),J!==null&&(J=J.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var ue=i,ge=C;F=s;var Ke=o;switch(ge.tag){case 1:if(ue=ge.payload,typeof ue=="function"){$=ue.call(Ke,$,F);break e}$=ue;break e;case 3:ue.flags=ue.flags&-65537|128;case 0:if(ue=ge.payload,F=typeof ue=="function"?ue.call(Ke,$,F):ue,F==null)break e;$=v({},$,F);break e;case 2:ha=!0}}F=C.callback,F!==null&&(i.flags|=64,K&&(i.flags|=8192),K=m.callbacks,K===null?m.callbacks=[F]:K.push(F))}else K={lane:F,tag:C.tag,payload:C.payload,callback:C.callback,next:null},J===null?(z=J=K,M=$):J=J.next=K,b|=F;if(C=C.next,C===null){if(C=m.shared.pending,C===null)break;K=C,C=K.next,K.next=null,m.lastBaseUpdate=K,m.shared.pending=null}}while(!0);J===null&&(M=$),m.baseState=M,m.firstBaseUpdate=z,m.lastBaseUpdate=J,g===null&&(m.shared.lanes=0),Sa|=b,i.lanes=b,i.memoizedState=$}}function jk(i,s){if(typeof i!="function")throw Error(a(191,i));i.call(s)}function Vk(i,s){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;i<o.length;i++)jk(o[i],s)}var lr=D(null),Vl=D(0);function zk(i,s){i=Pi,re(Vl,i),re(lr,s),Pi=i|s.baseLanes}function Im(){re(Vl,Pi),re(lr,lr.current)}function Um(){Pi=Vl.current,Z(lr),Z(Vl)}var fn=D(null),Dn=null;function ga(i){var s=i.alternate;re(ft,ft.current&1),re(fn,i),Dn===null&&(s===null||lr.current!==null||s.memoizedState!==null)&&(Dn=i)}function Bm(i){re(ft,ft.current),re(fn,i),Dn===null&&(Dn=i)}function Fk(i){i.tag===22?(re(ft,ft.current),re(fn,i),Dn===null&&(Dn=i)):va()}function va(){re(ft,ft.current),re(fn,fn.current)}function hn(i){Z(fn),Dn===i&&(Dn=null),Z(ft)}var ft=D(0);function zl(i){for(var s=i;s!==null;){if(s.tag===13){var o=s.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||Hp(o)||Gp(o)))return s}else if(s.tag===19&&(s.memoizedProps.revealOrder==="forwards"||s.memoizedProps.revealOrder==="backwards"||s.memoizedProps.revealOrder==="unstable_legacy-backwards"||s.memoizedProps.revealOrder==="together")){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var wi=0,ke=null,He=null,yt=null,Fl=!1,ur=!1,rs=!1,ql=0,Lo=0,dr=null,CU=0;function ct(){throw Error(a(321))}function jm(i,s){if(s===null)return!1;for(var o=0;o<s.length&&o<i.length;o++)if(!un(i[o],s[o]))return!1;return!0}function Vm(i,s,o,d,m,g){return wi=g,ke=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,H.H=i===null||i.memoizedState===null?wE:tp,rs=!1,g=o(d,m),rs=!1,ur&&(g=Hk(s,o,d,m)),qk(i),g}function qk(i){H.H=Bo;var s=He!==null&&He.next!==null;if(wi=0,yt=He=ke=null,Fl=!1,Lo=0,dr=null,s)throw Error(a(300));i===null||bt||(i=i.dependencies,i!==null&&Pl(i)&&(bt=!0))}function Hk(i,s,o,d){ke=i;var m=0;do{if(ur&&(dr=null),Lo=0,ur=!1,25<=m)throw Error(a(301));if(m+=1,yt=He=null,i.updateQueue!=null){var g=i.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}H.H=RE,g=s(o,d)}while(ur);return g}function kU(){var i=H.H,s=i.useState()[0];return s=typeof s.then=="function"?Io(s):s,i=i.useState()[0],(He!==null?He.memoizedState:null)!==i&&(ke.flags|=1024),s}function zm(){var i=ql!==0;return ql=0,i}function Fm(i,s,o){s.updateQueue=i.updateQueue,s.flags&=-2053,i.lanes&=~o}function qm(i){if(Fl){for(i=i.memoizedState;i!==null;){var s=i.queue;s!==null&&(s.pending=null),i=i.next}Fl=!1}wi=0,yt=He=ke=null,ur=!1,Lo=ql=0,dr=null}function Gt(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return yt===null?ke.memoizedState=yt=i:yt=yt.next=i,yt}function ht(){if(He===null){var i=ke.alternate;i=i!==null?i.memoizedState:null}else i=He.next;var s=yt===null?ke.memoizedState:yt.next;if(s!==null)yt=s,He=i;else{if(i===null)throw ke.alternate===null?Error(a(467)):Error(a(310));He=i,i={memoizedState:He.memoizedState,baseState:He.baseState,baseQueue:He.baseQueue,queue:He.queue,next:null},yt===null?ke.memoizedState=yt=i:yt=yt.next=i}return yt}function Hl(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Io(i){var s=Lo;return Lo+=1,dr===null&&(dr=[]),i=Nk(dr,i,s),s=ke,(yt===null?s.memoizedState:yt.next)===null&&(s=s.alternate,H.H=s===null||s.memoizedState===null?wE:tp),i}function Gl(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Io(i);if(i.$$typeof===L)return Nt(i)}throw Error(a(438,String(i)))}function Hm(i){var s=null,o=ke.updateQueue;if(o!==null&&(s=o.memoCache),s==null){var d=ke.alternate;d!==null&&(d=d.updateQueue,d!==null&&(d=d.memoCache,d!=null&&(s={data:d.data.map(function(m){return m.slice()}),index:0})))}if(s==null&&(s={data:[],index:0}),o===null&&(o=Hl(),ke.updateQueue=o),o.memoCache=s,o=s.data[s.index],o===void 0)for(o=s.data[s.index]=Array(i),d=0;d<i;d++)o[d]=V;return s.index++,o}function Ri(i,s){return typeof s=="function"?s(i):s}function Kl(i){var s=ht();return Gm(s,He,i)}function Gm(i,s,o){var d=i.queue;if(d===null)throw Error(a(311));d.lastRenderedReducer=o;var m=i.baseQueue,g=d.pending;if(g!==null){if(m!==null){var b=m.next;m.next=g.next,g.next=b}s.baseQueue=m=g,d.pending=null}if(g=i.baseState,m===null)i.memoizedState=g;else{s=m.next;var C=b=null,M=null,z=s,J=!1;do{var $=z.lane&-536870913;if($!==z.lane?(Oe&$)===$:(wi&$)===$){var F=z.revertLane;if(F===0)M!==null&&(M=M.next={lane:0,revertLane:0,gesture:null,action:z.action,hasEagerState:z.hasEagerState,eagerState:z.eagerState,next:null}),$===sr&&(J=!0);else if((wi&F)===F){z=z.next,F===sr&&(J=!0);continue}else $={lane:0,revertLane:z.revertLane,gesture:null,action:z.action,hasEagerState:z.hasEagerState,eagerState:z.eagerState,next:null},M===null?(C=M=$,b=g):M=M.next=$,ke.lanes|=F,Sa|=F;$=z.action,rs&&o(g,$),g=z.hasEagerState?z.eagerState:o(g,$)}else F={lane:$,revertLane:z.revertLane,gesture:z.gesture,action:z.action,hasEagerState:z.hasEagerState,eagerState:z.eagerState,next:null},M===null?(C=M=F,b=g):M=M.next=F,ke.lanes|=$,Sa|=$;z=z.next}while(z!==null&&z!==s);if(M===null?b=g:M.next=C,!un(g,i.memoizedState)&&(bt=!0,J&&(o=rr,o!==null)))throw o;i.memoizedState=g,i.baseState=b,i.baseQueue=M,d.lastRenderedState=g}return m===null&&(d.lanes=0),[i.memoizedState,d.dispatch]}function Km(i){var s=ht(),o=s.queue;if(o===null)throw Error(a(311));o.lastRenderedReducer=i;var d=o.dispatch,m=o.pending,g=s.memoizedState;if(m!==null){o.pending=null;var b=m=m.next;do g=i(g,b.action),b=b.next;while(b!==m);un(g,s.memoizedState)||(bt=!0),s.memoizedState=g,s.baseQueue===null&&(s.baseState=g),o.lastRenderedState=g}return[g,d]}function Gk(i,s,o){var d=ke,m=ht(),g=Le;if(g){if(o===void 0)throw Error(a(407));o=o()}else o=s();var b=!un((He||m).memoizedState,o);if(b&&(m.memoizedState=o,bt=!0),m=m.queue,Qm(Xk.bind(null,d,m,i),[i]),m.getSnapshot!==s||b||yt!==null&&yt.memoizedState.tag&1){if(d.flags|=2048,fr(9,{destroy:void 0},Yk.bind(null,d,m,o,s),null),Je===null)throw Error(a(349));g||(wi&127)!==0||Kk(d,s,o)}return o}function Kk(i,s,o){i.flags|=16384,i={getSnapshot:s,value:o},s=ke.updateQueue,s===null?(s=Hl(),ke.updateQueue=s,s.stores=[i]):(o=s.stores,o===null?s.stores=[i]:o.push(i))}function Yk(i,s,o,d){s.value=o,s.getSnapshot=d,Qk(s)&&Jk(i)}function Xk(i,s,o){return o(function(){Qk(s)&&Jk(i)})}function Qk(i){var s=i.getSnapshot;i=i.value;try{var o=s();return!un(i,o)}catch{return!0}}function Jk(i){var s=Za(i,2);s!==null&&nn(s,i,2)}function Ym(i){var s=Gt();if(typeof i=="function"){var o=i;if(i=o(),rs){ra(!0);try{o()}finally{ra(!1)}}}return s.memoizedState=s.baseState=i,s.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ri,lastRenderedState:i},s}function Zk(i,s,o,d){return i.baseState=o,Gm(i,He,typeof d=="function"?d:Ri)}function EU(i,s,o,d,m){if(Ql(i))throw Error(a(485));if(i=s.action,i!==null){var g={payload:m,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(b){g.listeners.push(b)}};H.T!==null?o(!0):g.isTransition=!1,d(g),o=s.pending,o===null?(g.next=s.pending=g,Wk(s,g)):(g.next=o.next,s.pending=o.next=g)}}function Wk(i,s){var o=s.action,d=s.payload,m=i.state;if(s.isTransition){var g=H.T,b={};H.T=b;try{var C=o(m,d),M=H.S;M!==null&&M(b,C),$k(i,s,C)}catch(z){Xm(i,s,z)}finally{g!==null&&b.types!==null&&(g.types=b.types),H.T=g}}else try{g=o(m,d),$k(i,s,g)}catch(z){Xm(i,s,z)}}function $k(i,s,o){o!==null&&typeof o=="object"&&typeof o.then=="function"?o.then(function(d){eE(i,s,d)},function(d){return Xm(i,s,d)}):eE(i,s,o)}function eE(i,s,o){s.status="fulfilled",s.value=o,tE(s),i.state=o,s=i.pending,s!==null&&(o=s.next,o===s?i.pending=null:(o=o.next,s.next=o,Wk(i,o)))}function Xm(i,s,o){var d=i.pending;if(i.pending=null,d!==null){d=d.next;do s.status="rejected",s.reason=o,tE(s),s=s.next;while(s!==d)}i.action=null}function tE(i){i=i.listeners;for(var s=0;s<i.length;s++)(0,i[s])()}function nE(i,s){return s}function iE(i,s){if(Le){var o=Je.formState;if(o!==null){e:{var d=ke;if(Le){if(We){t:{for(var m=We,g=Mn;m.nodeType!==8;){if(!g){m=null;break t}if(m=On(m.nextSibling),m===null){m=null;break t}}g=m.data,m=g==="F!"||g==="F"?m:null}if(m){We=On(m.nextSibling),d=m.data==="F!";break e}}da(d)}d=!1}d&&(s=o[0])}}return o=Gt(),o.memoizedState=o.baseState=s,d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:nE,lastRenderedState:s},o.queue=d,o=CE.bind(null,ke,d),d.dispatch=o,d=Ym(!1),g=ep.bind(null,ke,!1,d.queue),d=Gt(),m={state:s,dispatch:null,action:i,pending:null},d.queue=m,o=EU.bind(null,ke,m,g,o),m.dispatch=o,d.memoizedState=i,[s,o,!1]}function aE(i){var s=ht();return sE(s,He,i)}function sE(i,s,o){if(s=Gm(i,s,nE)[0],i=Kl(Ri)[0],typeof s=="object"&&s!==null&&typeof s.then=="function")try{var d=Io(s)}catch(b){throw b===or?Il:b}else d=s;s=ht();var m=s.queue,g=m.dispatch;return o!==s.memoizedState&&(ke.flags|=2048,fr(9,{destroy:void 0},wU.bind(null,m,o),null)),[d,g,i]}function wU(i,s){i.action=s}function rE(i){var s=ht(),o=He;if(o!==null)return sE(s,o,i);ht(),s=s.memoizedState,o=ht();var d=o.queue.dispatch;return o.memoizedState=i,[s,d,!1]}function fr(i,s,o,d){return i={tag:i,create:o,deps:d,inst:s,next:null},s=ke.updateQueue,s===null&&(s=Hl(),ke.updateQueue=s),o=s.lastEffect,o===null?s.lastEffect=i.next=i:(d=o.next,o.next=i,i.next=d,s.lastEffect=i),i}function oE(){return ht().memoizedState}function Yl(i,s,o,d){var m=Gt();ke.flags|=i,m.memoizedState=fr(1|s,{destroy:void 0},o,d===void 0?null:d)}function Xl(i,s,o,d){var m=ht();d=d===void 0?null:d;var g=m.memoizedState.inst;He!==null&&d!==null&&jm(d,He.memoizedState.deps)?m.memoizedState=fr(s,g,o,d):(ke.flags|=i,m.memoizedState=fr(1|s,g,o,d))}function cE(i,s){Yl(8390656,8,i,s)}function Qm(i,s){Xl(2048,8,i,s)}function RU(i){ke.flags|=4;var s=ke.updateQueue;if(s===null)s=Hl(),ke.updateQueue=s,s.events=[i];else{var o=s.events;o===null?s.events=[i]:o.push(i)}}function lE(i){var s=ht().memoizedState;return RU({ref:s,nextImpl:i}),function(){if((je&2)!==0)throw Error(a(440));return s.impl.apply(void 0,arguments)}}function uE(i,s){return Xl(4,2,i,s)}function dE(i,s){return Xl(4,4,i,s)}function fE(i,s){if(typeof s=="function"){i=i();var o=s(i);return function(){typeof o=="function"?o():s(null)}}if(s!=null)return i=i(),s.current=i,function(){s.current=null}}function hE(i,s,o){o=o!=null?o.concat([i]):null,Xl(4,4,fE.bind(null,s,i),o)}function Jm(){}function mE(i,s){var o=ht();s=s===void 0?null:s;var d=o.memoizedState;return s!==null&&jm(s,d[1])?d[0]:(o.memoizedState=[i,s],i)}function pE(i,s){var o=ht();s=s===void 0?null:s;var d=o.memoizedState;if(s!==null&&jm(s,d[1]))return d[0];if(d=i(),rs){ra(!0);try{i()}finally{ra(!1)}}return o.memoizedState=[d,s],d}function Zm(i,s,o){return o===void 0||(wi&1073741824)!==0&&(Oe&261930)===0?i.memoizedState=s:(i.memoizedState=o,i=g1(),ke.lanes|=i,Sa|=i,o)}function gE(i,s,o,d){return un(o,s)?o:lr.current!==null?(i=Zm(i,o,d),un(i,s)||(bt=!0),i):(wi&42)===0||(wi&1073741824)!==0&&(Oe&261930)===0?(bt=!0,i.memoizedState=o):(i=g1(),ke.lanes|=i,Sa|=i,s)}function vE(i,s,o,d,m){var g=ne.p;ne.p=g!==0&&8>g?g:8;var b=H.T,C={};H.T=C,ep(i,!1,s,o);try{var M=m(),z=H.S;if(z!==null&&z(C,M),M!==null&&typeof M=="object"&&typeof M.then=="function"){var J=TU(M,d);Uo(i,s,J,gn(i))}else Uo(i,s,d,gn(i))}catch($){Uo(i,s,{then:function(){},status:"rejected",reason:$},gn())}finally{ne.p=g,b!==null&&C.types!==null&&(b.types=C.types),H.T=b}}function _U(){}function Wm(i,s,o,d){if(i.tag!==5)throw Error(a(476));var m=yE(i).queue;vE(i,m,s,ce,o===null?_U:function(){return bE(i),o(d)})}function yE(i){var s=i.memoizedState;if(s!==null)return s;s={memoizedState:ce,baseState:ce,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ri,lastRenderedState:ce},next:null};var o={};return s.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ri,lastRenderedState:o},next:null},i.memoizedState=s,i=i.alternate,i!==null&&(i.memoizedState=s),s}function bE(i){var s=yE(i);s.next===null&&(s=i.alternate.memoizedState),Uo(i,s.next.queue,{},gn())}function $m(){return Nt(ec)}function SE(){return ht().memoizedState}function TE(){return ht().memoizedState}function xU(i){for(var s=i.return;s!==null;){switch(s.tag){case 24:case 3:var o=gn();i=ma(o);var d=pa(s,i,o);d!==null&&(nn(d,s,o),Oo(d,s,o)),s={cache:xm()},i.payload=s;return}s=s.return}}function AU(i,s,o){var d=gn();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Ql(i)?kE(s,o):(o=vm(i,s,o,d),o!==null&&(nn(o,i,d),EE(o,s,d)))}function CE(i,s,o){var d=gn();Uo(i,s,o,d)}function Uo(i,s,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Ql(i))kE(s,m);else{var g=i.alternate;if(i.lanes===0&&(g===null||g.lanes===0)&&(g=s.lastRenderedReducer,g!==null))try{var b=s.lastRenderedState,C=g(b,o);if(m.hasEagerState=!0,m.eagerState=C,un(C,b))return Al(i,s,m,0),Je===null&&xl(),!1}catch{}if(o=vm(i,s,m,d),o!==null)return nn(o,i,d),EE(o,s,d),!0}return!1}function ep(i,s,o,d){if(d={lane:2,revertLane:Op(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Ql(i)){if(s)throw Error(a(479))}else s=vm(i,o,d,2),s!==null&&nn(s,i,2)}function Ql(i){var s=i.alternate;return i===ke||s!==null&&s===ke}function kE(i,s){ur=Fl=!0;var o=i.pending;o===null?s.next=s:(s.next=o.next,o.next=s),i.pending=s}function EE(i,s,o){if((o&4194048)!==0){var d=s.lanes;d&=i.pendingLanes,o|=d,s.lanes=o,AC(i,o)}}var Bo={readContext:Nt,use:Gl,useCallback:ct,useContext:ct,useEffect:ct,useImperativeHandle:ct,useLayoutEffect:ct,useInsertionEffect:ct,useMemo:ct,useReducer:ct,useRef:ct,useState:ct,useDebugValue:ct,useDeferredValue:ct,useTransition:ct,useSyncExternalStore:ct,useId:ct,useHostTransitionStatus:ct,useFormState:ct,useActionState:ct,useOptimistic:ct,useMemoCache:ct,useCacheRefresh:ct};Bo.useEffectEvent=ct;var wE={readContext:Nt,use:Gl,useCallback:function(i,s){return Gt().memoizedState=[i,s===void 0?null:s],i},useContext:Nt,useEffect:cE,useImperativeHandle:function(i,s,o){o=o!=null?o.concat([i]):null,Yl(4194308,4,fE.bind(null,s,i),o)},useLayoutEffect:function(i,s){return Yl(4194308,4,i,s)},useInsertionEffect:function(i,s){Yl(4,2,i,s)},useMemo:function(i,s){var o=Gt();s=s===void 0?null:s;var d=i();if(rs){ra(!0);try{i()}finally{ra(!1)}}return o.memoizedState=[d,s],d},useReducer:function(i,s,o){var d=Gt();if(o!==void 0){var m=o(s);if(rs){ra(!0);try{o(s)}finally{ra(!1)}}}else m=s;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=AU.bind(null,ke,i),[d.memoizedState,i]},useRef:function(i){var s=Gt();return i={current:i},s.memoizedState=i},useState:function(i){i=Ym(i);var s=i.queue,o=CE.bind(null,ke,s);return s.dispatch=o,[i.memoizedState,o]},useDebugValue:Jm,useDeferredValue:function(i,s){var o=Gt();return Zm(o,i,s)},useTransition:function(){var i=Ym(!1);return i=vE.bind(null,ke,i.queue,!0,!1),Gt().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,s,o){var d=ke,m=Gt();if(Le){if(o===void 0)throw Error(a(407));o=o()}else{if(o=s(),Je===null)throw Error(a(349));(Oe&127)!==0||Kk(d,s,o)}m.memoizedState=o;var g={value:o,getSnapshot:s};return m.queue=g,cE(Xk.bind(null,d,g,i),[i]),d.flags|=2048,fr(9,{destroy:void 0},Yk.bind(null,d,g,o,s),null),o},useId:function(){var i=Gt(),s=Je.identifierPrefix;if(Le){var o=si,d=ai;o=(d&~(1<<32-ln(d)-1)).toString(32)+o,s="_"+s+"R_"+o,o=ql++,0<o&&(s+="H"+o.toString(32)),s+="_"}else o=CU++,s="_"+s+"r_"+o.toString(32)+"_";return i.memoizedState=s},useHostTransitionStatus:$m,useFormState:iE,useActionState:iE,useOptimistic:function(i){var s=Gt();s.memoizedState=s.baseState=i;var o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return s.queue=o,s=ep.bind(null,ke,!0,o),o.dispatch=s,[i,s]},useMemoCache:Hm,useCacheRefresh:function(){return Gt().memoizedState=xU.bind(null,ke)},useEffectEvent:function(i){var s=Gt(),o={impl:i};return s.memoizedState=o,function(){if((je&2)!==0)throw Error(a(440));return o.impl.apply(void 0,arguments)}}},tp={readContext:Nt,use:Gl,useCallback:mE,useContext:Nt,useEffect:Qm,useImperativeHandle:hE,useInsertionEffect:uE,useLayoutEffect:dE,useMemo:pE,useReducer:Kl,useRef:oE,useState:function(){return Kl(Ri)},useDebugValue:Jm,useDeferredValue:function(i,s){var o=ht();return gE(o,He.memoizedState,i,s)},useTransition:function(){var i=Kl(Ri)[0],s=ht().memoizedState;return[typeof i=="boolean"?i:Io(i),s]},useSyncExternalStore:Gk,useId:SE,useHostTransitionStatus:$m,useFormState:aE,useActionState:aE,useOptimistic:function(i,s){var o=ht();return Zk(o,He,i,s)},useMemoCache:Hm,useCacheRefresh:TE};tp.useEffectEvent=lE;var RE={readContext:Nt,use:Gl,useCallback:mE,useContext:Nt,useEffect:Qm,useImperativeHandle:hE,useInsertionEffect:uE,useLayoutEffect:dE,useMemo:pE,useReducer:Km,useRef:oE,useState:function(){return Km(Ri)},useDebugValue:Jm,useDeferredValue:function(i,s){var o=ht();return He===null?Zm(o,i,s):gE(o,He.memoizedState,i,s)},useTransition:function(){var i=Km(Ri)[0],s=ht().memoizedState;return[typeof i=="boolean"?i:Io(i),s]},useSyncExternalStore:Gk,useId:SE,useHostTransitionStatus:$m,useFormState:rE,useActionState:rE,useOptimistic:function(i,s){var o=ht();return He!==null?Zk(o,He,i,s):(o.baseState=i,[i,o.queue.dispatch])},useMemoCache:Hm,useCacheRefresh:TE};RE.useEffectEvent=lE;function np(i,s,o,d){s=i.memoizedState,o=o(d,s),o=o==null?s:v({},s,o),i.memoizedState=o,i.lanes===0&&(i.updateQueue.baseState=o)}var ip={enqueueSetState:function(i,s,o){i=i._reactInternals;var d=gn(),m=ma(d);m.payload=s,o!=null&&(m.callback=o),s=pa(i,m,d),s!==null&&(nn(s,i,d),Oo(s,i,d))},enqueueReplaceState:function(i,s,o){i=i._reactInternals;var d=gn(),m=ma(d);m.tag=1,m.payload=s,o!=null&&(m.callback=o),s=pa(i,m,d),s!==null&&(nn(s,i,d),Oo(s,i,d))},enqueueForceUpdate:function(i,s){i=i._reactInternals;var o=gn(),d=ma(o);d.tag=2,s!=null&&(d.callback=s),s=pa(i,d,o),s!==null&&(nn(s,i,o),Oo(s,i,o))}};function _E(i,s,o,d,m,g,b){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(d,g,b):s.prototype&&s.prototype.isPureReactComponent?!Eo(o,d)||!Eo(m,g):!0}function xE(i,s,o,d){i=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(o,d),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(o,d),s.state!==i&&ip.enqueueReplaceState(s,s.state,null)}function os(i,s){var o=s;if("ref"in s){o={};for(var d in s)d!=="ref"&&(o[d]=s[d])}if(i=i.defaultProps){o===s&&(o=v({},o));for(var m in i)o[m]===void 0&&(o[m]=i[m])}return o}function AE(i){_l(i)}function ME(i){console.error(i)}function DE(i){_l(i)}function Jl(i,s){try{var o=i.onUncaughtError;o(s.value,{componentStack:s.stack})}catch(d){setTimeout(function(){throw d})}}function OE(i,s,o){try{var d=i.onCaughtError;d(o.value,{componentStack:o.stack,errorBoundary:s.tag===1?s.stateNode:null})}catch(m){setTimeout(function(){throw m})}}function ap(i,s,o){return o=ma(o),o.tag=3,o.payload={element:null},o.callback=function(){Jl(i,s)},o}function PE(i){return i=ma(i),i.tag=3,i}function NE(i,s,o,d){var m=o.type.getDerivedStateFromError;if(typeof m=="function"){var g=d.value;i.payload=function(){return m(g)},i.callback=function(){OE(s,o,d)}}var b=o.stateNode;b!==null&&typeof b.componentDidCatch=="function"&&(i.callback=function(){OE(s,o,d),typeof m!="function"&&(Ta===null?Ta=new Set([this]):Ta.add(this));var C=d.stack;this.componentDidCatch(d.value,{componentStack:C!==null?C:""})})}function MU(i,s,o,d,m){if(o.flags|=32768,d!==null&&typeof d=="object"&&typeof d.then=="function"){if(s=o.alternate,s!==null&&ar(s,o,m,!0),o=fn.current,o!==null){switch(o.tag){case 31:case 13:return Dn===null?cu():o.alternate===null&<===0&&(lt=3),o.flags&=-257,o.flags|=65536,o.lanes=m,d===Ul?o.flags|=16384:(s=o.updateQueue,s===null?o.updateQueue=new Set([d]):s.add(d),Ap(i,d,m)),!1;case 22:return o.flags|=65536,d===Ul?o.flags|=16384:(s=o.updateQueue,s===null?(s={transitions:null,markerInstances:null,retryQueue:new Set([d])},o.updateQueue=s):(o=s.retryQueue,o===null?s.retryQueue=new Set([d]):o.add(d)),Ap(i,d,m)),!1}throw Error(a(435,o.tag))}return Ap(i,d,m),cu(),!1}if(Le)return s=fn.current,s!==null?((s.flags&65536)===0&&(s.flags|=256),s.flags|=65536,s.lanes=m,d!==km&&(i=Error(a(422),{cause:d}),_o(_n(i,o)))):(d!==km&&(s=Error(a(423),{cause:d}),_o(_n(s,o))),i=i.current.alternate,i.flags|=65536,m&=-m,i.lanes|=m,d=_n(d,o),m=ap(i.stateNode,d,m),Nm(i,m),lt!==4&&(lt=2)),!1;var g=Error(a(520),{cause:d});if(g=_n(g,o),Ko===null?Ko=[g]:Ko.push(g),lt!==4&&(lt=2),s===null)return!0;d=_n(d,o),o=s;do{switch(o.tag){case 3:return o.flags|=65536,i=m&-m,o.lanes|=i,i=ap(o.stateNode,d,i),Nm(o,i),!1;case 1:if(s=o.type,g=o.stateNode,(o.flags&128)===0&&(typeof s.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(Ta===null||!Ta.has(g))))return o.flags|=65536,m&=-m,o.lanes|=m,m=PE(m),NE(m,i,o,d),Nm(o,m),!1}o=o.return}while(o!==null);return!1}var sp=Error(a(461)),bt=!1;function Lt(i,s,o,d){s.child=i===null?Bk(s,null,o,d):ss(s,i.child,o,d)}function LE(i,s,o,d,m){o=o.render;var g=s.ref;if("ref"in d){var b={};for(var C in d)C!=="ref"&&(b[C]=d[C])}else b=d;return ts(s),d=Vm(i,s,o,b,g,m),C=zm(),i!==null&&!bt?(Fm(i,s,m),_i(i,s,m)):(Le&&C&&Tm(s),s.flags|=1,Lt(i,s,d,m),s.child)}function IE(i,s,o,d,m){if(i===null){var g=o.type;return typeof g=="function"&&!ym(g)&&g.defaultProps===void 0&&o.compare===null?(s.tag=15,s.type=g,UE(i,s,g,d,m)):(i=Dl(o.type,null,d,s,s.mode,m),i.ref=s.ref,i.return=s,s.child=i)}if(g=i.child,!hp(i,m)){var b=g.memoizedProps;if(o=o.compare,o=o!==null?o:Eo,o(b,d)&&i.ref===s.ref)return _i(i,s,m)}return s.flags|=1,i=Ti(g,d),i.ref=s.ref,i.return=s,s.child=i}function UE(i,s,o,d,m){if(i!==null){var g=i.memoizedProps;if(Eo(g,d)&&i.ref===s.ref)if(bt=!1,s.pendingProps=d=g,hp(i,m))(i.flags&131072)!==0&&(bt=!0);else return s.lanes=i.lanes,_i(i,s,m)}return rp(i,s,o,d,m)}function BE(i,s,o,d){var m=d.children,g=i!==null?i.memoizedState:null;if(i===null&&s.stateNode===null&&(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),d.mode==="hidden"){if((s.flags&128)!==0){if(g=g!==null?g.baseLanes|o:o,i!==null){for(d=s.child=i.child,m=0;d!==null;)m=m|d.lanes|d.childLanes,d=d.sibling;d=m&~g}else d=0,s.child=null;return jE(i,s,g,o,d)}if((o&536870912)!==0)s.memoizedState={baseLanes:0,cachePool:null},i!==null&&Ll(s,g!==null?g.cachePool:null),g!==null?zk(s,g):Im(),Fk(s);else return d=s.lanes=536870912,jE(i,s,g!==null?g.baseLanes|o:o,o,d)}else g!==null?(Ll(s,g.cachePool),zk(s,g),va(),s.memoizedState=null):(i!==null&&Ll(s,null),Im(),va());return Lt(i,s,m,o),s.child}function jo(i,s){return i!==null&&i.tag===22||s.stateNode!==null||(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.sibling}function jE(i,s,o,d,m){var g=Mm();return g=g===null?null:{parent:vt._currentValue,pool:g},s.memoizedState={baseLanes:o,cachePool:g},i!==null&&Ll(s,null),Im(),Fk(s),i!==null&&ar(i,s,d,!0),s.childLanes=m,null}function Zl(i,s){return s=$l({mode:s.mode,children:s.children},i.mode),s.ref=i.ref,i.child=s,s.return=i,s}function VE(i,s,o){return ss(s,i.child,null,o),i=Zl(s,s.pendingProps),i.flags|=2,hn(s),s.memoizedState=null,i}function DU(i,s,o){var d=s.pendingProps,m=(s.flags&128)!==0;if(s.flags&=-129,i===null){if(Le){if(d.mode==="hidden")return i=Zl(s,d),s.lanes=536870912,jo(null,i);if(Bm(s),(i=We)?(i=W1(i,Mn),i=i!==null&&i.data==="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:la!==null?{id:ai,overflow:si}:null,retryLane:536870912,hydrationErrors:null},o=kk(i),o.return=s,s.child=o,Pt=s,We=null)):i=null,i===null)throw da(s);return s.lanes=536870912,null}return Zl(s,d)}var g=i.memoizedState;if(g!==null){var b=g.dehydrated;if(Bm(s),m)if(s.flags&256)s.flags&=-257,s=VE(i,s,o);else if(s.memoizedState!==null)s.child=i.child,s.flags|=128,s=null;else throw Error(a(558));else if(bt||ar(i,s,o,!1),m=(o&i.childLanes)!==0,bt||m){if(d=Je,d!==null&&(b=MC(d,o),b!==0&&b!==g.retryLane))throw g.retryLane=b,Za(i,b),nn(d,i,b),sp;cu(),s=VE(i,s,o)}else i=g.treeContext,We=On(b.nextSibling),Pt=s,Le=!0,ua=null,Mn=!1,i!==null&&Rk(s,i),s=Zl(s,d),s.flags|=4096;return s}return i=Ti(i.child,{mode:d.mode,children:d.children}),i.ref=s.ref,s.child=i,i.return=s,i}function Wl(i,s){var o=s.ref;if(o===null)i!==null&&i.ref!==null&&(s.flags|=4194816);else{if(typeof o!="function"&&typeof o!="object")throw Error(a(284));(i===null||i.ref!==o)&&(s.flags|=4194816)}}function rp(i,s,o,d,m){return ts(s),o=Vm(i,s,o,d,void 0,m),d=zm(),i!==null&&!bt?(Fm(i,s,m),_i(i,s,m)):(Le&&d&&Tm(s),s.flags|=1,Lt(i,s,o,m),s.child)}function zE(i,s,o,d,m,g){return ts(s),s.updateQueue=null,o=Hk(s,d,o,m),qk(i),d=zm(),i!==null&&!bt?(Fm(i,s,g),_i(i,s,g)):(Le&&d&&Tm(s),s.flags|=1,Lt(i,s,o,g),s.child)}function FE(i,s,o,d,m){if(ts(s),s.stateNode===null){var g=er,b=o.contextType;typeof b=="object"&&b!==null&&(g=Nt(b)),g=new o(d,g),s.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=ip,s.stateNode=g,g._reactInternals=s,g=s.stateNode,g.props=d,g.state=s.memoizedState,g.refs={},Om(s),b=o.contextType,g.context=typeof b=="object"&&b!==null?Nt(b):er,g.state=s.memoizedState,b=o.getDerivedStateFromProps,typeof b=="function"&&(np(s,o,b,d),g.state=s.memoizedState),typeof o.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(b=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),b!==g.state&&ip.enqueueReplaceState(g,g.state,null),No(s,d,g,m),Po(),g.state=s.memoizedState),typeof g.componentDidMount=="function"&&(s.flags|=4194308),d=!0}else if(i===null){g=s.stateNode;var C=s.memoizedProps,M=os(o,C);g.props=M;var z=g.context,J=o.contextType;b=er,typeof J=="object"&&J!==null&&(b=Nt(J));var $=o.getDerivedStateFromProps;J=typeof $=="function"||typeof g.getSnapshotBeforeUpdate=="function",C=s.pendingProps!==C,J||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(C||z!==b)&&xE(s,g,d,b),ha=!1;var F=s.memoizedState;g.state=F,No(s,d,g,m),Po(),z=s.memoizedState,C||F!==z||ha?(typeof $=="function"&&(np(s,o,$,d),z=s.memoizedState),(M=ha||_E(s,o,M,d,F,z,b))?(J||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount()),typeof g.componentDidMount=="function"&&(s.flags|=4194308)):(typeof g.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=d,s.memoizedState=z),g.props=d,g.state=z,g.context=b,d=M):(typeof g.componentDidMount=="function"&&(s.flags|=4194308),d=!1)}else{g=s.stateNode,Pm(i,s),b=s.memoizedProps,J=os(o,b),g.props=J,$=s.pendingProps,F=g.context,z=o.contextType,M=er,typeof z=="object"&&z!==null&&(M=Nt(z)),C=o.getDerivedStateFromProps,(z=typeof C=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(b!==$||F!==M)&&xE(s,g,d,M),ha=!1,F=s.memoizedState,g.state=F,No(s,d,g,m),Po();var K=s.memoizedState;b!==$||F!==K||ha||i!==null&&i.dependencies!==null&&Pl(i.dependencies)?(typeof C=="function"&&(np(s,o,C,d),K=s.memoizedState),(J=ha||_E(s,o,J,d,F,K,M)||i!==null&&i.dependencies!==null&&Pl(i.dependencies))?(z||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(d,K,M),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(d,K,M)),typeof g.componentDidUpdate=="function"&&(s.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof g.componentDidUpdate!="function"||b===i.memoizedProps&&F===i.memoizedState||(s.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||b===i.memoizedProps&&F===i.memoizedState||(s.flags|=1024),s.memoizedProps=d,s.memoizedState=K),g.props=d,g.state=K,g.context=M,d=J):(typeof g.componentDidUpdate!="function"||b===i.memoizedProps&&F===i.memoizedState||(s.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||b===i.memoizedProps&&F===i.memoizedState||(s.flags|=1024),d=!1)}return g=d,Wl(i,s),d=(s.flags&128)!==0,g||d?(g=s.stateNode,o=d&&typeof o.getDerivedStateFromError!="function"?null:g.render(),s.flags|=1,i!==null&&d?(s.child=ss(s,i.child,null,m),s.child=ss(s,null,o,m)):Lt(i,s,o,m),s.memoizedState=g.state,i=s.child):i=_i(i,s,m),i}function qE(i,s,o,d){return $a(),s.flags|=256,Lt(i,s,o,d),s.child}var op={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function cp(i){return{baseLanes:i,cachePool:Ok()}}function lp(i,s,o){return i=i!==null?i.childLanes&~o:0,s&&(i|=pn),i}function HE(i,s,o){var d=s.pendingProps,m=!1,g=(s.flags&128)!==0,b;if((b=g)||(b=i!==null&&i.memoizedState===null?!1:(ft.current&2)!==0),b&&(m=!0,s.flags&=-129),b=(s.flags&32)!==0,s.flags&=-33,i===null){if(Le){if(m?ga(s):va(),(i=We)?(i=W1(i,Mn),i=i!==null&&i.data!=="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:la!==null?{id:ai,overflow:si}:null,retryLane:536870912,hydrationErrors:null},o=kk(i),o.return=s,s.child=o,Pt=s,We=null)):i=null,i===null)throw da(s);return Gp(i)?s.lanes=32:s.lanes=536870912,null}var C=d.children;return d=d.fallback,m?(va(),m=s.mode,C=$l({mode:"hidden",children:C},m),d=Wa(d,m,o,null),C.return=s,d.return=s,C.sibling=d,s.child=C,d=s.child,d.memoizedState=cp(o),d.childLanes=lp(i,b,o),s.memoizedState=op,jo(null,d)):(ga(s),up(s,C))}var M=i.memoizedState;if(M!==null&&(C=M.dehydrated,C!==null)){if(g)s.flags&256?(ga(s),s.flags&=-257,s=dp(i,s,o)):s.memoizedState!==null?(va(),s.child=i.child,s.flags|=128,s=null):(va(),C=d.fallback,m=s.mode,d=$l({mode:"visible",children:d.children},m),C=Wa(C,m,o,null),C.flags|=2,d.return=s,C.return=s,d.sibling=C,s.child=d,ss(s,i.child,null,o),d=s.child,d.memoizedState=cp(o),d.childLanes=lp(i,b,o),s.memoizedState=op,s=jo(null,d));else if(ga(s),Gp(C)){if(b=C.nextSibling&&C.nextSibling.dataset,b)var z=b.dgst;b=z,d=Error(a(419)),d.stack="",d.digest=b,_o({value:d,source:null,stack:null}),s=dp(i,s,o)}else if(bt||ar(i,s,o,!1),b=(o&i.childLanes)!==0,bt||b){if(b=Je,b!==null&&(d=MC(b,o),d!==0&&d!==M.retryLane))throw M.retryLane=d,Za(i,d),nn(b,i,d),sp;Hp(C)||cu(),s=dp(i,s,o)}else Hp(C)?(s.flags|=192,s.child=i.child,s=null):(i=M.treeContext,We=On(C.nextSibling),Pt=s,Le=!0,ua=null,Mn=!1,i!==null&&Rk(s,i),s=up(s,d.children),s.flags|=4096);return s}return m?(va(),C=d.fallback,m=s.mode,M=i.child,z=M.sibling,d=Ti(M,{mode:"hidden",children:d.children}),d.subtreeFlags=M.subtreeFlags&65011712,z!==null?C=Ti(z,C):(C=Wa(C,m,o,null),C.flags|=2),C.return=s,d.return=s,d.sibling=C,s.child=d,jo(null,d),d=s.child,C=i.child.memoizedState,C===null?C=cp(o):(m=C.cachePool,m!==null?(M=vt._currentValue,m=m.parent!==M?{parent:M,pool:M}:m):m=Ok(),C={baseLanes:C.baseLanes|o,cachePool:m}),d.memoizedState=C,d.childLanes=lp(i,b,o),s.memoizedState=op,jo(i.child,d)):(ga(s),o=i.child,i=o.sibling,o=Ti(o,{mode:"visible",children:d.children}),o.return=s,o.sibling=null,i!==null&&(b=s.deletions,b===null?(s.deletions=[i],s.flags|=16):b.push(i)),s.child=o,s.memoizedState=null,o)}function up(i,s){return s=$l({mode:"visible",children:s},i.mode),s.return=i,i.child=s}function $l(i,s){return i=dn(22,i,null,s),i.lanes=0,i}function dp(i,s,o){return ss(s,i.child,null,o),i=up(s,s.pendingProps.children),i.flags|=2,s.memoizedState=null,i}function GE(i,s,o){i.lanes|=s;var d=i.alternate;d!==null&&(d.lanes|=s),Rm(i.return,s,o)}function fp(i,s,o,d,m,g){var b=i.memoizedState;b===null?i.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:d,tail:o,tailMode:m,treeForkCount:g}:(b.isBackwards=s,b.rendering=null,b.renderingStartTime=0,b.last=d,b.tail=o,b.tailMode=m,b.treeForkCount=g)}function KE(i,s,o){var d=s.pendingProps,m=d.revealOrder,g=d.tail;d=d.children;var b=ft.current,C=(b&2)!==0;if(C?(b=b&1|2,s.flags|=128):b&=1,re(ft,b),Lt(i,s,d,o),d=Le?Ro:0,!C&&i!==null&&(i.flags&128)!==0)e:for(i=s.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&GE(i,o,s);else if(i.tag===19)GE(i,o,s);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===s)break e;for(;i.sibling===null;){if(i.return===null||i.return===s)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(m){case"forwards":for(o=s.child,m=null;o!==null;)i=o.alternate,i!==null&&zl(i)===null&&(m=o),o=o.sibling;o=m,o===null?(m=s.child,s.child=null):(m=o.sibling,o.sibling=null),fp(s,!1,m,o,g,d);break;case"backwards":case"unstable_legacy-backwards":for(o=null,m=s.child,s.child=null;m!==null;){if(i=m.alternate,i!==null&&zl(i)===null){s.child=m;break}i=m.sibling,m.sibling=o,o=m,m=i}fp(s,!0,o,null,g,d);break;case"together":fp(s,!1,null,null,void 0,d);break;default:s.memoizedState=null}return s.child}function _i(i,s,o){if(i!==null&&(s.dependencies=i.dependencies),Sa|=s.lanes,(o&s.childLanes)===0)if(i!==null){if(ar(i,s,o,!1),(o&s.childLanes)===0)return null}else return null;if(i!==null&&s.child!==i.child)throw Error(a(153));if(s.child!==null){for(i=s.child,o=Ti(i,i.pendingProps),s.child=o,o.return=s;i.sibling!==null;)i=i.sibling,o=o.sibling=Ti(i,i.pendingProps),o.return=s;o.sibling=null}return s.child}function hp(i,s){return(i.lanes&s)!==0?!0:(i=i.dependencies,!!(i!==null&&Pl(i)))}function OU(i,s,o){switch(s.tag){case 3:tt(s,s.stateNode.containerInfo),fa(s,vt,i.memoizedState.cache),$a();break;case 27:case 5:sa(s);break;case 4:tt(s,s.stateNode.containerInfo);break;case 10:fa(s,s.type,s.memoizedProps.value);break;case 31:if(s.memoizedState!==null)return s.flags|=128,Bm(s),null;break;case 13:var d=s.memoizedState;if(d!==null)return d.dehydrated!==null?(ga(s),s.flags|=128,null):(o&s.child.childLanes)!==0?HE(i,s,o):(ga(s),i=_i(i,s,o),i!==null?i.sibling:null);ga(s);break;case 19:var m=(i.flags&128)!==0;if(d=(o&s.childLanes)!==0,d||(ar(i,s,o,!1),d=(o&s.childLanes)!==0),m){if(d)return KE(i,s,o);s.flags|=128}if(m=s.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),re(ft,ft.current),d)break;return null;case 22:return s.lanes=0,BE(i,s,o,s.pendingProps);case 24:fa(s,vt,i.memoizedState.cache)}return _i(i,s,o)}function YE(i,s,o){if(i!==null)if(i.memoizedProps!==s.pendingProps)bt=!0;else{if(!hp(i,o)&&(s.flags&128)===0)return bt=!1,OU(i,s,o);bt=(i.flags&131072)!==0}else bt=!1,Le&&(s.flags&1048576)!==0&&wk(s,Ro,s.index);switch(s.lanes=0,s.tag){case 16:e:{var d=s.pendingProps;if(i=is(s.elementType),s.type=i,typeof i=="function")ym(i)?(d=os(i,d),s.tag=1,s=FE(null,s,i,d,o)):(s.tag=0,s=rp(null,s,i,d,o));else{if(i!=null){var m=i.$$typeof;if(m===E){s.tag=11,s=LE(null,s,i,d,o);break e}else if(m===N){s.tag=14,s=IE(null,s,i,d,o);break e}}throw s=be(i)||i,Error(a(306,s,""))}}return s;case 0:return rp(i,s,s.type,s.pendingProps,o);case 1:return d=s.type,m=os(d,s.pendingProps),FE(i,s,d,m,o);case 3:e:{if(tt(s,s.stateNode.containerInfo),i===null)throw Error(a(387));d=s.pendingProps;var g=s.memoizedState;m=g.element,Pm(i,s),No(s,d,null,o);var b=s.memoizedState;if(d=b.cache,fa(s,vt,d),d!==g.cache&&_m(s,[vt],o,!0),Po(),d=b.element,g.isDehydrated)if(g={element:d,isDehydrated:!1,cache:b.cache},s.updateQueue.baseState=g,s.memoizedState=g,s.flags&256){s=qE(i,s,d,o);break e}else if(d!==m){m=_n(Error(a(424)),s),_o(m),s=qE(i,s,d,o);break e}else for(i=s.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,We=On(i.firstChild),Pt=s,Le=!0,ua=null,Mn=!0,o=Bk(s,null,d,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if($a(),d===m){s=_i(i,s,o);break e}Lt(i,s,d,o)}s=s.child}return s;case 26:return Wl(i,s),i===null?(o=aw(s.type,null,s.pendingProps,null))?s.memoizedState=o:Le||(o=s.type,i=s.pendingProps,d=pu(Se.current).createElement(o),d[Ot]=s,d[Jt]=i,It(d,o,i),_t(d),s.stateNode=d):s.memoizedState=aw(s.type,i.memoizedProps,s.pendingProps,i.memoizedState),null;case 27:return sa(s),i===null&&Le&&(d=s.stateNode=tw(s.type,s.pendingProps,Se.current),Pt=s,Mn=!0,m=We,wa(s.type)?(Kp=m,We=On(d.firstChild)):We=m),Lt(i,s,s.pendingProps.children,o),Wl(i,s),i===null&&(s.flags|=4194304),s.child;case 5:return i===null&&Le&&((m=d=We)&&(d=c5(d,s.type,s.pendingProps,Mn),d!==null?(s.stateNode=d,Pt=s,We=On(d.firstChild),Mn=!1,m=!0):m=!1),m||da(s)),sa(s),m=s.type,g=s.pendingProps,b=i!==null?i.memoizedProps:null,d=g.children,zp(m,g)?d=null:b!==null&&zp(m,b)&&(s.flags|=32),s.memoizedState!==null&&(m=Vm(i,s,kU,null,null,o),ec._currentValue=m),Wl(i,s),Lt(i,s,d,o),s.child;case 6:return i===null&&Le&&((i=o=We)&&(o=l5(o,s.pendingProps,Mn),o!==null?(s.stateNode=o,Pt=s,We=null,i=!0):i=!1),i||da(s)),null;case 13:return HE(i,s,o);case 4:return tt(s,s.stateNode.containerInfo),d=s.pendingProps,i===null?s.child=ss(s,null,d,o):Lt(i,s,d,o),s.child;case 11:return LE(i,s,s.type,s.pendingProps,o);case 7:return Lt(i,s,s.pendingProps,o),s.child;case 8:return Lt(i,s,s.pendingProps.children,o),s.child;case 12:return Lt(i,s,s.pendingProps.children,o),s.child;case 10:return d=s.pendingProps,fa(s,s.type,d.value),Lt(i,s,d.children,o),s.child;case 9:return m=s.type._context,d=s.pendingProps.children,ts(s),m=Nt(m),d=d(m),s.flags|=1,Lt(i,s,d,o),s.child;case 14:return IE(i,s,s.type,s.pendingProps,o);case 15:return UE(i,s,s.type,s.pendingProps,o);case 19:return KE(i,s,o);case 31:return DU(i,s,o);case 22:return BE(i,s,o,s.pendingProps);case 24:return ts(s),d=Nt(vt),i===null?(m=Mm(),m===null&&(m=Je,g=xm(),m.pooledCache=g,g.refCount++,g!==null&&(m.pooledCacheLanes|=o),m=g),s.memoizedState={parent:d,cache:m},Om(s),fa(s,vt,m)):((i.lanes&o)!==0&&(Pm(i,s),No(s,null,null,o),Po()),m=i.memoizedState,g=s.memoizedState,m.parent!==d?(m={parent:d,cache:d},s.memoizedState=m,s.lanes===0&&(s.memoizedState=s.updateQueue.baseState=m),fa(s,vt,d)):(d=g.cache,fa(s,vt,d),d!==m.cache&&_m(s,[vt],o,!0))),Lt(i,s,s.pendingProps.children,o),s.child;case 29:throw s.pendingProps}throw Error(a(156,s.tag))}function xi(i){i.flags|=4}function mp(i,s,o,d,m){if((s=(i.mode&32)!==0)&&(s=!1),s){if(i.flags|=16777216,(m&335544128)===m)if(i.stateNode.complete)i.flags|=8192;else if(S1())i.flags|=8192;else throw as=Ul,Dm}else i.flags&=-16777217}function XE(i,s){if(s.type!=="stylesheet"||(s.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!lw(s))if(S1())i.flags|=8192;else throw as=Ul,Dm}function eu(i,s){s!==null&&(i.flags|=4),i.flags&16384&&(s=i.tag!==22?_C():536870912,i.lanes|=s,gr|=s)}function Vo(i,s){if(!Le)switch(i.tailMode){case"hidden":s=i.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?i.tail=null:o.sibling=null;break;case"collapsed":o=i.tail;for(var d=null;o!==null;)o.alternate!==null&&(d=o),o=o.sibling;d===null?s||i.tail===null?i.tail=null:i.tail.sibling=null:d.sibling=null}}function $e(i){var s=i.alternate!==null&&i.alternate.child===i.child,o=0,d=0;if(s)for(var m=i.child;m!==null;)o|=m.lanes|m.childLanes,d|=m.subtreeFlags&65011712,d|=m.flags&65011712,m.return=i,m=m.sibling;else for(m=i.child;m!==null;)o|=m.lanes|m.childLanes,d|=m.subtreeFlags,d|=m.flags,m.return=i,m=m.sibling;return i.subtreeFlags|=d,i.childLanes=o,s}function PU(i,s,o){var d=s.pendingProps;switch(Cm(s),s.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return $e(s),null;case 1:return $e(s),null;case 3:return o=s.stateNode,d=null,i!==null&&(d=i.memoizedState.cache),s.memoizedState.cache!==d&&(s.flags|=2048),Ei(vt),Qe(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),(i===null||i.child===null)&&(ir(s)?xi(s):i===null||i.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,Em())),$e(s),null;case 26:var m=s.type,g=s.memoizedState;return i===null?(xi(s),g!==null?($e(s),XE(s,g)):($e(s),mp(s,m,null,d,o))):g?g!==i.memoizedState?(xi(s),$e(s),XE(s,g)):($e(s),s.flags&=-16777217):(i=i.memoizedProps,i!==d&&xi(s),$e(s),mp(s,m,i,d,o)),null;case 27:if(dl(s),o=Se.current,m=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==d&&xi(s);else{if(!d){if(s.stateNode===null)throw Error(a(166));return $e(s),null}i=le.current,ir(s)?_k(s):(i=tw(m,d,o),s.stateNode=i,xi(s))}return $e(s),null;case 5:if(dl(s),m=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==d&&xi(s);else{if(!d){if(s.stateNode===null)throw Error(a(166));return $e(s),null}if(g=le.current,ir(s))_k(s);else{var b=pu(Se.current);switch(g){case 1:g=b.createElementNS("http://www.w3.org/2000/svg",m);break;case 2:g=b.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;default:switch(m){case"svg":g=b.createElementNS("http://www.w3.org/2000/svg",m);break;case"math":g=b.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;case"script":g=b.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof d.is=="string"?b.createElement("select",{is:d.is}):b.createElement("select"),d.multiple?g.multiple=!0:d.size&&(g.size=d.size);break;default:g=typeof d.is=="string"?b.createElement(m,{is:d.is}):b.createElement(m)}}g[Ot]=s,g[Jt]=d;e:for(b=s.child;b!==null;){if(b.tag===5||b.tag===6)g.appendChild(b.stateNode);else if(b.tag!==4&&b.tag!==27&&b.child!==null){b.child.return=b,b=b.child;continue}if(b===s)break e;for(;b.sibling===null;){if(b.return===null||b.return===s)break e;b=b.return}b.sibling.return=b.return,b=b.sibling}s.stateNode=g;e:switch(It(g,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&xi(s)}}return $e(s),mp(s,s.type,i===null?null:i.memoizedProps,s.pendingProps,o),null;case 6:if(i&&s.stateNode!=null)i.memoizedProps!==d&&xi(s);else{if(typeof d!="string"&&s.stateNode===null)throw Error(a(166));if(i=Se.current,ir(s)){if(i=s.stateNode,o=s.memoizedProps,d=null,m=Pt,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[Ot]=s,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||H1(i.nodeValue,o)),i||da(s,!0)}else i=pu(i).createTextNode(d),i[Ot]=s,s.stateNode=i}return $e(s),null;case 31:if(o=s.memoizedState,i===null||i.memoizedState!==null){if(d=ir(s),o!==null){if(i===null){if(!d)throw Error(a(318));if(i=s.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(a(557));i[Ot]=s}else $a(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;$e(s),i=!1}else o=Em(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return s.flags&256?(hn(s),s):(hn(s),null);if((s.flags&128)!==0)throw Error(a(558))}return $e(s),null;case 13:if(d=s.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=ir(s),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(a(318));if(m=s.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(a(317));m[Ot]=s}else $a(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;$e(s),m=!1}else m=Em(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return s.flags&256?(hn(s),s):(hn(s),null)}return hn(s),(s.flags&128)!==0?(s.lanes=o,s):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=s.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),g=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(g=d.memoizedState.cachePool.pool),g!==m&&(d.flags|=2048)),o!==i&&o&&(s.child.flags|=8192),eu(s,s.updateQueue),$e(s),null);case 4:return Qe(),i===null&&Ip(s.stateNode.containerInfo),$e(s),null;case 10:return Ei(s.type),$e(s),null;case 19:if(Z(ft),d=s.memoizedState,d===null)return $e(s),null;if(m=(s.flags&128)!==0,g=d.rendering,g===null)if(m)Vo(d,!1);else{if(lt!==0||i!==null&&(i.flags&128)!==0)for(i=s.child;i!==null;){if(g=zl(i),g!==null){for(s.flags|=128,Vo(d,!1),i=g.updateQueue,s.updateQueue=i,eu(s,i),s.subtreeFlags=0,i=o,o=s.child;o!==null;)Ck(o,i),o=o.sibling;return re(ft,ft.current&1|2),Le&&Ci(s,d.treeForkCount),s.child}i=i.sibling}d.tail!==null&&on()>su&&(s.flags|=128,m=!0,Vo(d,!1),s.lanes=4194304)}else{if(!m)if(i=zl(g),i!==null){if(s.flags|=128,m=!0,i=i.updateQueue,s.updateQueue=i,eu(s,i),Vo(d,!0),d.tail===null&&d.tailMode==="hidden"&&!g.alternate&&!Le)return $e(s),null}else 2*on()-d.renderingStartTime>su&&o!==536870912&&(s.flags|=128,m=!0,Vo(d,!1),s.lanes=4194304);d.isBackwards?(g.sibling=s.child,s.child=g):(i=d.last,i!==null?i.sibling=g:s.child=g,d.last=g)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=on(),i.sibling=null,o=ft.current,re(ft,m?o&1|2:o&1),Le&&Ci(s,d.treeForkCount),i):($e(s),null);case 22:case 23:return hn(s),Um(),d=s.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(s.flags|=8192):d&&(s.flags|=8192),d?(o&536870912)!==0&&(s.flags&128)===0&&($e(s),s.subtreeFlags&6&&(s.flags|=8192)):$e(s),o=s.updateQueue,o!==null&&eu(s,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(d=s.memoizedState.cachePool.pool),d!==o&&(s.flags|=2048),i!==null&&Z(ns),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),s.memoizedState.cache!==o&&(s.flags|=2048),Ei(vt),$e(s),null;case 25:return null;case 30:return null}throw Error(a(156,s.tag))}function NU(i,s){switch(Cm(s),s.tag){case 1:return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 3:return Ei(vt),Qe(),i=s.flags,(i&65536)!==0&&(i&128)===0?(s.flags=i&-65537|128,s):null;case 26:case 27:case 5:return dl(s),null;case 31:if(s.memoizedState!==null){if(hn(s),s.alternate===null)throw Error(a(340));$a()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 13:if(hn(s),i=s.memoizedState,i!==null&&i.dehydrated!==null){if(s.alternate===null)throw Error(a(340));$a()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 19:return Z(ft),null;case 4:return Qe(),null;case 10:return Ei(s.type),null;case 22:case 23:return hn(s),Um(),i!==null&&Z(ns),i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 24:return Ei(vt),null;case 25:return null;default:return null}}function QE(i,s){switch(Cm(s),s.tag){case 3:Ei(vt),Qe();break;case 26:case 27:case 5:dl(s);break;case 4:Qe();break;case 31:s.memoizedState!==null&&hn(s);break;case 13:hn(s);break;case 19:Z(ft);break;case 10:Ei(s.type);break;case 22:case 23:hn(s),Um(),i!==null&&Z(ns);break;case 24:Ei(vt)}}function zo(i,s){try{var o=s.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var g=o.create,b=o.inst;d=g(),b.destroy=d}o=o.next}while(o!==m)}}catch(C){ze(s,s.return,C)}}function ya(i,s,o){try{var d=s.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var g=m.next;d=g;do{if((d.tag&i)===i){var b=d.inst,C=b.destroy;if(C!==void 0){b.destroy=void 0,m=s;var M=o,z=C;try{z()}catch(J){ze(m,M,J)}}}d=d.next}while(d!==g)}}catch(J){ze(s,s.return,J)}}function JE(i){var s=i.updateQueue;if(s!==null){var o=i.stateNode;try{Vk(s,o)}catch(d){ze(i,i.return,d)}}}function ZE(i,s,o){o.props=os(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){ze(i,s,d)}}function Fo(i,s){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){ze(i,s,m)}}function ri(i,s){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){ze(i,s,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){ze(i,s,m)}else o.current=null}function WE(i){var s=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){ze(i,i.return,m)}}function pp(i,s,o){try{var d=i.stateNode;n5(d,i.type,o,s),d[Jt]=s}catch(m){ze(i,i.return,m)}}function $E(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&wa(i.type)||i.tag===4}function gp(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||$E(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&wa(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function vp(i,s,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,s?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,s):(s=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,s.appendChild(i),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=bi));else if(d!==4&&(d===27&&wa(i.type)&&(o=i.stateNode,s=null),i=i.child,i!==null))for(vp(i,s,o),i=i.sibling;i!==null;)vp(i,s,o),i=i.sibling}function tu(i,s,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,s?o.insertBefore(i,s):o.appendChild(i);else if(d!==4&&(d===27&&wa(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(tu(i,s,o),i=i.sibling;i!==null;)tu(i,s,o),i=i.sibling}function e1(i){var s=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=s.attributes;m.length;)s.removeAttributeNode(m[0]);It(s,d,o),s[Ot]=i,s[Jt]=o}catch(g){ze(i,i.return,g)}}var Ai=!1,St=!1,yp=!1,t1=typeof WeakSet=="function"?WeakSet:Set,xt=null;function LU(i,s){if(i=i.containerInfo,jp=Cu,i=hk(i),dm(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,g=d.focusNode;d=d.focusOffset;try{o.nodeType,g.nodeType}catch{o=null;break e}var b=0,C=-1,M=-1,z=0,J=0,$=i,F=null;t:for(;;){for(var K;$!==o||m!==0&&$.nodeType!==3||(C=b+m),$!==g||d!==0&&$.nodeType!==3||(M=b+d),$.nodeType===3&&(b+=$.nodeValue.length),(K=$.firstChild)!==null;)F=$,$=K;for(;;){if($===i)break t;if(F===o&&++z===m&&(C=b),F===g&&++J===d&&(M=b),(K=$.nextSibling)!==null)break;$=F,F=$.parentNode}$=K}o=C===-1||M===-1?null:{start:C,end:M}}else o=null}o=o||{start:0,end:0}}else o=null;for(Vp={focusedElem:i,selectionRange:o},Cu=!1,xt=s;xt!==null;)if(s=xt,i=s.child,(s.subtreeFlags&1028)!==0&&i!==null)i.return=s,xt=i;else for(;xt!==null;){switch(s=xt,g=s.alternate,i=s.flags,s.tag){case 0:if((i&4)!==0&&(i=s.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o<i.length;o++)m=i[o],m.ref.impl=m.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&g!==null){i=void 0,o=s,m=g.memoizedProps,g=g.memoizedState,d=o.stateNode;try{var ue=os(o.type,m);i=d.getSnapshotBeforeUpdate(ue,g),d.__reactInternalSnapshotBeforeUpdate=i}catch(ge){ze(o,o.return,ge)}}break;case 3:if((i&1024)!==0){if(i=s.stateNode.containerInfo,o=i.nodeType,o===9)qp(i);else if(o===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":qp(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(a(163))}if(i=s.sibling,i!==null){i.return=s.return,xt=i;break}xt=s.return}}function n1(i,s,o){var d=o.flags;switch(o.tag){case 0:case 11:case 15:Di(i,o),d&4&&zo(5,o);break;case 1:if(Di(i,o),d&4)if(i=o.stateNode,s===null)try{i.componentDidMount()}catch(b){ze(o,o.return,b)}else{var m=os(o.type,s.memoizedProps);s=s.memoizedState;try{i.componentDidUpdate(m,s,i.__reactInternalSnapshotBeforeUpdate)}catch(b){ze(o,o.return,b)}}d&64&&JE(o),d&512&&Fo(o,o.return);break;case 3:if(Di(i,o),d&64&&(i=o.updateQueue,i!==null)){if(s=null,o.child!==null)switch(o.child.tag){case 27:case 5:s=o.child.stateNode;break;case 1:s=o.child.stateNode}try{Vk(i,s)}catch(b){ze(o,o.return,b)}}break;case 27:s===null&&d&4&&e1(o);case 26:case 5:Di(i,o),s===null&&d&4&&WE(o),d&512&&Fo(o,o.return);break;case 12:Di(i,o);break;case 31:Di(i,o),d&4&&s1(i,o);break;case 13:Di(i,o),d&4&&r1(i,o),d&64&&(i=o.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(o=HU.bind(null,o),u5(i,o))));break;case 22:if(d=o.memoizedState!==null||Ai,!d){s=s!==null&&s.memoizedState!==null||St,m=Ai;var g=St;Ai=d,(St=s)&&!g?Oi(i,o,(o.subtreeFlags&8772)!==0):Di(i,o),Ai=m,St=g}break;case 30:break;default:Di(i,o)}}function i1(i){var s=i.alternate;s!==null&&(i.alternate=null,i1(s)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(s=i.stateNode,s!==null&&Xh(s)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var nt=null,Wt=!1;function Mi(i,s,o){for(o=o.child;o!==null;)a1(i,s,o),o=o.sibling}function a1(i,s,o){if(cn&&typeof cn.onCommitFiberUnmount=="function")try{cn.onCommitFiberUnmount(fo,o)}catch{}switch(o.tag){case 26:St||ri(o,s),Mi(i,s,o),o.memoizedState?o.memoizedState.count--:o.stateNode&&(o=o.stateNode,o.parentNode.removeChild(o));break;case 27:St||ri(o,s);var d=nt,m=Wt;wa(o.type)&&(nt=o.stateNode,Wt=!1),Mi(i,s,o),Zo(o.stateNode),nt=d,Wt=m;break;case 5:St||ri(o,s);case 6:if(d=nt,m=Wt,nt=null,Mi(i,s,o),nt=d,Wt=m,nt!==null)if(Wt)try{(nt.nodeType===9?nt.body:nt.nodeName==="HTML"?nt.ownerDocument.body:nt).removeChild(o.stateNode)}catch(g){ze(o,s,g)}else try{nt.removeChild(o.stateNode)}catch(g){ze(o,s,g)}break;case 18:nt!==null&&(Wt?(i=nt,J1(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,o.stateNode),Er(i)):J1(nt,o.stateNode));break;case 4:d=nt,m=Wt,nt=o.stateNode.containerInfo,Wt=!0,Mi(i,s,o),nt=d,Wt=m;break;case 0:case 11:case 14:case 15:ya(2,o,s),St||ya(4,o,s),Mi(i,s,o);break;case 1:St||(ri(o,s),d=o.stateNode,typeof d.componentWillUnmount=="function"&&ZE(o,s,d)),Mi(i,s,o);break;case 21:Mi(i,s,o);break;case 22:St=(d=St)||o.memoizedState!==null,Mi(i,s,o),St=d;break;default:Mi(i,s,o)}}function s1(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{Er(i)}catch(o){ze(s,s.return,o)}}}function r1(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{Er(i)}catch(o){ze(s,s.return,o)}}function IU(i){switch(i.tag){case 31:case 13:case 19:var s=i.stateNode;return s===null&&(s=i.stateNode=new t1),s;case 22:return i=i.stateNode,s=i._retryCache,s===null&&(s=i._retryCache=new t1),s;default:throw Error(a(435,i.tag))}}function nu(i,s){var o=IU(i);s.forEach(function(d){if(!o.has(d)){o.add(d);var m=GU.bind(null,i,d);d.then(m,m)}})}function $t(i,s){var o=s.deletions;if(o!==null)for(var d=0;d<o.length;d++){var m=o[d],g=i,b=s,C=b;e:for(;C!==null;){switch(C.tag){case 27:if(wa(C.type)){nt=C.stateNode,Wt=!1;break e}break;case 5:nt=C.stateNode,Wt=!1;break e;case 3:case 4:nt=C.stateNode.containerInfo,Wt=!0;break e}C=C.return}if(nt===null)throw Error(a(160));a1(g,b,m),nt=null,Wt=!1,g=m.alternate,g!==null&&(g.return=null),m.return=null}if(s.subtreeFlags&13886)for(s=s.child;s!==null;)o1(s,i),s=s.sibling}var Gn=null;function o1(i,s){var o=i.alternate,d=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:$t(s,i),en(i),d&4&&(ya(3,i,i.return),zo(3,i),ya(5,i,i.return));break;case 1:$t(s,i),en(i),d&512&&(St||o===null||ri(o,o.return)),d&64&&Ai&&(i=i.updateQueue,i!==null&&(d=i.callbacks,d!==null&&(o=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=o===null?d:o.concat(d))));break;case 26:var m=Gn;if($t(s,i),en(i),d&512&&(St||o===null||ri(o,o.return)),d&4){var g=o!==null?o.memoizedState:null;if(d=i.memoizedState,o===null)if(d===null)if(i.stateNode===null){e:{d=i.type,o=i.memoizedProps,m=m.ownerDocument||m;t:switch(d){case"title":g=m.getElementsByTagName("title")[0],(!g||g[po]||g[Ot]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=m.createElement(d),m.head.insertBefore(g,m.querySelector("head > title"))),It(g,d,o),g[Ot]=i,_t(g),d=g;break e;case"link":var b=ow("link","href",m).get(d+(o.href||""));if(b){for(var C=0;C<b.length;C++)if(g=b[C],g.getAttribute("href")===(o.href==null||o.href===""?null:o.href)&&g.getAttribute("rel")===(o.rel==null?null:o.rel)&&g.getAttribute("title")===(o.title==null?null:o.title)&&g.getAttribute("crossorigin")===(o.crossOrigin==null?null:o.crossOrigin)){b.splice(C,1);break t}}g=m.createElement(d),It(g,d,o),m.head.appendChild(g);break;case"meta":if(b=ow("meta","content",m).get(d+(o.content||""))){for(C=0;C<b.length;C++)if(g=b[C],g.getAttribute("content")===(o.content==null?null:""+o.content)&&g.getAttribute("name")===(o.name==null?null:o.name)&&g.getAttribute("property")===(o.property==null?null:o.property)&&g.getAttribute("http-equiv")===(o.httpEquiv==null?null:o.httpEquiv)&&g.getAttribute("charset")===(o.charSet==null?null:o.charSet)){b.splice(C,1);break t}}g=m.createElement(d),It(g,d,o),m.head.appendChild(g);break;default:throw Error(a(468,d))}g[Ot]=i,_t(g),d=g}i.stateNode=d}else cw(m,i.type,i.stateNode);else i.stateNode=rw(m,d,i.memoizedProps);else g!==d?(g===null?o.stateNode!==null&&(o=o.stateNode,o.parentNode.removeChild(o)):g.count--,d===null?cw(m,i.type,i.stateNode):rw(m,d,i.memoizedProps)):d===null&&i.stateNode!==null&&pp(i,i.memoizedProps,o.memoizedProps)}break;case 27:$t(s,i),en(i),d&512&&(St||o===null||ri(o,o.return)),o!==null&&d&4&&pp(i,i.memoizedProps,o.memoizedProps);break;case 5:if($t(s,i),en(i),d&512&&(St||o===null||ri(o,o.return)),i.flags&32){m=i.stateNode;try{Ys(m,"")}catch(ue){ze(i,i.return,ue)}}d&4&&i.stateNode!=null&&(m=i.memoizedProps,pp(i,m,o!==null?o.memoizedProps:m)),d&1024&&(yp=!0);break;case 6:if($t(s,i),en(i),d&4){if(i.stateNode===null)throw Error(a(162));d=i.memoizedProps,o=i.stateNode;try{o.nodeValue=d}catch(ue){ze(i,i.return,ue)}}break;case 3:if(yu=null,m=Gn,Gn=gu(s.containerInfo),$t(s,i),Gn=m,en(i),d&4&&o!==null&&o.memoizedState.isDehydrated)try{Er(s.containerInfo)}catch(ue){ze(i,i.return,ue)}yp&&(yp=!1,c1(i));break;case 4:d=Gn,Gn=gu(i.stateNode.containerInfo),$t(s,i),en(i),Gn=d;break;case 12:$t(s,i),en(i);break;case 31:$t(s,i),en(i),d&4&&(d=i.updateQueue,d!==null&&(i.updateQueue=null,nu(i,d)));break;case 13:$t(s,i),en(i),i.child.flags&8192&&i.memoizedState!==null!=(o!==null&&o.memoizedState!==null)&&(au=on()),d&4&&(d=i.updateQueue,d!==null&&(i.updateQueue=null,nu(i,d)));break;case 22:m=i.memoizedState!==null;var M=o!==null&&o.memoizedState!==null,z=Ai,J=St;if(Ai=z||m,St=J||M,$t(s,i),St=J,Ai=z,en(i),d&8192)e:for(s=i.stateNode,s._visibility=m?s._visibility&-2:s._visibility|1,m&&(o===null||M||Ai||St||cs(i)),o=null,s=i;;){if(s.tag===5||s.tag===26){if(o===null){M=o=s;try{if(g=M.stateNode,m)b=g.style,typeof b.setProperty=="function"?b.setProperty("display","none","important"):b.display="none";else{C=M.stateNode;var $=M.memoizedProps.style,F=$!=null&&$.hasOwnProperty("display")?$.display:null;C.style.display=F==null||typeof F=="boolean"?"":(""+F).trim()}}catch(ue){ze(M,M.return,ue)}}}else if(s.tag===6){if(o===null){M=s;try{M.stateNode.nodeValue=m?"":M.memoizedProps}catch(ue){ze(M,M.return,ue)}}}else if(s.tag===18){if(o===null){M=s;try{var K=M.stateNode;m?Z1(K,!0):Z1(M.stateNode,!1)}catch(ue){ze(M,M.return,ue)}}}else if((s.tag!==22&&s.tag!==23||s.memoizedState===null||s===i)&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break e;for(;s.sibling===null;){if(s.return===null||s.return===i)break e;o===s&&(o=null),s=s.return}o===s&&(o=null),s.sibling.return=s.return,s=s.sibling}d&4&&(d=i.updateQueue,d!==null&&(o=d.retryQueue,o!==null&&(d.retryQueue=null,nu(i,o))));break;case 19:$t(s,i),en(i),d&4&&(d=i.updateQueue,d!==null&&(i.updateQueue=null,nu(i,d)));break;case 30:break;case 21:break;default:$t(s,i),en(i)}}function en(i){var s=i.flags;if(s&2){try{for(var o,d=i.return;d!==null;){if($E(d)){o=d;break}d=d.return}if(o==null)throw Error(a(160));switch(o.tag){case 27:var m=o.stateNode,g=gp(i);tu(i,g,m);break;case 5:var b=o.stateNode;o.flags&32&&(Ys(b,""),o.flags&=-33);var C=gp(i);tu(i,C,b);break;case 3:case 4:var M=o.stateNode.containerInfo,z=gp(i);vp(i,z,M);break;default:throw Error(a(161))}}catch(J){ze(i,i.return,J)}i.flags&=-3}s&4096&&(i.flags&=-4097)}function c1(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var s=i;c1(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),i=i.sibling}}function Di(i,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)n1(i,s.alternate,s),s=s.sibling}function cs(i){for(i=i.child;i!==null;){var s=i;switch(s.tag){case 0:case 11:case 14:case 15:ya(4,s,s.return),cs(s);break;case 1:ri(s,s.return);var o=s.stateNode;typeof o.componentWillUnmount=="function"&&ZE(s,s.return,o),cs(s);break;case 27:Zo(s.stateNode);case 26:case 5:ri(s,s.return),cs(s);break;case 22:s.memoizedState===null&&cs(s);break;case 30:cs(s);break;default:cs(s)}i=i.sibling}}function Oi(i,s,o){for(o=o&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var d=s.alternate,m=i,g=s,b=g.flags;switch(g.tag){case 0:case 11:case 15:Oi(m,g,o),zo(4,g);break;case 1:if(Oi(m,g,o),d=g,m=d.stateNode,typeof m.componentDidMount=="function")try{m.componentDidMount()}catch(z){ze(d,d.return,z)}if(d=g,m=d.updateQueue,m!==null){var C=d.stateNode;try{var M=m.shared.hiddenCallbacks;if(M!==null)for(m.shared.hiddenCallbacks=null,m=0;m<M.length;m++)jk(M[m],C)}catch(z){ze(d,d.return,z)}}o&&b&64&&JE(g),Fo(g,g.return);break;case 27:e1(g);case 26:case 5:Oi(m,g,o),o&&d===null&&b&4&&WE(g),Fo(g,g.return);break;case 12:Oi(m,g,o);break;case 31:Oi(m,g,o),o&&b&4&&s1(m,g);break;case 13:Oi(m,g,o),o&&b&4&&r1(m,g);break;case 22:g.memoizedState===null&&Oi(m,g,o),Fo(g,g.return);break;case 30:break;default:Oi(m,g,o)}s=s.sibling}}function bp(i,s){var o=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),i=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(i=s.memoizedState.cachePool.pool),i!==o&&(i!=null&&i.refCount++,o!=null&&xo(o))}function Sp(i,s){i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&xo(i))}function Kn(i,s,o,d){if(s.subtreeFlags&10256)for(s=s.child;s!==null;)l1(i,s,o,d),s=s.sibling}function l1(i,s,o,d){var m=s.flags;switch(s.tag){case 0:case 11:case 15:Kn(i,s,o,d),m&2048&&zo(9,s);break;case 1:Kn(i,s,o,d);break;case 3:Kn(i,s,o,d),m&2048&&(i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&xo(i)));break;case 12:if(m&2048){Kn(i,s,o,d),i=s.stateNode;try{var g=s.memoizedProps,b=g.id,C=g.onPostCommit;typeof C=="function"&&C(b,s.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(M){ze(s,s.return,M)}}else Kn(i,s,o,d);break;case 31:Kn(i,s,o,d);break;case 13:Kn(i,s,o,d);break;case 23:break;case 22:g=s.stateNode,b=s.alternate,s.memoizedState!==null?g._visibility&2?Kn(i,s,o,d):qo(i,s):g._visibility&2?Kn(i,s,o,d):(g._visibility|=2,hr(i,s,o,d,(s.subtreeFlags&10256)!==0||!1)),m&2048&&bp(b,s);break;case 24:Kn(i,s,o,d),m&2048&&Sp(s.alternate,s);break;default:Kn(i,s,o,d)}}function hr(i,s,o,d,m){for(m=m&&((s.subtreeFlags&10256)!==0||!1),s=s.child;s!==null;){var g=i,b=s,C=o,M=d,z=b.flags;switch(b.tag){case 0:case 11:case 15:hr(g,b,C,M,m),zo(8,b);break;case 23:break;case 22:var J=b.stateNode;b.memoizedState!==null?J._visibility&2?hr(g,b,C,M,m):qo(g,b):(J._visibility|=2,hr(g,b,C,M,m)),m&&z&2048&&bp(b.alternate,b);break;case 24:hr(g,b,C,M,m),m&&z&2048&&Sp(b.alternate,b);break;default:hr(g,b,C,M,m)}s=s.sibling}}function qo(i,s){if(s.subtreeFlags&10256)for(s=s.child;s!==null;){var o=i,d=s,m=d.flags;switch(d.tag){case 22:qo(o,d),m&2048&&bp(d.alternate,d);break;case 24:qo(o,d),m&2048&&Sp(d.alternate,d);break;default:qo(o,d)}s=s.sibling}}var Ho=8192;function mr(i,s,o){if(i.subtreeFlags&Ho)for(i=i.child;i!==null;)u1(i,s,o),i=i.sibling}function u1(i,s,o){switch(i.tag){case 26:mr(i,s,o),i.flags&Ho&&i.memoizedState!==null&&C5(o,Gn,i.memoizedState,i.memoizedProps);break;case 5:mr(i,s,o);break;case 3:case 4:var d=Gn;Gn=gu(i.stateNode.containerInfo),mr(i,s,o),Gn=d;break;case 22:i.memoizedState===null&&(d=i.alternate,d!==null&&d.memoizedState!==null?(d=Ho,Ho=16777216,mr(i,s,o),Ho=d):mr(i,s,o));break;default:mr(i,s,o)}}function d1(i){var s=i.alternate;if(s!==null&&(i=s.child,i!==null)){s.child=null;do s=i.sibling,i.sibling=null,i=s;while(i!==null)}}function Go(i){var s=i.deletions;if((i.flags&16)!==0){if(s!==null)for(var o=0;o<s.length;o++){var d=s[o];xt=d,h1(d,i)}d1(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)f1(i),i=i.sibling}function f1(i){switch(i.tag){case 0:case 11:case 15:Go(i),i.flags&2048&&ya(9,i,i.return);break;case 3:Go(i);break;case 12:Go(i);break;case 22:var s=i.stateNode;i.memoizedState!==null&&s._visibility&2&&(i.return===null||i.return.tag!==13)?(s._visibility&=-3,iu(i)):Go(i);break;default:Go(i)}}function iu(i){var s=i.deletions;if((i.flags&16)!==0){if(s!==null)for(var o=0;o<s.length;o++){var d=s[o];xt=d,h1(d,i)}d1(i)}for(i=i.child;i!==null;){switch(s=i,s.tag){case 0:case 11:case 15:ya(8,s,s.return),iu(s);break;case 22:o=s.stateNode,o._visibility&2&&(o._visibility&=-3,iu(s));break;default:iu(s)}i=i.sibling}}function h1(i,s){for(;xt!==null;){var o=xt;switch(o.tag){case 0:case 11:case 15:ya(8,o,s);break;case 23:case 22:if(o.memoizedState!==null&&o.memoizedState.cachePool!==null){var d=o.memoizedState.cachePool.pool;d!=null&&d.refCount++}break;case 24:xo(o.memoizedState.cache)}if(d=o.child,d!==null)d.return=o,xt=d;else e:for(o=i;xt!==null;){d=xt;var m=d.sibling,g=d.return;if(i1(d),d===o){xt=null;break e}if(m!==null){m.return=g,xt=m;break e}xt=g}}}var UU={getCacheForType:function(i){var s=Nt(vt),o=s.data.get(i);return o===void 0&&(o=i(),s.data.set(i,o)),o},cacheSignal:function(){return Nt(vt).controller.signal}},BU=typeof WeakMap=="function"?WeakMap:Map,je=0,Je=null,Me=null,Oe=0,Ve=0,mn=null,ba=!1,pr=!1,Tp=!1,Pi=0,lt=0,Sa=0,ls=0,Cp=0,pn=0,gr=0,Ko=null,tn=null,kp=!1,au=0,m1=0,su=1/0,ru=null,Ta=null,Et=0,Ca=null,vr=null,Ni=0,Ep=0,wp=null,p1=null,Yo=0,Rp=null;function gn(){return(je&2)!==0&&Oe!==0?Oe&-Oe:H.T!==null?Op():DC()}function g1(){if(pn===0)if((Oe&536870912)===0||Le){var i=ml;ml<<=1,(ml&3932160)===0&&(ml=262144),pn=i}else pn=536870912;return i=fn.current,i!==null&&(i.flags|=32),pn}function nn(i,s,o){(i===Je&&(Ve===2||Ve===9)||i.cancelPendingCommit!==null)&&(yr(i,0),ka(i,Oe,pn,!1)),mo(i,o),((je&2)===0||i!==Je)&&(i===Je&&((je&2)===0&&(ls|=o),lt===4&&ka(i,Oe,pn,!1)),oi(i))}function v1(i,s,o){if((je&6)!==0)throw Error(a(327));var d=!o&&(s&127)===0&&(s&i.expiredLanes)===0||ho(i,s),m=d?zU(i,s):xp(i,s,!0),g=d;do{if(m===0){pr&&!d&&ka(i,s,0,!1);break}else{if(o=i.current.alternate,g&&!jU(o)){m=xp(i,s,!1),g=!1;continue}if(m===2){if(g=s,i.errorRecoveryDisabledLanes&g)var b=0;else b=i.pendingLanes&-536870913,b=b!==0?b:b&536870912?536870912:0;if(b!==0){s=b;e:{var C=i;m=Ko;var M=C.current.memoizedState.isDehydrated;if(M&&(yr(C,b).flags|=256),b=xp(C,b,!1),b!==2){if(Tp&&!M){C.errorRecoveryDisabledLanes|=g,ls|=g,m=4;break e}g=tn,tn=m,g!==null&&(tn===null?tn=g:tn.push.apply(tn,g))}m=b}if(g=!1,m!==2)continue}}if(m===1){yr(i,0),ka(i,s,0,!0);break}e:{switch(d=i,g=m,g){case 0:case 1:throw Error(a(345));case 4:if((s&4194048)!==s)break;case 6:ka(d,s,pn,!ba);break e;case 2:tn=null;break;case 3:case 5:break;default:throw Error(a(329))}if((s&62914560)===s&&(m=au+300-on(),10<m)){if(ka(d,s,pn,!ba),gl(d,0,!0)!==0)break e;Ni=s,d.timeoutHandle=X1(y1.bind(null,d,o,tn,ru,kp,s,pn,ls,gr,ba,g,"Throttled",-0,0),m);break e}y1(d,o,tn,ru,kp,s,pn,ls,gr,ba,g,null,-0,0)}}break}while(!0);oi(i)}function y1(i,s,o,d,m,g,b,C,M,z,J,$,F,K){if(i.timeoutHandle=-1,$=s.subtreeFlags,$&8192||($&16785408)===16785408){$={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:bi},u1(s,g,$);var ue=(g&62914560)===g?au-on():(g&4194048)===g?m1-on():0;if(ue=k5($,ue),ue!==null){Ni=g,i.cancelPendingCommit=ue(R1.bind(null,i,s,g,o,d,m,b,C,M,J,$,null,F,K)),ka(i,g,b,!z);return}}R1(i,s,g,o,d,m,b,C,M)}function jU(i){for(var s=i;;){var o=s.tag;if((o===0||o===11||o===15)&&s.flags&16384&&(o=s.updateQueue,o!==null&&(o=o.stores,o!==null)))for(var d=0;d<o.length;d++){var m=o[d],g=m.getSnapshot;m=m.value;try{if(!un(g(),m))return!1}catch{return!1}}if(o=s.child,s.subtreeFlags&16384&&o!==null)o.return=s,s=o;else{if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function ka(i,s,o,d){s&=~Cp,s&=~ls,i.suspendedLanes|=s,i.pingedLanes&=~s,d&&(i.warmLanes|=s),d=i.expirationTimes;for(var m=s;0<m;){var g=31-ln(m),b=1<<g;d[g]=-1,m&=~b}o!==0&&xC(i,o,s)}function ou(){return(je&6)===0?(Xo(0),!1):!0}function _p(){if(Me!==null){if(Ve===0)var i=Me.return;else i=Me,ki=es=null,qm(i),cr=null,Mo=0,i=Me;for(;i!==null;)QE(i.alternate,i),i=i.return;Me=null}}function yr(i,s){var o=i.timeoutHandle;o!==-1&&(i.timeoutHandle=-1,s5(o)),o=i.cancelPendingCommit,o!==null&&(i.cancelPendingCommit=null,o()),Ni=0,_p(),Je=i,Me=o=Ti(i.current,null),Oe=s,Ve=0,mn=null,ba=!1,pr=ho(i,s),Tp=!1,gr=pn=Cp=ls=Sa=lt=0,tn=Ko=null,kp=!1,(s&8)!==0&&(s|=s&32);var d=i.entangledLanes;if(d!==0)for(i=i.entanglements,d&=s;0<d;){var m=31-ln(d),g=1<<m;s|=i[m],d&=~g}return Pi=s,xl(),o}function b1(i,s){ke=null,H.H=Bo,s===or||s===Il?(s=Lk(),Ve=3):s===Dm?(s=Lk(),Ve=4):Ve=s===sp?8:s!==null&&typeof s=="object"&&typeof s.then=="function"?6:1,mn=s,Me===null&&(lt=1,Jl(i,_n(s,i.current)))}function S1(){var i=fn.current;return i===null?!0:(Oe&4194048)===Oe?Dn===null:(Oe&62914560)===Oe||(Oe&536870912)!==0?i===Dn:!1}function T1(){var i=H.H;return H.H=Bo,i===null?Bo:i}function C1(){var i=H.A;return H.A=UU,i}function cu(){lt=4,ba||(Oe&4194048)!==Oe&&fn.current!==null||(pr=!0),(Sa&134217727)===0&&(ls&134217727)===0||Je===null||ka(Je,Oe,pn,!1)}function xp(i,s,o){var d=je;je|=2;var m=T1(),g=C1();(Je!==i||Oe!==s)&&(ru=null,yr(i,s)),s=!1;var b=lt;e:do try{if(Ve!==0&&Me!==null){var C=Me,M=mn;switch(Ve){case 8:_p(),b=6;break e;case 3:case 2:case 9:case 6:fn.current===null&&(s=!0);var z=Ve;if(Ve=0,mn=null,br(i,C,M,z),o&&pr){b=0;break e}break;default:z=Ve,Ve=0,mn=null,br(i,C,M,z)}}VU(),b=lt;break}catch(J){b1(i,J)}while(!0);return s&&i.shellSuspendCounter++,ki=es=null,je=d,H.H=m,H.A=g,Me===null&&(Je=null,Oe=0,xl()),b}function VU(){for(;Me!==null;)k1(Me)}function zU(i,s){var o=je;je|=2;var d=T1(),m=C1();Je!==i||Oe!==s?(ru=null,su=on()+500,yr(i,s)):pr=ho(i,s);e:do try{if(Ve!==0&&Me!==null){s=Me;var g=mn;t:switch(Ve){case 1:Ve=0,mn=null,br(i,s,g,1);break;case 2:case 9:if(Pk(g)){Ve=0,mn=null,E1(s);break}s=function(){Ve!==2&&Ve!==9||Je!==i||(Ve=7),oi(i)},g.then(s,s);break e;case 3:Ve=7;break e;case 4:Ve=5;break e;case 7:Pk(g)?(Ve=0,mn=null,E1(s)):(Ve=0,mn=null,br(i,s,g,7));break;case 5:var b=null;switch(Me.tag){case 26:b=Me.memoizedState;case 5:case 27:var C=Me;if(b?lw(b):C.stateNode.complete){Ve=0,mn=null;var M=C.sibling;if(M!==null)Me=M;else{var z=C.return;z!==null?(Me=z,lu(z)):Me=null}break t}}Ve=0,mn=null,br(i,s,g,5);break;case 6:Ve=0,mn=null,br(i,s,g,6);break;case 8:_p(),lt=6;break e;default:throw Error(a(462))}}FU();break}catch(J){b1(i,J)}while(!0);return ki=es=null,H.H=d,H.A=m,je=o,Me!==null?0:(Je=null,Oe=0,xl(),lt)}function FU(){for(;Me!==null&&!dI();)k1(Me)}function k1(i){var s=YE(i.alternate,i,Pi);i.memoizedProps=i.pendingProps,s===null?lu(i):Me=s}function E1(i){var s=i,o=s.alternate;switch(s.tag){case 15:case 0:s=zE(o,s,s.pendingProps,s.type,void 0,Oe);break;case 11:s=zE(o,s,s.pendingProps,s.type.render,s.ref,Oe);break;case 5:qm(s);default:QE(o,s),s=Me=Ck(s,Pi),s=YE(o,s,Pi)}i.memoizedProps=i.pendingProps,s===null?lu(i):Me=s}function br(i,s,o,d){ki=es=null,qm(s),cr=null,Mo=0;var m=s.return;try{if(MU(i,m,s,o,Oe)){lt=1,Jl(i,_n(o,i.current)),Me=null;return}}catch(g){if(m!==null)throw Me=m,g;lt=1,Jl(i,_n(o,i.current)),Me=null;return}s.flags&32768?(Le||d===1?i=!0:pr||(Oe&536870912)!==0?i=!1:(ba=i=!0,(d===2||d===9||d===3||d===6)&&(d=fn.current,d!==null&&d.tag===13&&(d.flags|=16384))),w1(s,i)):lu(s)}function lu(i){var s=i;do{if((s.flags&32768)!==0){w1(s,ba);return}i=s.return;var o=PU(s.alternate,s,Pi);if(o!==null){Me=o;return}if(s=s.sibling,s!==null){Me=s;return}Me=s=i}while(s!==null);lt===0&&(lt=5)}function w1(i,s){do{var o=NU(i.alternate,i);if(o!==null){o.flags&=32767,Me=o;return}if(o=i.return,o!==null&&(o.flags|=32768,o.subtreeFlags=0,o.deletions=null),!s&&(i=i.sibling,i!==null)){Me=i;return}Me=i=o}while(i!==null);lt=6,Me=null}function R1(i,s,o,d,m,g,b,C,M){i.cancelPendingCommit=null;do uu();while(Et!==0);if((je&6)!==0)throw Error(a(327));if(s!==null){if(s===i.current)throw Error(a(177));if(g=s.lanes|s.childLanes,g|=gm,TI(i,o,g,b,C,M),i===Je&&(Me=Je=null,Oe=0),vr=s,Ca=i,Ni=o,Ep=g,wp=m,p1=d,(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,KU(fl,function(){return D1(),null})):(i.callbackNode=null,i.callbackPriority=0),d=(s.flags&13878)!==0,(s.subtreeFlags&13878)!==0||d){d=H.T,H.T=null,m=ne.p,ne.p=2,b=je,je|=4;try{LU(i,s,o)}finally{je=b,ne.p=m,H.T=d}}Et=1,_1(),x1(),A1()}}function _1(){if(Et===1){Et=0;var i=Ca,s=vr,o=(s.flags&13878)!==0;if((s.subtreeFlags&13878)!==0||o){o=H.T,H.T=null;var d=ne.p;ne.p=2;var m=je;je|=4;try{o1(s,i);var g=Vp,b=hk(i.containerInfo),C=g.focusedElem,M=g.selectionRange;if(b!==C&&C&&C.ownerDocument&&fk(C.ownerDocument.documentElement,C)){if(M!==null&&dm(C)){var z=M.start,J=M.end;if(J===void 0&&(J=z),"selectionStart"in C)C.selectionStart=z,C.selectionEnd=Math.min(J,C.value.length);else{var $=C.ownerDocument||document,F=$&&$.defaultView||window;if(F.getSelection){var K=F.getSelection(),ue=C.textContent.length,ge=Math.min(M.start,ue),Ke=M.end===void 0?ge:Math.min(M.end,ue);!K.extend&&ge>Ke&&(b=Ke,Ke=ge,ge=b);var I=dk(C,ge),O=dk(C,Ke);if(I&&O&&(K.rangeCount!==1||K.anchorNode!==I.node||K.anchorOffset!==I.offset||K.focusNode!==O.node||K.focusOffset!==O.offset)){var B=$.createRange();B.setStart(I.node,I.offset),K.removeAllRanges(),ge>Ke?(K.addRange(B),K.extend(O.node,O.offset)):(B.setEnd(O.node,O.offset),K.addRange(B))}}}}for($=[],K=C;K=K.parentNode;)K.nodeType===1&&$.push({element:K,left:K.scrollLeft,top:K.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;C<$.length;C++){var W=$[C];W.element.scrollLeft=W.left,W.element.scrollTop=W.top}}Cu=!!jp,Vp=jp=null}finally{je=m,ne.p=d,H.T=o}}i.current=s,Et=2}}function x1(){if(Et===2){Et=0;var i=Ca,s=vr,o=(s.flags&8772)!==0;if((s.subtreeFlags&8772)!==0||o){o=H.T,H.T=null;var d=ne.p;ne.p=2;var m=je;je|=4;try{n1(i,s.alternate,s)}finally{je=m,ne.p=d,H.T=o}}Et=3}}function A1(){if(Et===4||Et===3){Et=0,fI();var i=Ca,s=vr,o=Ni,d=p1;(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?Et=5:(Et=0,vr=Ca=null,M1(i,i.pendingLanes));var m=i.pendingLanes;if(m===0&&(Ta=null),Kh(o),s=s.stateNode,cn&&typeof cn.onCommitFiberRoot=="function")try{cn.onCommitFiberRoot(fo,s,void 0,(s.current.flags&128)===128)}catch{}if(d!==null){s=H.T,m=ne.p,ne.p=2,H.T=null;try{for(var g=i.onRecoverableError,b=0;b<d.length;b++){var C=d[b];g(C.value,{componentStack:C.stack})}}finally{H.T=s,ne.p=m}}(Ni&3)!==0&&uu(),oi(i),m=i.pendingLanes,(o&261930)!==0&&(m&42)!==0?i===Rp?Yo++:(Yo=0,Rp=i):Yo=0,Xo(0)}}function M1(i,s){(i.pooledCacheLanes&=s)===0&&(s=i.pooledCache,s!=null&&(i.pooledCache=null,xo(s)))}function uu(){return _1(),x1(),A1(),D1()}function D1(){if(Et!==5)return!1;var i=Ca,s=Ep;Ep=0;var o=Kh(Ni),d=H.T,m=ne.p;try{ne.p=32>o?32:o,H.T=null,o=wp,wp=null;var g=Ca,b=Ni;if(Et=0,vr=Ca=null,Ni=0,(je&6)!==0)throw Error(a(331));var C=je;if(je|=4,f1(g.current),l1(g,g.current,b,o),je=C,Xo(0,!1),cn&&typeof cn.onPostCommitFiberRoot=="function")try{cn.onPostCommitFiberRoot(fo,g)}catch{}return!0}finally{ne.p=m,H.T=d,M1(i,s)}}function O1(i,s,o){s=_n(o,s),s=ap(i.stateNode,s,2),i=pa(i,s,2),i!==null&&(mo(i,2),oi(i))}function ze(i,s,o){if(i.tag===3)O1(i,i,o);else for(;s!==null;){if(s.tag===3){O1(s,i,o);break}else if(s.tag===1){var d=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(Ta===null||!Ta.has(d))){i=_n(o,i),o=PE(2),d=pa(s,o,2),d!==null&&(NE(o,d,s,i),mo(d,2),oi(d));break}}s=s.return}}function Ap(i,s,o){var d=i.pingCache;if(d===null){d=i.pingCache=new BU;var m=new Set;d.set(s,m)}else m=d.get(s),m===void 0&&(m=new Set,d.set(s,m));m.has(o)||(Tp=!0,m.add(o),i=qU.bind(null,i,s,o),s.then(i,i))}function qU(i,s,o){var d=i.pingCache;d!==null&&d.delete(s),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Je===i&&(Oe&o)===o&&(lt===4||lt===3&&(Oe&62914560)===Oe&&300>on()-au?(je&2)===0&&yr(i,0):Cp|=o,gr===Oe&&(gr=0)),oi(i)}function P1(i,s){s===0&&(s=_C()),i=Za(i,s),i!==null&&(mo(i,s),oi(i))}function HU(i){var s=i.memoizedState,o=0;s!==null&&(o=s.retryLane),P1(i,o)}function GU(i,s){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(a(314))}d!==null&&d.delete(s),P1(i,o)}function KU(i,s){return Fh(i,s)}var du=null,Sr=null,Mp=!1,fu=!1,Dp=!1,Ea=0;function oi(i){i!==Sr&&i.next===null&&(Sr===null?du=Sr=i:Sr=Sr.next=i),fu=!0,Mp||(Mp=!0,XU())}function Xo(i,s){if(!Dp&&fu){Dp=!0;do for(var o=!1,d=du;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var g=0;else{var b=d.suspendedLanes,C=d.pingedLanes;g=(1<<31-ln(42|i)+1)-1,g&=m&~(b&~C),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(o=!0,U1(d,g))}else g=Oe,g=gl(d,d===Je?g:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(g&3)===0||ho(d,g)||(o=!0,U1(d,g));d=d.next}while(o);Dp=!1}}function YU(){N1()}function N1(){fu=Mp=!1;var i=0;Ea!==0&&a5()&&(i=Ea);for(var s=on(),o=null,d=du;d!==null;){var m=d.next,g=L1(d,s);g===0?(d.next=null,o===null?du=m:o.next=m,m===null&&(Sr=o)):(o=d,(i!==0||(g&3)!==0)&&(fu=!0)),d=m}Et!==0&&Et!==5||Xo(i),Ea!==0&&(Ea=0)}function L1(i,s){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,g=i.pendingLanes&-62914561;0<g;){var b=31-ln(g),C=1<<b,M=m[b];M===-1?((C&o)===0||(C&d)!==0)&&(m[b]=SI(C,s)):M<=s&&(i.expiredLanes|=C),g&=~C}if(s=Je,o=Oe,o=gl(i,i===s?o:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),d=i.callbackNode,o===0||i===s&&(Ve===2||Ve===9)||i.cancelPendingCommit!==null)return d!==null&&d!==null&&qh(d),i.callbackNode=null,i.callbackPriority=0;if((o&3)===0||ho(i,o)){if(s=o&-o,s===i.callbackPriority)return s;switch(d!==null&&qh(d),Kh(o)){case 2:case 8:o=wC;break;case 32:o=fl;break;case 268435456:o=RC;break;default:o=fl}return d=I1.bind(null,i),o=Fh(o,d),i.callbackPriority=s,i.callbackNode=o,s}return d!==null&&d!==null&&qh(d),i.callbackPriority=2,i.callbackNode=null,2}function I1(i,s){if(Et!==0&&Et!==5)return i.callbackNode=null,i.callbackPriority=0,null;var o=i.callbackNode;if(uu()&&i.callbackNode!==o)return null;var d=Oe;return d=gl(i,i===Je?d:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),d===0?null:(v1(i,d,s),L1(i,on()),i.callbackNode!=null&&i.callbackNode===o?I1.bind(null,i):null)}function U1(i,s){if(uu())return null;v1(i,s,!0)}function XU(){r5(function(){(je&6)!==0?Fh(EC,YU):N1()})}function Op(){if(Ea===0){var i=sr;i===0&&(i=hl,hl<<=1,(hl&261888)===0&&(hl=256)),Ea=i}return Ea}function B1(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Sl(""+i)}function j1(i,s){var o=s.ownerDocument.createElement("input");return o.name=s.name,o.value=s.value,i.id&&o.setAttribute("form",i.id),s.parentNode.insertBefore(o,s),i=new FormData(i),o.parentNode.removeChild(o),i}function QU(i,s,o,d,m){if(s==="submit"&&o&&o.stateNode===m){var g=B1((m[Jt]||null).action),b=d.submitter;b&&(s=(s=b[Jt]||null)?B1(s.formAction):b.getAttribute("formAction"),s!==null&&(g=s,b=null));var C=new El("action","action",null,d,m);i.push({event:C,listeners:[{instance:null,listener:function(){if(d.defaultPrevented){if(Ea!==0){var M=b?j1(m,b):new FormData(m);Wm(o,{pending:!0,data:M,method:m.method,action:g},null,M)}}else typeof g=="function"&&(C.preventDefault(),M=b?j1(m,b):new FormData(m),Wm(o,{pending:!0,data:M,method:m.method,action:g},g,M))},currentTarget:m}]})}}for(var Pp=0;Pp<pm.length;Pp++){var Np=pm[Pp],JU=Np.toLowerCase(),ZU=Np[0].toUpperCase()+Np.slice(1);Hn(JU,"on"+ZU)}Hn(gk,"onAnimationEnd"),Hn(vk,"onAnimationIteration"),Hn(yk,"onAnimationStart"),Hn("dblclick","onDoubleClick"),Hn("focusin","onFocus"),Hn("focusout","onBlur"),Hn(hU,"onTransitionRun"),Hn(mU,"onTransitionStart"),Hn(pU,"onTransitionCancel"),Hn(bk,"onTransitionEnd"),Gs("onMouseEnter",["mouseout","mouseover"]),Gs("onMouseLeave",["mouseout","mouseover"]),Gs("onPointerEnter",["pointerout","pointerover"]),Gs("onPointerLeave",["pointerout","pointerover"]),Ya("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ya("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ya("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ya("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ya("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ya("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Qo="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),WU=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Qo));function V1(i,s){s=(s&4)!==0;for(var o=0;o<i.length;o++){var d=i[o],m=d.event;d=d.listeners;e:{var g=void 0;if(s)for(var b=d.length-1;0<=b;b--){var C=d[b],M=C.instance,z=C.currentTarget;if(C=C.listener,M!==g&&m.isPropagationStopped())break e;g=C,m.currentTarget=z;try{g(m)}catch(J){_l(J)}m.currentTarget=null,g=M}else for(b=0;b<d.length;b++){if(C=d[b],M=C.instance,z=C.currentTarget,C=C.listener,M!==g&&m.isPropagationStopped())break e;g=C,m.currentTarget=z;try{g(m)}catch(J){_l(J)}m.currentTarget=null,g=M}}}}function De(i,s){var o=s[Yh];o===void 0&&(o=s[Yh]=new Set);var d=i+"__bubble";o.has(d)||(z1(s,i,2,!1),o.add(d))}function Lp(i,s,o){var d=0;s&&(d|=4),z1(o,i,d,s)}var hu="_reactListening"+Math.random().toString(36).slice(2);function Ip(i){if(!i[hu]){i[hu]=!0,NC.forEach(function(o){o!=="selectionchange"&&(WU.has(o)||Lp(o,!1,i),Lp(o,!0,i))});var s=i.nodeType===9?i:i.ownerDocument;s===null||s[hu]||(s[hu]=!0,Lp("selectionchange",!1,s))}}function z1(i,s,o,d){switch(gw(s)){case 2:var m=R5;break;case 8:m=_5;break;default:m=Zp}o=m.bind(null,s,o,i),m=void 0,!nm||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(m=!0),d?m!==void 0?i.addEventListener(s,o,{capture:!0,passive:m}):i.addEventListener(s,o,!0):m!==void 0?i.addEventListener(s,o,{passive:m}):i.addEventListener(s,o,!1)}function Up(i,s,o,d,m){var g=d;if((s&1)===0&&(s&2)===0&&d!==null)e:for(;;){if(d===null)return;var b=d.tag;if(b===3||b===4){var C=d.stateNode.containerInfo;if(C===m)break;if(b===4)for(b=d.return;b!==null;){var M=b.tag;if((M===3||M===4)&&b.stateNode.containerInfo===m)return;b=b.return}for(;C!==null;){if(b=Fs(C),b===null)return;if(M=b.tag,M===5||M===6||M===26||M===27){d=g=b;continue e}C=C.parentNode}}d=d.return}KC(function(){var z=g,J=em(o),$=[];e:{var F=Sk.get(i);if(F!==void 0){var K=El,ue=i;switch(i){case"keypress":if(Cl(o)===0)break e;case"keydown":case"keyup":K=GI;break;case"focusin":ue="focus",K=rm;break;case"focusout":ue="blur",K=rm;break;case"beforeblur":case"afterblur":K=rm;break;case"click":if(o.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":K=QC;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":K=PI;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":K=XI;break;case gk:case vk:case yk:K=II;break;case bk:K=JI;break;case"scroll":case"scrollend":K=DI;break;case"wheel":K=WI;break;case"copy":case"cut":case"paste":K=BI;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":K=ZC;break;case"toggle":case"beforetoggle":K=eU}var ge=(s&4)!==0,Ke=!ge&&(i==="scroll"||i==="scrollend"),I=ge?F!==null?F+"Capture":null:F;ge=[];for(var O=z,B;O!==null;){var W=O;if(B=W.stateNode,W=W.tag,W!==5&&W!==26&&W!==27||B===null||I===null||(W=vo(O,I),W!=null&&ge.push(Jo(O,W,B))),Ke)break;O=O.return}0<ge.length&&(F=new K(F,ue,null,o,J),$.push({event:F,listeners:ge}))}}if((s&7)===0){e:{if(F=i==="mouseover"||i==="pointerover",K=i==="mouseout"||i==="pointerout",F&&o!==$h&&(ue=o.relatedTarget||o.fromElement)&&(Fs(ue)||ue[zs]))break e;if((K||F)&&(F=J.window===J?J:(F=J.ownerDocument)?F.defaultView||F.parentWindow:window,K?(ue=o.relatedTarget||o.toElement,K=z,ue=ue?Fs(ue):null,ue!==null&&(Ke=c(ue),ge=ue.tag,ue!==Ke||ge!==5&&ge!==27&&ge!==6)&&(ue=null)):(K=null,ue=z),K!==ue)){if(ge=QC,W="onMouseLeave",I="onMouseEnter",O="mouse",(i==="pointerout"||i==="pointerover")&&(ge=ZC,W="onPointerLeave",I="onPointerEnter",O="pointer"),Ke=K==null?F:go(K),B=ue==null?F:go(ue),F=new ge(W,O+"leave",K,o,J),F.target=Ke,F.relatedTarget=B,W=null,Fs(J)===z&&(ge=new ge(I,O+"enter",ue,o,J),ge.target=B,ge.relatedTarget=Ke,W=ge),Ke=W,K&&ue)t:{for(ge=$U,I=K,O=ue,B=0,W=I;W;W=ge(W))B++;W=0;for(var me=O;me;me=ge(me))W++;for(;0<B-W;)I=ge(I),B--;for(;0<W-B;)O=ge(O),W--;for(;B--;){if(I===O||O!==null&&I===O.alternate){ge=I;break t}I=ge(I),O=ge(O)}ge=null}else ge=null;K!==null&&F1($,F,K,ge,!1),ue!==null&&Ke!==null&&F1($,Ke,ue,ge,!0)}}e:{if(F=z?go(z):window,K=F.nodeName&&F.nodeName.toLowerCase(),K==="select"||K==="input"&&F.type==="file")var Ue=sk;else if(ik(F))if(rk)Ue=uU;else{Ue=cU;var fe=oU}else K=F.nodeName,!K||K.toLowerCase()!=="input"||F.type!=="checkbox"&&F.type!=="radio"?z&&Wh(z.elementType)&&(Ue=sk):Ue=lU;if(Ue&&(Ue=Ue(i,z))){ak($,Ue,o,J);break e}fe&&fe(i,F,z),i==="focusout"&&z&&F.type==="number"&&z.memoizedProps.value!=null&&Zh(F,"number",F.value)}switch(fe=z?go(z):window,i){case"focusin":(ik(fe)||fe.contentEditable==="true")&&(Zs=fe,fm=z,wo=null);break;case"focusout":wo=fm=Zs=null;break;case"mousedown":hm=!0;break;case"contextmenu":case"mouseup":case"dragend":hm=!1,mk($,o,J);break;case"selectionchange":if(fU)break;case"keydown":case"keyup":mk($,o,J)}var we;if(cm)e:{switch(i){case"compositionstart":var Pe="onCompositionStart";break e;case"compositionend":Pe="onCompositionEnd";break e;case"compositionupdate":Pe="onCompositionUpdate";break e}Pe=void 0}else Js?tk(i,o)&&(Pe="onCompositionEnd"):i==="keydown"&&o.keyCode===229&&(Pe="onCompositionStart");Pe&&(WC&&o.locale!=="ko"&&(Js||Pe!=="onCompositionStart"?Pe==="onCompositionEnd"&&Js&&(we=YC()):(ca=J,im="value"in ca?ca.value:ca.textContent,Js=!0)),fe=mu(z,Pe),0<fe.length&&(Pe=new JC(Pe,i,null,o,J),$.push({event:Pe,listeners:fe}),we?Pe.data=we:(we=nk(o),we!==null&&(Pe.data=we)))),(we=nU?iU(i,o):aU(i,o))&&(Pe=mu(z,"onBeforeInput"),0<Pe.length&&(fe=new JC("onBeforeInput","beforeinput",null,o,J),$.push({event:fe,listeners:Pe}),fe.data=we)),QU($,i,z,o,J)}V1($,s)})}function Jo(i,s,o){return{instance:i,listener:s,currentTarget:o}}function mu(i,s){for(var o=s+"Capture",d=[];i!==null;){var m=i,g=m.stateNode;if(m=m.tag,m!==5&&m!==26&&m!==27||g===null||(m=vo(i,o),m!=null&&d.unshift(Jo(i,m,g)),m=vo(i,s),m!=null&&d.push(Jo(i,m,g))),i.tag===3)return d;i=i.return}return[]}function $U(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function F1(i,s,o,d,m){for(var g=s._reactName,b=[];o!==null&&o!==d;){var C=o,M=C.alternate,z=C.stateNode;if(C=C.tag,M!==null&&M===d)break;C!==5&&C!==26&&C!==27||z===null||(M=z,m?(z=vo(o,g),z!=null&&b.unshift(Jo(o,z,M))):m||(z=vo(o,g),z!=null&&b.push(Jo(o,z,M)))),o=o.return}b.length!==0&&i.push({event:s,listeners:b})}var e5=/\r\n?/g,t5=/\u0000|\uFFFD/g;function q1(i){return(typeof i=="string"?i:""+i).replace(e5,`
|
|
9
|
+
`).replace(t5,"")}function H1(i,s){return s=q1(s),q1(i)===s}function Ge(i,s,o,d,m,g){switch(o){case"children":typeof d=="string"?s==="body"||s==="textarea"&&d===""||Ys(i,d):(typeof d=="number"||typeof d=="bigint")&&s!=="body"&&Ys(i,""+d);break;case"className":yl(i,"class",d);break;case"tabIndex":yl(i,"tabindex",d);break;case"dir":case"role":case"viewBox":case"width":case"height":yl(i,o,d);break;case"style":HC(i,d,g);break;case"data":if(s!=="object"){yl(i,"data",d);break}case"src":case"href":if(d===""&&(s!=="a"||o!=="href")){i.removeAttribute(o);break}if(d==null||typeof d=="function"||typeof d=="symbol"||typeof d=="boolean"){i.removeAttribute(o);break}d=Sl(""+d),i.setAttribute(o,d);break;case"action":case"formAction":if(typeof d=="function"){i.setAttribute(o,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof g=="function"&&(o==="formAction"?(s!=="input"&&Ge(i,s,"name",m.name,m,null),Ge(i,s,"formEncType",m.formEncType,m,null),Ge(i,s,"formMethod",m.formMethod,m,null),Ge(i,s,"formTarget",m.formTarget,m,null)):(Ge(i,s,"encType",m.encType,m,null),Ge(i,s,"method",m.method,m,null),Ge(i,s,"target",m.target,m,null)));if(d==null||typeof d=="symbol"||typeof d=="boolean"){i.removeAttribute(o);break}d=Sl(""+d),i.setAttribute(o,d);break;case"onClick":d!=null&&(i.onclick=bi);break;case"onScroll":d!=null&&De("scroll",i);break;case"onScrollEnd":d!=null&&De("scrollend",i);break;case"dangerouslySetInnerHTML":if(d!=null){if(typeof d!="object"||!("__html"in d))throw Error(a(61));if(o=d.__html,o!=null){if(m.children!=null)throw Error(a(60));i.innerHTML=o}}break;case"multiple":i.multiple=d&&typeof d!="function"&&typeof d!="symbol";break;case"muted":i.muted=d&&typeof d!="function"&&typeof d!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(d==null||typeof d=="function"||typeof d=="boolean"||typeof d=="symbol"){i.removeAttribute("xlink:href");break}o=Sl(""+d),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":d!=null&&typeof d!="function"&&typeof d!="symbol"?i.setAttribute(o,""+d):i.removeAttribute(o);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":d&&typeof d!="function"&&typeof d!="symbol"?i.setAttribute(o,""):i.removeAttribute(o);break;case"capture":case"download":d===!0?i.setAttribute(o,""):d!==!1&&d!=null&&typeof d!="function"&&typeof d!="symbol"?i.setAttribute(o,d):i.removeAttribute(o);break;case"cols":case"rows":case"size":case"span":d!=null&&typeof d!="function"&&typeof d!="symbol"&&!isNaN(d)&&1<=d?i.setAttribute(o,d):i.removeAttribute(o);break;case"rowSpan":case"start":d==null||typeof d=="function"||typeof d=="symbol"||isNaN(d)?i.removeAttribute(o):i.setAttribute(o,d);break;case"popover":De("beforetoggle",i),De("toggle",i),vl(i,"popover",d);break;case"xlinkActuate":yi(i,"http://www.w3.org/1999/xlink","xlink:actuate",d);break;case"xlinkArcrole":yi(i,"http://www.w3.org/1999/xlink","xlink:arcrole",d);break;case"xlinkRole":yi(i,"http://www.w3.org/1999/xlink","xlink:role",d);break;case"xlinkShow":yi(i,"http://www.w3.org/1999/xlink","xlink:show",d);break;case"xlinkTitle":yi(i,"http://www.w3.org/1999/xlink","xlink:title",d);break;case"xlinkType":yi(i,"http://www.w3.org/1999/xlink","xlink:type",d);break;case"xmlBase":yi(i,"http://www.w3.org/XML/1998/namespace","xml:base",d);break;case"xmlLang":yi(i,"http://www.w3.org/XML/1998/namespace","xml:lang",d);break;case"xmlSpace":yi(i,"http://www.w3.org/XML/1998/namespace","xml:space",d);break;case"is":vl(i,"is",d);break;case"innerText":case"textContent":break;default:(!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(o=AI.get(o)||o,vl(i,o,d))}}function Bp(i,s,o,d,m,g){switch(o){case"style":HC(i,d,g);break;case"dangerouslySetInnerHTML":if(d!=null){if(typeof d!="object"||!("__html"in d))throw Error(a(61));if(o=d.__html,o!=null){if(m.children!=null)throw Error(a(60));i.innerHTML=o}}break;case"children":typeof d=="string"?Ys(i,d):(typeof d=="number"||typeof d=="bigint")&&Ys(i,""+d);break;case"onScroll":d!=null&&De("scroll",i);break;case"onScrollEnd":d!=null&&De("scrollend",i);break;case"onClick":d!=null&&(i.onclick=bi);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!LC.hasOwnProperty(o))e:{if(o[0]==="o"&&o[1]==="n"&&(m=o.endsWith("Capture"),s=o.slice(2,m?o.length-7:void 0),g=i[Jt]||null,g=g!=null?g[o]:null,typeof g=="function"&&i.removeEventListener(s,g,m),typeof d=="function")){typeof g!="function"&&g!==null&&(o in i?i[o]=null:i.hasAttribute(o)&&i.removeAttribute(o)),i.addEventListener(s,d,m);break e}o in i?i[o]=d:d===!0?i.setAttribute(o,""):vl(i,o,d)}}}function It(i,s,o){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":De("error",i),De("load",i);var d=!1,m=!1,g;for(g in o)if(o.hasOwnProperty(g)){var b=o[g];if(b!=null)switch(g){case"src":d=!0;break;case"srcSet":m=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(a(137,s));default:Ge(i,s,g,b,o,null)}}m&&Ge(i,s,"srcSet",o.srcSet,o,null),d&&Ge(i,s,"src",o.src,o,null);return;case"input":De("invalid",i);var C=g=b=m=null,M=null,z=null;for(d in o)if(o.hasOwnProperty(d)){var J=o[d];if(J!=null)switch(d){case"name":m=J;break;case"type":b=J;break;case"checked":M=J;break;case"defaultChecked":z=J;break;case"value":g=J;break;case"defaultValue":C=J;break;case"children":case"dangerouslySetInnerHTML":if(J!=null)throw Error(a(137,s));break;default:Ge(i,s,d,J,o,null)}}VC(i,g,C,M,z,b,m,!1);return;case"select":De("invalid",i),d=b=g=null;for(m in o)if(o.hasOwnProperty(m)&&(C=o[m],C!=null))switch(m){case"value":g=C;break;case"defaultValue":b=C;break;case"multiple":d=C;default:Ge(i,s,m,C,o,null)}s=g,o=b,i.multiple=!!d,s!=null?Ks(i,!!d,s,!1):o!=null&&Ks(i,!!d,o,!0);return;case"textarea":De("invalid",i),g=m=d=null;for(b in o)if(o.hasOwnProperty(b)&&(C=o[b],C!=null))switch(b){case"value":d=C;break;case"defaultValue":m=C;break;case"children":g=C;break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(a(91));break;default:Ge(i,s,b,C,o,null)}FC(i,d,m,g);return;case"option":for(M in o)o.hasOwnProperty(M)&&(d=o[M],d!=null)&&(M==="selected"?i.selected=d&&typeof d!="function"&&typeof d!="symbol":Ge(i,s,M,d,o,null));return;case"dialog":De("beforetoggle",i),De("toggle",i),De("cancel",i),De("close",i);break;case"iframe":case"object":De("load",i);break;case"video":case"audio":for(d=0;d<Qo.length;d++)De(Qo[d],i);break;case"image":De("error",i),De("load",i);break;case"details":De("toggle",i);break;case"embed":case"source":case"link":De("error",i),De("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(z in o)if(o.hasOwnProperty(z)&&(d=o[z],d!=null))switch(z){case"children":case"dangerouslySetInnerHTML":throw Error(a(137,s));default:Ge(i,s,z,d,o,null)}return;default:if(Wh(s)){for(J in o)o.hasOwnProperty(J)&&(d=o[J],d!==void 0&&Bp(i,s,J,d,o,void 0));return}}for(C in o)o.hasOwnProperty(C)&&(d=o[C],d!=null&&Ge(i,s,C,d,o,null))}function n5(i,s,o,d){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var m=null,g=null,b=null,C=null,M=null,z=null,J=null;for(K in o){var $=o[K];if(o.hasOwnProperty(K)&&$!=null)switch(K){case"checked":break;case"value":break;case"defaultValue":M=$;default:d.hasOwnProperty(K)||Ge(i,s,K,null,d,$)}}for(var F in d){var K=d[F];if($=o[F],d.hasOwnProperty(F)&&(K!=null||$!=null))switch(F){case"type":g=K;break;case"name":m=K;break;case"checked":z=K;break;case"defaultChecked":J=K;break;case"value":b=K;break;case"defaultValue":C=K;break;case"children":case"dangerouslySetInnerHTML":if(K!=null)throw Error(a(137,s));break;default:K!==$&&Ge(i,s,F,K,d,$)}}Jh(i,b,C,M,z,J,g,m);return;case"select":K=b=C=F=null;for(g in o)if(M=o[g],o.hasOwnProperty(g)&&M!=null)switch(g){case"value":break;case"multiple":K=M;default:d.hasOwnProperty(g)||Ge(i,s,g,null,d,M)}for(m in d)if(g=d[m],M=o[m],d.hasOwnProperty(m)&&(g!=null||M!=null))switch(m){case"value":F=g;break;case"defaultValue":C=g;break;case"multiple":b=g;default:g!==M&&Ge(i,s,m,g,d,M)}s=C,o=b,d=K,F!=null?Ks(i,!!o,F,!1):!!d!=!!o&&(s!=null?Ks(i,!!o,s,!0):Ks(i,!!o,o?[]:"",!1));return;case"textarea":K=F=null;for(C in o)if(m=o[C],o.hasOwnProperty(C)&&m!=null&&!d.hasOwnProperty(C))switch(C){case"value":break;case"children":break;default:Ge(i,s,C,null,d,m)}for(b in d)if(m=d[b],g=o[b],d.hasOwnProperty(b)&&(m!=null||g!=null))switch(b){case"value":F=m;break;case"defaultValue":K=m;break;case"children":break;case"dangerouslySetInnerHTML":if(m!=null)throw Error(a(91));break;default:m!==g&&Ge(i,s,b,m,d,g)}zC(i,F,K);return;case"option":for(var ue in o)F=o[ue],o.hasOwnProperty(ue)&&F!=null&&!d.hasOwnProperty(ue)&&(ue==="selected"?i.selected=!1:Ge(i,s,ue,null,d,F));for(M in d)F=d[M],K=o[M],d.hasOwnProperty(M)&&F!==K&&(F!=null||K!=null)&&(M==="selected"?i.selected=F&&typeof F!="function"&&typeof F!="symbol":Ge(i,s,M,F,d,K));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var ge in o)F=o[ge],o.hasOwnProperty(ge)&&F!=null&&!d.hasOwnProperty(ge)&&Ge(i,s,ge,null,d,F);for(z in d)if(F=d[z],K=o[z],d.hasOwnProperty(z)&&F!==K&&(F!=null||K!=null))switch(z){case"children":case"dangerouslySetInnerHTML":if(F!=null)throw Error(a(137,s));break;default:Ge(i,s,z,F,d,K)}return;default:if(Wh(s)){for(var Ke in o)F=o[Ke],o.hasOwnProperty(Ke)&&F!==void 0&&!d.hasOwnProperty(Ke)&&Bp(i,s,Ke,void 0,d,F);for(J in d)F=d[J],K=o[J],!d.hasOwnProperty(J)||F===K||F===void 0&&K===void 0||Bp(i,s,J,F,d,K);return}}for(var I in o)F=o[I],o.hasOwnProperty(I)&&F!=null&&!d.hasOwnProperty(I)&&Ge(i,s,I,null,d,F);for($ in d)F=d[$],K=o[$],!d.hasOwnProperty($)||F===K||F==null&&K==null||Ge(i,s,$,F,d,K)}function G1(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function i5(){if(typeof performance.getEntriesByType=="function"){for(var i=0,s=0,o=performance.getEntriesByType("resource"),d=0;d<o.length;d++){var m=o[d],g=m.transferSize,b=m.initiatorType,C=m.duration;if(g&&C&&G1(b)){for(b=0,C=m.responseEnd,d+=1;d<o.length;d++){var M=o[d],z=M.startTime;if(z>C)break;var J=M.transferSize,$=M.initiatorType;J&&G1($)&&(M=M.responseEnd,b+=J*(M<C?1:(C-z)/(M-z)))}if(--d,s+=8*(g+b)/(m.duration/1e3),i++,10<i)break}}if(0<i)return s/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var jp=null,Vp=null;function pu(i){return i.nodeType===9?i:i.ownerDocument}function K1(i){switch(i){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Y1(i,s){if(i===0)switch(s){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&s==="foreignObject"?0:i}function zp(i,s){return i==="textarea"||i==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.children=="bigint"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Fp=null;function a5(){var i=window.event;return i&&i.type==="popstate"?i===Fp?!1:(Fp=i,!0):(Fp=null,!1)}var X1=typeof setTimeout=="function"?setTimeout:void 0,s5=typeof clearTimeout=="function"?clearTimeout:void 0,Q1=typeof Promise=="function"?Promise:void 0,r5=typeof queueMicrotask=="function"?queueMicrotask:typeof Q1!="undefined"?function(i){return Q1.resolve(null).then(i).catch(o5)}:X1;function o5(i){setTimeout(function(){throw i})}function wa(i){return i==="head"}function J1(i,s){var o=s,d=0;do{var m=o.nextSibling;if(i.removeChild(o),m&&m.nodeType===8)if(o=m.data,o==="/$"||o==="/&"){if(d===0){i.removeChild(m),Er(s);return}d--}else if(o==="$"||o==="$?"||o==="$~"||o==="$!"||o==="&")d++;else if(o==="html")Zo(i.ownerDocument.documentElement);else if(o==="head"){o=i.ownerDocument.head,Zo(o);for(var g=o.firstChild;g;){var b=g.nextSibling,C=g.nodeName;g[po]||C==="SCRIPT"||C==="STYLE"||C==="LINK"&&g.rel.toLowerCase()==="stylesheet"||o.removeChild(g),g=b}}else o==="body"&&Zo(i.ownerDocument.body);o=m}while(o);Er(s)}function Z1(i,s){var o=i;i=0;do{var d=o.nextSibling;if(o.nodeType===1?s?(o._stashedDisplay=o.style.display,o.style.display="none"):(o.style.display=o._stashedDisplay||"",o.getAttribute("style")===""&&o.removeAttribute("style")):o.nodeType===3&&(s?(o._stashedText=o.nodeValue,o.nodeValue=""):o.nodeValue=o._stashedText||""),d&&d.nodeType===8)if(o=d.data,o==="/$"){if(i===0)break;i--}else o!=="$"&&o!=="$?"&&o!=="$~"&&o!=="$!"||i++;o=d}while(o)}function qp(i){var s=i.firstChild;for(s&&s.nodeType===10&&(s=s.nextSibling);s;){var o=s;switch(s=s.nextSibling,o.nodeName){case"HTML":case"HEAD":case"BODY":qp(o),Xh(o);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(o.rel.toLowerCase()==="stylesheet")continue}i.removeChild(o)}}function c5(i,s,o,d){for(;i.nodeType===1;){var m=o;if(i.nodeName.toLowerCase()!==s.toLowerCase()){if(!d&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(d){if(!i[po])switch(s){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(g=i.getAttribute("rel"),g==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(g!==m.rel||i.getAttribute("href")!==(m.href==null||m.href===""?null:m.href)||i.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin)||i.getAttribute("title")!==(m.title==null?null:m.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(g=i.getAttribute("src"),(g!==(m.src==null?null:m.src)||i.getAttribute("type")!==(m.type==null?null:m.type)||i.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin))&&g&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(s==="input"&&i.type==="hidden"){var g=m.name==null?null:""+m.name;if(m.type==="hidden"&&i.getAttribute("name")===g)return i}else return i;if(i=On(i.nextSibling),i===null)break}return null}function l5(i,s,o){if(s==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!o||(i=On(i.nextSibling),i===null))return null;return i}function W1(i,s){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!s||(i=On(i.nextSibling),i===null))return null;return i}function Hp(i){return i.data==="$?"||i.data==="$~"}function Gp(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function u5(i,s){var o=i.ownerDocument;if(i.data==="$~")i._reactRetry=s;else if(i.data!=="$?"||o.readyState!=="loading")s();else{var d=function(){s(),o.removeEventListener("DOMContentLoaded",d)};o.addEventListener("DOMContentLoaded",d),i._reactRetry=d}}function On(i){for(;i!=null;i=i.nextSibling){var s=i.nodeType;if(s===1||s===3)break;if(s===8){if(s=i.data,s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"||s==="F!"||s==="F")break;if(s==="/$"||s==="/&")return null}}return i}var Kp=null;function $1(i){i=i.nextSibling;for(var s=0;i;){if(i.nodeType===8){var o=i.data;if(o==="/$"||o==="/&"){if(s===0)return On(i.nextSibling);s--}else o!=="$"&&o!=="$!"&&o!=="$?"&&o!=="$~"&&o!=="&"||s++}i=i.nextSibling}return null}function ew(i){i=i.previousSibling;for(var s=0;i;){if(i.nodeType===8){var o=i.data;if(o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"){if(s===0)return i;s--}else o!=="/$"&&o!=="/&"||s++}i=i.previousSibling}return null}function tw(i,s,o){switch(s=pu(o),i){case"html":if(i=s.documentElement,!i)throw Error(a(452));return i;case"head":if(i=s.head,!i)throw Error(a(453));return i;case"body":if(i=s.body,!i)throw Error(a(454));return i;default:throw Error(a(451))}}function Zo(i){for(var s=i.attributes;s.length;)i.removeAttributeNode(s[0]);Xh(i)}var Pn=new Map,nw=new Set;function gu(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Li=ne.d;ne.d={f:d5,r:f5,D:h5,C:m5,L:p5,m:g5,X:y5,S:v5,M:b5};function d5(){var i=Li.f(),s=ou();return i||s}function f5(i){var s=qs(i);s!==null&&s.tag===5&&s.type==="form"?bE(s):Li.r(i)}var Tr=typeof document=="undefined"?null:document;function iw(i,s,o){var d=Tr;if(d&&typeof s=="string"&&s){var m=wn(s);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),nw.has(m)||(nw.add(m),i={rel:i,crossOrigin:o,href:s},d.querySelector(m)===null&&(s=d.createElement("link"),It(s,"link",i),_t(s),d.head.appendChild(s)))}}function h5(i){Li.D(i),iw("dns-prefetch",i,null)}function m5(i,s){Li.C(i,s),iw("preconnect",i,s)}function p5(i,s,o){Li.L(i,s,o);var d=Tr;if(d&&i&&s){var m='link[rel="preload"][as="'+wn(s)+'"]';s==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+wn(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+wn(o.imageSizes)+'"]')):m+='[href="'+wn(i)+'"]';var g=m;switch(s){case"style":g=Cr(i);break;case"script":g=kr(i)}Pn.has(g)||(i=v({rel:"preload",href:s==="image"&&o&&o.imageSrcSet?void 0:i,as:s},o),Pn.set(g,i),d.querySelector(m)!==null||s==="style"&&d.querySelector(Wo(g))||s==="script"&&d.querySelector($o(g))||(s=d.createElement("link"),It(s,"link",i),_t(s),d.head.appendChild(s)))}}function g5(i,s){Li.m(i,s);var o=Tr;if(o&&i){var d=s&&typeof s.as=="string"?s.as:"script",m='link[rel="modulepreload"][as="'+wn(d)+'"][href="'+wn(i)+'"]',g=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=kr(i)}if(!Pn.has(g)&&(i=v({rel:"modulepreload",href:i},s),Pn.set(g,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector($o(g)))return}d=o.createElement("link"),It(d,"link",i),_t(d),o.head.appendChild(d)}}}function v5(i,s,o){Li.S(i,s,o);var d=Tr;if(d&&i){var m=Hs(d).hoistableStyles,g=Cr(i);s=s||"default";var b=m.get(g);if(!b){var C={loading:0,preload:null};if(b=d.querySelector(Wo(g)))C.loading=5;else{i=v({rel:"stylesheet",href:i,"data-precedence":s},o),(o=Pn.get(g))&&Yp(i,o);var M=b=d.createElement("link");_t(M),It(M,"link",i),M._p=new Promise(function(z,J){M.onload=z,M.onerror=J}),M.addEventListener("load",function(){C.loading|=1}),M.addEventListener("error",function(){C.loading|=2}),C.loading|=4,vu(b,s,d)}b={type:"stylesheet",instance:b,count:1,state:C},m.set(g,b)}}}function y5(i,s){Li.X(i,s);var o=Tr;if(o&&i){var d=Hs(o).hoistableScripts,m=kr(i),g=d.get(m);g||(g=o.querySelector($o(m)),g||(i=v({src:i,async:!0},s),(s=Pn.get(m))&&Xp(i,s),g=o.createElement("script"),_t(g),It(g,"link",i),o.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},d.set(m,g))}}function b5(i,s){Li.M(i,s);var o=Tr;if(o&&i){var d=Hs(o).hoistableScripts,m=kr(i),g=d.get(m);g||(g=o.querySelector($o(m)),g||(i=v({src:i,async:!0,type:"module"},s),(s=Pn.get(m))&&Xp(i,s),g=o.createElement("script"),_t(g),It(g,"link",i),o.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},d.set(m,g))}}function aw(i,s,o,d){var m=(m=Se.current)?gu(m):null;if(!m)throw Error(a(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(s=Cr(o.href),o=Hs(m).hoistableStyles,d=o.get(s),d||(d={type:"style",instance:null,count:0,state:null},o.set(s,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=Cr(o.href);var g=Hs(m).hoistableStyles,b=g.get(i);if(b||(m=m.ownerDocument||m,b={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(i,b),(g=m.querySelector(Wo(i)))&&!g._p&&(b.instance=g,b.state.loading=5),Pn.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},Pn.set(i,o),g||S5(m,i,o,b.state))),s&&d===null)throw Error(a(528,""));return b}if(s&&d!==null)throw Error(a(529,""));return null;case"script":return s=o.async,o=o.src,typeof o=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=kr(o),o=Hs(m).hoistableScripts,d=o.get(s),d||(d={type:"script",instance:null,count:0,state:null},o.set(s,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,i))}}function Cr(i){return'href="'+wn(i)+'"'}function Wo(i){return'link[rel="stylesheet"]['+i+"]"}function sw(i){return v({},i,{"data-precedence":i.precedence,precedence:null})}function S5(i,s,o,d){i.querySelector('link[rel="preload"][as="style"]['+s+"]")?d.loading=1:(s=i.createElement("link"),d.preload=s,s.addEventListener("load",function(){return d.loading|=1}),s.addEventListener("error",function(){return d.loading|=2}),It(s,"link",o),_t(s),i.head.appendChild(s))}function kr(i){return'[src="'+wn(i)+'"]'}function $o(i){return"script[async]"+i}function rw(i,s,o){if(s.count++,s.instance===null)switch(s.type){case"style":var d=i.querySelector('style[data-href~="'+wn(o.href)+'"]');if(d)return s.instance=d,_t(d),d;var m=v({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),_t(d),It(d,"style",m),vu(d,o.precedence,i),s.instance=d;case"stylesheet":m=Cr(o.href);var g=i.querySelector(Wo(m));if(g)return s.state.loading|=4,s.instance=g,_t(g),g;d=sw(o),(m=Pn.get(m))&&Yp(d,m),g=(i.ownerDocument||i).createElement("link"),_t(g);var b=g;return b._p=new Promise(function(C,M){b.onload=C,b.onerror=M}),It(g,"link",d),s.state.loading|=4,vu(g,o.precedence,i),s.instance=g;case"script":return g=kr(o.src),(m=i.querySelector($o(g)))?(s.instance=m,_t(m),m):(d=o,(m=Pn.get(g))&&(d=v({},o),Xp(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),_t(m),It(m,"link",d),i.head.appendChild(m),s.instance=m);case"void":return null;default:throw Error(a(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(d=s.instance,s.state.loading|=4,vu(d,o.precedence,i));return s.instance}function vu(i,s,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,g=m,b=0;b<d.length;b++){var C=d[b];if(C.dataset.precedence===s)g=C;else if(g!==m)break}g?g.parentNode.insertBefore(i,g.nextSibling):(s=o.nodeType===9?o.head:o,s.insertBefore(i,s.firstChild))}function Yp(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.title==null&&(i.title=s.title)}function Xp(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.integrity==null&&(i.integrity=s.integrity)}var yu=null;function ow(i,s,o){if(yu===null){var d=new Map,m=yu=new Map;m.set(o,d)}else m=yu,d=m.get(o),d||(d=new Map,m.set(o,d));if(d.has(i))return d;for(d.set(i,null),o=o.getElementsByTagName(i),m=0;m<o.length;m++){var g=o[m];if(!(g[po]||g[Ot]||i==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var b=g.getAttribute(s)||"";b=i+b;var C=d.get(b);C?C.push(g):d.set(b,[g])}}return d}function cw(i,s,o){i=i.ownerDocument||i,i.head.insertBefore(o,s==="title"?i.querySelector("head > title"):null)}function T5(i,s,o){if(o===1||s.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;return s.rel==="stylesheet"?(i=s.disabled,typeof s.precedence=="string"&&i==null):!0;case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function lw(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function C5(i,s,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=Cr(d.href),g=s.querySelector(Wo(m));if(g){s=g._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(i.count++,i=bu.bind(i),s.then(i,i)),o.state.loading|=4,o.instance=g,_t(g);return}g=s.ownerDocument||s,d=sw(d),(m=Pn.get(m))&&Yp(d,m),g=g.createElement("link"),_t(g);var b=g;b._p=new Promise(function(C,M){b.onload=C,b.onerror=M}),It(g,"link",d),o.instance=g}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,s),(s=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=bu.bind(i),s.addEventListener("load",o),s.addEventListener("error",o))}}var Qp=0;function k5(i,s){return i.stylesheets&&i.count===0&&Tu(i,i.stylesheets),0<i.count||0<i.imgCount?function(o){var d=setTimeout(function(){if(i.stylesheets&&Tu(i,i.stylesheets),i.unsuspend){var g=i.unsuspend;i.unsuspend=null,g()}},6e4+s);0<i.imgBytes&&Qp===0&&(Qp=62500*i5());var m=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&Tu(i,i.stylesheets),i.unsuspend)){var g=i.unsuspend;i.unsuspend=null,g()}},(i.imgBytes>Qp?50:800)+s);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function bu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Tu(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Su=null;function Tu(i,s){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Su=new Map,s.forEach(E5,i),Su=null,bu.call(i))}function E5(i,s){if(!(s.state.loading&4)){var o=Su.get(i);if(o)var d=o.get(null);else{o=new Map,Su.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<m.length;g++){var b=m[g];(b.nodeName==="LINK"||b.getAttribute("media")!=="not all")&&(o.set(b.dataset.precedence,b),d=b)}d&&o.set(null,d)}m=s.instance,b=m.getAttribute("data-precedence"),g=o.get(b)||d,g===d&&o.set(null,m),o.set(b,m),this.count++,d=bu.bind(this),m.addEventListener("load",d),m.addEventListener("error",d),g?g.parentNode.insertBefore(m,g.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(m,i.firstChild)),s.state.loading|=4}}var ec={$$typeof:L,Provider:null,Consumer:null,_currentValue:ce,_currentValue2:ce,_threadCount:0};function w5(i,s,o,d,m,g,b,C,M){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Hh(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Hh(0),this.hiddenUpdates=Hh(null),this.identifierPrefix=d,this.onUncaughtError=m,this.onCaughtError=g,this.onRecoverableError=b,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=M,this.incompleteTransitions=new Map}function uw(i,s,o,d,m,g,b,C,M,z,J,$){return i=new w5(i,s,o,b,M,z,J,$,C),s=1,g===!0&&(s|=24),g=dn(3,null,null,s),i.current=g,g.stateNode=i,s=xm(),s.refCount++,i.pooledCache=s,s.refCount++,g.memoizedState={element:d,isDehydrated:o,cache:s},Om(g),i}function dw(i){return i?(i=er,i):er}function fw(i,s,o,d,m,g){m=dw(m),d.context===null?d.context=m:d.pendingContext=m,d=ma(s),d.payload={element:o},g=g===void 0?null:g,g!==null&&(d.callback=g),o=pa(i,d,s),o!==null&&(nn(o,i,s),Oo(o,i,s))}function hw(i,s){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var o=i.retryLane;i.retryLane=o!==0&&o<s?o:s}}function Jp(i,s){hw(i,s),(i=i.alternate)&&hw(i,s)}function mw(i){if(i.tag===13||i.tag===31){var s=Za(i,67108864);s!==null&&nn(s,i,67108864),Jp(i,67108864)}}function pw(i){if(i.tag===13||i.tag===31){var s=gn();s=Gh(s);var o=Za(i,s);o!==null&&nn(o,i,s),Jp(i,s)}}var Cu=!0;function R5(i,s,o,d){var m=H.T;H.T=null;var g=ne.p;try{ne.p=2,Zp(i,s,o,d)}finally{ne.p=g,H.T=m}}function _5(i,s,o,d){var m=H.T;H.T=null;var g=ne.p;try{ne.p=8,Zp(i,s,o,d)}finally{ne.p=g,H.T=m}}function Zp(i,s,o,d){if(Cu){var m=Wp(d);if(m===null)Up(i,s,d,ku,o),vw(i,d);else if(A5(m,i,s,o,d))d.stopPropagation();else if(vw(i,d),s&4&&-1<x5.indexOf(i)){for(;m!==null;){var g=qs(m);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var b=Ka(g.pendingLanes);if(b!==0){var C=g;for(C.pendingLanes|=2,C.entangledLanes|=2;b;){var M=1<<31-ln(b);C.entanglements[1]|=M,b&=~M}oi(g),(je&6)===0&&(su=on()+500,Xo(0))}}break;case 31:case 13:C=Za(g,2),C!==null&&nn(C,g,2),ou(),Jp(g,2)}if(g=Wp(d),g===null&&Up(i,s,d,ku,o),g===m)break;m=g}m!==null&&d.stopPropagation()}else Up(i,s,d,null,o)}}function Wp(i){return i=em(i),$p(i)}var ku=null;function $p(i){if(ku=null,i=Fs(i),i!==null){var s=c(i);if(s===null)i=null;else{var o=s.tag;if(o===13){if(i=l(s),i!==null)return i;i=null}else if(o===31){if(i=u(s),i!==null)return i;i=null}else if(o===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;i=null}else s!==i&&(i=null)}}return ku=i,null}function gw(i){switch(i){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(hI()){case EC:return 2;case wC:return 8;case fl:case mI:return 32;case RC:return 268435456;default:return 32}default:return 32}}var eg=!1,Ra=null,_a=null,xa=null,tc=new Map,nc=new Map,Aa=[],x5="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function vw(i,s){switch(i){case"focusin":case"focusout":Ra=null;break;case"dragenter":case"dragleave":_a=null;break;case"mouseover":case"mouseout":xa=null;break;case"pointerover":case"pointerout":tc.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":nc.delete(s.pointerId)}}function ic(i,s,o,d,m,g){return i===null||i.nativeEvent!==g?(i={blockedOn:s,domEventName:o,eventSystemFlags:d,nativeEvent:g,targetContainers:[m]},s!==null&&(s=qs(s),s!==null&&mw(s)),i):(i.eventSystemFlags|=d,s=i.targetContainers,m!==null&&s.indexOf(m)===-1&&s.push(m),i)}function A5(i,s,o,d,m){switch(s){case"focusin":return Ra=ic(Ra,i,s,o,d,m),!0;case"dragenter":return _a=ic(_a,i,s,o,d,m),!0;case"mouseover":return xa=ic(xa,i,s,o,d,m),!0;case"pointerover":var g=m.pointerId;return tc.set(g,ic(tc.get(g)||null,i,s,o,d,m)),!0;case"gotpointercapture":return g=m.pointerId,nc.set(g,ic(nc.get(g)||null,i,s,o,d,m)),!0}return!1}function yw(i){var s=Fs(i.target);if(s!==null){var o=c(s);if(o!==null){if(s=o.tag,s===13){if(s=l(o),s!==null){i.blockedOn=s,OC(i.priority,function(){pw(o)});return}}else if(s===31){if(s=u(o),s!==null){i.blockedOn=s,OC(i.priority,function(){pw(o)});return}}else if(s===3&&o.stateNode.current.memoizedState.isDehydrated){i.blockedOn=o.tag===3?o.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Eu(i){if(i.blockedOn!==null)return!1;for(var s=i.targetContainers;0<s.length;){var o=Wp(i.nativeEvent);if(o===null){o=i.nativeEvent;var d=new o.constructor(o.type,o);$h=d,o.target.dispatchEvent(d),$h=null}else return s=qs(o),s!==null&&mw(s),i.blockedOn=o,!1;s.shift()}return!0}function bw(i,s,o){Eu(i)&&o.delete(s)}function M5(){eg=!1,Ra!==null&&Eu(Ra)&&(Ra=null),_a!==null&&Eu(_a)&&(_a=null),xa!==null&&Eu(xa)&&(xa=null),tc.forEach(bw),nc.forEach(bw)}function wu(i,s){i.blockedOn===s&&(i.blockedOn=null,eg||(eg=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,M5)))}var Ru=null;function Sw(i){Ru!==i&&(Ru=i,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Ru===i&&(Ru=null);for(var s=0;s<i.length;s+=3){var o=i[s],d=i[s+1],m=i[s+2];if(typeof d!="function"){if($p(d||o)===null)continue;break}var g=qs(o);g!==null&&(i.splice(s,3),s-=3,Wm(g,{pending:!0,data:m,method:o.method,action:d},d,m))}}))}function Er(i){function s(M){return wu(M,i)}Ra!==null&&wu(Ra,i),_a!==null&&wu(_a,i),xa!==null&&wu(xa,i),tc.forEach(s),nc.forEach(s);for(var o=0;o<Aa.length;o++){var d=Aa[o];d.blockedOn===i&&(d.blockedOn=null)}for(;0<Aa.length&&(o=Aa[0],o.blockedOn===null);)yw(o),o.blockedOn===null&&Aa.shift();if(o=(i.ownerDocument||i).$$reactFormReplay,o!=null)for(d=0;d<o.length;d+=3){var m=o[d],g=o[d+1],b=m[Jt]||null;if(typeof g=="function")b||Sw(o);else if(b){var C=null;if(g&&g.hasAttribute("formAction")){if(m=g,b=g[Jt]||null)C=b.formAction;else if($p(m)!==null)continue}else C=b.action;typeof C=="function"?o[d+1]=C:(o.splice(d,3),d-=3),Sw(o)}}}function Tw(){function i(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(b){return m=b})},focusReset:"manual",scroll:"manual"})}function s(){m!==null&&(m(),m=null),d||setTimeout(o,20)}function o(){if(!d&&!navigation.transition){var g=navigation.currentEntry;g&&g.url!=null&&navigation.navigate(g.url,{state:g.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var d=!1,m=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",s),navigation.addEventListener("navigateerror",s),setTimeout(o,100),function(){d=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",s),navigation.removeEventListener("navigateerror",s),m!==null&&(m(),m=null)}}}function tg(i){this._internalRoot=i}_u.prototype.render=tg.prototype.render=function(i){var s=this._internalRoot;if(s===null)throw Error(a(409));var o=s.current,d=gn();fw(o,d,i,s,null,null)},_u.prototype.unmount=tg.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var s=i.containerInfo;fw(i.current,2,null,i,null,null),ou(),s[zs]=null}};function _u(i){this._internalRoot=i}_u.prototype.unstable_scheduleHydration=function(i){if(i){var s=DC();i={blockedOn:null,target:i,priority:s};for(var o=0;o<Aa.length&&s!==0&&s<Aa[o].priority;o++);Aa.splice(o,0,i),o===0&&yw(i)}};var Cw=e.version;if(Cw!=="19.2.3")throw Error(a(527,Cw,"19.2.3"));ne.findDOMNode=function(i){var s=i._reactInternals;if(s===void 0)throw typeof i.render=="function"?Error(a(188)):(i=Object.keys(i).join(","),Error(a(268,i)));return i=h(s),i=i!==null?p(i):null,i=i===null?null:i.stateNode,i};var D5={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:H,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"){var xu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!xu.isDisabled&&xu.supportsFiber)try{fo=xu.inject(D5),cn=xu}catch{}}return Rr.createRoot=function(i,s){if(!r(i))throw Error(a(299));var o=!1,d="",m=AE,g=ME,b=DE;return s!=null&&(s.unstable_strictMode===!0&&(o=!0),s.identifierPrefix!==void 0&&(d=s.identifierPrefix),s.onUncaughtError!==void 0&&(m=s.onUncaughtError),s.onCaughtError!==void 0&&(g=s.onCaughtError),s.onRecoverableError!==void 0&&(b=s.onRecoverableError)),s=uw(i,1,!1,null,null,o,d,null,m,g,b,Tw),i[zs]=s.current,Ip(i),new tg(s)},Rr.hydrateRoot=function(i,s,o){if(!r(i))throw Error(a(299));var d=!1,m="",g=AE,b=ME,C=DE,M=null;return o!=null&&(o.unstable_strictMode===!0&&(d=!0),o.identifierPrefix!==void 0&&(m=o.identifierPrefix),o.onUncaughtError!==void 0&&(g=o.onUncaughtError),o.onCaughtError!==void 0&&(b=o.onCaughtError),o.onRecoverableError!==void 0&&(C=o.onRecoverableError),o.formState!==void 0&&(M=o.formState)),s=uw(i,1,!0,s,o!=null?o:null,d,m,M,g,b,C,Tw),s.context=dw(null),o=s.current,d=gn(),d=Gh(d),m=ma(d),m.callback=null,pa(o,m,d),o=d,s.current.lanes=o,mo(s,o),oi(s),i[zs]=s.current,Ip(i),new _u(s)},Rr.version="19.2.3",Rr}var dg;function Dw(){if(dg)return Au.exports;dg=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Au.exports=Mw(),Au.exports}var Ow=Dw();function Pw(t="bello-widget-root"){let e=document.getElementById(t);return e||(e=document.createElement("div"),e.id=t,e.style.position="relative",e.style.zIndex="2147483646",document.body.appendChild(e)),e}function Nw(t){let e=t._shadowRoot;return e||(e=t.attachShadow({mode:"open"}),t._shadowRoot=e),e}function Nu(t){if(!t||typeof t!="object")return;const e={};for(const[n,a]of Object.entries(t)){if(a==null)continue;const r=n.startsWith("--")?n:`--${n}`;e[r]=String(a)}return Object.keys(e).length?e:void 0}async function Lw(t){var l,u,f,h,p,v,y,S,w,T,x,R,P,L;const e=(l=t.apiBaseUrl)!=null?l:"",n=await fetch(`${e}/api/projects/${encodeURIComponent(t.projectId)}`,{method:"GET",mode:"cors",credentials:"omit",headers:{Accept:"application/json"}});if(!n.ok)throw new Error(`Config fetch failed: ${n.status}`);const a=await n.json(),r=(h=(f=(u=a==null?void 0:a.project)==null?void 0:u.widget_config)!=null?f:a==null?void 0:a.widget_config)!=null?h:{},c=Nu(r.theme_vars)||Nu(r.themeVars)||Nu(r.css_vars)||void 0;return{widgetTitle:(v=(p=r.widget_title)!=null?p:t.widgetTitle)!=null?v:"Chat with AI",widgetButtonTitle:(S=(y=r.widget_button_title)!=null?y:t.widgetButtonTitle)!=null?S:"Start chat",orbStyle:(T=(w=r.orb_style)!=null?w:t.orbStyle)!=null?T:"galaxy",theme:(R=(x=r.theme)!=null?x:t.theme)!=null?R:"dark",position:(L=(P=r.position)!=null?P:t.position)!=null?L:"bottom-right",themeVars:c}}async function Iw(t){var r,c,l;const e=(r=t.apiBaseUrl)!=null?r:"",n=await fetch(`${e}/api/livekit/token/${encodeURIComponent(t.projectId)}`,{method:"POST",mode:"cors",credentials:"omit",headers:{"Content-Type":"application/json"}});if(!n.ok)throw new Error(`Token fetch failed: ${n.status}`);const a=await n.json();return{serverUrl:(c=a.serverUrl)!=null?c:a.livekit_url,participantToken:(l=a.participantToken)!=null?l:a.token}}var q=ac();const fg=q.createContext({});function Uw(t){const e=q.useRef(null);return e.current===null&&(e.current=t()),e.current}const hg=typeof window!="undefined",Bw=hg?q.useLayoutEffect:q.useEffect,Lu=q.createContext(null);function Iu(t,e){t.indexOf(e)===-1&&t.push(e)}function Uu(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Yn=(t,e,n)=>n>e?e:n<t?t:n;let Bu=()=>{};const ci={},mg=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function pg(t){return typeof t=="object"&&t!==null}const gg=t=>/^0[^.\s]+$/u.test(t);function ju(t){let e;return()=>(e===void 0&&(e=t()),e)}const vn=t=>t,jw=(t,e)=>n=>e(t(n)),_r=(...t)=>t.reduce(jw),xr=(t,e,n)=>{const a=e-t;return a===0?1:(n-t)/a};class Vu{constructor(){this.subscriptions=[]}add(e){return Iu(this.subscriptions,e),()=>Uu(this.subscriptions,e)}notify(e,n,a){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,n,a);else for(let c=0;c<r;c++){const l=this.subscriptions[c];l&&l(e,n,a)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const li=t=>t*1e3,yn=t=>t/1e3;function vg(t,e){return e?t*(1e3/e):0}const yg=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Vw=1e-7,zw=12;function Fw(t,e,n,a,r){let c,l,u=0;do l=e+(n-e)/2,c=yg(l,a,r)-t,c>0?n=l:e=l;while(Math.abs(c)>Vw&&++u<zw);return l}function Ar(t,e,n,a){if(t===e&&n===a)return vn;const r=c=>Fw(c,0,1,t,n);return c=>c===0||c===1?c:yg(r(c),e,a)}const bg=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Sg=t=>e=>1-t(1-e),Tg=Ar(.33,1.53,.69,.99),zu=Sg(Tg),Cg=bg(zu),kg=t=>(t*=2)<1?.5*zu(t):.5*(2-Math.pow(2,-10*(t-1))),Fu=t=>1-Math.sin(Math.acos(t)),Eg=Sg(Fu),wg=bg(Fu),qw=Ar(.42,0,1,1),Hw=Ar(0,0,.58,1),Rg=Ar(.42,0,.58,1),Gw=t=>Array.isArray(t)&&typeof t[0]!="number",_g=t=>Array.isArray(t)&&typeof t[0]=="number",Kw={linear:vn,easeIn:qw,easeInOut:Rg,easeOut:Hw,circIn:Fu,circInOut:wg,circOut:Eg,backIn:zu,backInOut:Cg,backOut:Tg,anticipate:kg},Yw=t=>typeof t=="string",xg=t=>{if(_g(t)){Bu(t.length===4);const[e,n,a,r]=t;return Ar(e,n,a,r)}else if(Yw(t))return Kw[t];return t},sc=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Xw(t,e){let n=new Set,a=new Set,r=!1,c=!1;const l=new WeakSet;let u={delta:0,timestamp:0,isProcessing:!1};function f(p){l.has(p)&&(h.schedule(p),t()),p(u)}const h={schedule:(p,v=!1,y=!1)=>{const w=y&&r?n:a;return v&&l.add(p),w.has(p)||w.add(p),p},cancel:p=>{a.delete(p),l.delete(p)},process:p=>{if(u=p,r){c=!0;return}r=!0,[n,a]=[a,n],n.forEach(f),n.clear(),r=!1,c&&(c=!1,h.process(p))}};return h}const Qw=40;function Ag(t,e){let n=!1,a=!0;const r={delta:0,timestamp:0,isProcessing:!1},c=()=>n=!0,l=sc.reduce((L,E)=>(L[E]=Xw(c),L),{}),{setup:u,read:f,resolveKeyframes:h,preUpdate:p,update:v,preRender:y,render:S,postRender:w}=l,T=()=>{const L=ci.useManualTiming?r.timestamp:performance.now();n=!1,ci.useManualTiming||(r.delta=a?1e3/60:Math.max(Math.min(L-r.timestamp,Qw),1)),r.timestamp=L,r.isProcessing=!0,u.process(r),f.process(r),h.process(r),p.process(r),v.process(r),y.process(r),S.process(r),w.process(r),r.isProcessing=!1,n&&e&&(a=!1,t(T))},x=()=>{n=!0,a=!0,r.isProcessing||t(T)};return{schedule:sc.reduce((L,E)=>{const k=l[E];return L[E]=(_,N=!1,U=!1)=>(n||x(),k.schedule(_,N,U)),L},{}),cancel:L=>{for(let E=0;E<sc.length;E++)l[sc[E]].cancel(L)},state:r,steps:l}}const{schedule:Ze,cancel:Ii,state:At,steps:qu}=Ag(typeof requestAnimationFrame!="undefined"?requestAnimationFrame:vn,!0);let rc;function Jw(){rc=void 0}const jt={now:()=>(rc===void 0&&jt.set(At.isProcessing||ci.useManualTiming?At.timestamp:performance.now()),rc),set:t=>{rc=t,queueMicrotask(Jw)}},Mg=t=>e=>typeof e=="string"&&e.startsWith(t),Dg=Mg("--"),Zw=Mg("var(--"),Hu=t=>Zw(t)?Ww.test(t.split("/*")[0].trim()):!1,Ww=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Og(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const ds={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Mr={...ds,transform:t=>Yn(0,1,t)},oc={...ds,default:1},Dr=t=>Math.round(t*1e5)/1e5,Gu=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function $w(t){return t==null}const eR=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Ku=(t,e)=>n=>!!(typeof n=="string"&&eR.test(n)&&n.startsWith(t)||e&&!$w(n)&&Object.prototype.hasOwnProperty.call(n,e)),Pg=(t,e,n)=>a=>{if(typeof a!="string")return a;const[r,c,l,u]=a.match(Gu);return{[t]:parseFloat(r),[e]:parseFloat(c),[n]:parseFloat(l),alpha:u!==void 0?parseFloat(u):1}},tR=t=>Yn(0,255,t),Yu={...ds,transform:t=>Math.round(tR(t))},Da={test:Ku("rgb","red"),parse:Pg("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:a=1})=>"rgba("+Yu.transform(t)+", "+Yu.transform(e)+", "+Yu.transform(n)+", "+Dr(Mr.transform(a))+")"};function nR(t){let e="",n="",a="",r="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),a=t.substring(5,7),r=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),a=t.substring(3,4),r=t.substring(4,5),e+=e,n+=n,a+=a,r+=r),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(a,16),alpha:r?parseInt(r,16)/255:1}}const Xu={test:Ku("#"),parse:nR,transform:Da.transform},Or=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Ui=Or("deg"),Xn=Or("%"),de=Or("px"),iR=Or("vh"),aR=Or("vw"),Ng={...Xn,parse:t=>Xn.parse(t)/100,transform:t=>Xn.transform(t*100)},fs={test:Ku("hsl","hue"),parse:Pg("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:a=1})=>"hsla("+Math.round(t)+", "+Xn.transform(Dr(e))+", "+Xn.transform(Dr(n))+", "+Dr(Mr.transform(a))+")"},mt={test:t=>Da.test(t)||Xu.test(t)||fs.test(t),parse:t=>Da.test(t)?Da.parse(t):fs.test(t)?fs.parse(t):Xu.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Da.transform(t):fs.transform(t),getAnimatableNone:t=>{const e=mt.parse(t);return e.alpha=0,mt.transform(e)}},sR=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function rR(t){var e,n;return isNaN(t)&&typeof t=="string"&&(((e=t.match(Gu))==null?void 0:e.length)||0)+(((n=t.match(sR))==null?void 0:n.length)||0)>0}const Lg="number",Ig="color",oR="var",cR="var(",Ug="${}",lR=/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 Pr(t){const e=t.toString(),n=[],a={color:[],number:[],var:[]},r=[];let c=0;const u=e.replace(lR,f=>(mt.test(f)?(a.color.push(c),r.push(Ig),n.push(mt.parse(f))):f.startsWith(cR)?(a.var.push(c),r.push(oR),n.push(f)):(a.number.push(c),r.push(Lg),n.push(parseFloat(f))),++c,Ug)).split(Ug);return{values:n,split:u,indexes:a,types:r}}function Bg(t){return Pr(t).values}function jg(t){const{split:e,types:n}=Pr(t),a=e.length;return r=>{let c="";for(let l=0;l<a;l++)if(c+=e[l],r[l]!==void 0){const u=n[l];u===Lg?c+=Dr(r[l]):u===Ig?c+=mt.transform(r[l]):c+=r[l]}return c}}const uR=t=>typeof t=="number"?0:mt.test(t)?mt.getAnimatableNone(t):t;function dR(t){const e=Bg(t);return jg(t)(e.map(uR))}const Bi={test:rR,parse:Bg,createTransformer:jg,getAnimatableNone:dR};function Qu(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 fR({hue:t,saturation:e,lightness:n,alpha:a}){t/=360,e/=100,n/=100;let r=0,c=0,l=0;if(!e)r=c=l=n;else{const u=n<.5?n*(1+e):n+e-n*e,f=2*n-u;r=Qu(f,u,t+1/3),c=Qu(f,u,t),l=Qu(f,u,t-1/3)}return{red:Math.round(r*255),green:Math.round(c*255),blue:Math.round(l*255),alpha:a}}function cc(t,e){return n=>n>0?e:t}const it=(t,e,n)=>t+(e-t)*n,Ju=(t,e,n)=>{const a=t*t,r=n*(e*e-a)+a;return r<0?0:Math.sqrt(r)},hR=[Xu,Da,fs],mR=t=>hR.find(e=>e.test(t));function Vg(t){const e=mR(t);if(!e)return!1;let n=e.parse(t);return e===fs&&(n=fR(n)),n}const zg=(t,e)=>{const n=Vg(t),a=Vg(e);if(!n||!a)return cc(t,e);const r={...n};return c=>(r.red=Ju(n.red,a.red,c),r.green=Ju(n.green,a.green,c),r.blue=Ju(n.blue,a.blue,c),r.alpha=it(n.alpha,a.alpha,c),Da.transform(r))},Zu=new Set(["none","hidden"]);function pR(t,e){return Zu.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function gR(t,e){return n=>it(t,e,n)}function Wu(t){return typeof t=="number"?gR:typeof t=="string"?Hu(t)?cc:mt.test(t)?zg:bR:Array.isArray(t)?Fg:typeof t=="object"?mt.test(t)?zg:vR:cc}function Fg(t,e){const n=[...t],a=n.length,r=t.map((c,l)=>Wu(c)(c,e[l]));return c=>{for(let l=0;l<a;l++)n[l]=r[l](c);return n}}function vR(t,e){const n={...t,...e},a={};for(const r in n)t[r]!==void 0&&e[r]!==void 0&&(a[r]=Wu(t[r])(t[r],e[r]));return r=>{for(const c in a)n[c]=a[c](r);return n}}function yR(t,e){var r;const n=[],a={color:0,var:0,number:0};for(let c=0;c<e.values.length;c++){const l=e.types[c],u=t.indexes[l][a[l]],f=(r=t.values[u])!=null?r:0;n[c]=f,a[l]++}return n}const bR=(t,e)=>{const n=Bi.createTransformer(e),a=Pr(t),r=Pr(e);return a.indexes.var.length===r.indexes.var.length&&a.indexes.color.length===r.indexes.color.length&&a.indexes.number.length>=r.indexes.number.length?Zu.has(t)&&!r.values.length||Zu.has(e)&&!a.values.length?pR(t,e):_r(Fg(yR(a,r),r.values),n):cc(t,e)};function qg(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?it(t,e,n):Wu(t)(t,e)}const SR=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>Ze.update(e,n),stop:()=>Ii(e),now:()=>At.isProcessing?At.timestamp:jt.now()}},Hg=(t,e,n=10)=>{let a="";const r=Math.max(Math.round(e/n),2);for(let c=0;c<r;c++)a+=Math.round(t(c/(r-1))*1e4)/1e4+", ";return`linear(${a.substring(0,a.length-2)})`},lc=2e4;function $u(t){let e=0;const n=50;let a=t.next(e);for(;!a.done&&e<lc;)e+=n,a=t.next(e);return e>=lc?1/0:e}function TR(t,e=100,n){const a=n({...t,keyframes:[0,e]}),r=Math.min($u(a),lc);return{type:"keyframes",ease:c=>a.next(r*c).value/e,duration:yn(r)}}const CR=5;function Gg(t,e,n){const a=Math.max(e-CR,0);return vg(n-t(a),e-a)}const at={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},ed=.001;function kR({duration:t=at.duration,bounce:e=at.bounce,velocity:n=at.velocity,mass:a=at.mass}){let r,c,l=1-e;l=Yn(at.minDamping,at.maxDamping,l),t=Yn(at.minDuration,at.maxDuration,yn(t)),l<1?(r=h=>{const p=h*l,v=p*t,y=p-n,S=td(h,l),w=Math.exp(-v);return ed-y/S*w},c=h=>{const v=h*l*t,y=v*n+n,S=Math.pow(l,2)*Math.pow(h,2)*t,w=Math.exp(-v),T=td(Math.pow(h,2),l);return(-r(h)+ed>0?-1:1)*((y-S)*w)/T}):(r=h=>{const p=Math.exp(-h*t),v=(h-n)*t+1;return-ed+p*v},c=h=>{const p=Math.exp(-h*t),v=(n-h)*(t*t);return p*v});const u=5/t,f=wR(r,c,u);if(t=li(t),isNaN(f))return{stiffness:at.stiffness,damping:at.damping,duration:t};{const h=Math.pow(f,2)*a;return{stiffness:h,damping:l*2*Math.sqrt(a*h),duration:t}}}const ER=12;function wR(t,e,n){let a=n;for(let r=1;r<ER;r++)a=a-t(a)/e(a);return a}function td(t,e){return t*Math.sqrt(1-e*e)}const RR=["duration","bounce"],_R=["stiffness","damping","mass"];function Kg(t,e){return e.some(n=>t[n]!==void 0)}function xR(t){let e={velocity:at.velocity,stiffness:at.stiffness,damping:at.damping,mass:at.mass,isResolvedFromDuration:!1,...t};if(!Kg(t,_R)&&Kg(t,RR))if(t.visualDuration){const n=t.visualDuration,a=2*Math.PI/(n*1.2),r=a*a,c=2*Yn(.05,1,1-(t.bounce||0))*Math.sqrt(r);e={...e,mass:at.mass,stiffness:r,damping:c}}else{const n=kR(t);e={...e,...n,mass:at.mass},e.isResolvedFromDuration=!0}return e}function uc(t=at.visualDuration,e=at.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:a,restDelta:r}=n;const c=n.keyframes[0],l=n.keyframes[n.keyframes.length-1],u={done:!1,value:c},{stiffness:f,damping:h,mass:p,duration:v,velocity:y,isResolvedFromDuration:S}=xR({...n,velocity:-yn(n.velocity||0)}),w=y||0,T=h/(2*Math.sqrt(f*p)),x=l-c,R=yn(Math.sqrt(f/p)),P=Math.abs(x)<5;a||(a=P?at.restSpeed.granular:at.restSpeed.default),r||(r=P?at.restDelta.granular:at.restDelta.default);let L;if(T<1){const k=td(R,T);L=_=>{const N=Math.exp(-T*R*_);return l-N*((w+T*R*x)/k*Math.sin(k*_)+x*Math.cos(k*_))}}else if(T===1)L=k=>l-Math.exp(-R*k)*(x+(w+R*x)*k);else{const k=R*Math.sqrt(T*T-1);L=_=>{const N=Math.exp(-T*R*_),U=Math.min(k*_,300);return l-N*((w+T*R*x)*Math.sinh(U)+k*x*Math.cosh(U))/k}}const E={calculatedDuration:S&&v||null,next:k=>{const _=L(k);if(S)u.done=k>=v;else{let N=k===0?w:0;T<1&&(N=k===0?li(w):Gg(L,k,_));const U=Math.abs(N)<=a,G=Math.abs(l-_)<=r;u.done=U&&G}return u.value=u.done?l:_,u},toString:()=>{const k=Math.min($u(E),lc),_=Hg(N=>E.next(k*N).value,k,30);return k+"ms "+_},toTransition:()=>{}};return E}uc.applyToOptions=t=>{const e=TR(t,100,uc);return t.ease=e.ease,t.duration=li(e.duration),t.type="keyframes",t};function nd({keyframes:t,velocity:e=0,power:n=.8,timeConstant:a=325,bounceDamping:r=10,bounceStiffness:c=500,modifyTarget:l,min:u,max:f,restDelta:h=.5,restSpeed:p}){const v=t[0],y={done:!1,value:v},S=U=>u!==void 0&&U<u||f!==void 0&&U>f,w=U=>u===void 0?f:f===void 0||Math.abs(u-U)<Math.abs(f-U)?u:f;let T=n*e;const x=v+T,R=l===void 0?x:l(x);R!==x&&(T=R-v);const P=U=>-T*Math.exp(-U/a),L=U=>R+P(U),E=U=>{const G=P(U),V=L(U);y.done=Math.abs(G)<=h,y.value=y.done?R:V};let k,_;const N=U=>{S(y.value)&&(k=U,_=uc({keyframes:[y.value,w(y.value)],velocity:Gg(L,U,y.value),damping:r,stiffness:c,restDelta:h,restSpeed:p}))};return N(0),{calculatedDuration:null,next:U=>{let G=!1;return!_&&k===void 0&&(G=!0,E(U),N(U)),k!==void 0&&U>=k?_.next(U-k):(!G&&E(U),y)}}}function AR(t,e,n){const a=[],r=n||ci.mix||qg,c=t.length-1;for(let l=0;l<c;l++){let u=r(t[l],t[l+1]);if(e){const f=Array.isArray(e)?e[l]||vn:e;u=_r(f,u)}a.push(u)}return a}function MR(t,e,{clamp:n=!0,ease:a,mixer:r}={}){const c=t.length;if(Bu(c===e.length),c===1)return()=>e[0];if(c===2&&e[0]===e[1])return()=>e[1];const l=t[0]===t[1];t[0]>t[c-1]&&(t=[...t].reverse(),e=[...e].reverse());const u=AR(e,a,r),f=u.length,h=p=>{if(l&&p<t[0])return e[0];let v=0;if(f>1)for(;v<t.length-2&&!(p<t[v+1]);v++);const y=xr(t[v],t[v+1],p);return u[v](y)};return n?p=>h(Yn(t[0],t[c-1],p)):h}function DR(t,e){const n=t[t.length-1];for(let a=1;a<=e;a++){const r=xr(0,e,a);t.push(it(n,1,r))}}function OR(t){const e=[0];return DR(e,t.length-1),e}function PR(t,e){return t.map(n=>n*e)}function NR(t,e){return t.map(()=>e||Rg).splice(0,t.length-1)}function Nr({duration:t=300,keyframes:e,times:n,ease:a="easeInOut"}){const r=Gw(a)?a.map(xg):xg(a),c={done:!1,value:e[0]},l=PR(n&&n.length===e.length?n:OR(e),t),u=MR(l,e,{ease:Array.isArray(r)?r:NR(e,r)});return{calculatedDuration:t,next:f=>(c.value=u(f),c.done=f>=t,c)}}const LR=t=>t!==null;function id(t,{repeat:e,repeatType:n="loop"},a,r=1){const c=t.filter(LR),u=r<0||e&&n!=="loop"&&e%2===1?0:c.length-1;return!u||a===void 0?c[u]:a}const IR={decay:nd,inertia:nd,tween:Nr,keyframes:Nr,spring:uc};function Yg(t){typeof t.type=="string"&&(t.type=IR[t.type])}class ad{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 UR=t=>t/100;class sd extends ad{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{var a,r;const{motionValue:n}=this.options;n&&n.updatedAt!==jt.now()&&this.tick(jt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(r=(a=this.options).onStop)==null||r.call(a))},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;Yg(e);const{type:n=Nr,repeat:a=0,repeatDelay:r=0,repeatType:c,velocity:l=0}=e;let{keyframes:u}=e;const f=n||Nr;f!==Nr&&typeof u[0]!="number"&&(this.mixKeyframes=_r(UR,qg(u[0],u[1])),u=[0,100]);const h=f({...e,keyframes:u});c==="mirror"&&(this.mirroredGenerator=f({...e,keyframes:[...u].reverse(),velocity:-l})),h.calculatedDuration===null&&(h.calculatedDuration=$u(h));const{calculatedDuration:p}=h;this.calculatedDuration=p,this.resolvedDuration=p+r,this.totalDuration=this.resolvedDuration*(a+1)-r,this.generator=h}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:a,totalDuration:r,mixKeyframes:c,mirroredGenerator:l,resolvedDuration:u,calculatedDuration:f}=this;if(this.startTime===null)return a.next(0);const{delay:h=0,keyframes:p,repeat:v,repeatType:y,repeatDelay:S,type:w,onUpdate:T,finalKeyframe:x}=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 R=this.currentTime-h*(this.playbackSpeed>=0?1:-1),P=this.playbackSpeed>=0?R<0:R>r;this.currentTime=Math.max(R,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let L=this.currentTime,E=a;if(v){const U=Math.min(this.currentTime,r)/u;let G=Math.floor(U),V=U%1;!V&&U>=1&&(V=1),V===1&&G--,G=Math.min(G,v+1),G%2&&(y==="reverse"?(V=1-V,S&&(V-=S/u)):y==="mirror"&&(E=l)),L=Yn(0,1,V)*u}const k=P?{done:!1,value:p[0]}:E.next(L);c&&(k.value=c(k.value));let{done:_}=k;!P&&f!==null&&(_=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const N=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&_);return N&&w!==nd&&(k.value=id(p,this.options,x,this.speed)),T&&T(k.value),N&&this.finish(),k}then(e,n){return this.finished.then(e,n)}get duration(){return yn(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+yn(e)}get time(){return yn(this.currentTime)}set time(e){var n;e=li(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(jt.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=yn(this.currentTime))}play(){var r,c;if(this.isStopped)return;const{driver:e=SR,startTime:n}=this.options;this.driver||(this.driver=e(l=>this.tick(l))),(c=(r=this.options).onPlay)==null||c.call(r);const a=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=a):this.holdTime!==null?this.startTime=a-this.holdTime:this.startTime||(this.startTime=n!=null?n:a),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(jt.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 BR(t){var e;for(let n=1;n<t.length;n++)(e=t[n])!=null||(t[n]=t[n-1])}const Oa=t=>t*180/Math.PI,rd=t=>{const e=Oa(Math.atan2(t[1],t[0]));return od(e)},jR={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:rd,rotateZ:rd,skewX:t=>Oa(Math.atan(t[1])),skewY:t=>Oa(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},od=t=>(t=t%360,t<0&&(t+=360),t),Xg=rd,Qg=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Jg=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),VR={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Qg,scaleY:Jg,scale:t=>(Qg(t)+Jg(t))/2,rotateX:t=>od(Oa(Math.atan2(t[6],t[5]))),rotateY:t=>od(Oa(Math.atan2(-t[2],t[0]))),rotateZ:Xg,rotate:Xg,skewX:t=>Oa(Math.atan(t[4])),skewY:t=>Oa(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function cd(t){return t.includes("scale")?1:0}function ld(t,e){if(!t||t==="none")return cd(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let a,r;if(n)a=VR,r=n;else{const u=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);a=jR,r=u}if(!r)return cd(e);const c=a[e],l=r[1].split(",").map(FR);return typeof c=="function"?c(l):l[c]}const zR=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return ld(n,e)};function FR(t){return parseFloat(t.trim())}const hs=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ms=new Set(hs),Zg=t=>t===ds||t===de,qR=new Set(["x","y","z"]),HR=hs.filter(t=>!qR.has(t));function GR(t){const e=[];return HR.forEach(n=>{const a=t.getValue(n);a!==void 0&&(e.push([n,a.get()]),a.set(n.startsWith("scale")?1:0))}),e}const ji={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})=>ld(e,"x"),y:(t,{transform:e})=>ld(e,"y")};ji.translateX=ji.x,ji.translateY=ji.y;const Pa=new Set;let ud=!1,dd=!1,fd=!1;function Wg(){if(dd){const t=Array.from(Pa).filter(a=>a.needsMeasurement),e=new Set(t.map(a=>a.element)),n=new Map;e.forEach(a=>{const r=GR(a);r.length&&(n.set(a,r),a.render())}),t.forEach(a=>a.measureInitialState()),e.forEach(a=>{a.render();const r=n.get(a);r&&r.forEach(([c,l])=>{var u;(u=a.getValue(c))==null||u.set(l)})}),t.forEach(a=>a.measureEndState()),t.forEach(a=>{a.suspendedScrollY!==void 0&&window.scrollTo(0,a.suspendedScrollY)})}dd=!1,ud=!1,Pa.forEach(t=>t.complete(fd)),Pa.clear()}function $g(){Pa.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(dd=!0)})}function KR(){fd=!0,$g(),Wg(),fd=!1}class hd{constructor(e,n,a,r,c,l=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=a,this.motionValue=r,this.element=c,this.isAsync=l}scheduleResolve(){this.state="scheduled",this.isAsync?(Pa.add(this),ud||(ud=!0,Ze.read($g),Ze.resolveKeyframes(Wg))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:a,motionValue:r}=this;if(e[0]===null){const c=r==null?void 0:r.get(),l=e[e.length-1];if(c!==void 0)e[0]=c;else if(a&&n){const u=a.readValue(n,l);u!=null&&(e[0]=u)}e[0]===void 0&&(e[0]=l),r&&c===void 0&&r.set(e[0])}BR(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Pa.delete(this)}cancel(){this.state==="scheduled"&&(Pa.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const YR=t=>t.startsWith("--");function XR(t,e,n){YR(e)?t.style.setProperty(e,n):t.style[e]=n}const QR=ju(()=>window.ScrollTimeline!==void 0),JR={};function ZR(t,e){const n=ju(t);return()=>{var a;return(a=JR[e])!=null?a:n()}}const ev=ZR(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Lr=([t,e,n,a])=>`cubic-bezier(${t}, ${e}, ${n}, ${a})`,tv={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Lr([0,.65,.55,1]),circOut:Lr([.55,0,1,.45]),backIn:Lr([.31,.01,.66,-.59]),backOut:Lr([.33,1.53,.69,.99])};function nv(t,e){if(t)return typeof t=="function"?ev()?Hg(t,e):"ease-out":_g(t)?Lr(t):Array.isArray(t)?t.map(n=>nv(n,e)||tv.easeOut):tv[t]}function WR(t,e,n,{delay:a=0,duration:r=300,repeat:c=0,repeatType:l="loop",ease:u="easeOut",times:f}={},h=void 0){const p={[e]:n};f&&(p.offset=f);const v=nv(u,r);Array.isArray(v)&&(p.easing=v);const y={delay:a,duration:r,easing:Array.isArray(v)?"linear":v,fill:"both",iterations:c+1,direction:l==="reverse"?"alternate":"normal"};return h&&(y.pseudoElement=h),t.animate(p,y)}function iv(t){return typeof t=="function"&&"applyToOptions"in t}function $R({type:t,...e}){var n,a;return iv(t)&&ev()?t.applyToOptions(e):((n=e.duration)!=null||(e.duration=300),(a=e.ease)!=null||(e.ease="easeOut"),e)}class e_ extends ad{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:n,name:a,keyframes:r,pseudoElement:c,allowFlatten:l=!1,finalKeyframe:u,onComplete:f}=e;this.isPseudoElement=!!c,this.allowFlatten=l,this.options=e,Bu(typeof e.type!="string");const h=$R(e);this.animation=WR(n,a,r,h,c),h.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!c){const p=id(r,this.options,u,this.speed);this.updateMotionValue?this.updateMotionValue(p):XR(n,a,p),this.animation.cancel()}f==null||f(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,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,a;const e=((a=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:a.call(n).duration)||0;return yn(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+yn(e)}get time(){return yn(Number(this.animation.currentTime)||0)}set time(e){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=li(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(){var e;return(e=this.manualStartTime)!=null?e:Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){var a;return this.allowFlatten&&((a=this.animation.effect)==null||a.updateTiming({easing:"linear"})),this.animation.onfinish=null,e&&QR()?(this.animation.timeline=e,vn):n(this)}}const av={anticipate:kg,backInOut:Cg,circInOut:wg};function t_(t){return t in av}function n_(t){typeof t.ease=="string"&&t_(t.ease)&&(t.ease=av[t.ease])}const md=10;class i_ extends e_{constructor(e){n_(e),Yg(e),super(e),e.startTime!==void 0&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:a,onComplete:r,element:c,...l}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const u=new sd({...l,autoplay:!1}),f=Math.max(md,jt.now()-this.startTime),h=Yn(0,md,f-md);n.setWithVelocity(u.sample(Math.max(0,f-h)).value,u.sample(f).value,h),u.stop()}}const sv=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Bi.test(t)||t==="0")&&!t.startsWith("url("));function a_(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 s_(t,e,n,a){const r=t[0];if(r===null)return!1;if(e==="display"||e==="visibility")return!0;const c=t[t.length-1],l=sv(r,e),u=sv(c,e);return!l||!u?!1:a_(t)||(n==="spring"||iv(n))&&a}function pd(t){t.duration=0,t.type="keyframes"}const r_=new Set(["opacity","clipPath","filter","transform"]),o_=ju(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function c_(t){var p;const{motionValue:e,name:n,repeatDelay:a,repeatType:r,damping:c,type:l}=t;if(!(((p=e==null?void 0:e.owner)==null?void 0:p.current)instanceof HTMLElement))return!1;const{onUpdate:f,transformTemplate:h}=e.owner.getProps();return o_()&&n&&r_.has(n)&&(n!=="transform"||!h)&&!f&&!a&&r!=="mirror"&&c!==0&&l!=="inertia"}const l_=40;class u_ extends ad{constructor({autoplay:e=!0,delay:n=0,type:a="keyframes",repeat:r=0,repeatDelay:c=0,repeatType:l="loop",keyframes:u,name:f,motionValue:h,element:p,...v}){var w;super(),this.stop=()=>{var T,x;this._animation&&(this._animation.stop(),(T=this.stopTimeline)==null||T.call(this)),(x=this.keyframeResolver)==null||x.cancel()},this.createdAt=jt.now();const y={autoplay:e,delay:n,type:a,repeat:r,repeatDelay:c,repeatType:l,name:f,motionValue:h,element:p,...v},S=(p==null?void 0:p.KeyframeResolver)||hd;this.keyframeResolver=new S(u,(T,x,R)=>this.onKeyframesResolved(T,x,y,!R),f,h,p),(w=this.keyframeResolver)==null||w.scheduleResolve()}onKeyframesResolved(e,n,a,r){var x,R;this.keyframeResolver=void 0;const{name:c,type:l,velocity:u,delay:f,isHandoff:h,onUpdate:p}=a;this.resolvedAt=jt.now(),s_(e,c,l,u)||((ci.instantAnimations||!f)&&(p==null||p(id(e,a,n))),e[0]=e[e.length-1],pd(a),a.repeat=0);const y={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>l_?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...a,keyframes:e},S=!h&&c_(y),w=(R=(x=y.motionValue)==null?void 0:x.owner)==null?void 0:R.current,T=S?new i_({...y,element:w}):new sd(y);T.finished.then(()=>{this.notifyFinished()}).catch(vn),this.pendingTimeline&&(this.stopTimeline=T.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=T}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(),KR()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}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()}}function rv(t,e,n,a=0,r=1){const c=Array.from(t).sort((h,p)=>h.sortNodePosition(p)).indexOf(e),l=t.size,u=(l-1)*a;return typeof n=="function"?n(c,l):r===1?c*a:u-c*a}const d_=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function f_(t){const e=d_.exec(t);if(!e)return[,];const[,n,a,r]=e;return[`--${n!=null?n:a}`,r]}function ov(t,e,n=1){const[a,r]=f_(t);if(!a)return;const c=window.getComputedStyle(e).getPropertyValue(a);if(c){const l=c.trim();return mg(l)?parseFloat(l):l}return Hu(r)?ov(r,e,n+1):r}const h_={type:"spring",stiffness:500,damping:25,restSpeed:10},m_=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),p_={type:"keyframes",duration:.8},g_={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},v_=(t,{keyframes:e})=>e.length>2?p_:ms.has(t)?t.startsWith("scale")?m_(e[1]):h_:g_,y_=t=>t!==null;function b_(t,{repeat:e,repeatType:n="loop"},a){const r=t.filter(y_),c=e&&n!=="loop"&&e%2===1?0:r.length-1;return r[c]}function gd(t,e){var n,a;return(a=(n=t==null?void 0:t[e])!=null?n:t==null?void 0:t.default)!=null?a:t}function S_({when:t,delay:e,delayChildren:n,staggerChildren:a,staggerDirection:r,repeat:c,repeatType:l,repeatDelay:u,from:f,elapsed:h,...p}){return!!Object.keys(p).length}const vd=(t,e,n,a={},r,c)=>l=>{const u=gd(a,t)||{},f=u.delay||a.delay||0;let{elapsed:h=0}=a;h=h-li(f);const p={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...u,delay:-h,onUpdate:y=>{e.set(y),u.onUpdate&&u.onUpdate(y)},onComplete:()=>{l(),u.onComplete&&u.onComplete()},name:t,motionValue:e,element:c?void 0:r};S_(u)||Object.assign(p,v_(t,p)),p.duration&&(p.duration=li(p.duration)),p.repeatDelay&&(p.repeatDelay=li(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let v=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(pd(p),p.delay===0&&(v=!0)),(ci.instantAnimations||ci.skipAnimations)&&(v=!0,pd(p),p.delay=0),p.allowFlatten=!u.type&&!u.ease,v&&!c&&e.get()!==void 0){const y=b_(p.keyframes,u);if(y!==void 0){Ze.update(()=>{p.onUpdate(y),p.onComplete()});return}}return u.isSync?new sd(p):new u_(p)};function cv(t){const e=[{},{}];return t==null||t.values.forEach((n,a)=>{e[0][a]=n.get(),e[1][a]=n.getVelocity()}),e}function yd(t,e,n,a){if(typeof e=="function"){const[r,c]=cv(a);e=e(n!==void 0?n:t.custom,r,c)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[r,c]=cv(a);e=e(n!==void 0?n:t.custom,r,c)}return e}function ps(t,e,n){const a=t.getProps();return yd(a,e,n!==void 0?n:a.custom,t)}const lv=new Set(["width","height","top","left","right","bottom",...hs]),uv=30,T_=t=>!isNaN(parseFloat(t));class C_{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=a=>{var c;const r=jt.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(a),this.current!==this.prev&&((c=this.events.change)==null||c.notify(this.current),this.dependents))for(const l of this.dependents)l.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=jt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=T_(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Vu);const a=this.events[e].add(n);return e==="change"?()=>{a(),Ze.read(()=>{this.events.change.getSize()||this.stop()})}:a}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,a){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-a}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=jt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>uv)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,uv);return vg(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 gs(t,e){return new C_(t,e)}const bd=t=>Array.isArray(t);function k_(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,gs(n))}function E_(t){return bd(t)?t[t.length-1]||0:t}function w_(t,e){const n=ps(t,e);let{transitionEnd:a={},transition:r={},...c}=n||{};c={...c,...a};for(const l in c){const u=E_(c[l]);k_(t,l,u)}}const Bt=t=>!!(t&&t.getVelocity);function R_(t){return!!(Bt(t)&&t.add)}function Sd(t,e){const n=t.getValue("willChange");if(R_(n))return n.add(e);if(!n&&ci.WillChange){const a=new ci.WillChange("auto");t.addValue("willChange",a),a.add(e)}}function Td(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const dv="data-"+Td("framerAppearId");function fv(t){return t.props[dv]}function __({protectedKeys:t,needsAnimating:e},n){const a=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,a}function hv(t,e,{delay:n=0,transitionOverride:a,type:r}={}){var p;let{transition:c=t.getDefaultTransition(),transitionEnd:l,...u}=e;a&&(c=a);const f=[],h=r&&t.animationState&&t.animationState.getState()[r];for(const v in u){const y=t.getValue(v,(p=t.latestValues[v])!=null?p:null),S=u[v];if(S===void 0||h&&__(h,v))continue;const w={delay:n,...gd(c||{},v)},T=y.get();if(T!==void 0&&!y.isAnimating&&!Array.isArray(S)&&S===T&&!w.velocity)continue;let x=!1;if(window.MotionHandoffAnimation){const P=fv(t);if(P){const L=window.MotionHandoffAnimation(P,v,Ze);L!==null&&(w.startTime=L,x=!0)}}Sd(t,v),y.start(vd(v,y,S,t.shouldReduceMotion&&lv.has(v)?{type:!1}:w,t,x));const R=y.animation;R&&f.push(R)}return l&&Promise.all(f).then(()=>{Ze.update(()=>{l&&w_(t,l)})}),f}function Cd(t,e,n={}){var f;const a=ps(t,e,n.type==="exit"?(f=t.presenceContext)==null?void 0:f.custom:void 0);let{transition:r=t.getDefaultTransition()||{}}=a||{};n.transitionOverride&&(r=n.transitionOverride);const c=a?()=>Promise.all(hv(t,a,n)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(h=0)=>{const{delayChildren:p=0,staggerChildren:v,staggerDirection:y}=r;return x_(t,e,h,p,v,y,n)}:()=>Promise.resolve(),{when:u}=r;if(u){const[h,p]=u==="beforeChildren"?[c,l]:[l,c];return h().then(()=>p())}else return Promise.all([c(),l(n.delay)])}function x_(t,e,n=0,a=0,r=0,c=1,l){const u=[];for(const f of t.variantChildren)f.notify("AnimationStart",e),u.push(Cd(f,e,{...l,delay:n+(typeof a=="function"?0:a)+rv(t.variantChildren,f,a,r,c)}).then(()=>f.notify("AnimationComplete",e)));return Promise.all(u)}function A_(t,e,n={}){t.notify("AnimationStart",e);let a;if(Array.isArray(e)){const r=e.map(c=>Cd(t,c,n));a=Promise.all(r)}else if(typeof e=="string")a=Cd(t,e,n);else{const r=typeof e=="function"?ps(t,e,n.custom):e;a=Promise.all(hv(t,r,n))}return a.then(()=>{t.notify("AnimationComplete",e)})}const M_={test:t=>t==="auto",parse:t=>t},mv=t=>e=>e.test(t),pv=[ds,de,Xn,Ui,aR,iR,M_],gv=t=>pv.find(mv(t));function D_(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||gg(t):!0}const O_=new Set(["brightness","contrast","saturate","opacity"]);function P_(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[a]=n.match(Gu)||[];if(!a)return t;const r=n.replace(a,"");let c=O_.has(e)?1:0;return a!==n&&(c*=100),e+"("+c+r+")"}const N_=/\b([a-z-]*)\(.*?\)/gu,kd={...Bi,getAnimatableNone:t=>{const e=t.match(N_);return e?e.map(P_).join(" "):t}},vv={...ds,transform:Math.round},Ed={borderWidth:de,borderTopWidth:de,borderRightWidth:de,borderBottomWidth:de,borderLeftWidth:de,borderRadius:de,radius:de,borderTopLeftRadius:de,borderTopRightRadius:de,borderBottomRightRadius:de,borderBottomLeftRadius:de,width:de,maxWidth:de,height:de,maxHeight:de,top:de,right:de,bottom:de,left:de,inset:de,insetBlock:de,insetBlockStart:de,insetBlockEnd:de,insetInline:de,insetInlineStart:de,insetInlineEnd:de,padding:de,paddingTop:de,paddingRight:de,paddingBottom:de,paddingLeft:de,paddingBlock:de,paddingBlockStart:de,paddingBlockEnd:de,paddingInline:de,paddingInlineStart:de,paddingInlineEnd:de,margin:de,marginTop:de,marginRight:de,marginBottom:de,marginLeft:de,marginBlock:de,marginBlockStart:de,marginBlockEnd:de,marginInline:de,marginInlineStart:de,marginInlineEnd:de,backgroundPositionX:de,backgroundPositionY:de,...{rotate:Ui,rotateX:Ui,rotateY:Ui,rotateZ:Ui,scale:oc,scaleX:oc,scaleY:oc,scaleZ:oc,skew:Ui,skewX:Ui,skewY:Ui,distance:de,translateX:de,translateY:de,translateZ:de,x:de,y:de,z:de,perspective:de,transformPerspective:de,opacity:Mr,originX:Ng,originY:Ng,originZ:de},zIndex:vv,fillOpacity:Mr,strokeOpacity:Mr,numOctaves:vv},L_={...Ed,color:mt,backgroundColor:mt,outlineColor:mt,fill:mt,stroke:mt,borderColor:mt,borderTopColor:mt,borderRightColor:mt,borderBottomColor:mt,borderLeftColor:mt,filter:kd,WebkitFilter:kd},yv=t=>L_[t];function bv(t,e){let n=yv(t);return n!==kd&&(n=Bi),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const I_=new Set(["auto","none","0"]);function U_(t,e,n){let a=0,r;for(;a<t.length&&!r;){const c=t[a];typeof c=="string"&&!I_.has(c)&&Pr(c).values.length&&(r=t[a]),a++}if(r&&n)for(const c of e)t[c]=bv(n,r)}class B_ extends hd{constructor(e,n,a,r,c){super(e,n,a,r,c,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:a}=this;if(!n||!n.current)return;super.readKeyframes();for(let p=0;p<e.length;p++){let v=e[p];if(typeof v=="string"&&(v=v.trim(),Hu(v))){const y=ov(v,n.current);y!==void 0&&(e[p]=y),p===e.length-1&&(this.finalKeyframe=v)}}if(this.resolveNoneKeyframes(),!lv.has(a)||e.length!==2)return;const[r,c]=e,l=gv(r),u=gv(c),f=Og(r),h=Og(c);if(f!==h&&ji[a]){this.needsMeasurement=!0;return}if(l!==u)if(Zg(l)&&Zg(u))for(let p=0;p<e.length;p++){const v=e[p];typeof v=="string"&&(e[p]=parseFloat(v))}else ji[a]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,a=[];for(let r=0;r<e.length;r++)(e[r]===null||D_(e[r]))&&a.push(r);a.length&&U_(e,a,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:a}=this;if(!e||!e.current)return;a==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=ji[a](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const r=n[n.length-1];r!==void 0&&e.getValue(a,r).jump(r,!1)}measureEndState(){var u;const{element:e,name:n,unresolvedKeyframes:a}=this;if(!e||!e.current)return;const r=e.getValue(n);r&&r.jump(this.measuredOrigin,!1);const c=a.length-1,l=a[c];a[c]=ji[n](e.measureViewportBox(),window.getComputedStyle(e.current)),l!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=l),(u=this.removedTransforms)!=null&&u.length&&this.removedTransforms.forEach(([f,h])=>{e.getValue(f).set(h)}),this.resolveNoneKeyframes()}}function j_(t,e,n){var a;if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){let r=document;const c=(a=n==null?void 0:n[t])!=null?a:r.querySelectorAll(t);return c?Array.from(c):[]}return Array.from(t).filter(r=>r!=null)}const Sv=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function V_(t){return pg(t)&&"offsetHeight"in t}const{schedule:wd}=Ag(queueMicrotask,!1),Nn={x:!1,y:!1};function Tv(){return Nn.x||Nn.y}function z_(t){return t==="x"||t==="y"?Nn[t]?null:(Nn[t]=!0,()=>{Nn[t]=!1}):Nn.x||Nn.y?null:(Nn.x=Nn.y=!0,()=>{Nn.x=Nn.y=!1})}function Cv(t,e){const n=j_(t),a=new AbortController,r={passive:!0,...e,signal:a.signal};return[n,r,()=>a.abort()]}function kv(t){return!(t.pointerType==="touch"||Tv())}function F_(t,e,n={}){const[a,r,c]=Cv(t,n),l=u=>{if(!kv(u))return;const{target:f}=u,h=e(f,u);if(typeof h!="function"||!f)return;const p=v=>{kv(v)&&(h(v),f.removeEventListener("pointerleave",p))};f.addEventListener("pointerleave",p,r)};return a.forEach(u=>{u.addEventListener("pointerenter",l,r)}),c}const Ev=(t,e)=>e?t===e?!0:Ev(t,e.parentElement):!1,Rd=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,q_=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function wv(t){return q_.has(t.tagName)||t.isContentEditable===!0}const dc=new WeakSet;function Rv(t){return e=>{e.key==="Enter"&&t(e)}}function _d(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const H_=(t,e)=>{const n=t.currentTarget;if(!n)return;const a=Rv(()=>{if(dc.has(n))return;_d(n,"down");const r=Rv(()=>{_d(n,"up")}),c=()=>_d(n,"cancel");n.addEventListener("keyup",r,e),n.addEventListener("blur",c,e)});n.addEventListener("keydown",a,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",a),e)};function _v(t){return Rd(t)&&!Tv()}function G_(t,e,n={}){const[a,r,c]=Cv(t,n),l=u=>{const f=u.currentTarget;if(!_v(u))return;dc.add(f);const h=e(f,u),p=(S,w)=>{window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",y),dc.has(f)&&dc.delete(f),_v(S)&&typeof h=="function"&&h(S,{success:w})},v=S=>{p(S,f===window||f===document||n.useGlobalTarget||Ev(f,S.target))},y=S=>{p(S,!1)};window.addEventListener("pointerup",v,r),window.addEventListener("pointercancel",y,r)};return a.forEach(u=>{(n.useGlobalTarget?window:u).addEventListener("pointerdown",l,r),V_(u)&&(u.addEventListener("focus",h=>H_(h,r)),!wv(u)&&!u.hasAttribute("tabindex")&&(u.tabIndex=0))}),c}function xv(t){return pg(t)&&"ownerSVGElement"in t}function K_(t){return xv(t)&&t.tagName==="svg"}const Y_=[...pv,mt,Bi],X_=t=>Y_.find(mv(t)),Av=()=>({translate:0,scale:1,origin:0,originPoint:0}),vs=()=>({x:Av(),y:Av()}),Mv=()=>({min:0,max:0}),Tt=()=>({x:Mv(),y:Mv()}),xd={current:null},Dv={current:!1},Q_=typeof window!="undefined";function J_(){if(Dv.current=!0,!!Q_)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>xd.current=t.matches;t.addEventListener("change",e),e()}else xd.current=!1}const Z_=new WeakMap;function fc(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Ir(t){return typeof t=="string"||Array.isArray(t)}const Ad=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Md=["initial",...Ad];function hc(t){return fc(t.animate)||Md.some(e=>Ir(t[e]))}function Ov(t){return!!(hc(t)||t.variants)}function W_(t,e,n){for(const a in e){const r=e[a],c=n[a];if(Bt(r))t.addValue(a,r);else if(Bt(c))t.addValue(a,gs(r,{owner:t}));else if(c!==r)if(t.hasValue(a)){const l=t.getValue(a);l.liveStyle===!0?l.jump(r):l.hasAnimated||l.set(r)}else{const l=t.getStaticValue(a);t.addValue(a,gs(l!==void 0?l:r,{owner:t}))}}for(const a in n)e[a]===void 0&&t.removeValue(a);return e}const Pv=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let mc={};function Nv(t){mc=t}function $_(){return mc}class ex{scrapeMotionValuesFromProps(e,n,a){return{}}constructor({parent:e,props:n,presenceContext:a,reducedMotionConfig:r,blockInitialAnimation:c,visualState:l},u={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=hd,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 y=jt.now();this.renderScheduledAt<y&&(this.renderScheduledAt=y,Ze.render(this.render,!1,!0))};const{latestValues:f,renderState:h}=l;this.latestValues=f,this.baseTarget={...f},this.initialValues=n.initial?{...f}:{},this.renderState=h,this.parent=e,this.props=n,this.presenceContext=a,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.options=u,this.blockInitialAnimation=!!c,this.isControllingVariants=hc(n),this.isVariantNode=Ov(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:p,...v}=this.scrapeMotionValuesFromProps(n,{},this);for(const y in v){const S=v[y];f[y]!==void 0&&Bt(S)&&S.set(f[y])}}mount(e){var n;this.current=e,Z_.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((a,r)=>this.bindToMotionValue(r,a)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(Dv.current||J_(),this.shouldReduceMotion=xd.current),(n=this.parent)==null||n.addChild(this),this.update(this.props,this.presenceContext)}unmount(){var e;this.projection&&this.projection.unmount(),Ii(this.notifyUpdate),Ii(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 a=this.features[n];a&&(a.unmount(),a.isMounted=!1)}this.current=null}addChild(e){var n;this.children.add(e),(n=this.enteringChildren)!=null||(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 a=ms.has(e);a&&this.onBindTransform&&this.onBindTransform();const r=n.on("change",l=>{this.latestValues[e]=l,this.props.onUpdate&&Ze.preRender(this.notifyUpdate),a&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let c;typeof window!="undefined"&&window.MotionCheckAppearSync&&(c=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{r(),c&&c(),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 mc){const n=mc[e];if(!n)continue;const{isEnabled:a,Feature:r}=n;if(!this.features[e]&&r&&a(this.props)&&(this.features[e]=new r(this)),this.features[e]){const c=this.features[e];c.isMounted?c.update():(c.mount(),c.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Tt()}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 a=0;a<Pv.length;a++){const r=Pv[a];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);const c="on"+r,l=e[c];l&&(this.propEventSubscriptions[r]=this.on(r,l))}this.prevMotionValues=W_(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 a=this.values.get(e);n!==a&&(a&&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 a=this.values.get(e);return a===void 0&&n!==void 0&&(a=gs(n===null?void 0:n,{owner:this}),this.addValue(e,a)),a}readValue(e,n){var r;let a=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:(r=this.getBaseTargetFromProps(this.props,e))!=null?r:this.readValueFromInstance(this.current,e,this.options);return a!=null&&(typeof a=="string"&&(mg(a)||gg(a))?a=parseFloat(a):!X_(a)&&Bi.test(n)&&(a=bv(e,n)),this.setBaseTarget(e,Bt(a)?a.get():a)),Bt(a)?a.get():a}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){var c;const{initial:n}=this.props;let a;if(typeof n=="string"||typeof n=="object"){const l=yd(this.props,n,(c=this.presenceContext)==null?void 0:c.custom);l&&(a=l[e])}if(n&&a!==void 0)return a;const r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!Bt(r)?r:this.initialValues[e]!==void 0&&a===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new Vu),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){wd.render(this.render)}}class Lv extends ex{constructor(){super(...arguments),this.KeyframeResolver=B_}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){const a=e.style;return a?a[n]:void 0}removeValueFromRenderState(e,{vars:n,style:a}){delete n[e],delete a[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Bt(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class Vi{constructor(e){this.isMounted=!1,this.node=e}update(){}}function Iv({top:t,left:e,right:n,bottom:a}){return{x:{min:e,max:n},y:{min:t,max:a}}}function tx({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function nx(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),a=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:a.y,right:a.x}}function Dd(t){return t===void 0||t===1}function Od({scale:t,scaleX:e,scaleY:n}){return!Dd(t)||!Dd(e)||!Dd(n)}function Na(t){return Od(t)||Uv(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Uv(t){return Bv(t.x)||Bv(t.y)}function Bv(t){return t&&t!=="0%"}function pc(t,e,n){const a=t-n,r=e*a;return n+r}function jv(t,e,n,a,r){return r!==void 0&&(t=pc(t,r,a)),pc(t,n,a)+e}function Pd(t,e=0,n=1,a,r){t.min=jv(t.min,e,n,a,r),t.max=jv(t.max,e,n,a,r)}function Vv(t,{x:e,y:n}){Pd(t.x,e.translate,e.scale,e.originPoint),Pd(t.y,n.translate,n.scale,n.originPoint)}const zv=.999999999999,Fv=1.0000000000001;function ix(t,e,n,a=!1){const r=n.length;if(!r)return;e.x=e.y=1;let c,l;for(let u=0;u<r;u++){c=n[u],l=c.projectionDelta;const{visualElement:f}=c.options;f&&f.props.style&&f.props.style.display==="contents"||(a&&c.options.layoutScroll&&c.scroll&&c!==c.root&&bs(t,{x:-c.scroll.offset.x,y:-c.scroll.offset.y}),l&&(e.x*=l.x.scale,e.y*=l.y.scale,Vv(t,l)),a&&Na(c.latestValues)&&bs(t,c.latestValues))}e.x<Fv&&e.x>zv&&(e.x=1),e.y<Fv&&e.y>zv&&(e.y=1)}function ys(t,e){t.min=t.min+e,t.max=t.max+e}function qv(t,e,n,a,r=.5){const c=it(t.min,t.max,r);Pd(t,e,n,c,a)}function bs(t,e){qv(t.x,e.x,e.scaleX,e.scale,e.originX),qv(t.y,e.y,e.scaleY,e.scale,e.originY)}function Hv(t,e){return Iv(nx(t.getBoundingClientRect(),e))}function ax(t,e,n){const a=Hv(t,n),{scroll:r}=e;return r&&(ys(a.x,r.offset.x),ys(a.y,r.offset.y)),a}const sx={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},rx=hs.length;function ox(t,e,n){let a="",r=!0;for(let c=0;c<rx;c++){const l=hs[c],u=t[l];if(u===void 0)continue;let f=!0;if(typeof u=="number"?f=u===(l.startsWith("scale")?1:0):f=parseFloat(u)===0,!f||n){const h=Sv(u,Ed[l]);if(!f){r=!1;const p=sx[l]||l;a+=`${p}(${h}) `}n&&(e[l]=h)}}return a=a.trim(),n?a=n(e,r?"":a):r&&(a="none"),a}function Nd(t,e,n){const{style:a,vars:r,transformOrigin:c}=t;let l=!1,u=!1;for(const f in e){const h=e[f];if(ms.has(f)){l=!0;continue}else if(Dg(f)){r[f]=h;continue}else{const p=Sv(h,Ed[f]);f.startsWith("origin")?(u=!0,c[f]=p):a[f]=p}}if(e.transform||(l||n?a.transform=ox(e,t.transform,n):a.transform&&(a.transform="none")),u){const{originX:f="50%",originY:h="50%",originZ:p=0}=c;a.transformOrigin=`${f} ${h} ${p}`}}function Gv(t,{style:e,vars:n},a,r){const c=t.style;let l;for(l in e)c[l]=e[l];r==null||r.applyProjectionStyles(c,a);for(l in n)c.setProperty(l,n[l])}function Kv(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Ur={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(de.test(t))t=parseFloat(t);else return t;const n=Kv(t,e.target.x),a=Kv(t,e.target.y);return`${n}% ${a}%`}},cx={correct:(t,{treeScale:e,projectionDelta:n})=>{const a=t,r=Bi.parse(t);if(r.length>5)return a;const c=Bi.createTransformer(t),l=typeof r[0]!="number"?1:0,u=n.x.scale*e.x,f=n.y.scale*e.y;r[0+l]/=u,r[1+l]/=f;const h=it(u,f,.5);return typeof r[2+l]=="number"&&(r[2+l]/=h),typeof r[3+l]=="number"&&(r[3+l]/=h),c(r)}},Ld={borderRadius:{...Ur,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Ur,borderTopRightRadius:Ur,borderBottomLeftRadius:Ur,borderBottomRightRadius:Ur,boxShadow:cx};function Yv(t,{layout:e,layoutId:n}){return ms.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Ld[t]||t==="opacity")}function Id(t,e,n){var l;const a=t.style,r=e==null?void 0:e.style,c={};if(!a)return c;for(const u in a)(Bt(a[u])||r&&Bt(r[u])||Yv(u,t)||((l=n==null?void 0:n.getValue(u))==null?void 0:l.liveStyle)!==void 0)&&(c[u]=a[u]);return c}function lx(t){return window.getComputedStyle(t)}class ux extends Lv{constructor(){super(...arguments),this.type="html",this.renderInstance=Gv}readValueFromInstance(e,n){var a;if(ms.has(n))return(a=this.projection)!=null&&a.isProjecting?cd(n):zR(e,n);{const r=lx(e),c=(Dg(n)?r.getPropertyValue(n):r[n])||0;return typeof c=="string"?c.trim():c}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Hv(e,n)}build(e,n,a){Nd(e,n,a.transformTemplate)}scrapeMotionValuesFromProps(e,n,a){return Id(e,n,a)}}const dx={offset:"stroke-dashoffset",array:"stroke-dasharray"},fx={offset:"strokeDashoffset",array:"strokeDasharray"};function hx(t,e,n=1,a=0,r=!0){t.pathLength=1;const c=r?dx:fx;t[c.offset]=`${-a}`,t[c.array]=`${e} ${n}`}const mx=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function Xv(t,{attrX:e,attrY:n,attrScale:a,pathLength:r,pathSpacing:c=1,pathOffset:l=0,...u},f,h,p){var S,w;if(Nd(t,u,h),f){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:v,style:y}=t;v.transform&&(y.transform=v.transform,delete v.transform),(y.transform||v.transformOrigin)&&(y.transformOrigin=(S=v.transformOrigin)!=null?S:"50% 50%",delete v.transformOrigin),y.transform&&(y.transformBox=(w=p==null?void 0:p.transformBox)!=null?w:"fill-box",delete v.transformBox);for(const T of mx)v[T]!==void 0&&(y[T]=v[T],delete v[T]);e!==void 0&&(v.x=e),n!==void 0&&(v.y=n),a!==void 0&&(v.scale=a),r!==void 0&&hx(v,r,c,l,!1)}const Qv=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"]),Jv=t=>typeof t=="string"&&t.toLowerCase()==="svg";function px(t,e,n,a){Gv(t,e,void 0,a);for(const r in e.attrs)t.setAttribute(Qv.has(r)?r:Td(r),e.attrs[r])}function Zv(t,e,n){const a=Id(t,e,n);for(const r in t)if(Bt(t[r])||Bt(e[r])){const c=hs.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;a[c]=t[r]}return a}class gx extends Lv{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Tt}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(ms.has(n)){const a=yv(n);return a&&a.default||0}return n=Qv.has(n)?n:Td(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,a){return Zv(e,n,a)}build(e,n,a){Xv(e,n,this.isSVGTag,a.transformTemplate,a.style)}renderInstance(e,n,a,r){px(e,n,a,r)}mount(e){this.isSVGTag=Jv(e.tagName),super.mount(e)}}const vx=Md.length;function Wv(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Wv(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<vx;n++){const a=Md[n],r=t.props[a];(Ir(r)||r===!1)&&(e[a]=r)}return e}function $v(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let a=0;a<n;a++)if(e[a]!==t[a])return!1;return!0}const yx=[...Ad].reverse(),bx=Ad.length;function Sx(t){return e=>Promise.all(e.map(({animation:n,options:a})=>A_(t,n,a)))}function Tx(t){let e=Sx(t),n=ey(),a=!0;const r=f=>(h,p)=>{var y;const v=ps(t,p,f==="exit"?(y=t.presenceContext)==null?void 0:y.custom:void 0);if(v){const{transition:S,transitionEnd:w,...T}=v;h={...h,...T,...w}}return h};function c(f){e=f(t)}function l(f){const{props:h}=t,p=Wv(t.parent)||{},v=[],y=new Set;let S={},w=1/0;for(let x=0;x<bx;x++){const R=yx[x],P=n[R],L=h[R]!==void 0?h[R]:p[R],E=Ir(L),k=R===f?P.isActive:null;k===!1&&(w=x);let _=L===p[R]&&L!==h[R]&&E;if(_&&a&&t.manuallyAnimateOnMount&&(_=!1),P.protectedKeys={...S},!P.isActive&&k===null||!L&&!P.prevProp||fc(L)||typeof L=="boolean")continue;const N=Cx(P.prevProp,L);let U=N||R===f&&P.isActive&&!_&&E||x>w&&E,G=!1;const V=Array.isArray(L)?L:[L];let Y=V.reduce(r(R),{});k===!1&&(Y={});const{prevResolvedValues:ie={}}=P,he={...ie,...Y},be=ne=>{U=!0,y.has(ne)&&(G=!0,y.delete(ne)),P.needsAnimating[ne]=!0;const ce=t.getValue(ne);ce&&(ce.liveStyle=!1)};for(const ne in he){const ce=Y[ne],Ce=ie[ne];if(S.hasOwnProperty(ne))continue;let Re=!1;bd(ce)&&bd(Ce)?Re=!$v(ce,Ce):Re=ce!==Ce,Re?ce!=null?be(ne):y.add(ne):ce!==void 0&&y.has(ne)?be(ne):P.protectedKeys[ne]=!0}P.prevProp=L,P.prevResolvedValues=Y,P.isActive&&(S={...S,...Y}),a&&t.blockInitialAnimation&&(U=!1);const qe=_&&N;U&&(!qe||G)&&v.push(...V.map(ne=>{const ce={type:R};if(typeof ne=="string"&&a&&!qe&&t.manuallyAnimateOnMount&&t.parent){const{parent:Ce}=t,Re=ps(Ce,ne);if(Ce.enteringChildren&&Re){const{delayChildren:D}=Re.transition||{};ce.delay=rv(Ce.enteringChildren,t,D)}}return{animation:ne,options:ce}}))}if(y.size){const x={};if(typeof h.initial!="boolean"){const R=ps(t,Array.isArray(h.initial)?h.initial[0]:h.initial);R&&R.transition&&(x.transition=R.transition)}y.forEach(R=>{const P=t.getBaseTarget(R),L=t.getValue(R);L&&(L.liveStyle=!0),x[R]=P!=null?P:null}),v.push({animation:x})}let T=!!v.length;return a&&(h.initial===!1||h.initial===h.animate)&&!t.manuallyAnimateOnMount&&(T=!1),a=!1,T?e(v):Promise.resolve()}function u(f,h){var v;if(n[f].isActive===h)return Promise.resolve();(v=t.variantChildren)==null||v.forEach(y=>{var S;return(S=y.animationState)==null?void 0:S.setActive(f,h)}),n[f].isActive=h;const p=l(f);for(const y in n)n[y].protectedKeys={};return p}return{animateChanges:l,setActive:u,setAnimateFunction:c,getState:()=>n,reset:()=>{n=ey()}}}function Cx(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!$v(e,t):!1}function La(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function ey(){return{animate:La(!0),whileInView:La(),whileHover:La(),whileTap:La(),whileDrag:La(),whileFocus:La(),exit:La()}}function ty(t,e){t.min=e.min,t.max=e.max}function Ln(t,e){ty(t.x,e.x),ty(t.y,e.y)}function ny(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const iy=1e-4,kx=1-iy,Ex=1+iy,ay=.01,wx=0-ay,Rx=0+ay;function Vt(t){return t.max-t.min}function _x(t,e,n){return Math.abs(t-e)<=n}function sy(t,e,n,a=.5){t.origin=a,t.originPoint=it(e.min,e.max,t.origin),t.scale=Vt(n)/Vt(e),t.translate=it(n.min,n.max,t.origin)-t.originPoint,(t.scale>=kx&&t.scale<=Ex||isNaN(t.scale))&&(t.scale=1),(t.translate>=wx&&t.translate<=Rx||isNaN(t.translate))&&(t.translate=0)}function Br(t,e,n,a){sy(t.x,e.x,n.x,a?a.originX:void 0),sy(t.y,e.y,n.y,a?a.originY:void 0)}function ry(t,e,n){t.min=n.min+e.min,t.max=t.min+Vt(e)}function xx(t,e,n){ry(t.x,e.x,n.x),ry(t.y,e.y,n.y)}function oy(t,e,n){t.min=e.min-n.min,t.max=t.min+Vt(e)}function gc(t,e,n){oy(t.x,e.x,n.x),oy(t.y,e.y,n.y)}function cy(t,e,n,a,r){return t-=e,t=pc(t,1/n,a),r!==void 0&&(t=pc(t,1/r,a)),t}function Ax(t,e=0,n=1,a=.5,r,c=t,l=t){if(Xn.test(e)&&(e=parseFloat(e),e=it(l.min,l.max,e/100)-l.min),typeof e!="number")return;let u=it(c.min,c.max,a);t===c&&(u-=e),t.min=cy(t.min,e,n,u,r),t.max=cy(t.max,e,n,u,r)}function ly(t,e,[n,a,r],c,l){Ax(t,e[n],e[a],e[r],e.scale,c,l)}const Mx=["x","scaleX","originX"],Dx=["y","scaleY","originY"];function uy(t,e,n,a){ly(t.x,e,Mx,n?n.x:void 0,a?a.x:void 0),ly(t.y,e,Dx,n?n.y:void 0,a?a.y:void 0)}function dy(t){return t.translate===0&&t.scale===1}function fy(t){return dy(t.x)&&dy(t.y)}function hy(t,e){return t.min===e.min&&t.max===e.max}function Ox(t,e){return hy(t.x,e.x)&&hy(t.y,e.y)}function my(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function py(t,e){return my(t.x,e.x)&&my(t.y,e.y)}function gy(t){return Vt(t.x)/Vt(t.y)}function vy(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function bn(t){return[t("x"),t("y")]}function Px(t,e,n){let a="";const r=t.x.translate/e.x,c=t.y.translate/e.y,l=(n==null?void 0:n.z)||0;if((r||c||l)&&(a=`translate3d(${r}px, ${c}px, ${l}px) `),(e.x!==1||e.y!==1)&&(a+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:h,rotate:p,rotateX:v,rotateY:y,skewX:S,skewY:w}=n;h&&(a=`perspective(${h}px) ${a}`),p&&(a+=`rotate(${p}deg) `),v&&(a+=`rotateX(${v}deg) `),y&&(a+=`rotateY(${y}deg) `),S&&(a+=`skewX(${S}deg) `),w&&(a+=`skewY(${w}deg) `)}const u=t.x.scale*e.x,f=t.y.scale*e.y;return(u!==1||f!==1)&&(a+=`scale(${u}, ${f})`),a||"none"}const yy=["TopLeft","TopRight","BottomLeft","BottomRight"],Nx=yy.length,by=t=>typeof t=="string"?parseFloat(t):t,Sy=t=>typeof t=="number"||de.test(t);function Lx(t,e,n,a,r,c){var l,u,f,h;r?(t.opacity=it(0,(l=n.opacity)!=null?l:1,Ix(a)),t.opacityExit=it((u=e.opacity)!=null?u:1,0,Ux(a))):c&&(t.opacity=it((f=e.opacity)!=null?f:1,(h=n.opacity)!=null?h:1,a));for(let p=0;p<Nx;p++){const v=`border${yy[p]}Radius`;let y=Ty(e,v),S=Ty(n,v);if(y===void 0&&S===void 0)continue;y||(y=0),S||(S=0),y===0||S===0||Sy(y)===Sy(S)?(t[v]=Math.max(it(by(y),by(S),a),0),(Xn.test(S)||Xn.test(y))&&(t[v]+="%")):t[v]=S}(e.rotate||n.rotate)&&(t.rotate=it(e.rotate||0,n.rotate||0,a))}function Ty(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Ix=Cy(0,.5,Eg),Ux=Cy(.5,.95,vn);function Cy(t,e,n){return a=>a<t?0:a>e?1:n(xr(t,e,a))}function Bx(t,e,n){const a=Bt(t)?t:gs(t);return a.start(vd("",a,e,n)),a.animation}function jr(t,e,n,a={passive:!0}){return t.addEventListener(e,n,a),()=>t.removeEventListener(e,n)}const jx=(t,e)=>t.depth-e.depth;class Vx{constructor(){this.children=[],this.isDirty=!1}add(e){Iu(this.children,e),this.isDirty=!0}remove(e){Uu(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(jx),this.isDirty=!1,this.children.forEach(e)}}function zx(t,e){const n=jt.now(),a=({timestamp:r})=>{const c=r-n;c>=e&&(Ii(a),t(c-e))};return Ze.setup(a,!0),()=>Ii(a)}function vc(t){return Bt(t)?t.get():t}class Fx{constructor(){this.members=[]}add(e){Iu(this.members,e),e.scheduleRender()}remove(e){if(Uu(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 a;for(let r=n;r>=0;r--){const c=this.members[r];if(c.isPresent!==!1){a=c;break}}return a?(this.promote(a),!0):!1}promote(e,n){const a=this.lead;if(e!==a&&(this.prevLead=a,this.lead=e,e.show(),a)){a.instance&&a.scheduleRender(),e.scheduleRender(),e.resumeFrom=a,n&&(e.resumeFrom.preserveOpacity=!0),a.snapshot&&(e.snapshot=a.snapshot,e.snapshot.latestValues=a.animationValues||a.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:r}=e.options;r===!1&&a.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:a}=e;n.onExitComplete&&n.onExitComplete(),a&&a.options.onExitComplete&&a.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const yc={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Ud=["","X","Y","Z"],qx=1e3;let Hx=0;function Bd(t,e,n,a){const{latestValues:r}=e;r[t]&&(n[t]=r[t],e.setStaticValue(t,0),a&&(a[t]=0))}function ky(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=fv(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:c}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",Ze,!(r||c))}const{parent:a}=t;a&&!a.hasCheckedOptimisedAppear&&ky(a)}function Ey({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:a,resetTransform:r}){return class{constructor(l={},u=e==null?void 0:e()){this.id=Hx++,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.layoutVersion=0,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(Yx),this.nodes.forEach(Zx),this.nodes.forEach(Wx),this.nodes.forEach(Xx)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=l,this.root=u?u.root||u:this,this.path=u?[...u.path,u]:[],this.parent=u,this.depth=u?u.depth+1:0;for(let f=0;f<this.path.length;f++)this.path[f].shouldResetTransform=!0;this.root===this&&(this.nodes=new Vx)}addEventListener(l,u){return this.eventHandlers.has(l)||this.eventHandlers.set(l,new Vu),this.eventHandlers.get(l).add(u)}notifyListeners(l,...u){const f=this.eventHandlers.get(l);f&&f.notify(...u)}hasListeners(l){return this.eventHandlers.has(l)}mount(l){if(this.instance)return;this.isSVG=xv(l)&&!K_(l),this.instance=l;const{layoutId:u,layout:f,visualElement:h}=this.options;if(h&&!h.current&&h.mount(l),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(f||u)&&(this.isLayoutDirty=!0),t){let p,v=0;const y=()=>this.root.updateBlockedByResize=!1;Ze.read(()=>{v=window.innerWidth}),t(l,()=>{const S=window.innerWidth;S!==v&&(v=S,this.root.updateBlockedByResize=!0,p&&p(),p=zx(y,250),yc.hasAnimatedSinceResize&&(yc.hasAnimatedSinceResize=!1,this.nodes.forEach(_y)))})}u&&this.root.registerSharedNode(u,this),this.options.animate!==!1&&h&&(u||f)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:v,hasRelativeLayoutChanged:y,layout:S})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const w=this.options.transition||h.getDefaultTransition()||iA,{onLayoutAnimationStart:T,onLayoutAnimationComplete:x}=h.getProps(),R=!this.targetLayout||!py(this.targetLayout,S),P=!v&&y;if(this.options.layoutRoot||this.resumeFrom||P||v&&(R||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const L={...gd(w,"layout"),onPlay:T,onComplete:x};(h.shouldReduceMotion||this.options.layoutRoot)&&(L.delay=0,L.type=!1),this.startAnimation(L),this.setAnimationOrigin(p,P)}else v||_y(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=S})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const l=this.getStack();l&&l.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Ii(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($x),this.animationId++)}getTransformTemplate(){const{visualElement:l}=this.options;return l&&l.getProps().transformTemplate}willUpdate(l=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&ky(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let p=0;p<this.path.length;p++){const v=this.path[p];v.shouldResetTransform=!0,v.updateScroll("snapshot"),v.options.layoutRoot&&v.willUpdate(!1)}const{layoutId:u,layout:f}=this.options;if(u===void 0&&!f)return;const h=this.getTransformTemplate();this.prevTransformTemplateValue=h?h(this.latestValues,""):void 0,this.updateSnapshot(),l&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(wy);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Ry);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Jx),this.nodes.forEach(Gx),this.nodes.forEach(Kx)):this.nodes.forEach(Ry),this.clearAllSnapshots();const u=jt.now();At.delta=Yn(0,1e3/60,u-At.timestamp),At.timestamp=u,At.isProcessing=!0,qu.update.process(At),qu.preRender.process(At),qu.render.process(At),At.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,wd.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Qx),this.sharedNodes.forEach(eA)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Ze.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Ze.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Vt(this.snapshot.measuredBox.x)&&!Vt(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 f=0;f<this.path.length;f++)this.path[f].updateScroll();const l=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=Tt(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:u}=this.options;u&&u.notify("LayoutMeasure",this.layout.layoutBox,l?l.layoutBox:void 0)}updateScroll(l="measure"){let u=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===l&&(u=!1),u&&this.instance){const f=a(this.instance);this.scroll={animationId:this.root.animationId,phase:l,isRoot:f,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:f}}}resetTransform(){if(!r)return;const l=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,u=this.projectionDelta&&!fy(this.projectionDelta),f=this.getTransformTemplate(),h=f?f(this.latestValues,""):void 0,p=h!==this.prevTransformTemplateValue;l&&this.instance&&(u||Na(this.latestValues)||p)&&(r(this.instance,h),this.shouldResetTransform=!1,this.scheduleRender())}measure(l=!0){const u=this.measurePageBox();let f=this.removeElementScroll(u);return l&&(f=this.removeTransform(f)),aA(f),{animationId:this.root.animationId,measuredBox:u,layoutBox:f,latestValues:{},source:this.id}}measurePageBox(){var h;const{visualElement:l}=this.options;if(!l)return Tt();const u=l.measureViewportBox();if(!(((h=this.scroll)==null?void 0:h.wasRoot)||this.path.some(sA))){const{scroll:p}=this.root;p&&(ys(u.x,p.offset.x),ys(u.y,p.offset.y))}return u}removeElementScroll(l){var f;const u=Tt();if(Ln(u,l),(f=this.scroll)!=null&&f.wasRoot)return u;for(let h=0;h<this.path.length;h++){const p=this.path[h],{scroll:v,options:y}=p;p!==this.root&&v&&y.layoutScroll&&(v.wasRoot&&Ln(u,l),ys(u.x,v.offset.x),ys(u.y,v.offset.y))}return u}applyTransform(l,u=!1){const f=Tt();Ln(f,l);for(let h=0;h<this.path.length;h++){const p=this.path[h];!u&&p.options.layoutScroll&&p.scroll&&p!==p.root&&bs(f,{x:-p.scroll.offset.x,y:-p.scroll.offset.y}),Na(p.latestValues)&&bs(f,p.latestValues)}return Na(this.latestValues)&&bs(f,this.latestValues),f}removeTransform(l){const u=Tt();Ln(u,l);for(let f=0;f<this.path.length;f++){const h=this.path[f];if(!h.instance||!Na(h.latestValues))continue;Od(h.latestValues)&&h.updateSnapshot();const p=Tt(),v=h.measurePageBox();Ln(p,v),uy(u,h.latestValues,h.snapshot?h.snapshot.layoutBox:void 0,p)}return Na(this.latestValues)&&uy(u,this.latestValues),u}setTargetDelta(l){this.targetDelta=l,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(l){this.options={...this.options,...l,crossfade:l.crossfade!==void 0?l.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!==At.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(l=!1){var S;const u=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=u.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=u.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=u.isSharedProjectionDirty);const f=!!this.resumingFrom||this!==u;if(!(l||f&&this.isSharedProjectionDirty||this.isProjectionDirty||(S=this.parent)!=null&&S.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:p,layoutId:v}=this.options;if(!this.layout||!(p||v))return;this.resolvedRelativeTargetAt=At.timestamp;const y=this.getClosestProjectingParent();y&&this.linkedParentVersion!==y.layoutVersion&&!y.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(y&&y.layout?this.createRelativeTarget(y,this.layout.layoutBox,y.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Tt(),this.targetWithTransforms=Tt()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),xx(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Ln(this.target,this.layout.layoutBox),Vv(this.target,this.targetDelta)):Ln(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,y&&!!y.resumingFrom==!!this.resumingFrom&&!y.options.layoutScroll&&y.target&&this.animationProgress!==1?this.createRelativeTarget(y,this.target,y.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||Od(this.parent.latestValues)||Uv(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(l,u,f){this.relativeParent=l,this.linkedParentVersion=l.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Tt(),this.relativeTargetOrigin=Tt(),gc(this.relativeTargetOrigin,u,f),Ln(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){var w;const l=this.getLead(),u=!!this.resumingFrom||this!==l;let f=!0;if((this.isProjectionDirty||(w=this.parent)!=null&&w.isProjectionDirty)&&(f=!1),u&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(f=!1),this.resolvedRelativeTargetAt===At.timestamp&&(f=!1),f)return;const{layout:h,layoutId:p}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(h||p))return;Ln(this.layoutCorrected,this.layout.layoutBox);const v=this.treeScale.x,y=this.treeScale.y;ix(this.layoutCorrected,this.treeScale,this.path,u),l.layout&&!l.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(l.target=l.layout.layoutBox,l.targetWithTransforms=Tt());const{target:S}=l;if(!S){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(ny(this.prevProjectionDelta.x,this.projectionDelta.x),ny(this.prevProjectionDelta.y,this.projectionDelta.y)),Br(this.projectionDelta,this.layoutCorrected,S,this.latestValues),(this.treeScale.x!==v||this.treeScale.y!==y||!vy(this.projectionDelta.x,this.prevProjectionDelta.x)||!vy(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",S))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(l=!0){var u;if((u=this.options.visualElement)==null||u.scheduleRender(),l){const f=this.getStack();f&&f.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=vs(),this.projectionDelta=vs(),this.projectionDeltaWithTransform=vs()}setAnimationOrigin(l,u=!1){const f=this.snapshot,h=f?f.latestValues:{},p={...this.latestValues},v=vs();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!u;const y=Tt(),S=f?f.source:void 0,w=this.layout?this.layout.source:void 0,T=S!==w,x=this.getStack(),R=!x||x.members.length<=1,P=!!(T&&!R&&this.options.crossfade===!0&&!this.path.some(nA));this.animationProgress=0;let L;this.mixTargetDelta=E=>{const k=E/1e3;xy(v.x,l.x,k),xy(v.y,l.y,k),this.setTargetDelta(v),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(gc(y,this.layout.layoutBox,this.relativeParent.layout.layoutBox),tA(this.relativeTarget,this.relativeTargetOrigin,y,k),L&&Ox(this.relativeTarget,L)&&(this.isProjectionDirty=!1),L||(L=Tt()),Ln(L,this.relativeTarget)),T&&(this.animationValues=p,Lx(p,h,this.latestValues,k,P,R)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=k},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){var u,f,h;this.notifyListeners("animationStart"),(u=this.currentAnimation)==null||u.stop(),(h=(f=this.resumingFrom)==null?void 0:f.currentAnimation)==null||h.stop(),this.pendingAnimation&&(Ii(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Ze.update(()=>{yc.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=gs(0)),this.currentAnimation=Bx(this.motionValue,[0,1e3],{...l,velocity:0,isSync:!0,onUpdate:p=>{this.mixTargetDelta(p),l.onUpdate&&l.onUpdate(p)},onStop:()=>{},onComplete:()=>{l.onComplete&&l.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 l=this.getStack();l&&l.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(qx),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:u,target:f,layout:h,latestValues:p}=l;if(!(!u||!f||!h)){if(this!==l&&this.layout&&h&&Py(this.options.animationType,this.layout.layoutBox,h.layoutBox)){f=this.target||Tt();const v=Vt(this.layout.layoutBox.x);f.x.min=l.target.x.min,f.x.max=f.x.min+v;const y=Vt(this.layout.layoutBox.y);f.y.min=l.target.y.min,f.y.max=f.y.min+y}Ln(u,f),bs(u,p),Br(this.projectionDeltaWithTransform,this.layoutCorrected,u,p)}}registerSharedNode(l,u){this.sharedNodes.has(l)||this.sharedNodes.set(l,new Fx),this.sharedNodes.get(l).add(u);const h=u.options.initialPromotionConfig;u.promote({transition:h?h.transition:void 0,preserveFollowOpacity:h&&h.shouldPreserveFollowOpacity?h.shouldPreserveFollowOpacity(u):void 0})}isLead(){const l=this.getStack();return l?l.lead===this:!0}getLead(){var u;const{layoutId:l}=this.options;return l?((u=this.getStack())==null?void 0:u.lead)||this:this}getPrevLead(){var u;const{layoutId:l}=this.options;return l?(u=this.getStack())==null?void 0:u.prevLead:void 0}getStack(){const{layoutId:l}=this.options;if(l)return this.root.sharedNodes.get(l)}promote({needsReset:l,transition:u,preserveFollowOpacity:f}={}){const h=this.getStack();h&&h.promote(this,f),l&&(this.projectionDelta=void 0,this.needsReset=!0),u&&this.setOptions({transition:u})}relegate(){const l=this.getStack();return l?l.relegate(this):!1}resetSkewAndRotation(){const{visualElement:l}=this.options;if(!l)return;let u=!1;const{latestValues:f}=l;if((f.z||f.rotate||f.rotateX||f.rotateY||f.rotateZ||f.skewX||f.skewY)&&(u=!0),!u)return;const h={};f.z&&Bd("z",l,h,this.animationValues);for(let p=0;p<Ud.length;p++)Bd(`rotate${Ud[p]}`,l,h,this.animationValues),Bd(`skew${Ud[p]}`,l,h,this.animationValues);l.render();for(const p in h)l.setStaticValue(p,h[p]),this.animationValues&&(this.animationValues[p]=h[p]);l.scheduleRender()}applyProjectionStyles(l,u){var w,T;if(!this.instance||this.isSVG)return;if(!this.isVisible){l.visibility="hidden";return}const f=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,l.visibility="",l.opacity="",l.pointerEvents=vc(u==null?void 0:u.pointerEvents)||"",l.transform=f?f(this.latestValues,""):"none";return}const h=this.getLead();if(!this.projectionDelta||!this.layout||!h.target){this.options.layoutId&&(l.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,l.pointerEvents=vc(u==null?void 0:u.pointerEvents)||""),this.hasProjected&&!Na(this.latestValues)&&(l.transform=f?f({},""):"none",this.hasProjected=!1);return}l.visibility="";const p=h.animationValues||h.latestValues;this.applyTransformsToTarget();let v=Px(this.projectionDeltaWithTransform,this.treeScale,p);f&&(v=f(p,v)),l.transform=v;const{x:y,y:S}=this.projectionDelta;l.transformOrigin=`${y.origin*100}% ${S.origin*100}% 0`,h.animationValues?l.opacity=h===this?(T=(w=p.opacity)!=null?w:this.latestValues.opacity)!=null?T:1:this.preserveOpacity?this.latestValues.opacity:p.opacityExit:l.opacity=h===this?p.opacity!==void 0?p.opacity:"":p.opacityExit!==void 0?p.opacityExit:0;for(const x in Ld){if(p[x]===void 0)continue;const{correct:R,applyTo:P,isCSSVariable:L}=Ld[x],E=v==="none"?p[x]:R(p[x],h);if(P){const k=P.length;for(let _=0;_<k;_++)l[P[_]]=E}else L?this.options.visualElement.renderState.vars[x]=E:l[x]=E}this.options.layoutId&&(l.pointerEvents=h===this?vc(u==null?void 0:u.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(l=>{var u;return(u=l.currentAnimation)==null?void 0:u.stop()}),this.root.nodes.forEach(wy),this.root.sharedNodes.clear()}}}function Gx(t){t.updateLayout()}function Kx(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:a,measuredBox:r}=t.layout,{animationType:c}=t.options,l=e.source!==t.layout.source;c==="size"?bn(v=>{const y=l?e.measuredBox[v]:e.layoutBox[v],S=Vt(y);y.min=a[v].min,y.max=y.min+S}):Py(c,e.layoutBox,a)&&bn(v=>{const y=l?e.measuredBox[v]:e.layoutBox[v],S=Vt(a[v]);y.max=y.min+S,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[v].max=t.relativeTarget[v].min+S)});const u=vs();Br(u,a,e.layoutBox);const f=vs();l?Br(f,t.applyTransform(r,!0),e.measuredBox):Br(f,a,e.layoutBox);const h=!fy(u);let p=!1;if(!t.resumeFrom){const v=t.getClosestProjectingParent();if(v&&!v.resumeFrom){const{snapshot:y,layout:S}=v;if(y&&S){const w=Tt();gc(w,e.layoutBox,y.layoutBox);const T=Tt();gc(T,a,S.layoutBox),py(w,T)||(p=!0),v.options.layoutRoot&&(t.relativeTarget=T,t.relativeTargetOrigin=w,t.relativeParent=v)}}}t.notifyListeners("didUpdate",{layout:a,snapshot:e,delta:f,layoutDelta:u,hasLayoutChanged:h,hasRelativeLayoutChanged:p})}else if(t.isLead()){const{onExitComplete:a}=t.options;a&&a()}t.options.transition=void 0}function Yx(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 Xx(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Qx(t){t.clearSnapshot()}function wy(t){t.clearMeasurements()}function Ry(t){t.isLayoutDirty=!1}function Jx(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function _y(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function Zx(t){t.resolveTargetDelta()}function Wx(t){t.calcProjection()}function $x(t){t.resetSkewAndRotation()}function eA(t){t.removeLeadSnapshot()}function xy(t,e,n){t.translate=it(e.translate,0,n),t.scale=it(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function Ay(t,e,n,a){t.min=it(e.min,n.min,a),t.max=it(e.max,n.max,a)}function tA(t,e,n,a){Ay(t.x,e.x,n.x,a),Ay(t.y,e.y,n.y,a)}function nA(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const iA={duration:.45,ease:[.4,0,.1,1]},My=t=>typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Dy=My("applewebkit/")&&!My("chrome/")?Math.round:vn;function Oy(t){t.min=Dy(t.min),t.max=Dy(t.max)}function aA(t){Oy(t.x),Oy(t.y)}function Py(t,e,n){return t==="position"||t==="preserve-aspect"&&!_x(gy(e),gy(n),.2)}function sA(t){var e;return t!==t.root&&((e=t.scroll)==null?void 0:e.wasRoot)}const rA=Ey({attachResizeListener:(t,e)=>jr(t,"resize",e),measureScroll:()=>{var t,e;return{x:document.documentElement.scrollLeft||((t=document.body)==null?void 0:t.scrollLeft)||0,y:document.documentElement.scrollTop||((e=document.body)==null?void 0:e.scrollTop)||0}},checkIsScrollRoot:()=>!0}),jd={current:void 0},Ny=Ey({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!jd.current){const t=new rA({});t.mount(window),t.setOptions({layoutScroll:!0}),jd.current=t}return jd.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Ly=q.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function oA(t=!0){const e=q.useContext(Lu);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:a,register:r}=e,c=q.useId();q.useEffect(()=>{if(t)return r(c)},[t]);const l=q.useCallback(()=>t&&a&&a(c),[c,a,t]);return!n&&a?[!1,l]:[!0]}const Iy=q.createContext({strict:!1}),Uy={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"]};let By=!1;function cA(){if(By)return;const t={};for(const e in Uy)t[e]={isEnabled:n=>Uy[e].some(a=>!!n[a])};Nv(t),By=!0}function jy(){return cA(),$_()}function lA(t){const e=jy();for(const n in t)e[n]={...e[n],...t[n]};Nv(e)}const uA=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 bc(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||uA.has(t)}let Vy=t=>!bc(t);function dA(t){typeof t=="function"&&(Vy=e=>e.startsWith("on")?!bc(e):t(e))}try{dA(require("@emotion/is-prop-valid").default)}catch{}function fA(t,e,n){const a={};for(const r in t)r==="values"&&typeof t.values=="object"||(Vy(r)||n===!0&&bc(r)||!e&&!bc(r)||t.draggable&&r.startsWith("onDrag"))&&(a[r]=t[r]);return a}const Sc=q.createContext({});function hA(t,e){if(hc(t)){const{initial:n,animate:a}=t;return{initial:n===!1||Ir(n)?n:void 0,animate:Ir(a)?a:void 0}}return t.inherit!==!1?e:{}}function mA(t){const{initial:e,animate:n}=hA(t,q.useContext(Sc));return q.useMemo(()=>({initial:e,animate:n}),[zy(e),zy(n)])}function zy(t){return Array.isArray(t)?t.join(" "):t}const Vd=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Fy(t,e,n){for(const a in e)!Bt(e[a])&&!Yv(a,n)&&(t[a]=e[a])}function pA({transformTemplate:t},e){return q.useMemo(()=>{const n=Vd();return Nd(n,e,t),Object.assign({},n.vars,n.style)},[e])}function gA(t,e){const n=t.style||{},a={};return Fy(a,n,t),Object.assign(a,pA(t,e)),a}function vA(t,e){const n={},a=gA(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,a.userSelect=a.WebkitUserSelect=a.WebkitTouchCallout="none",a.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=a,n}const qy=()=>({...Vd(),attrs:{}});function yA(t,e,n,a){const r=q.useMemo(()=>{const c=qy();return Xv(c,e,Jv(a),t.transformTemplate,t.style),{...c.attrs,style:{...c.style}}},[e]);if(t.style){const c={};Fy(c,t.style,t),r.style={...c,...r.style}}return r}const bA=["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 zd(t){return typeof t!="string"||t.includes("-")?!1:!!(bA.indexOf(t)>-1||/[A-Z]/u.test(t))}function SA(t,e,n,{latestValues:a},r,c=!1,l){const f=((l!=null?l:zd(t))?yA:vA)(e,a,r,t),h=fA(e,typeof t=="string",c),p=t!==q.Fragment?{...h,...f,ref:n}:{},{children:v}=e,y=q.useMemo(()=>Bt(v)?v.get():v,[v]);return q.createElement(t,{...p,children:y})}function TA({scrapeMotionValuesFromProps:t,createRenderState:e},n,a,r){return{latestValues:CA(n,a,r,t),renderState:e()}}function CA(t,e,n,a){const r={},c=a(t,{});for(const y in c)r[y]=vc(c[y]);let{initial:l,animate:u}=t;const f=hc(t),h=Ov(t);e&&h&&!f&&t.inherit!==!1&&(l===void 0&&(l=e.initial),u===void 0&&(u=e.animate));let p=n?n.initial===!1:!1;p=p||l===!1;const v=p?u:l;if(v&&typeof v!="boolean"&&!fc(v)){const y=Array.isArray(v)?v:[v];for(let S=0;S<y.length;S++){const w=yd(t,y[S]);if(w){const{transitionEnd:T,transition:x,...R}=w;for(const P in R){let L=R[P];if(Array.isArray(L)){const E=p?L.length-1:0;L=L[E]}L!==null&&(r[P]=L)}for(const P in T)r[P]=T[P]}}}return r}const Hy=t=>(e,n)=>{const a=q.useContext(Sc),r=q.useContext(Lu),c=()=>TA(t,e,a,r);return n?c():Uw(c)},kA=Hy({scrapeMotionValuesFromProps:Id,createRenderState:Vd}),EA=Hy({scrapeMotionValuesFromProps:Zv,createRenderState:qy}),wA=Symbol.for("motionComponentSymbol");function RA(t,e,n){const a=q.useRef(n);q.useInsertionEffect(()=>{a.current=n});const r=q.useRef(null);return q.useCallback(c=>{var u;c&&((u=t.onMount)==null||u.call(t,c)),e&&(c?e.mount(c):e.unmount());const l=a.current;if(typeof l=="function")if(c){const f=l(c);typeof f=="function"&&(r.current=f)}else r.current?(r.current(),r.current=null):l(c);else l&&(l.current=c)},[e])}const Gy=q.createContext({});function Vr(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function _A(t,e,n,a,r,c){var x,R;const{visualElement:l}=q.useContext(Sc),u=q.useContext(Iy),f=q.useContext(Lu),h=q.useContext(Ly).reducedMotion,p=q.useRef(null);a=a||u.renderer,!p.current&&a&&(p.current=a(t,{visualState:e,parent:l,props:n,presenceContext:f,blockInitialAnimation:f?f.initial===!1:!1,reducedMotionConfig:h,isSVG:c}));const v=p.current,y=q.useContext(Gy);v&&!v.projection&&r&&(v.type==="html"||v.type==="svg")&&xA(p.current,n,r,y);const S=q.useRef(!1);q.useInsertionEffect(()=>{v&&S.current&&v.update(n,f)});const w=n[dv],T=q.useRef(!!w&&!((x=window.MotionHandoffIsComplete)!=null&&x.call(window,w))&&((R=window.MotionHasOptimisedAnimation)==null?void 0:R.call(window,w)));return Bw(()=>{v&&(S.current=!0,window.MotionIsMounted=!0,v.updateFeatures(),v.scheduleRenderMicrotask(),T.current&&v.animationState&&v.animationState.animateChanges())}),q.useEffect(()=>{v&&(!T.current&&v.animationState&&v.animationState.animateChanges(),T.current&&(queueMicrotask(()=>{var P;(P=window.MotionHandoffMarkAsComplete)==null||P.call(window,w)}),T.current=!1),v.enteringChildren=void 0)}),v}function xA(t,e,n,a){const{layoutId:r,layout:c,drag:l,dragConstraints:u,layoutScroll:f,layoutRoot:h,layoutCrossfade:p}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:Ky(t.parent)),t.projection.setOptions({layoutId:r,layout:c,alwaysMeasureLayout:!!l||u&&Vr(u),visualElement:t,animationType:typeof c=="string"?c:"both",initialPromotionConfig:a,crossfade:p,layoutScroll:f,layoutRoot:h})}function Ky(t){if(t)return t.options.allowProjection!==!1?t.projection:Ky(t.parent)}function Fd(t,{forwardMotionProps:e=!1,type:n}={},a,r){var h,p;a&&lA(a);const c=n?n==="svg":zd(t),l=c?EA:kA;function u(v,y){let S;const w={...q.useContext(Ly),...v,layoutId:AA(v)},{isStatic:T}=w,x=mA(v),R=l(v,T);if(!T&&hg){MA();const P=DA(w);S=P.MeasureLayout,x.visualElement=_A(t,R,w,r,P.ProjectionNode,c)}return oe.jsxs(Sc.Provider,{value:x,children:[S&&x.visualElement?oe.jsx(S,{visualElement:x.visualElement,...w}):null,SA(t,v,RA(R,x.visualElement,y),R,T,e,c)]})}u.displayName=`motion.${typeof t=="string"?t:`create(${(p=(h=t.displayName)!=null?h:t.name)!=null?p:""})`}`;const f=q.forwardRef(u);return f[wA]=t,f}function AA({layoutId:t}){const e=q.useContext(fg).id;return e&&t!==void 0?e+"-"+t:t}function MA(t,e){q.useContext(Iy).strict}function DA(t){const e=jy(),{drag:n,layout:a}=e;if(!n&&!a)return{};const r={...n,...a};return{MeasureLayout:n!=null&&n.isEnabled(t)||a!=null&&a.isEnabled(t)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function OA(t,e){if(typeof Proxy=="undefined")return Fd;const n=new Map,a=(c,l)=>Fd(c,l,t,e),r=(c,l)=>a(c,l);return new Proxy(r,{get:(c,l)=>l==="create"?a:(n.has(l)||n.set(l,Fd(l,void 0,t,e)),n.get(l))})}const PA=(t,e)=>{var a;return((a=e.isSVG)!=null?a:zd(t))?new gx(e):new ux(e,{allowProjection:t!==q.Fragment})};class NA extends Vi{constructor(e){super(e),e.animationState||(e.animationState=Tx(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();fc(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 LA=0;class IA extends Vi{constructor(){super(...arguments),this.id=LA++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:a}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===a)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 UA={animation:{Feature:NA},exit:{Feature:IA}};function zr(t){return{point:{x:t.pageX,y:t.pageY}}}const BA=t=>e=>Rd(e)&&t(e,zr(e));function Fr(t,e,n,a){return jr(t,e,BA(n),a)}const Yy=({current:t})=>t?t.ownerDocument.defaultView:null,Xy=(t,e)=>Math.abs(t-e);function jA(t,e){const n=Xy(t.x,e.x),a=Xy(t.y,e.y);return Math.sqrt(n**2+a**2)}const Qy=new Set(["auto","scroll"]);class Jy{constructor(e,n,{transformPagePoint:a,contextWindow:r=window,dragSnapToOrigin:c=!1,distanceThreshold:l=3,element:u}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=S=>{this.handleScroll(S.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const S=Hd(this.lastMoveEventInfo,this.history),w=this.startEvent!==null,T=jA(S.offset,{x:0,y:0})>=this.distanceThreshold;if(!w&&!T)return;const{point:x}=S,{timestamp:R}=At;this.history.push({...x,timestamp:R});const{onStart:P,onMove:L}=this.handlers;w||(P&&P(this.lastMoveEvent,S),this.startEvent=this.lastMoveEvent),L&&L(this.lastMoveEvent,S)},this.handlePointerMove=(S,w)=>{this.lastMoveEvent=S,this.lastMoveEventInfo=qd(w,this.transformPagePoint),Ze.update(this.updatePoint,!0)},this.handlePointerUp=(S,w)=>{this.end();const{onEnd:T,onSessionEnd:x,resumeAnimation:R}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&R&&R(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const P=Hd(S.type==="pointercancel"?this.lastMoveEventInfo:qd(w,this.transformPagePoint),this.history);this.startEvent&&T&&T(S,P),x&&x(S,P)},!Rd(e))return;this.dragSnapToOrigin=c,this.handlers=n,this.transformPagePoint=a,this.distanceThreshold=l,this.contextWindow=r||window;const f=zr(e),h=qd(f,this.transformPagePoint),{point:p}=h,{timestamp:v}=At;this.history=[{...p,timestamp:v}];const{onSessionStart:y}=n;y&&y(e,Hd(h,this.history)),this.removeListeners=_r(Fr(this.contextWindow,"pointermove",this.handlePointerMove),Fr(this.contextWindow,"pointerup",this.handlePointerUp),Fr(this.contextWindow,"pointercancel",this.handlePointerUp)),u&&this.startScrollTracking(u)}startScrollTracking(e){let n=e.parentElement;for(;n;){const a=getComputedStyle(n);(Qy.has(a.overflowX)||Qy.has(a.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0,passive:!0}),window.addEventListener("scroll",this.onWindowScroll,{passive:!0}),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const n=this.scrollPositions.get(e);if(!n)return;const a=e===window,r=a?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},c={x:r.x-n.x,y:r.y-n.y};c.x===0&&c.y===0||(a?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=c.x,this.lastMoveEventInfo.point.y+=c.y):this.history.length>0&&(this.history[0].x-=c.x,this.history[0].y-=c.y),this.scrollPositions.set(e,r),Ze.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Ii(this.updatePoint)}}function qd(t,e){return e?{point:e(t.point)}:t}function Zy(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Hd({point:t},e){return{point:t,delta:Zy(t,Wy(e)),offset:Zy(t,VA(e)),velocity:zA(e,.1)}}function VA(t){return t[0]}function Wy(t){return t[t.length-1]}function zA(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,a=null;const r=Wy(t);for(;n>=0&&(a=t[n],!(r.timestamp-a.timestamp>li(e)));)n--;if(!a)return{x:0,y:0};const c=yn(r.timestamp-a.timestamp);if(c===0)return{x:0,y:0};const l={x:(r.x-a.x)/c,y:(r.y-a.y)/c};return l.x===1/0&&(l.x=0),l.y===1/0&&(l.y=0),l}function FA(t,{min:e,max:n},a){return e!==void 0&&t<e?t=a?it(e,t,a.min):Math.max(t,e):n!==void 0&&t>n&&(t=a?it(n,t,a.max):Math.min(t,n)),t}function $y(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 qA(t,{top:e,left:n,bottom:a,right:r}){return{x:$y(t.x,n,r),y:$y(t.y,e,a)}}function e0(t,e){let n=e.min-t.min,a=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,a]=[a,n]),{min:n,max:a}}function HA(t,e){return{x:e0(t.x,e.x),y:e0(t.y,e.y)}}function GA(t,e){let n=.5;const a=Vt(t),r=Vt(e);return r>a?n=xr(e.min,e.max-a,t.min):a>r&&(n=xr(t.min,t.max-r,e.min)),Yn(0,1,n)}function KA(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 Gd=.35;function YA(t=Gd){return t===!1?t=0:t===!0&&(t=Gd),{x:t0(t,"left","right"),y:t0(t,"top","bottom")}}function t0(t,e,n){return{min:n0(t,e),max:n0(t,n)}}function n0(t,e){return typeof t=="number"?t:t[e]||0}const XA=new WeakMap;class QA{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=Tt(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:a}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const c=v=>{n?(this.stopAnimation(),this.snapToCursor(zr(v).point)):this.pauseAnimation()},l=(v,y)=>{this.stopAnimation();const{drag:S,dragPropagation:w,onDragStart:T}=this.getProps();if(S&&!w&&(this.openDragLock&&this.openDragLock(),this.openDragLock=z_(S),!this.openDragLock))return;this.latestPointerEvent=v,this.latestPanInfo=y,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),bn(R=>{let P=this.getAxisMotionValue(R).get()||0;if(Xn.test(P)){const{projection:L}=this.visualElement;if(L&&L.layout){const E=L.layout.layoutBox[R];E&&(P=Vt(E)*(parseFloat(P)/100))}}this.originPoint[R]=P}),T&&Ze.postRender(()=>T(v,y)),Sd(this.visualElement,"transform");const{animationState:x}=this.visualElement;x&&x.setActive("whileDrag",!0)},u=(v,y)=>{this.latestPointerEvent=v,this.latestPanInfo=y;const{dragPropagation:S,dragDirectionLock:w,onDirectionLock:T,onDrag:x}=this.getProps();if(!S&&!this.openDragLock)return;const{offset:R}=y;if(w&&this.currentDirection===null){this.currentDirection=JA(R),this.currentDirection!==null&&T&&T(this.currentDirection);return}this.updateAxis("x",y.point,R),this.updateAxis("y",y.point,R),this.visualElement.render(),x&&x(v,y)},f=(v,y)=>{this.latestPointerEvent=v,this.latestPanInfo=y,this.stop(v,y),this.latestPointerEvent=null,this.latestPanInfo=null},h=()=>bn(v=>{var y;return this.getAnimationState(v)==="paused"&&((y=this.getAxisMotionValue(v).animation)==null?void 0:y.play())}),{dragSnapToOrigin:p}=this.getProps();this.panSession=new Jy(e,{onSessionStart:c,onStart:l,onMove:u,onSessionEnd:f,resumeAnimation:h},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:a,contextWindow:Yy(this.visualElement),element:this.visualElement.current})}stop(e,n){const a=e||this.latestPointerEvent,r=n||this.latestPanInfo,c=this.isDragging;if(this.cancel(),!c||!r||!a)return;const{velocity:l}=r;this.startAnimation(l);const{onDragEnd:u}=this.getProps();u&&Ze.postRender(()=>u(a,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:a}=this.getProps();!a&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,n,a){const{drag:r}=this.getProps();if(!a||!Tc(e,r,this.currentDirection))return;const c=this.getAxisMotionValue(e);let l=this.originPoint[e]+a[e];this.constraints&&this.constraints[e]&&(l=FA(l,this.constraints[e],this.elastic[e])),c.set(l)}resolveConstraints(){var c;const{dragConstraints:e,dragElastic:n}=this.getProps(),a=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(c=this.visualElement.projection)==null?void 0:c.layout,r=this.constraints;e&&Vr(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&a?this.constraints=qA(a.layoutBox,e):this.constraints=!1,this.elastic=YA(n),r!==this.constraints&&a&&this.constraints&&!this.hasMutatedConstraints&&bn(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=KA(a.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Vr(e))return!1;const a=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const c=ax(a,r.root,this.visualElement.getTransformPagePoint());let l=HA(r.layout.layoutBox,c);if(n){const u=n(tx(l));this.hasMutatedConstraints=!!u,u&&(l=Iv(u))}return l}startAnimation(e){const{drag:n,dragMomentum:a,dragElastic:r,dragTransition:c,dragSnapToOrigin:l,onDragTransitionEnd:u}=this.getProps(),f=this.constraints||{},h=bn(p=>{if(!Tc(p,n,this.currentDirection))return;let v=f&&f[p]||{};l&&(v={min:0,max:0});const y=r?200:1e6,S=r?40:1e7,w={type:"inertia",velocity:a?e[p]:0,bounceStiffness:y,bounceDamping:S,timeConstant:750,restDelta:1,restSpeed:10,...c,...v};return this.startAxisValueAnimation(p,w)});return Promise.all(h).then(u)}startAxisValueAnimation(e,n){const a=this.getAxisMotionValue(e);return Sd(this.visualElement,e),a.start(vd(e,a,0,n,this.visualElement,!1))}stopAnimation(){bn(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){bn(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()}`,a=this.visualElement.getProps(),r=a[n];return r||this.visualElement.getValue(e,(a.initial?a.initial[e]:void 0)||0)}snapToCursor(e){bn(n=>{const{drag:a}=this.getProps();if(!Tc(n,a,this.currentDirection))return;const{projection:r}=this.visualElement,c=this.getAxisMotionValue(n);if(r&&r.layout){const{min:l,max:u}=r.layout.layoutBox[n],f=c.get()||0;c.set(e[n]-it(l,u,.5)+f)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:a}=this.visualElement;if(!Vr(n)||!a||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};bn(l=>{const u=this.getAxisMotionValue(l);if(u&&this.constraints!==!1){const f=u.get();r[l]=GA({min:f,max:f},this.constraints[l])}});const{transformTemplate:c}=this.visualElement.getProps();this.visualElement.current.style.transform=c?c({},""):"none",a.root&&a.root.updateScroll(),a.updateLayout(),this.resolveConstraints(),bn(l=>{if(!Tc(l,e,null))return;const u=this.getAxisMotionValue(l),{min:f,max:h}=this.constraints[l];u.set(it(f,h,r[l]))})}addListeners(){if(!this.visualElement.current)return;XA.set(this.visualElement,this);const e=this.visualElement.current,n=Fr(e,"pointerdown",f=>{const{drag:h,dragListener:p=!0}=this.getProps(),v=f.target,y=v!==e&&wv(v);h&&p&&!y&&this.start(f)}),a=()=>{const{dragConstraints:f}=this.getProps();Vr(f)&&f.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,c=r.addEventListener("measure",a);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),Ze.read(a);const l=jr(window,"resize",()=>this.scalePositionWithinConstraints()),u=r.addEventListener("didUpdate",(({delta:f,hasLayoutChanged:h})=>{this.isDragging&&h&&(bn(p=>{const v=this.getAxisMotionValue(p);v&&(this.originPoint[p]+=f[p].translate,v.set(v.get()+f[p].translate))}),this.visualElement.render())}));return()=>{l(),n(),c(),u&&u()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:a=!1,dragPropagation:r=!1,dragConstraints:c=!1,dragElastic:l=Gd,dragMomentum:u=!0}=e;return{...e,drag:n,dragDirectionLock:a,dragPropagation:r,dragConstraints:c,dragElastic:l,dragMomentum:u}}}function Tc(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function JA(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class ZA extends Vi{constructor(e){super(e),this.removeGroupControls=vn,this.removeListeners=vn,this.controls=new QA(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||vn}update(){const{dragControls:e}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};e!==n&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.endPanSession()}}const i0=t=>(e,n)=>{t&&Ze.postRender(()=>t(e,n))};class WA extends Vi{constructor(){super(...arguments),this.removePointerDownListener=vn}onPointerDown(e){this.session=new Jy(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Yy(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:a,onPanEnd:r}=this.node.getProps();return{onSessionStart:i0(e),onStart:i0(n),onMove:a,onEnd:(c,l)=>{delete this.session,r&&Ze.postRender(()=>r(c,l))}}}mount(){this.removePointerDownListener=Fr(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Kd=!1;class $A extends q.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:a,layoutId:r}=this.props,{projection:c}=e;c&&(n.group&&n.group.add(c),a&&a.register&&r&&a.register(c),Kd&&c.root.didUpdate(),c.addEventListener("animationComplete",()=>{this.safeToRemove()}),c.setOptions({...c.options,onExitComplete:()=>this.safeToRemove()})),yc.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:a,drag:r,isPresent:c}=this.props,{projection:l}=a;return l&&(l.isPresent=c,Kd=!0,r||e.layoutDependency!==n||n===void 0||e.isPresent!==c?l.willUpdate():this.safeToRemove(),e.isPresent!==c&&(c?l.promote():l.relegate()||Ze.postRender(()=>{const u=l.getStack();(!u||!u.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),wd.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:a}=this.props,{projection:r}=e;Kd=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),a&&a.deregister&&a.deregister(r))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function a0(t){const[e,n]=oA(),a=q.useContext(fg);return oe.jsx($A,{...t,layoutGroup:a,switchLayoutGroup:q.useContext(Gy),isPresent:e,safeToRemove:n})}const eM={pan:{Feature:WA},drag:{Feature:ZA,ProjectionNode:Ny,MeasureLayout:a0}};function s0(t,e,n){const{props:a}=t;t.animationState&&a.whileHover&&t.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,c=a[r];c&&Ze.postRender(()=>c(e,zr(e)))}class tM extends Vi{mount(){const{current:e}=this.node;e&&(this.unmount=F_(e,(n,a)=>(s0(this.node,a,"Start"),r=>s0(this.node,r,"End"))))}unmount(){}}class nM extends Vi{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=_r(jr(this.node.current,"focus",()=>this.onFocus()),jr(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function r0(t,e,n){const{props:a}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&a.whileTap&&t.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),c=a[r];c&&Ze.postRender(()=>c(e,zr(e)))}class iM extends Vi{mount(){const{current:e}=this.node;e&&(this.unmount=G_(e,(n,a)=>(r0(this.node,a,"Start"),(r,{success:c})=>r0(this.node,r,c?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Yd=new WeakMap,Xd=new WeakMap,aM=t=>{const e=Yd.get(t.target);e&&e(t)},sM=t=>{t.forEach(aM)};function rM({root:t,...e}){const n=t||document;Xd.has(n)||Xd.set(n,{});const a=Xd.get(n),r=JSON.stringify(e);return a[r]||(a[r]=new IntersectionObserver(sM,{root:t,...e})),a[r]}function oM(t,e,n){const a=rM(e);return Yd.set(t,n),a.observe(t),()=>{Yd.delete(t),a.unobserve(t)}}const cM={some:0,all:1};class lM extends Vi{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:a,amount:r="some",once:c}=e,l={root:n?n.current:void 0,rootMargin:a,threshold:typeof r=="number"?r:cM[r]},u=f=>{const{isIntersecting:h}=f;if(this.isInView===h||(this.isInView=h,c&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:p,onViewportLeave:v}=this.node.getProps(),y=h?p:v;y&&y(f)};return oM(this.node.current,l,u)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver=="undefined")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(uM(e,n))&&this.startObserver()}unmount(){}}function uM({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const dM={...UA,...{inView:{Feature:lM},tap:{Feature:iM},focus:{Feature:nM},hover:{Feature:tM}},...eM,...{layout:{ProjectionNode:Ny,MeasureLayout:a0}}},fM=OA(dM,PA);var o0={};function hM(t,e){return e.forEach(function(n){n&&typeof n!="string"&&!Array.isArray(n)&&Object.keys(n).forEach(function(a){if(a!=="default"&&!(a in t)){var r=Object.getOwnPropertyDescriptor(n,a);Object.defineProperty(t,a,r.get?r:{enumerable:!0,get:function(){return n[a]}})}})}),Object.freeze(t)}var mM=Object.defineProperty,pM=(t,e,n)=>e in t?mM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,c0=(t,e,n)=>pM(t,typeof e!="symbol"?e+"":e,n);class zt{constructor(){c0(this,"_locking"),c0(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()}),a=this._locking.then(()=>e);return this._locking=this._locking.then(()=>n),a}}function st(t,e){if(!t)throw new Error(e)}const gM=34028234663852886e22,vM=-34028234663852886e22,yM=4294967295,bM=2147483647,SM=-2147483648;function Cc(t){if(typeof t!="number")throw new Error("invalid int 32: "+typeof t);if(!Number.isInteger(t)||t>bM||t<SM)throw new Error("invalid int 32: "+t)}function Qd(t){if(typeof t!="number")throw new Error("invalid uint 32: "+typeof t);if(!Number.isInteger(t)||t>yM||t<0)throw new Error("invalid uint 32: "+t)}function l0(t){if(typeof t!="number")throw new Error("invalid float 32: "+typeof t);if(Number.isFinite(t)&&(t>gM||t<vM))throw new Error("invalid float 32: "+t)}const u0=Symbol("@bufbuild/protobuf/enum-type");function TM(t){const e=t[u0];return st(e,"missing enum type on enum object"),e}function d0(t,e,n,a){t[u0]=f0(e,n.map(r=>({no:r.no,name:r.name,localName:t[r.no]})))}function f0(t,e,n){const a=Object.create(null),r=Object.create(null),c=[];for(const l of e){const u=h0(l);c.push(u),a[l.name]=u,r[l.no]=u}return{typeName:t,values:c,findName(l){return a[l]},findNumber(l){return r[l]}}}function CM(t,e,n){const a={};for(const r of e){const c=h0(r);a[c.localName]=c.no,a[c.no]=c.localName}return d0(a,t,e),a}function h0(t){return"localName"in t?t:Object.assign(Object.assign({},t),{localName:t.name})}class Jd{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,n){const a=this.getType(),r=a.runtime.bin,c=r.makeReadOptions(n);return r.readMessage(this,c.readerFactory(e),e.byteLength,c),this}fromJson(e,n){const a=this.getType(),r=a.runtime.json,c=r.makeReadOptions(n);return r.readMessage(a,e,c,this),this}fromJsonString(e,n){let a;try{a=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(a,n)}toBinary(e){const n=this.getType(),a=n.runtime.bin,r=a.makeWriteOptions(e),c=r.writerFactory();return a.writeMessage(this,c,r),c.finish()}toJson(e){const n=this.getType(),a=n.runtime.json,r=a.makeWriteOptions(e);return a.writeMessage(this,r)}toJsonString(e){var n;const a=this.toJson(e);return JSON.stringify(a,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 kM(t,e,n,a){var r;const c=(r=a==null?void 0:a.localName)!==null&&r!==void 0?r:e.substring(e.lastIndexOf(".")+1),l={[c]:function(u){t.util.initFields(this),t.util.initPartial(u,this)}}[c];return Object.setPrototypeOf(l.prototype,new Jd),Object.assign(l,{runtime:t,typeName:e,fields:t.util.newFieldList(n),fromBinary(u,f){return new l().fromBinary(u,f)},fromJson(u,f){return new l().fromJson(u,f)},fromJsonString(u,f){return new l().fromJsonString(u,f)},equals(u,f){return t.util.equals(l,u,f)}}),l}function EM(){let t=0,e=0;for(let a=0;a<28;a+=7){let r=this.buf[this.pos++];if(t|=(r&127)<<a,(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 a=3;a<=31;a+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<a,(r&128)==0)return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function Zd(t,e,n){for(let c=0;c<28;c=c+7){const l=t>>>c,u=!(!(l>>>7)&&e==0),f=(u?l|128:l)&255;if(n.push(f),!u)return}const a=t>>>28&15|(e&7)<<4,r=e>>3!=0;if(n.push((r?a|128:a)&255),!!r){for(let c=3;c<31;c=c+7){const l=e>>>c,u=!!(l>>>7),f=(u?l|128:l)&255;if(n.push(f),!u)return}n.push(e>>>31&1)}}const kc=4294967296;function m0(t){const e=t[0]==="-";e&&(t=t.slice(1));const n=1e6;let a=0,r=0;function c(l,u){const f=Number(t.slice(l,u));r*=n,a=a*n+f,a>=kc&&(r=r+(a/kc|0),a=a%kc)}return c(-24,-18),c(-18,-12),c(-12,-6),c(-6),e?g0(a,r):Wd(a,r)}function wM(t,e){let n=Wd(t,e);const a=n.hi&2147483648;a&&(n=g0(n.lo,n.hi));const r=p0(n.lo,n.hi);return a?"-"+r:r}function p0(t,e){if({lo:t,hi:e}=RM(t,e),e<=2097151)return String(kc*e+t);const n=t&16777215,a=(t>>>24|e<<8)&16777215,r=e>>16&65535;let c=n+a*6777216+r*6710656,l=a+r*8147497,u=r*2;const f=1e7;return c>=f&&(l+=Math.floor(c/f),c%=f),l>=f&&(u+=Math.floor(l/f),l%=f),u.toString()+v0(l)+v0(c)}function RM(t,e){return{lo:t>>>0,hi:e>>>0}}function Wd(t,e){return{lo:t|0,hi:e|0}}function g0(t,e){return e=~e,t?t=~t+1:e+=1,Wd(t,e)}const v0=t=>{const e=String(t);return"0000000".slice(e.length)+e};function y0(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 _M(){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 xM(){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 o0!="object"||o0.BUF_BIGINT_DISABLE!=="1")){const r=BigInt("-9223372036854775808"),c=BigInt("9223372036854775807"),l=BigInt("0"),u=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(f){const h=typeof f=="bigint"?f:BigInt(f);if(h>c||h<r)throw new Error("int64 invalid: ".concat(f));return h},uParse(f){const h=typeof f=="bigint"?f:BigInt(f);if(h>u||h<l)throw new Error("uint64 invalid: ".concat(f));return h},enc(f){return t.setBigInt64(0,this.parse(f),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(f){return t.setBigInt64(0,this.uParse(f),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec(f,h){return t.setInt32(0,f,!0),t.setInt32(4,h,!0),t.getBigInt64(0,!0)},uDec(f,h){return t.setInt32(0,f,!0),t.setInt32(4,h,!0),t.getBigUint64(0,!0)}}}const n=r=>st(/^-?[0-9]+$/.test(r),"int64 invalid: ".concat(r)),a=r=>st(/^[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()),a(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),n(r),m0(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),a(r),m0(r)},dec(r,c){return wM(r,c)},uDec(r,c){return p0(r,c)}}}const et=xM();var te;(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"})(te||(te={}));var zi;(function(t){t[t.BIGINT=0]="BIGINT",t[t.STRING=1]="STRING"})(zi||(zi={}));function Fi(t,e,n){if(e===n)return!0;if(t==te.BYTES){if(!(e instanceof Uint8Array)||!(n instanceof Uint8Array)||e.length!==n.length)return!1;for(let a=0;a<e.length;a++)if(e[a]!==n[a])return!1;return!0}switch(t){case te.UINT64:case te.FIXED64:case te.INT64:case te.SFIXED64:case te.SINT64:return e==n}return!1}function Ss(t,e){switch(t){case te.BOOL:return!1;case te.UINT64:case te.FIXED64:case te.INT64:case te.SFIXED64:case te.SINT64:return e==0?et.zero:"0";case te.DOUBLE:case te.FLOAT:return 0;case te.BYTES:return new Uint8Array(0);case te.STRING:return"";default:return 0}}function b0(t,e){switch(t){case te.BOOL:return e===!1;case te.STRING:return e==="";case te.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}var ut;(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"})(ut||(ut={}));class AM{constructor(e){this.stack=[],this.textEncoder=e!=null?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),a=0;for(let r=0;r<this.chunks.length;r++)n.set(this.chunks[r],a),a+=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(Qd(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Cc(e),y0(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){l0(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){Qd(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){Cc(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return Cc(e),e=(e<<1^e>>31)>>>0,y0(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),a=new DataView(n.buffer),r=et.enc(e);return a.setInt32(0,r.lo,!0),a.setInt32(4,r.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),a=new DataView(n.buffer),r=et.uEnc(e);return a.setInt32(0,r.lo,!0),a.setInt32(4,r.hi,!0),this.raw(n)}int64(e){let n=et.enc(e);return Zd(n.lo,n.hi,this.buf),this}sint64(e){let n=et.enc(e),a=n.hi>>31,r=n.lo<<1^a,c=(n.hi<<1|n.lo>>>31)^a;return Zd(r,c,this.buf),this}uint64(e){let n=et.uEnc(e);return Zd(n.lo,n.hi,this.buf),this}}class MM{constructor(e,n){this.varint64=EM,this.uint32=_M,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=n!=null?n:new TextDecoder}tag(){let e=this.uint32(),n=e>>>3,a=e&7;if(n<=0||a<0||a>5)throw new Error("illegal tag: field no "+n+" wire type "+a);return[n,a]}skip(e,n){let a=this.pos;switch(e){case ut.Varint:for(;this.buf[this.pos++]&128;);break;case ut.Bit64:this.pos+=4;case ut.Bit32:this.pos+=4;break;case ut.LengthDelimited:let r=this.uint32();this.pos+=r;break;case ut.StartGroup:for(;;){const[c,l]=this.tag();if(l===ut.EndGroup){if(n!==void 0&&c!==n)throw new Error("invalid end group tag");break}this.skip(l,c)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(a,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 et.dec(...this.varint64())}uint64(){return et.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),a=-(e&1);return e=(e>>>1|(n&1)<<31)^a,n=n>>>1^a,et.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 et.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return et.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 DM(t,e,n,a){let r;return{typeName:e,extendee:n,get field(){if(!r){const c=typeof a=="function"?a():a;c.name=e.split(".").pop(),c.jsonName="[".concat(e,"]"),r=t.util.newFieldList([c]).list()[0]}return r},runtime:t}}function S0(t){const e=t.field.localName,n=Object.create(null);return n[e]=OM(t),[n,()=>n[e]]}function OM(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 Ss(e.T,e.L);case"message":const n=e.T,a=new n;return n.fieldWrapper?n.fieldWrapper.unwrapField(a):a;case"map":throw"map fields are not allowed to be extensions"}}function PM(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 ui="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Ec=[];for(let t=0;t<ui.length;t++)Ec[ui[t].charCodeAt(0)]=t;Ec[45]=ui.indexOf("+"),Ec[95]=ui.indexOf("/");const T0={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),a=0,r=0,c,l=0;for(let u=0;u<t.length;u++){if(c=Ec[t.charCodeAt(u)],c===void 0)switch(t[u]){case"=":r=0;case`
|
|
10
|
+
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(r){case 0:l=c,r=1;break;case 1:n[a++]=l<<2|(c&48)>>4,l=c,r=2;break;case 2:n[a++]=(l&15)<<4|(c&60)>>2,l=c,r=3;break;case 3:n[a++]=(l&3)<<6|c,r=0;break}}if(r==1)throw Error("invalid base64 string.");return n.subarray(0,a)},enc(t){let e="",n=0,a,r=0;for(let c=0;c<t.length;c++)switch(a=t[c],n){case 0:e+=ui[a>>2],r=(a&3)<<4,n=1;break;case 1:e+=ui[r|a>>4],r=(a&15)<<2,n=2;break;case 2:e+=ui[r|a>>6],e+=ui[a&63],n=0;break}return n&&(e+=ui[r],e+="=",n==1&&(e+="=")),e}};function NM(t,e,n){k0(e,t);const a=e.runtime.bin.makeReadOptions(n),r=PM(t.getType().runtime.bin.listUnknownFields(t),e.field),[c,l]=S0(e);for(const u of r)e.runtime.bin.readField(c,a.readerFactory(u.data),e.field,u.wireType,a);return l()}function LM(t,e,n,a){k0(e,t);const r=e.runtime.bin.makeReadOptions(a),c=e.runtime.bin.makeWriteOptions(a);if(C0(t,e)){const h=t.getType().runtime.bin.listUnknownFields(t).filter(p=>p.no!=e.field.no);t.getType().runtime.bin.discardUnknownFields(t);for(const p of h)t.getType().runtime.bin.onUnknownField(t,p.no,p.wireType,p.data)}const l=c.writerFactory();let u=e.field;!u.opt&&!u.repeated&&(u.kind=="enum"||u.kind=="scalar")&&(u=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(u,n,l,c);const f=r.readerFactory(l.finish());for(;f.pos<f.len;){const[h,p]=f.tag(),v=f.skip(p,h);t.getType().runtime.bin.onUnknownField(t,h,p,v)}}function C0(t,e){const n=t.getType();return e.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(t).find(a=>a.no==e.field.no)}function k0(t,e){st(t.extendee.typeName==e.getType().typeName,"extension ".concat(t.typeName," can only be applied to message ").concat(t.extendee.typeName))}function E0(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:!b0(t.T,e[n]);case"message":return e[n]!==void 0;case"map":return Object.keys(e[n]).length>0}}function w0(t,e){const n=t.localName,a=!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]=a?t.T.values[0].no:void 0;break;case"scalar":e[n]=a?Ss(t.T,t.L):void 0;break;case"message":e[n]=void 0;break}}function di(t,e){if(t===null||typeof t!="object"||!Object.getOwnPropertyNames(Jd.prototype).every(a=>a in t&&typeof t[a]=="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 R0(t,e){return di(e)||!t.fieldWrapper?e:t.fieldWrapper.wrapField(e)}te.DOUBLE,te.FLOAT,te.INT64,te.UINT64,te.INT32,te.UINT32,te.BOOL,te.STRING,te.BYTES;const _0={ignoreUnknownFields:!1},x0={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function IM(t){return t?Object.assign(Object.assign({},_0),t):_0}function UM(t){return t?Object.assign(Object.assign({},x0),t):x0}const wc=Symbol(),Rc=Symbol();function BM(){return{makeReadOptions:IM,makeWriteOptions:UM,readMessage(t,e,n,a){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error("cannot decode message ".concat(t.typeName," from JSON: ").concat(Qn(e)));a=a!=null?a:new t;const r=new Map,c=n.typeRegistry;for(const[l,u]of Object.entries(e)){const f=t.fields.findJsonName(l);if(f){if(f.oneof){if(u===null&&f.kind=="scalar")continue;const h=r.get(f.oneof);if(h!==void 0)throw new Error("cannot decode message ".concat(t.typeName,' from JSON: multiple keys for oneof "').concat(f.oneof.name,'" present: "').concat(h,'", "').concat(l,'"'));r.set(f.oneof,l)}A0(a,u,f,n,t)}else{let h=!1;if(c!=null&&c.findExtension&&l.startsWith("[")&&l.endsWith("]")){const p=c.findExtension(l.substring(1,l.length-1));if(p&&p.extendee.typeName==t.typeName){h=!0;const[v,y]=S0(p);A0(v,u,p.field,n,p),LM(a,p,y(),n)}}if(!h&&!n.ignoreUnknownFields)throw new Error("cannot decode message ".concat(t.typeName,' from JSON: key "').concat(l,'" is unknown'))}}return a},writeMessage(t,e){const n=t.getType(),a={};let r;try{for(r of n.fields.byNumber()){if(!E0(r,t)){if(r.req)throw"required field not set";if(!e.emitDefaultValues||!VM(r))continue}const l=r.oneof?t[r.oneof.localName].value:t[r.localName],u=M0(r,l,e);u!==void 0&&(a[e.useProtoFieldName?r.name:r.jsonName]=u)}const c=e.typeRegistry;if(c!=null&&c.findExtensionFor)for(const l of n.runtime.bin.listUnknownFields(t)){const u=c.findExtensionFor(n.typeName,l.no);if(u&&C0(t,u)){const f=NM(t,u,e),h=M0(u.field,f,e);h!==void 0&&(a[u.field.jsonName]=h)}}}catch(c){const l=r?"cannot encode field ".concat(n.typeName,".").concat(r.name," to JSON"):"cannot encode message ".concat(n.typeName," to JSON"),u=c instanceof Error?c.message:String(c);throw new Error(l+(u.length>0?": ".concat(u):""))}return a},readScalar(t,e,n){return qr(t,e,n!=null?n:zi.BIGINT,!0)},writeScalar(t,e,n){if(e!==void 0&&(n||b0(t,e)))return _c(t,e)},debug:Qn}}function Qn(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 A0(t,e,n,a,r){let c=n.localName;if(n.repeated){if(st(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(Qn(e)));const l=t[c];for(const u of e){if(u===null)throw new Error("cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(Qn(u)));switch(n.kind){case"message":l.push(n.T.fromJson(u,a));break;case"enum":const f=$d(n.T,u,a.ignoreUnknownFields,!0);f!==Rc&&l.push(f);break;case"scalar":try{l.push(qr(n.T,u,n.L,!0))}catch(h){let p="cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(Qn(u));throw h instanceof Error&&h.message.length>0&&(p+=": ".concat(h.message)),new Error(p)}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(Qn(e)));const l=t[c];for(const[u,f]of Object.entries(e)){if(f===null)throw new Error("cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: map value null"));let h;try{h=jM(n.K,u)}catch(p){let v="cannot decode map key for field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(Qn(e));throw p instanceof Error&&p.message.length>0&&(v+=": ".concat(p.message)),new Error(v)}switch(n.V.kind){case"message":l[h]=n.V.T.fromJson(f,a);break;case"enum":const p=$d(n.V.T,f,a.ignoreUnknownFields,!0);p!==Rc&&(l[h]=p);break;case"scalar":try{l[h]=qr(n.V.T,f,zi.BIGINT,!0)}catch(v){let y="cannot decode map value for field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(Qn(e));throw v instanceof Error&&v.message.length>0&&(y+=": ".concat(v.message)),new Error(y)}break}}}else switch(n.oneof&&(t=t[n.oneof.localName]={case:c},c="value"),n.kind){case"message":const l=n.T;if(e===null&&l.typeName!="google.protobuf.Value")return;let u=t[c];di(u)?u.fromJson(e,a):(t[c]=u=l.fromJson(e,a),l.fieldWrapper&&!n.oneof&&(t[c]=l.fieldWrapper.unwrapField(u)));break;case"enum":const f=$d(n.T,e,a.ignoreUnknownFields,!1);switch(f){case wc:w0(n,t);break;case Rc:break;default:t[c]=f;break}break;case"scalar":try{const h=qr(n.T,e,n.L,!1);h===wc?w0(n,t):t[c]=h}catch(h){let p="cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(Qn(e));throw h instanceof Error&&h.message.length>0&&(p+=": ".concat(h.message)),new Error(p)}break}}function jM(t,e){if(t===te.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return qr(t,e,zi.BIGINT,!0).toString()}function qr(t,e,n,a){if(e===null)return a?Ss(t,n):wc;switch(t){case te.DOUBLE:case te.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==te.FLOAT&&l0(r),r;case te.INT32:case te.FIXED32:case te.SFIXED32:case te.SINT32:case te.UINT32:let c;if(typeof e=="number"?c=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(c=Number(e)),c===void 0)break;return t==te.UINT32||t==te.FIXED32?Qd(c):Cc(c),c;case te.INT64:case te.SFIXED64:case te.SINT64:if(typeof e!="number"&&typeof e!="string")break;const l=et.parse(e);return n?l.toString():l;case te.FIXED64:case te.UINT64:if(typeof e!="number"&&typeof e!="string")break;const u=et.uParse(e);return n?u.toString():u;case te.BOOL:if(typeof e!="boolean")break;return e;case te.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case te.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return T0.dec(e)}throw new Error}function $d(t,e,n,a){if(e===null)return t.typeName=="google.protobuf.NullValue"?0:a?t.values[0].no:wc;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 Rc;break}throw new Error("cannot decode enum ".concat(t.typeName," from JSON: ").concat(Qn(e)))}function VM(t){return t.repeated||t.kind=="map"?!0:!(t.oneof||t.kind=="message"||t.opt||t.req)}function M0(t,e,n){if(t.kind=="map"){st(typeof e=="object"&&e!=null);const a={},r=Object.entries(e);switch(t.V.kind){case"scalar":for(const[l,u]of r)a[l.toString()]=_c(t.V.T,u);break;case"message":for(const[l,u]of r)a[l.toString()]=u.toJson(n);break;case"enum":const c=t.V.T;for(const[l,u]of r)a[l.toString()]=ef(c,u,n.enumAsInteger);break}return n.emitDefaultValues||r.length>0?a:void 0}if(t.repeated){st(Array.isArray(e));const a=[];switch(t.kind){case"scalar":for(let r=0;r<e.length;r++)a.push(_c(t.T,e[r]));break;case"enum":for(let r=0;r<e.length;r++)a.push(ef(t.T,e[r],n.enumAsInteger));break;case"message":for(let r=0;r<e.length;r++)a.push(e[r].toJson(n));break}return n.emitDefaultValues||a.length>0?a:void 0}switch(t.kind){case"scalar":return _c(t.T,e);case"enum":return ef(t.T,e,n.enumAsInteger);case"message":return R0(t.T,e).toJson(n)}}function ef(t,e,n){var a;if(st(typeof e=="number"),t.typeName=="google.protobuf.NullValue")return null;if(n)return e;const r=t.findNumber(e);return(a=r==null?void 0:r.name)!==null&&a!==void 0?a:e}function _c(t,e){switch(t){case te.INT32:case te.SFIXED32:case te.SINT32:case te.FIXED32:case te.UINT32:return st(typeof e=="number"),e;case te.FLOAT:case te.DOUBLE:return st(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case te.STRING:return st(typeof e=="string"),e;case te.BOOL:return st(typeof e=="boolean"),e;case te.UINT64:case te.FIXED64:case te.INT64:case te.SFIXED64:case te.SINT64:return st(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case te.BYTES:return st(e instanceof Uint8Array),T0.enc(e)}}const Ts=Symbol("@bufbuild/protobuf/unknown-fields"),D0={readUnknownFields:!0,readerFactory:t=>new MM(t)},O0={writeUnknownFields:!0,writerFactory:()=>new AM};function zM(t){return t?Object.assign(Object.assign({},D0),t):D0}function FM(t){return t?Object.assign(Object.assign({},O0),t):O0}function qM(){return{makeReadOptions:zM,makeWriteOptions:FM,listUnknownFields(t){var e;return(e=t[Ts])!==null&&e!==void 0?e:[]},discardUnknownFields(t){delete t[Ts]},writeUnknownFields(t,e){const a=t[Ts];if(a)for(const r of a)e.tag(r.no,r.wireType).raw(r.data)},onUnknownField(t,e,n,a){const r=t;Array.isArray(r[Ts])||(r[Ts]=[]),r[Ts].push({no:e,wireType:n,data:a})},readMessage(t,e,n,a,r){const c=t.getType(),l=r?e.len:e.pos+n;let u,f;for(;e.pos<l&&([u,f]=e.tag(),!(r===!0&&f==ut.EndGroup));){const h=c.fields.find(u);if(!h){const p=e.skip(f,u);a.readUnknownFields&&this.onUnknownField(t,u,f,p);continue}P0(t,e,h,f,a)}if(r&&(f!=ut.EndGroup||u!==n))throw new Error("invalid end group tag")},readField:P0,writeMessage(t,e,n){const a=t.getType();for(const r of a.fields.byNumber()){if(!E0(r,t)){if(r.req)throw new Error("cannot encode field ".concat(a.typeName,".").concat(r.name," to binary: required field not set"));continue}const c=r.oneof?t[r.oneof.localName].value:t[r.localName];N0(r,c,e,n)}return n.writeUnknownFields&&this.writeUnknownFields(t,e),e},writeField(t,e,n,a){e!==void 0&&N0(t,e,n,a)}}}function P0(t,e,n,a,r){let{repeated:c,localName:l}=n;switch(n.oneof&&(t=t[n.oneof.localName],t.case!=l&&delete t.value,t.case=l,l="value"),n.kind){case"scalar":case"enum":const u=n.kind=="enum"?te.INT32:n.T;let f=Ac;if(n.kind=="scalar"&&n.L>0&&(f=GM),c){let y=t[l];if(a==ut.LengthDelimited&&u!=te.STRING&&u!=te.BYTES){let w=e.uint32()+e.pos;for(;e.pos<w;)y.push(f(e,u))}else y.push(f(e,u))}else t[l]=f(e,u);break;case"message":const h=n.T;c?t[l].push(xc(e,new h,r,n)):di(t[l])?xc(e,t[l],r,n):(t[l]=xc(e,new h,r,n),h.fieldWrapper&&!n.oneof&&!n.repeated&&(t[l]=h.fieldWrapper.unwrapField(t[l])));break;case"map":let[p,v]=HM(n,e,r);t[l][p]=v;break}}function xc(t,e,n,a){const r=e.getType().runtime.bin,c=a==null?void 0:a.delimited;return r.readMessage(e,t,c?a.no:t.uint32(),n,c),e}function HM(t,e,n){const a=e.uint32(),r=e.pos+a;let c,l;for(;e.pos<r;){const[u]=e.tag();switch(u){case 1:c=Ac(e,t.K);break;case 2:switch(t.V.kind){case"scalar":l=Ac(e,t.V.T);break;case"enum":l=e.int32();break;case"message":l=xc(e,new t.V.T,n,void 0);break}break}}if(c===void 0&&(c=Ss(t.K,zi.BIGINT)),typeof c!="string"&&typeof c!="number"&&(c=c.toString()),l===void 0)switch(t.V.kind){case"scalar":l=Ss(t.V.T,zi.BIGINT);break;case"enum":l=t.V.T.values[0].no;break;case"message":l=new t.V.T;break}return[c,l]}function GM(t,e){const n=Ac(t,e);return typeof n=="bigint"?n.toString():n}function Ac(t,e){switch(e){case te.STRING:return t.string();case te.BOOL:return t.bool();case te.DOUBLE:return t.double();case te.FLOAT:return t.float();case te.INT32:return t.int32();case te.INT64:return t.int64();case te.UINT64:return t.uint64();case te.FIXED64:return t.fixed64();case te.BYTES:return t.bytes();case te.FIXED32:return t.fixed32();case te.SFIXED32:return t.sfixed32();case te.SFIXED64:return t.sfixed64();case te.SINT64:return t.sint64();case te.UINT32:return t.uint32();case te.SINT32:return t.sint32()}}function N0(t,e,n,a){st(e!==void 0);const r=t.repeated;switch(t.kind){case"scalar":case"enum":let c=t.kind=="enum"?te.INT32:t.T;if(r)if(st(Array.isArray(e)),t.packed)YM(n,c,t.no,e);else for(const l of e)Hr(n,c,t.no,l);else Hr(n,c,t.no,e);break;case"message":if(r){st(Array.isArray(e));for(const l of e)L0(n,a,t,l)}else L0(n,a,t,e);break;case"map":st(typeof e=="object"&&e!=null);for(const[l,u]of Object.entries(e))KM(n,a,t,l,u);break}}function KM(t,e,n,a,r){t.tag(n.no,ut.LengthDelimited),t.fork();let c=a;switch(n.K){case te.INT32:case te.FIXED32:case te.UINT32:case te.SFIXED32:case te.SINT32:c=Number.parseInt(a);break;case te.BOOL:st(a=="true"||a=="false"),c=a=="true";break}switch(Hr(t,n.K,1,c),n.V.kind){case"scalar":Hr(t,n.V.T,2,r);break;case"enum":Hr(t,te.INT32,2,r);break;case"message":st(r!==void 0),t.tag(2,ut.LengthDelimited).bytes(r.toBinary(e));break}t.join()}function L0(t,e,n,a){const r=R0(n.T,a);n.delimited?t.tag(n.no,ut.StartGroup).raw(r.toBinary(e)).tag(n.no,ut.EndGroup):t.tag(n.no,ut.LengthDelimited).bytes(r.toBinary(e))}function Hr(t,e,n,a){st(a!==void 0);let[r,c]=I0(e);t.tag(n,r)[c](a)}function YM(t,e,n,a){if(!a.length)return;t.tag(n,ut.LengthDelimited).fork();let[,r]=I0(e);for(let c=0;c<a.length;c++)t[r](a[c]);t.join()}function I0(t){let e=ut.Varint;switch(t){case te.BYTES:case te.STRING:e=ut.LengthDelimited;break;case te.DOUBLE:case te.FIXED64:case te.SFIXED64:e=ut.Bit64;break;case te.FIXED32:case te.SFIXED32:case te.FLOAT:e=ut.Bit32;break}const n=te[t].toLowerCase();return[e,n]}function XM(){return{setEnumType:d0,initPartial(t,e){if(t===void 0)return;const n=e.getType();for(const a of n.fields.byMember()){const r=a.localName,c=e,l=t;if(l[r]!=null)switch(a.kind){case"oneof":const u=l[r].case;if(u===void 0)continue;const f=a.findField(u);let h=l[r].value;f&&f.kind=="message"&&!di(h,f.T)?h=new f.T(h):f&&f.kind==="scalar"&&f.T===te.BYTES&&(h=Gr(h)),c[r]={case:u,value:h};break;case"scalar":case"enum":let p=l[r];a.T===te.BYTES&&(p=a.repeated?p.map(Gr):Gr(p)),c[r]=p;break;case"map":switch(a.V.kind){case"scalar":case"enum":if(a.V.T===te.BYTES)for(const[S,w]of Object.entries(l[r]))c[r][S]=Gr(w);else Object.assign(c[r],l[r]);break;case"message":const y=a.V.T;for(const S of Object.keys(l[r])){let w=l[r][S];y.fieldWrapper||(w=new y(w)),c[r][S]=w}break}break;case"message":const v=a.T;if(a.repeated)c[r]=l[r].map(y=>di(y,v)?y:new v(y));else{const y=l[r];v.fieldWrapper?v.typeName==="google.protobuf.BytesValue"?c[r]=Gr(y):c[r]=y:c[r]=di(y,v)?y:new v(y)}break}}},equals(t,e,n){return e===n?!0:!e||!n?!1:t.fields.byMember().every(a=>{const r=e[a.localName],c=n[a.localName];if(a.repeated){if(r.length!==c.length)return!1;switch(a.kind){case"message":return r.every((l,u)=>a.T.equals(l,c[u]));case"scalar":return r.every((l,u)=>Fi(a.T,l,c[u]));case"enum":return r.every((l,u)=>Fi(te.INT32,l,c[u]))}throw new Error("repeated cannot contain ".concat(a.kind))}switch(a.kind){case"message":let l=r,u=c;return a.T.fieldWrapper&&(l!==void 0&&!di(l)&&(l=a.T.fieldWrapper.wrapField(l)),u!==void 0&&!di(u)&&(u=a.T.fieldWrapper.wrapField(u))),a.T.equals(l,u);case"enum":return Fi(te.INT32,r,c);case"scalar":return Fi(a.T,r,c);case"oneof":if(r.case!==c.case)return!1;const f=a.findField(r.case);if(f===void 0)return!0;switch(f.kind){case"message":return f.T.equals(r.value,c.value);case"enum":return Fi(te.INT32,r.value,c.value);case"scalar":return Fi(f.T,r.value,c.value)}throw new Error("oneof cannot contain ".concat(f.kind));case"map":const h=Object.keys(r).concat(Object.keys(c));switch(a.V.kind){case"message":const p=a.V.T;return h.every(y=>p.equals(r[y],c[y]));case"enum":return h.every(y=>Fi(te.INT32,r[y],c[y]));case"scalar":const v=a.V.T;return h.every(y=>Fi(v,r[y],c[y]))}break}})},clone(t){const e=t.getType(),n=new e,a=n;for(const r of e.fields.byMember()){const c=t[r.localName];let l;if(r.repeated)l=c.map(Mc);else if(r.kind=="map"){l=a[r.localName];for(const[u,f]of Object.entries(c))l[u]=Mc(f)}else r.kind=="oneof"?l=r.findField(c.case)?{case:c.case,value:Mc(c.value)}:{case:void 0}:l=Mc(c);a[r.localName]=l}for(const r of e.runtime.bin.listUnknownFields(t))e.runtime.bin.onUnknownField(a,r.no,r.wireType,r.data);return n}}}function Mc(t){if(t===void 0)return t;if(di(t))return t.clone();if(t instanceof Uint8Array){const e=new Uint8Array(t.byteLength);return e.set(t),e}return t}function Gr(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function QM(t,e,n){return{syntax:t,json:BM(),bin:qM(),util:Object.assign(Object.assign({},XM()),{newFieldList:e,initFields:n}),makeMessageType(a,r,c){return kM(this,a,r,c)},makeEnum:CM,makeEnumType:f0,getEnumType:TM,makeExtension(a,r,c){return DM(this,a,r,c)}}}class JM{constructor(e,n){this._fields=e,this._normalizer=n}findJsonName(e){if(!this.jsonNames){const n={};for(const a of this.list())n[a.jsonName]=n[a.name]=a;this.jsonNames=n}return this.jsonNames[e]}find(e){if(!this.numbers){const n={};for(const a of this.list())n[a.no]=a;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 a of this.list())a.oneof?a.oneof!==n&&(n=a.oneof,e.push(n)):e.push(a)}return this.members}}function U0(t,e){const n=B0(t);return e?n:nD(tD(n))}function ZM(t){return U0(t,!1)}const WM=B0;function B0(t){let e=!1;const n=[];for(let a=0;a<t.length;a++){let r=t.charAt(a);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 $M=new Set(["constructor","toString","toJSON","valueOf"]),eD=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),j0=t=>"".concat(t,"$"),tD=t=>eD.has(t)?j0(t):t,nD=t=>$M.has(t)?j0(t):t;class iD{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=ZM(e)}addField(e){st(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 aD(t,e){var n,a,r,c,l,u;const f=[];let h;for(const p of typeof t=="function"?t():t){const v=p;if(v.localName=U0(p.name,p.oneof!==void 0),v.jsonName=(n=p.jsonName)!==null&&n!==void 0?n:WM(p.name),v.repeated=(a=p.repeated)!==null&&a!==void 0?a:!1,p.kind=="scalar"&&(v.L=(r=p.L)!==null&&r!==void 0?r:zi.BIGINT),v.delimited=(c=p.delimited)!==null&&c!==void 0?c:!1,v.req=(l=p.req)!==null&&l!==void 0?l:!1,v.opt=(u=p.opt)!==null&&u!==void 0?u:!1,p.packed===void 0&&(v.packed=p.kind=="enum"||p.kind=="scalar"&&p.T!=te.BYTES&&p.T!=te.STRING),p.oneof!==void 0){const y=typeof p.oneof=="string"?p.oneof:p.oneof.name;(!h||h.name!=y)&&(h=new iD(y)),v.oneof=h,h.addField(v)}f.push(v)}return f}const j=QM("proto3",t=>new JM(t,e=>aD(e)),t=>{for(const e of t.getType().fields.byMember()){if(e.opt)continue;const n=e.localName,a=t;if(e.repeated){a[n]=[];continue}switch(e.kind){case"oneof":a[n]={case:void 0};break;case"enum":a[n]=0;break;case"map":a[n]={};break;case"scalar":a[n]=Ss(e.T,e.L);break}}});class Kt extends Jd{constructor(e){super(),this.seconds=et.zero,this.nanos=0,j.util.initPartial(e,this)}fromJson(e,n){if(typeof e!="string")throw new Error("cannot decode google.protobuf.Timestamp from JSON: ".concat(j.json.debug(e)));const a=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(!a)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const r=Date.parse(a[1]+"-"+a[2]+"-"+a[3]+"T"+a[4]+":"+a[5]+":"+a[6]+(a[8]?a[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=et.parse(r/1e3),this.nanos=0,a[7]&&(this.nanos=parseInt("1"+a[7]+"0".repeat(9-a[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 a="Z";if(this.nanos>0){const r=(this.nanos+1e9).toString().substring(1);r.substring(3)==="000000"?a="."+r.substring(0,3)+"Z":r.substring(6)==="000"?a="."+r.substring(0,6)+"Z":a="."+r+"Z"}return new Date(n).toISOString().replace(".000Z",a)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Kt.fromDate(new Date)}static fromDate(e){const n=e.getTime();return new Kt({seconds:et.parse(Math.floor(n/1e3)),nanos:n%1e3*1e6})}static fromBinary(e,n){return new Kt().fromBinary(e,n)}static fromJson(e,n){return new Kt().fromJson(e,n)}static fromJsonString(e,n){return new Kt().fromJsonString(e,n)}static equals(e,n){return j.util.equals(Kt,e,n)}}Kt.runtime=j,Kt.typeName="google.protobuf.Timestamp",Kt.fields=j.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);const sD=j.makeMessageType("livekit.MetricsBatch",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:Kt},{no:3,name:"str_data",kind:"scalar",T:9,repeated:!0},{no:4,name:"time_series",kind:"message",T:rD,repeated:!0},{no:5,name:"events",kind:"message",T:cD,repeated:!0}]),rD=j.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:oD,repeated:!0},{no:5,name:"rid",kind:"scalar",T:13}]),oD=j.makeMessageType("livekit.MetricSample",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:Kt},{no:3,name:"value",kind:"scalar",T:2}]),cD=j.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:Kt},{no:7,name:"normalized_end_timestamp",kind:"message",T:Kt,opt:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"rid",kind:"scalar",T:13}]),V0=j.makeEnum("livekit.BackupCodecPolicy",[{no:0,name:"PREFER_REGRESSION"},{no:1,name:"SIMULCAST"},{no:2,name:"REGRESSION"}]),In=j.makeEnum("livekit.TrackType",[{no:0,name:"AUDIO"},{no:1,name:"VIDEO"},{no:2,name:"DATA"}]),pt=j.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"}]),tf=j.makeEnum("livekit.VideoQuality",[{no:0,name:"LOW"},{no:1,name:"MEDIUM"},{no:2,name:"HIGH"},{no:3,name:"OFF"}]),Kr=j.makeEnum("livekit.ConnectionQuality",[{no:0,name:"POOR"},{no:1,name:"GOOD"},{no:2,name:"EXCELLENT"},{no:3,name:"LOST"}]),Yr=j.makeEnum("livekit.ClientConfigSetting",[{no:0,name:"UNSET"},{no:1,name:"DISABLED"},{no:2,name:"ENABLED"}]),Un=j.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"}]),Ia=j.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"}]),lD=j.makeEnum("livekit.SubscriptionError",[{no:0,name:"SE_UNKNOWN"},{no:1,name:"SE_CODEC_UNSUPPORTED"},{no:2,name:"SE_TRACK_NOTFOUND"}]),wt=j.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"}]),Dc=j.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:Oc,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:eb}]),Oc=j.makeMessageType("livekit.Codec",()=>[{no:1,name:"mime",kind:"scalar",T:9},{no:2,name:"fmtp_line",kind:"scalar",T:9}]),uD=j.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:j.getEnumType(pt),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}]),Ua=j.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:j.getEnumType(Cs)},{no:4,name:"tracks",kind:"message",T:ks,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:uD},{no:12,name:"region",kind:"scalar",T:9},{no:13,name:"is_publisher",kind:"scalar",T:8},{no:14,name:"kind",kind:"enum",T:j.getEnumType(Ba)},{no:15,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:16,name:"disconnect_reason",kind:"enum",T:j.getEnumType(Un)},{no:18,name:"kind_details",kind:"enum",T:j.getEnumType(dD),repeated:!0}]),Cs=j.makeEnum("livekit.ParticipantInfo.State",[{no:0,name:"JOINING"},{no:1,name:"JOINED"},{no:2,name:"ACTIVE"},{no:3,name:"DISCONNECTED"}]),Ba=j.makeEnum("livekit.ParticipantInfo.Kind",[{no:0,name:"STANDARD"},{no:1,name:"INGRESS"},{no:2,name:"EGRESS"},{no:3,name:"SIP"},{no:4,name:"AGENT"},{no:7,name:"CONNECTOR"}]),dD=j.makeEnum("livekit.ParticipantInfo.KindDetail",[{no:0,name:"CLOUD_AGENT"},{no:1,name:"FORWARDED"}]),Ct=j.makeEnum("livekit.Encryption.Type",[{no:0,name:"NONE"},{no:1,name:"GCM"},{no:2,name:"CUSTOM"}]),fD=j.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:qi,repeated:!0},{no:5,name:"video_layer_mode",kind:"enum",T:j.getEnumType(z0)},{no:6,name:"sdp_cid",kind:"scalar",T:9}]),ks=j.makeMessageType("livekit.TrackInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"type",kind:"enum",T:j.getEnumType(In)},{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:j.getEnumType(pt)},{no:10,name:"layers",kind:"message",T:qi,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:fD,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:j.getEnumType(Ct)},{no:17,name:"stream",kind:"scalar",T:9},{no:18,name:"version",kind:"message",T:eb},{no:19,name:"audio_features",kind:"enum",T:j.getEnumType(wt),repeated:!0},{no:20,name:"backup_codec_policy",kind:"enum",T:j.getEnumType(V0)}]),qi=j.makeMessageType("livekit.VideoLayer",()=>[{no:1,name:"quality",kind:"enum",T:j.getEnumType(tf)},{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},{no:6,name:"spatial_layer",kind:"scalar",T:5},{no:7,name:"rid",kind:"scalar",T:9}]),z0=j.makeEnum("livekit.VideoLayer.Mode",[{no:0,name:"MODE_UNUSED"},{no:1,name:"ONE_SPATIAL_LAYER_PER_STREAM"},{no:2,name:"MULTIPLE_SPATIAL_LAYERS_PER_STREAM"},{no:3,name:"ONE_SPATIAL_LAYER_PER_STREAM_INCOMPLETE_RTCP_SR"}]),Ft=j.makeMessageType("livekit.DataPacket",()=>[{no:1,name:"kind",kind:"enum",T:j.getEnumType(_e)},{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:nf,oneof:"value"},{no:3,name:"speaker",kind:"message",T:hD,oneof:"value"},{no:6,name:"sip_dtmf",kind:"message",T:G0,oneof:"value"},{no:7,name:"transcription",kind:"message",T:mD,oneof:"value"},{no:8,name:"metrics",kind:"message",T:sD,oneof:"value"},{no:9,name:"chat_message",kind:"message",T:Pc,oneof:"value"},{no:10,name:"rpc_request",kind:"message",T:af,oneof:"value"},{no:11,name:"rpc_ack",kind:"message",T:sf,oneof:"value"},{no:12,name:"rpc_response",kind:"message",T:rf,oneof:"value"},{no:13,name:"stream_header",kind:"message",T:Nc,oneof:"value"},{no:14,name:"stream_chunk",kind:"message",T:Lc,oneof:"value"},{no:15,name:"stream_trailer",kind:"message",T:Ic,oneof:"value"},{no:18,name:"encrypted_packet",kind:"message",T:F0,oneof:"value"},{no:16,name:"sequence",kind:"scalar",T:13},{no:17,name:"participant_sid",kind:"scalar",T:9}]),_e=j.makeEnum("livekit.DataPacket.Kind",[{no:0,name:"RELIABLE"},{no:1,name:"LOSSY"}]),F0=j.makeMessageType("livekit.EncryptedPacket",()=>[{no:1,name:"encryption_type",kind:"enum",T:j.getEnumType(Ct)},{no:2,name:"iv",kind:"scalar",T:12},{no:3,name:"key_index",kind:"scalar",T:13},{no:4,name:"encrypted_value",kind:"scalar",T:12}]),q0=j.makeMessageType("livekit.EncryptedPacketPayload",()=>[{no:1,name:"user",kind:"message",T:nf,oneof:"value"},{no:3,name:"chat_message",kind:"message",T:Pc,oneof:"value"},{no:4,name:"rpc_request",kind:"message",T:af,oneof:"value"},{no:5,name:"rpc_ack",kind:"message",T:sf,oneof:"value"},{no:6,name:"rpc_response",kind:"message",T:rf,oneof:"value"},{no:7,name:"stream_header",kind:"message",T:Nc,oneof:"value"},{no:8,name:"stream_chunk",kind:"message",T:Lc,oneof:"value"},{no:9,name:"stream_trailer",kind:"message",T:Ic,oneof:"value"}]),hD=j.makeMessageType("livekit.ActiveSpeakerUpdate",()=>[{no:1,name:"speakers",kind:"message",T:H0,repeated:!0}]),H0=j.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}]),nf=j.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}]),G0=j.makeMessageType("livekit.SipDTMF",()=>[{no:3,name:"code",kind:"scalar",T:13},{no:4,name:"digit",kind:"scalar",T:9}]),mD=j.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:pD,repeated:!0}]),pD=j.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}]),Pc=j.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}]),af=j.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}]),sf=j.makeMessageType("livekit.RpcAck",()=>[{no:1,name:"request_id",kind:"scalar",T:9}]),rf=j.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:K0,oneof:"value"}]),K0=j.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}]),Y0=j.makeMessageType("livekit.ParticipantTracks",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sids",kind:"scalar",T:9,repeated:!0}]),X0=j.makeMessageType("livekit.ServerInfo",()=>[{no:1,name:"edition",kind:"enum",T:j.getEnumType(Q0)},{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}]),Q0=j.makeEnum("livekit.ServerInfo.Edition",[{no:0,name:"Standard"},{no:1,name:"Cloud"}]),J0=j.makeMessageType("livekit.ClientInfo",()=>[{no:1,name:"sdk",kind:"enum",T:j.getEnumType(Z0)},{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}]),Z0=j.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"},{no:14,name:"ESP32"}]),W0=j.makeMessageType("livekit.ClientConfiguration",()=>[{no:1,name:"video",kind:"message",T:$0},{no:2,name:"screen",kind:"message",T:$0},{no:3,name:"resume_connection",kind:"enum",T:j.getEnumType(Yr)},{no:4,name:"disabled_codecs",kind:"message",T:gD},{no:5,name:"force_relay",kind:"enum",T:j.getEnumType(Yr)}]),$0=j.makeMessageType("livekit.VideoConfiguration",()=>[{no:1,name:"hardware_encoder",kind:"enum",T:j.getEnumType(Yr)}]),gD=j.makeMessageType("livekit.DisabledCodecs",()=>[{no:1,name:"codecs",kind:"message",T:Oc,repeated:!0},{no:2,name:"publish",kind:"message",T:Oc,repeated:!0}]),eb=j.makeMessageType("livekit.TimedVersion",()=>[{no:1,name:"unix_micro",kind:"scalar",T:3},{no:2,name:"ticks",kind:"scalar",T:5}]),of=j.makeEnum("livekit.DataStream.OperationType",[{no:0,name:"CREATE"},{no:1,name:"UPDATE"},{no:2,name:"DELETE"},{no:3,name:"REACTION"}]),tb=j.makeMessageType("livekit.DataStream.TextHeader",()=>[{no:1,name:"operation_type",kind:"enum",T:j.getEnumType(of)},{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"}),nb=j.makeMessageType("livekit.DataStream.ByteHeader",()=>[{no:1,name:"name",kind:"scalar",T:9}],{localName:"DataStream_ByteHeader"}),Nc=j.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:j.getEnumType(Ct)},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:9,name:"text_header",kind:"message",T:tb,oneof:"content_header"},{no:10,name:"byte_header",kind:"message",T:nb,oneof:"content_header"}],{localName:"DataStream_Header"}),Lc=j.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"}),Ic=j.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"}),vD=j.makeMessageType("livekit.SubscribedAudioCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"enabled",kind:"scalar",T:8}]),Bn=j.makeEnum("livekit.SignalTarget",[{no:0,name:"PUBLISHER"},{no:1,name:"SUBSCRIBER"}]),cf=j.makeEnum("livekit.StreamState",[{no:0,name:"ACTIVE"},{no:1,name:"PAUSED"}]),yD=j.makeEnum("livekit.CandidateProtocol",[{no:0,name:"UDP"},{no:1,name:"TCP"},{no:2,name:"TLS"}]),bD=j.makeMessageType("livekit.SignalRequest",()=>[{no:1,name:"offer",kind:"message",T:Hi,oneof:"message"},{no:2,name:"answer",kind:"message",T:Hi,oneof:"message"},{no:3,name:"trickle",kind:"message",T:Uc,oneof:"message"},{no:4,name:"add_track",kind:"message",T:Xr,oneof:"message"},{no:5,name:"mute",kind:"message",T:Bc,oneof:"message"},{no:6,name:"subscription",kind:"message",T:jc,oneof:"message"},{no:7,name:"track_setting",kind:"message",T:ab,oneof:"message"},{no:8,name:"leave",kind:"message",T:Vc,oneof:"message"},{no:10,name:"update_layers",kind:"message",T:rb,oneof:"message"},{no:11,name:"subscription_permission",kind:"message",T:lb,oneof:"message"},{no:12,name:"sync_state",kind:"message",T:mf,oneof:"message"},{no:13,name:"simulate",kind:"message",T:Jn,oneof:"message"},{no:14,name:"ping",kind:"scalar",T:3,oneof:"message"},{no:15,name:"update_metadata",kind:"message",T:ff,oneof:"message"},{no:16,name:"ping_req",kind:"message",T:fb,oneof:"message"},{no:17,name:"update_audio_track",kind:"message",T:df,oneof:"message"},{no:18,name:"update_video_track",kind:"message",T:sb,oneof:"message"}]),ib=j.makeMessageType("livekit.SignalResponse",()=>[{no:1,name:"join",kind:"message",T:SD,oneof:"message"},{no:2,name:"answer",kind:"message",T:Hi,oneof:"message"},{no:3,name:"offer",kind:"message",T:Hi,oneof:"message"},{no:4,name:"trickle",kind:"message",T:Uc,oneof:"message"},{no:5,name:"update",kind:"message",T:kD,oneof:"message"},{no:6,name:"track_published",kind:"message",T:uf,oneof:"message"},{no:8,name:"leave",kind:"message",T:Vc,oneof:"message"},{no:9,name:"mute",kind:"message",T:Bc,oneof:"message"},{no:10,name:"speakers_changed",kind:"message",T:ED,oneof:"message"},{no:11,name:"room_update",kind:"message",T:wD,oneof:"message"},{no:12,name:"connection_quality",kind:"message",T:_D,oneof:"message"},{no:13,name:"stream_state_update",kind:"message",T:AD,oneof:"message"},{no:14,name:"subscribed_quality_update",kind:"message",T:DD,oneof:"message"},{no:15,name:"subscription_permission_update",kind:"message",T:PD,oneof:"message"},{no:16,name:"refresh_token",kind:"scalar",T:9,oneof:"message"},{no:17,name:"track_unpublished",kind:"message",T:CD,oneof:"message"},{no:18,name:"pong",kind:"scalar",T:3,oneof:"message"},{no:19,name:"reconnect",kind:"message",T:TD,oneof:"message"},{no:20,name:"pong_resp",kind:"message",T:LD,oneof:"message"},{no:21,name:"subscription_response",kind:"message",T:BD,oneof:"message"},{no:22,name:"request_response",kind:"message",T:jD,oneof:"message"},{no:23,name:"track_subscribed",kind:"message",T:VD,oneof:"message"},{no:24,name:"room_moved",kind:"message",T:ND,oneof:"message"},{no:25,name:"media_sections_requirement",kind:"message",T:HD,oneof:"message"},{no:26,name:"subscribed_audio_codec_update",kind:"message",T:OD,oneof:"message"}]),lf=j.makeMessageType("livekit.SimulcastCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"cid",kind:"scalar",T:9},{no:4,name:"layers",kind:"message",T:qi,repeated:!0},{no:5,name:"video_layer_mode",kind:"enum",T:j.getEnumType(z0)}]),Xr=j.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:j.getEnumType(In)},{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:j.getEnumType(pt)},{no:9,name:"layers",kind:"message",T:qi,repeated:!0},{no:10,name:"simulcast_codecs",kind:"message",T:lf,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:j.getEnumType(Ct)},{no:15,name:"stream",kind:"scalar",T:9},{no:16,name:"backup_codec_policy",kind:"enum",T:j.getEnumType(V0)},{no:17,name:"audio_features",kind:"enum",T:j.getEnumType(wt),repeated:!0}]),Uc=j.makeMessageType("livekit.TrickleRequest",()=>[{no:1,name:"candidateInit",kind:"scalar",T:9},{no:2,name:"target",kind:"enum",T:j.getEnumType(Bn)},{no:3,name:"final",kind:"scalar",T:8}]),Bc=j.makeMessageType("livekit.MuteTrackRequest",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"muted",kind:"scalar",T:8}]),SD=j.makeMessageType("livekit.JoinResponse",()=>[{no:1,name:"room",kind:"message",T:Dc},{no:2,name:"participant",kind:"message",T:Ua},{no:3,name:"other_participants",kind:"message",T:Ua,repeated:!0},{no:4,name:"server_version",kind:"scalar",T:9},{no:5,name:"ice_servers",kind:"message",T:ob,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:W0},{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:X0},{no:13,name:"sif_trailer",kind:"scalar",T:12},{no:14,name:"enabled_publish_codecs",kind:"message",T:Oc,repeated:!0},{no:15,name:"fast_publish",kind:"scalar",T:8}]),TD=j.makeMessageType("livekit.ReconnectResponse",()=>[{no:1,name:"ice_servers",kind:"message",T:ob,repeated:!0},{no:2,name:"client_configuration",kind:"message",T:W0},{no:3,name:"server_info",kind:"message",T:X0},{no:4,name:"last_message_seq",kind:"scalar",T:13}]),uf=j.makeMessageType("livekit.TrackPublishedResponse",()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"track",kind:"message",T:ks}]),CD=j.makeMessageType("livekit.TrackUnpublishedResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]),Hi=j.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},{no:4,name:"mid_to_track_id",kind:"map",K:9,V:{kind:"scalar",T:9}}]),kD=j.makeMessageType("livekit.ParticipantUpdate",()=>[{no:1,name:"participants",kind:"message",T:Ua,repeated:!0}]),jc=j.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:Y0,repeated:!0}]),ab=j.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:j.getEnumType(tf)},{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}]),df=j.makeMessageType("livekit.UpdateLocalAudioTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"features",kind:"enum",T:j.getEnumType(wt),repeated:!0}]),sb=j.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}]),Vc=j.makeMessageType("livekit.LeaveRequest",()=>[{no:1,name:"can_reconnect",kind:"scalar",T:8},{no:2,name:"reason",kind:"enum",T:j.getEnumType(Un)},{no:3,name:"action",kind:"enum",T:j.getEnumType(Es)},{no:4,name:"regions",kind:"message",T:ID}]),Es=j.makeEnum("livekit.LeaveRequest.Action",[{no:0,name:"DISCONNECT"},{no:1,name:"RESUME"},{no:2,name:"RECONNECT"}]),rb=j.makeMessageType("livekit.UpdateVideoLayers",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"layers",kind:"message",T:qi,repeated:!0}]),ff=j.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}]),ob=j.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}]),ED=j.makeMessageType("livekit.SpeakersChanged",()=>[{no:1,name:"speakers",kind:"message",T:H0,repeated:!0}]),wD=j.makeMessageType("livekit.RoomUpdate",()=>[{no:1,name:"room",kind:"message",T:Dc}]),RD=j.makeMessageType("livekit.ConnectionQualityInfo",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"quality",kind:"enum",T:j.getEnumType(Kr)},{no:3,name:"score",kind:"scalar",T:2}]),_D=j.makeMessageType("livekit.ConnectionQualityUpdate",()=>[{no:1,name:"updates",kind:"message",T:RD,repeated:!0}]),xD=j.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:j.getEnumType(cf)}]),AD=j.makeMessageType("livekit.StreamStateUpdate",()=>[{no:1,name:"stream_states",kind:"message",T:xD,repeated:!0}]),hf=j.makeMessageType("livekit.SubscribedQuality",()=>[{no:1,name:"quality",kind:"enum",T:j.getEnumType(tf)},{no:2,name:"enabled",kind:"scalar",T:8}]),MD=j.makeMessageType("livekit.SubscribedCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"qualities",kind:"message",T:hf,repeated:!0}]),DD=j.makeMessageType("livekit.SubscribedQualityUpdate",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_qualities",kind:"message",T:hf,repeated:!0},{no:3,name:"subscribed_codecs",kind:"message",T:MD,repeated:!0}]),OD=j.makeMessageType("livekit.SubscribedAudioCodecUpdate",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_audio_codecs",kind:"message",T:vD,repeated:!0}]),cb=j.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}]),lb=j.makeMessageType("livekit.SubscriptionPermission",()=>[{no:1,name:"all_participants",kind:"scalar",T:8},{no:2,name:"track_permissions",kind:"message",T:cb,repeated:!0}]),PD=j.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}]),ND=j.makeMessageType("livekit.RoomMovedResponse",()=>[{no:1,name:"room",kind:"message",T:Dc},{no:2,name:"token",kind:"scalar",T:9},{no:3,name:"participant",kind:"message",T:Ua},{no:4,name:"other_participants",kind:"message",T:Ua,repeated:!0}]),mf=j.makeMessageType("livekit.SyncState",()=>[{no:1,name:"answer",kind:"message",T:Hi},{no:2,name:"subscription",kind:"message",T:jc},{no:3,name:"publish_tracks",kind:"message",T:uf,repeated:!0},{no:4,name:"data_channels",kind:"message",T:db,repeated:!0},{no:5,name:"offer",kind:"message",T:Hi},{no:6,name:"track_sids_disabled",kind:"scalar",T:9,repeated:!0},{no:7,name:"datachannel_receive_states",kind:"message",T:ub,repeated:!0}]),ub=j.makeMessageType("livekit.DataChannelReceiveState",()=>[{no:1,name:"publisher_sid",kind:"scalar",T:9},{no:2,name:"last_seq",kind:"scalar",T:13}]),db=j.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:j.getEnumType(Bn)}]),Jn=j.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:j.getEnumType(yD),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"}]),fb=j.makeMessageType("livekit.Ping",()=>[{no:1,name:"timestamp",kind:"scalar",T:3},{no:2,name:"rtt",kind:"scalar",T:3}]),LD=j.makeMessageType("livekit.Pong",()=>[{no:1,name:"last_ping_timestamp",kind:"scalar",T:3},{no:2,name:"timestamp",kind:"scalar",T:3}]),ID=j.makeMessageType("livekit.RegionSettings",()=>[{no:1,name:"regions",kind:"message",T:UD,repeated:!0}]),UD=j.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}]),BD=j.makeMessageType("livekit.SubscriptionResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"err",kind:"enum",T:j.getEnumType(lD)}]),jD=j.makeMessageType("livekit.RequestResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:13},{no:2,name:"reason",kind:"enum",T:j.getEnumType(pf)},{no:3,name:"message",kind:"scalar",T:9},{no:4,name:"trickle",kind:"message",T:Uc,oneof:"request"},{no:5,name:"add_track",kind:"message",T:Xr,oneof:"request"},{no:6,name:"mute",kind:"message",T:Bc,oneof:"request"},{no:7,name:"update_metadata",kind:"message",T:ff,oneof:"request"},{no:8,name:"update_audio_track",kind:"message",T:df,oneof:"request"},{no:9,name:"update_video_track",kind:"message",T:sb,oneof:"request"}]),pf=j.makeEnum("livekit.RequestResponse.Reason",[{no:0,name:"OK"},{no:1,name:"NOT_FOUND"},{no:2,name:"NOT_ALLOWED"},{no:3,name:"LIMIT_EXCEEDED"},{no:4,name:"QUEUED"},{no:5,name:"UNSUPPORTED_TYPE"},{no:6,name:"UNCLASSIFIED_ERROR"}]),VD=j.makeMessageType("livekit.TrackSubscribed",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]),hb=j.makeMessageType("livekit.ConnectionSettings",()=>[{no:1,name:"auto_subscribe",kind:"scalar",T:8},{no:2,name:"adaptive_stream",kind:"scalar",T:8},{no:3,name:"subscriber_allow_pause",kind:"scalar",T:8,opt:!0},{no:4,name:"disable_ice_lite",kind:"scalar",T:8}]),zD=j.makeMessageType("livekit.JoinRequest",()=>[{no:1,name:"client_info",kind:"message",T:J0},{no:2,name:"connection_settings",kind:"message",T:hb},{no:3,name:"metadata",kind:"scalar",T:9},{no:4,name:"participant_attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"add_track_requests",kind:"message",T:Xr,repeated:!0},{no:6,name:"publisher_offer",kind:"message",T:Hi},{no:7,name:"reconnect",kind:"scalar",T:8},{no:8,name:"reconnect_reason",kind:"enum",T:j.getEnumType(Ia)},{no:9,name:"participant_sid",kind:"scalar",T:9},{no:10,name:"sync_state",kind:"message",T:mf}]),FD=j.makeMessageType("livekit.WrappedJoinRequest",()=>[{no:1,name:"compression",kind:"enum",T:j.getEnumType(qD)},{no:2,name:"join_request",kind:"scalar",T:12}]),qD=j.makeEnum("livekit.WrappedJoinRequest.Compression",[{no:0,name:"NONE"},{no:1,name:"GZIP"}]),HD=j.makeMessageType("livekit.MediaSectionsRequirement",()=>[{no:1,name:"num_audios",kind:"scalar",T:13},{no:2,name:"num_videos",kind:"scalar",T:13}]);function GD(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var zc={exports:{}},KD=zc.exports,mb;function YD(){return mb||(mb=1,(function(t){(function(e,n){t.exports?t.exports=n():e.log=n()})(KD,function(){var e=function(){},n="undefined",a=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"],c={},l=null;function u(T,x){var R=T[x];if(typeof R.bind=="function")return R.bind(T);try{return Function.prototype.bind.call(R,T)}catch{return function(){return Function.prototype.apply.apply(R,[T,arguments])}}}function f(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function h(T){return T==="debug"&&(T="log"),typeof console===n?!1:T==="trace"&&a?f:console[T]!==void 0?u(console,T):console.log!==void 0?u(console,"log"):e}function p(){for(var T=this.getLevel(),x=0;x<r.length;x++){var R=r[x];this[R]=x<T?e:this.methodFactory(R,T,this.name)}if(this.log=this.debug,typeof console===n&&T<this.levels.SILENT)return"No console available for logging"}function v(T){return function(){typeof console!==n&&(p.call(this),this[T].apply(this,arguments))}}function y(T,x,R){return h(T)||v.apply(this,arguments)}function S(T,x){var R=this,P,L,E,k="loglevel";typeof T=="string"?k+=":"+T:typeof T=="symbol"&&(k=void 0);function _(Y){var ie=(r[Y]||"silent").toUpperCase();if(!(typeof window===n||!k)){try{window.localStorage[k]=ie;return}catch{}try{window.document.cookie=encodeURIComponent(k)+"="+ie+";"}catch{}}}function N(){var Y;if(!(typeof window===n||!k)){try{Y=window.localStorage[k]}catch{}if(typeof Y===n)try{var ie=window.document.cookie,he=encodeURIComponent(k),be=ie.indexOf(he+"=");be!==-1&&(Y=/^([^;]+)/.exec(ie.slice(be+he.length+1))[1])}catch{}return R.levels[Y]===void 0&&(Y=void 0),Y}}function U(){if(!(typeof window===n||!k)){try{window.localStorage.removeItem(k)}catch{}try{window.document.cookie=encodeURIComponent(k)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function G(Y){var ie=Y;if(typeof ie=="string"&&R.levels[ie.toUpperCase()]!==void 0&&(ie=R.levels[ie.toUpperCase()]),typeof ie=="number"&&ie>=0&&ie<=R.levels.SILENT)return ie;throw new TypeError("log.setLevel() called with invalid level: "+Y)}R.name=T,R.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},R.methodFactory=x||y,R.getLevel=function(){return E!=null?E:L!=null?L:P},R.setLevel=function(Y,ie){return E=G(Y),ie!==!1&&_(E),p.call(R)},R.setDefaultLevel=function(Y){L=G(Y),N()||R.setLevel(Y,!1)},R.resetLevel=function(){E=null,U(),p.call(R)},R.enableAll=function(Y){R.setLevel(R.levels.TRACE,Y)},R.disableAll=function(Y){R.setLevel(R.levels.SILENT,Y)},R.rebuild=function(){if(l!==R&&(P=G(l.getLevel())),p.call(R),l===R)for(var Y in c)c[Y].rebuild()},P=G(l?l.getLevel():"WARN");var V=N();V!=null&&(E=G(V)),p.call(R)}l=new S,l.getLogger=function(x){if(typeof x!="symbol"&&typeof x!="string"||x==="")throw new TypeError("You must supply a name when creating a logger.");var R=c[x];return R||(R=c[x]=new S(x,l.methodFactory)),R};var w=typeof window!==n?window.log:void 0;return l.noConflict=function(){return typeof window!==n&&window.log===l&&(window.log=w),l},l.getLoggers=function(){return c},l.default=l,l})})(zc)),zc.exports}var Fc=YD(),gf;(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"})(gf||(gf={}));var jn;(function(t){t.Default="livekit",t.Room="livekit-room",t.TokenSource="livekit-token-source",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"})(jn||(jn={}));let Ee=Fc.getLogger("livekit");Object.values(jn).map(t=>Fc.getLogger(t)),Ee.setDefaultLevel(gf.info);function fi(t){const e=Fc.getLogger(t);return e.setDefaultLevel(Ee.getLevel()),e}const XD=Fc.getLogger("lk-e2ee"),Qr=7e3,QD=[0,300,4*300,9*300,16*300,Qr,Qr,Qr,Qr,Qr];class JD{constructor(e){this._retryDelays=e!==void 0?[...e]:QD}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 ZD(t,e){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(n[a]=t[a]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,a=Object.getOwnPropertySymbols(t);r<a.length;r++)e.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(t,a[r])&&(n[a[r]]=t[a[r]]);return n}function A(t,e,n,a){function r(c){return c instanceof n?c:new n(function(l){l(c)})}return new(n||(n=Promise))(function(c,l){function u(p){try{h(a.next(p))}catch(v){l(v)}}function f(p){try{h(a.throw(p))}catch(v){l(v)}}function h(p){p.done?c(p.value):r(p.value).then(u,f)}h((a=a.apply(t,e||[])).next())})}function pb(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],a=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&a>=t.length&&(t=void 0),{value:t&&t[a++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function hi(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 pb=="function"?pb(t):t[Symbol.iterator](),n={},a("next"),a("throw"),a("return"),n[Symbol.asyncIterator]=function(){return this},n);function a(c){n[c]=t[c]&&function(l){return new Promise(function(u,f){l=t[c](l),r(u,f,l.done,l.value)})}}function r(c,l,u,f){Promise.resolve(f).then(function(h){c({value:h,done:u})},l)}}typeof SuppressedError=="function"&&SuppressedError;var qc={exports:{}},gb;function WD(){if(gb)return qc.exports;gb=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(k,_,N){return Function.prototype.apply.call(k,_,N)},n;t&&typeof t.ownKeys=="function"?n=t.ownKeys:Object.getOwnPropertySymbols?n=function(k){return Object.getOwnPropertyNames(k).concat(Object.getOwnPropertySymbols(k))}:n=function(k){return Object.getOwnPropertyNames(k)};function a(E){console&&console.warn&&console.warn(E)}var r=Number.isNaN||function(k){return k!==k};function c(){c.init.call(this)}qc.exports=c,qc.exports.once=R,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var l=10;function u(E){if(typeof E!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof E)}Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return l},set:function(E){if(typeof E!="number"||E<0||r(E))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+E+".");l=E}}),c.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},c.prototype.setMaxListeners=function(k){if(typeof k!="number"||k<0||r(k))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+k+".");return this._maxListeners=k,this};function f(E){return E._maxListeners===void 0?c.defaultMaxListeners:E._maxListeners}c.prototype.getMaxListeners=function(){return f(this)},c.prototype.emit=function(k){for(var _=[],N=1;N<arguments.length;N++)_.push(arguments[N]);var U=k==="error",G=this._events;if(G!==void 0)U=U&&G.error===void 0;else if(!U)return!1;if(U){var V;if(_.length>0&&(V=_[0]),V instanceof Error)throw V;var Y=new Error("Unhandled error."+(V?" ("+V.message+")":""));throw Y.context=V,Y}var ie=G[k];if(ie===void 0)return!1;if(typeof ie=="function")e(ie,this,_);else for(var he=ie.length,be=w(ie,he),N=0;N<he;++N)e(be[N],this,_);return!0};function h(E,k,_,N){var U,G,V;if(u(_),G=E._events,G===void 0?(G=E._events=Object.create(null),E._eventsCount=0):(G.newListener!==void 0&&(E.emit("newListener",k,_.listener?_.listener:_),G=E._events),V=G[k]),V===void 0)V=G[k]=_,++E._eventsCount;else if(typeof V=="function"?V=G[k]=N?[_,V]:[V,_]:N?V.unshift(_):V.push(_),U=f(E),U>0&&V.length>U&&!V.warned){V.warned=!0;var Y=new Error("Possible EventEmitter memory leak detected. "+V.length+" "+String(k)+" listeners added. Use emitter.setMaxListeners() to increase limit");Y.name="MaxListenersExceededWarning",Y.emitter=E,Y.type=k,Y.count=V.length,a(Y)}return E}c.prototype.addListener=function(k,_){return h(this,k,_,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(k,_){return h(this,k,_,!0)};function p(){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 v(E,k,_){var N={fired:!1,wrapFn:void 0,target:E,type:k,listener:_},U=p.bind(N);return U.listener=_,N.wrapFn=U,U}c.prototype.once=function(k,_){return u(_),this.on(k,v(this,k,_)),this},c.prototype.prependOnceListener=function(k,_){return u(_),this.prependListener(k,v(this,k,_)),this},c.prototype.removeListener=function(k,_){var N,U,G,V,Y;if(u(_),U=this._events,U===void 0)return this;if(N=U[k],N===void 0)return this;if(N===_||N.listener===_)--this._eventsCount===0?this._events=Object.create(null):(delete U[k],U.removeListener&&this.emit("removeListener",k,N.listener||_));else if(typeof N!="function"){for(G=-1,V=N.length-1;V>=0;V--)if(N[V]===_||N[V].listener===_){Y=N[V].listener,G=V;break}if(G<0)return this;G===0?N.shift():T(N,G),N.length===1&&(U[k]=N[0]),U.removeListener!==void 0&&this.emit("removeListener",k,Y||_)}return this},c.prototype.off=c.prototype.removeListener,c.prototype.removeAllListeners=function(k){var _,N,U;if(N=this._events,N===void 0)return this;if(N.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):N[k]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete N[k]),this;if(arguments.length===0){var G=Object.keys(N),V;for(U=0;U<G.length;++U)V=G[U],V!=="removeListener"&&this.removeAllListeners(V);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(_=N[k],typeof _=="function")this.removeListener(k,_);else if(_!==void 0)for(U=_.length-1;U>=0;U--)this.removeListener(k,_[U]);return this};function y(E,k,_){var N=E._events;if(N===void 0)return[];var U=N[k];return U===void 0?[]:typeof U=="function"?_?[U.listener||U]:[U]:_?x(U):w(U,U.length)}c.prototype.listeners=function(k){return y(this,k,!0)},c.prototype.rawListeners=function(k){return y(this,k,!1)},c.listenerCount=function(E,k){return typeof E.listenerCount=="function"?E.listenerCount(k):S.call(E,k)},c.prototype.listenerCount=S;function S(E){var k=this._events;if(k!==void 0){var _=k[E];if(typeof _=="function")return 1;if(_!==void 0)return _.length}return 0}c.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function w(E,k){for(var _=new Array(k),N=0;N<k;++N)_[N]=E[N];return _}function T(E,k){for(;k+1<E.length;k++)E[k]=E[k+1];E.pop()}function x(E){for(var k=new Array(E.length),_=0;_<k.length;++_)k[_]=E[_].listener||E[_];return k}function R(E,k){return new Promise(function(_,N){function U(V){E.removeListener(k,G),N(V)}function G(){typeof E.removeListener=="function"&&E.removeListener("error",U),_([].slice.call(arguments))}L(E,k,G,{once:!0}),k!=="error"&&P(E,U,{once:!0})})}function P(E,k,_){typeof E.on=="function"&&L(E,"error",k,_)}function L(E,k,_,N){if(typeof E.on=="function")N.once?E.once(k,_):E.on(k,_);else if(typeof E.addEventListener=="function")E.addEventListener(k,function U(G){N.once&&E.removeEventListener(k,U),_(G)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof E)}return qc.exports}var Zn=WD();let vb=!0,yb=!0;function Jr(t,e,n){const a=t.match(e);return a&&a.length>=n&&parseFloat(a[n],10)}function ja(t,e,n){if(!t.RTCPeerConnection)return;const a=t.RTCPeerConnection.prototype,r=a.addEventListener;a.addEventListener=function(l,u){if(l!==e)return r.apply(this,arguments);const f=h=>{const p=n(h);p&&(u.handleEvent?u.handleEvent(p):u(p))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(u,f),r.apply(this,[l,f])};const c=a.removeEventListener;a.removeEventListener=function(l,u){if(l!==e||!this._eventMap||!this._eventMap[e])return c.apply(this,arguments);if(!this._eventMap[e].has(u))return c.apply(this,arguments);const f=this._eventMap[e].get(u);return this._eventMap[e].delete(u),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,c.apply(this,[l,f])},Object.defineProperty(a,"on"+e,{get(){return this["_on"+e]},set(l){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),l&&this.addEventListener(e,this["_on"+e]=l)},enumerable:!0,configurable:!0})}function $D(t){return typeof t!="boolean"?new Error("Argument type: "+typeof t+". Please use a boolean."):(vb=t,t?"adapter.js logging disabled":"adapter.js logging enabled")}function eO(t){return typeof t!="boolean"?new Error("Argument type: "+typeof t+". Please use a boolean."):(yb=!t,"adapter.js deprecation warnings "+(t?"disabled":"enabled"))}function bb(){if(typeof window=="object"){if(vb)return;typeof console!="undefined"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function vf(t,e){yb&&console.warn(t+" is deprecated, please use "+e+" instead.")}function tO(t){const e={browser:null,version:null};if(typeof t=="undefined"||!t.navigator||!t.navigator.userAgent)return e.browser="Not a browser.",e;const{navigator:n}=t;if(n.userAgentData&&n.userAgentData.brands){const a=n.userAgentData.brands.find(r=>r.brand==="Chromium");if(a)return{browser:"chrome",version:parseInt(a.version,10)}}if(n.mozGetUserMedia)e.browser="firefox",e.version=parseInt(Jr(n.userAgent,/Firefox\/(\d+)\./,1));else if(n.webkitGetUserMedia||t.isSecureContext===!1&&t.webkitRTCPeerConnection)e.browser="chrome",e.version=parseInt(Jr(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2));else if(t.RTCPeerConnection&&n.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=parseInt(Jr(n.userAgent,/AppleWebKit\/(\d+)\./,1)),e.supportsUnifiedPlan=t.RTCRtpTransceiver&&"currentDirection"in t.RTCRtpTransceiver.prototype,e._safariVersion=Jr(n.userAgent,/Version\/(\d+(\.?\d+))/,1);else return e.browser="Not a supported browser.",e;return e}function Sb(t){return Object.prototype.toString.call(t)==="[object Object]"}function Tb(t){return Sb(t)?Object.keys(t).reduce(function(e,n){const a=Sb(t[n]),r=a?Tb(t[n]):t[n],c=a&&!Object.keys(r).length;return r===void 0||c?e:Object.assign(e,{[n]:r})},{}):t}function yf(t,e,n){!e||n.has(e.id)||(n.set(e.id,e),Object.keys(e).forEach(a=>{a.endsWith("Id")?yf(t,t.get(e[a]),n):a.endsWith("Ids")&&e[a].forEach(r=>{yf(t,t.get(r),n)})}))}function Cb(t,e,n){const a=n?"outbound-rtp":"inbound-rtp",r=new Map;if(e===null)return r;const c=[];return t.forEach(l=>{l.type==="track"&&l.trackIdentifier===e.id&&c.push(l)}),c.forEach(l=>{t.forEach(u=>{u.type===a&&u.trackId===l.id&&yf(t,u,r)})}),r}const kb=bb;function Eb(t,e){const n=t&&t.navigator;if(!n.mediaDevices)return;const a=function(u){if(typeof u!="object"||u.mandatory||u.optional)return u;const f={};return Object.keys(u).forEach(h=>{if(h==="require"||h==="advanced"||h==="mediaSource")return;const p=typeof u[h]=="object"?u[h]:{ideal:u[h]};p.exact!==void 0&&typeof p.exact=="number"&&(p.min=p.max=p.exact);const v=function(y,S){return y?y+S.charAt(0).toUpperCase()+S.slice(1):S==="deviceId"?"sourceId":S};if(p.ideal!==void 0){f.optional=f.optional||[];let y={};typeof p.ideal=="number"?(y[v("min",h)]=p.ideal,f.optional.push(y),y={},y[v("max",h)]=p.ideal,f.optional.push(y)):(y[v("",h)]=p.ideal,f.optional.push(y))}p.exact!==void 0&&typeof p.exact!="number"?(f.mandatory=f.mandatory||{},f.mandatory[v("",h)]=p.exact):["min","max"].forEach(y=>{p[y]!==void 0&&(f.mandatory=f.mandatory||{},f.mandatory[v(y,h)]=p[y])})}),u.advanced&&(f.optional=(f.optional||[]).concat(u.advanced)),f},r=function(u,f){if(e.version>=61)return f(u);if(u=JSON.parse(JSON.stringify(u)),u&&typeof u.audio=="object"){const h=function(p,v,y){v in p&&!(y in p)&&(p[y]=p[v],delete p[v])};u=JSON.parse(JSON.stringify(u)),h(u.audio,"autoGainControl","googAutoGainControl"),h(u.audio,"noiseSuppression","googNoiseSuppression"),u.audio=a(u.audio)}if(u&&typeof u.video=="object"){let h=u.video.facingMode;h=h&&(typeof h=="object"?h:{ideal:h});const p=e.version<66;if(h&&(h.exact==="user"||h.exact==="environment"||h.ideal==="user"||h.ideal==="environment")&&!(n.mediaDevices.getSupportedConstraints&&n.mediaDevices.getSupportedConstraints().facingMode&&!p)){delete u.video.facingMode;let v;if(h.exact==="environment"||h.ideal==="environment"?v=["back","rear"]:(h.exact==="user"||h.ideal==="user")&&(v=["front"]),v)return n.mediaDevices.enumerateDevices().then(y=>{y=y.filter(w=>w.kind==="videoinput");let S=y.find(w=>v.some(T=>w.label.toLowerCase().includes(T)));return!S&&y.length&&v.includes("back")&&(S=y[y.length-1]),S&&(u.video.deviceId=h.exact?{exact:S.deviceId}:{ideal:S.deviceId}),u.video=a(u.video),kb("chrome: "+JSON.stringify(u)),f(u)})}u.video=a(u.video)}return kb("chrome: "+JSON.stringify(u)),f(u)},c=function(u){return e.version>=64?u:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[u.name]||u.name,message:u.message,constraint:u.constraint||u.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},l=function(u,f,h){r(u,p=>{n.webkitGetUserMedia(p,f,v=>{h&&h(c(v))})})};if(n.getUserMedia=l.bind(n),n.mediaDevices.getUserMedia){const u=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(f){return r(f,h=>u(h).then(p=>{if(h.audio&&!p.getAudioTracks().length||h.video&&!p.getVideoTracks().length)throw p.getTracks().forEach(v=>{v.stop()}),new DOMException("","NotFoundError");return p},p=>Promise.reject(c(p))))}}}function wb(t){t.MediaStream=t.MediaStream||t.webkitMediaStream}function Rb(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=a=>{a.stream.addEventListener("addtrack",r=>{let c;t.RTCPeerConnection.prototype.getReceivers?c=this.getReceivers().find(u=>u.track&&u.track.id===r.track.id):c={track:r.track};const l=new Event("track");l.track=r.track,l.receiver=c,l.transceiver={receiver:c},l.streams=[a.stream],this.dispatchEvent(l)}),a.stream.getTracks().forEach(r=>{let c;t.RTCPeerConnection.prototype.getReceivers?c=this.getReceivers().find(u=>u.track&&u.track.id===r.id):c={track:r};const l=new Event("track");l.track=r,l.receiver=c,l.transceiver={receiver:c},l.streams=[a.stream],this.dispatchEvent(l)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else ja(t,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function _b(t){if(typeof t=="object"&&t.RTCPeerConnection&&!("getSenders"in t.RTCPeerConnection.prototype)&&"createDTMFSender"in t.RTCPeerConnection.prototype){const e=function(r,c){return{track:c,get dtmf(){return this._dtmf===void 0&&(c.kind==="audio"?this._dtmf=r.createDTMFSender(c):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(u,f){let h=r.apply(this,arguments);return h||(h=e(this,u),this._senders.push(h)),h};const c=t.RTCPeerConnection.prototype.removeTrack;t.RTCPeerConnection.prototype.removeTrack=function(u){c.apply(this,arguments);const f=this._senders.indexOf(u);f!==-1&&this._senders.splice(f,1)}}const n=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(c){this._senders=this._senders||[],n.apply(this,[c]),c.getTracks().forEach(l=>{this._senders.push(e(this,l))})};const a=t.RTCPeerConnection.prototype.removeStream;t.RTCPeerConnection.prototype.removeStream=function(c){this._senders=this._senders||[],a.apply(this,[c]),c.getTracks().forEach(l=>{const u=this._senders.find(f=>f.track===l);u&&this._senders.splice(this._senders.indexOf(u),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 a=e.apply(this,[]);return a.forEach(r=>r._pc=this),a},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 xb(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 c=n.apply(this,[]);return c.forEach(l=>l._pc=this),c});const a=t.RTCPeerConnection.prototype.addTrack;a&&(t.RTCPeerConnection.prototype.addTrack=function(){const c=a.apply(this,arguments);return c._pc=this,c}),t.RTCRtpSender.prototype.getStats=function(){const c=this;return this._pc.getStats().then(l=>Cb(l,c.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(c=>c._pc=this),r}),ja(t,"track",a=>(a.receiver._pc=a.srcElement,a)),t.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(c=>Cb(c,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 a=arguments[0];let r,c,l;return this.getSenders().forEach(u=>{u.track===a&&(r?l=!0:r=u)}),this.getReceivers().forEach(u=>(u.track===a&&(c?l=!0:c=u),u.track===a)),l||r&&c?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():c?c.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function Ab(t){t.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(l=>this._shimmedLocalStreams[l][0])};const e=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addTrack=function(l,u){if(!u)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const f=e.apply(this,arguments);return this._shimmedLocalStreams[u.id]?this._shimmedLocalStreams[u.id].indexOf(f)===-1&&this._shimmedLocalStreams[u.id].push(f):this._shimmedLocalStreams[u.id]=[u,f],f};const n=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(l){this._shimmedLocalStreams=this._shimmedLocalStreams||{},l.getTracks().forEach(h=>{if(this.getSenders().find(v=>v.track===h))throw new DOMException("Track already exists.","InvalidAccessError")});const u=this.getSenders();n.apply(this,arguments);const f=this.getSenders().filter(h=>u.indexOf(h)===-1);this._shimmedLocalStreams[l.id]=[l].concat(f)};const a=t.RTCPeerConnection.prototype.removeStream;t.RTCPeerConnection.prototype.removeStream=function(l){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[l.id],a.apply(this,arguments)};const r=t.RTCPeerConnection.prototype.removeTrack;t.RTCPeerConnection.prototype.removeTrack=function(l){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},l&&Object.keys(this._shimmedLocalStreams).forEach(u=>{const f=this._shimmedLocalStreams[u].indexOf(l);f!==-1&&this._shimmedLocalStreams[u].splice(f,1),this._shimmedLocalStreams[u].length===1&&delete this._shimmedLocalStreams[u]}),r.apply(this,arguments)}}function Mb(t,e){if(!t.RTCPeerConnection)return;if(t.RTCPeerConnection.prototype.addTrack&&e.version>=65)return Ab(t);const n=t.RTCPeerConnection.prototype.getLocalStreams;t.RTCPeerConnection.prototype.getLocalStreams=function(){const p=n.apply(this);return this._reverseStreams=this._reverseStreams||{},p.map(v=>this._reverseStreams[v.id])};const a=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(p){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},p.getTracks().forEach(v=>{if(this.getSenders().find(S=>S.track===v))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[p.id]){const v=new t.MediaStream(p.getTracks());this._streams[p.id]=v,this._reverseStreams[v.id]=p,p=v}a.apply(this,[p])};const r=t.RTCPeerConnection.prototype.removeStream;t.RTCPeerConnection.prototype.removeStream=function(p){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},r.apply(this,[this._streams[p.id]||p]),delete this._reverseStreams[this._streams[p.id]?this._streams[p.id].id:p.id],delete this._streams[p.id]},t.RTCPeerConnection.prototype.addTrack=function(p,v){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const y=[].slice.call(arguments,1);if(y.length!==1||!y[0].getTracks().find(T=>T===p))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(T=>T.track===p))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const w=this._streams[v.id];if(w)w.addTrack(p),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const T=new t.MediaStream([p]);this._streams[v.id]=T,this._reverseStreams[T.id]=v,this.addStream(T)}return this.getSenders().find(T=>T.track===p)};function c(h,p){let v=p.sdp;return Object.keys(h._reverseStreams||[]).forEach(y=>{const S=h._reverseStreams[y],w=h._streams[S.id];v=v.replace(new RegExp(w.id,"g"),S.id)}),new RTCSessionDescription({type:p.type,sdp:v})}function l(h,p){let v=p.sdp;return Object.keys(h._reverseStreams||[]).forEach(y=>{const S=h._reverseStreams[y],w=h._streams[S.id];v=v.replace(new RegExp(S.id,"g"),w.id)}),new RTCSessionDescription({type:p.type,sdp:v})}["createOffer","createAnswer"].forEach(function(h){const p=t.RTCPeerConnection.prototype[h],v={[h](){const y=arguments;return arguments.length&&typeof arguments[0]=="function"?p.apply(this,[w=>{const T=c(this,w);y[0].apply(null,[T])},w=>{y[1]&&y[1].apply(null,w)},arguments[2]]):p.apply(this,arguments).then(w=>c(this,w))}};t.RTCPeerConnection.prototype[h]=v[h]});const u=t.RTCPeerConnection.prototype.setLocalDescription;t.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?u.apply(this,arguments):(arguments[0]=l(this,arguments[0]),u.apply(this,arguments))};const f=Object.getOwnPropertyDescriptor(t.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(t.RTCPeerConnection.prototype,"localDescription",{get(){const h=f.get.apply(this);return h.type===""?h:c(this,h)}}),t.RTCPeerConnection.prototype.removeTrack=function(p){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!p._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(p._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let y;Object.keys(this._streams).forEach(S=>{this._streams[S].getTracks().find(T=>p.track===T)&&(y=this._streams[S])}),y&&(y.getTracks().length===1?this.removeStream(this._reverseStreams[y.id]):y.removeTrack(p.track),this.dispatchEvent(new Event("negotiationneeded")))}}function bf(t,e){!t.RTCPeerConnection&&t.webkitRTCPeerConnection&&(t.RTCPeerConnection=t.webkitRTCPeerConnection),t.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(n){const a=t.RTCPeerConnection.prototype[n],r={[n](){return arguments[0]=new(n==="addIceCandidate"?t.RTCIceCandidate:t.RTCSessionDescription)(arguments[0]),a.apply(this,arguments)}};t.RTCPeerConnection.prototype[n]=r[n]})}function Db(t,e){ja(t,"negotiationneeded",n=>{const a=n.target;if(!((e.version<72||a.getConfiguration&&a.getConfiguration().sdpSemantics==="plan-b")&&a.signalingState!=="stable"))return n})}var Ob=Object.freeze({__proto__:null,fixNegotiationNeeded:Db,shimAddTrackRemoveTrack:Mb,shimAddTrackRemoveTrackWithNative:Ab,shimGetSendersWithDtmf:_b,shimGetUserMedia:Eb,shimMediaStream:wb,shimOnTrack:Rb,shimPeerConnection:bf,shimSenderReceiverGetStats:xb});function Pb(t,e){const n=t&&t.navigator,a=t&&t.MediaStreamTrack;if(n.getUserMedia=function(r,c,l){vf("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(r).then(c,l)},!(e.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){const r=function(l,u,f){u in l&&!(f in l)&&(l[f]=l[u],delete l[u])},c=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(l){return typeof l=="object"&&typeof l.audio=="object"&&(l=JSON.parse(JSON.stringify(l)),r(l.audio,"autoGainControl","mozAutoGainControl"),r(l.audio,"noiseSuppression","mozNoiseSuppression")),c(l)},a&&a.prototype.getSettings){const l=a.prototype.getSettings;a.prototype.getSettings=function(){const u=l.apply(this,arguments);return r(u,"mozAutoGainControl","autoGainControl"),r(u,"mozNoiseSuppression","noiseSuppression"),u}}if(a&&a.prototype.applyConstraints){const l=a.prototype.applyConstraints;a.prototype.applyConstraints=function(u){return this.kind==="audio"&&typeof u=="object"&&(u=JSON.parse(JSON.stringify(u)),r(u,"autoGainControl","mozAutoGainControl"),r(u,"noiseSuppression","mozNoiseSuppression")),l.apply(this,[u])}}}}function nO(t,e){t.navigator.mediaDevices&&"getDisplayMedia"in t.navigator.mediaDevices||t.navigator.mediaDevices&&(t.navigator.mediaDevices.getDisplayMedia=function(a){if(!(a&&a.video)){const r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return a.video===!0?a.video={mediaSource:e}:a.video.mediaSource=e,t.navigator.mediaDevices.getUserMedia(a)})}function Nb(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 Sf(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 c=t.RTCPeerConnection.prototype[r],l={[r](){return arguments[0]=new(r==="addIceCandidate"?t.RTCIceCandidate:t.RTCSessionDescription)(arguments[0]),c.apply(this,arguments)}};t.RTCPeerConnection.prototype[r]=l[r]});const n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},a=t.RTCPeerConnection.prototype.getStats;t.RTCPeerConnection.prototype.getStats=function(){const[c,l,u]=arguments;return a.apply(this,[c||null]).then(f=>{if(e.version<53&&!l)try{f.forEach(h=>{h.type=n[h.type]||h.type})}catch(h){if(h.name!=="TypeError")throw h;f.forEach((p,v)=>{f.set(v,Object.assign({},p,{type:n[p.type]||p.type}))})}return f}).then(l,u)}}function Lb(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(c=>c._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 Ib(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 a=e.apply(this,[]);return a.forEach(r=>r._pc=this),a}),ja(t,"track",n=>(n.receiver._pc=n.srcElement,n)),t.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function Ub(t){!t.RTCPeerConnection||"removeStream"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.removeStream=function(n){vf("removeStream","removeTrack"),this.getSenders().forEach(a=>{a.track&&n.getTracks().includes(a.track)&&this.removeTrack(a)})})}function Bb(t){t.DataChannel&&!t.RTCDataChannel&&(t.RTCDataChannel=t.DataChannel)}function jb(t){if(!(typeof t=="object"&&t.RTCPeerConnection))return;const e=t.RTCPeerConnection.prototype.addTransceiver;e&&(t.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let a=arguments[1]&&arguments[1].sendEncodings;a===void 0&&(a=[]),a=[...a];const r=a.length>0;r&&a.forEach(l=>{if("rid"in l&&!/^[a-z0-9]{0,16}$/i.test(l.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in l&&!(parseFloat(l.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in l&&!(parseFloat(l.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const c=e.apply(this,arguments);if(r){const{sender:l}=c,u=l.getParameters();(!("encodings"in u)||u.encodings.length===1&&Object.keys(u.encodings[0]).length===0)&&(u.encodings=a,l.sendEncodings=a,this.setParametersPromises.push(l.setParameters(u).then(()=>{delete l.sendEncodings}).catch(()=>{delete l.sendEncodings})))}return c})}function Vb(t){if(!(typeof t=="object"&&t.RTCRtpSender))return;const e=t.RTCRtpSender.prototype.getParameters;e&&(t.RTCRtpSender.prototype.getParameters=function(){const a=e.apply(this,arguments);return"encodings"in a||(a.encodings=[].concat(this.sendEncodings||[{}])),a})}function zb(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 Fb(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 qb=Object.freeze({__proto__:null,shimAddTransceiver:jb,shimCreateAnswer:Fb,shimCreateOffer:zb,shimGetDisplayMedia:nO,shimGetParameters:Vb,shimGetUserMedia:Pb,shimOnTrack:Nb,shimPeerConnection:Sf,shimRTCDataChannel:Bb,shimReceiverGetStats:Ib,shimRemoveStream:Ub,shimSenderGetStats:Lb});function Hb(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(a){this._localStreams||(this._localStreams=[]),this._localStreams.includes(a)||this._localStreams.push(a),a.getAudioTracks().forEach(r=>e.call(this,r,a)),a.getVideoTracks().forEach(r=>e.call(this,r,a))},t.RTCPeerConnection.prototype.addTrack=function(a){for(var r=arguments.length,c=new Array(r>1?r-1:0),l=1;l<r;l++)c[l-1]=arguments[l];return c&&c.forEach(u=>{this._localStreams?this._localStreams.includes(u)||this._localStreams.push(u):this._localStreams=[u]}),e.apply(this,arguments)}}"removeStream"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.removeStream=function(n){this._localStreams||(this._localStreams=[]);const a=this._localStreams.indexOf(n);if(a===-1)return;this._localStreams.splice(a,1);const r=n.getTracks();this.getSenders().forEach(c=>{r.includes(c.track)&&this.removeTrack(c)})})}}function Gb(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=a=>{a.streams.forEach(r=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(r))return;this._remoteStreams.push(r);const c=new Event("addstream");c.stream=r,this.dispatchEvent(c)})})}});const e=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){const a=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(r){r.streams.forEach(c=>{if(a._remoteStreams||(a._remoteStreams=[]),a._remoteStreams.indexOf(c)>=0)return;a._remoteStreams.push(c);const l=new Event("addstream");l.stream=c,a.dispatchEvent(l)})}),e.apply(a,arguments)}}}function Kb(t){if(typeof t!="object"||!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype,n=e.createOffer,a=e.createAnswer,r=e.setLocalDescription,c=e.setRemoteDescription,l=e.addIceCandidate;e.createOffer=function(h,p){const v=arguments.length>=2?arguments[2]:arguments[0],y=n.apply(this,[v]);return p?(y.then(h,p),Promise.resolve()):y},e.createAnswer=function(h,p){const v=arguments.length>=2?arguments[2]:arguments[0],y=a.apply(this,[v]);return p?(y.then(h,p),Promise.resolve()):y};let u=function(f,h,p){const v=r.apply(this,[f]);return p?(v.then(h,p),Promise.resolve()):v};e.setLocalDescription=u,u=function(f,h,p){const v=c.apply(this,[f]);return p?(v.then(h,p),Promise.resolve()):v},e.setRemoteDescription=u,u=function(f,h,p){const v=l.apply(this,[f]);return p?(v.then(h,p),Promise.resolve()):v},e.addIceCandidate=u}function Yb(t){const e=t&&t.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const n=e.mediaDevices,a=n.getUserMedia.bind(n);e.mediaDevices.getUserMedia=r=>a(Xb(r))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=function(a,r,c){e.mediaDevices.getUserMedia(a).then(r,c)}.bind(e))}function Xb(t){return t&&t.video!==void 0?Object.assign({},t,{video:Tb(t.video)}):t}function Qb(t){if(!t.RTCPeerConnection)return;const e=t.RTCPeerConnection;t.RTCPeerConnection=function(a,r){if(a&&a.iceServers){const c=[];for(let l=0;l<a.iceServers.length;l++){let u=a.iceServers[l];u.urls===void 0&&u.url?(vf("RTCIceServer.url","RTCIceServer.urls"),u=JSON.parse(JSON.stringify(u)),u.urls=u.url,delete u.url,c.push(u)):c.push(a.iceServers[l])}a.iceServers=c}return new e(a,r)},t.RTCPeerConnection.prototype=e.prototype,"generateCertificate"in e&&Object.defineProperty(t.RTCPeerConnection,"generateCertificate",{get(){return e.generateCertificate}})}function Jb(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 Zb(t){const e=t.RTCPeerConnection.prototype.createOffer;t.RTCPeerConnection.prototype.createOffer=function(a){if(a){typeof a.offerToReceiveAudio!="undefined"&&(a.offerToReceiveAudio=!!a.offerToReceiveAudio);const r=this.getTransceivers().find(l=>l.receiver.track.kind==="audio");a.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"):a.offerToReceiveAudio===!0&&!r&&this.addTransceiver("audio",{direction:"recvonly"}),typeof a.offerToReceiveVideo!="undefined"&&(a.offerToReceiveVideo=!!a.offerToReceiveVideo);const c=this.getTransceivers().find(l=>l.receiver.track.kind==="video");a.offerToReceiveVideo===!1&&c?c.direction==="sendrecv"?c.setDirection?c.setDirection("sendonly"):c.direction="sendonly":c.direction==="recvonly"&&(c.setDirection?c.setDirection("inactive"):c.direction="inactive"):a.offerToReceiveVideo===!0&&!c&&this.addTransceiver("video",{direction:"recvonly"})}return e.apply(this,arguments)}}function Wb(t){typeof t!="object"||t.AudioContext||(t.AudioContext=t.webkitAudioContext)}var $b=Object.freeze({__proto__:null,shimAudioContext:Wb,shimCallbacksAPI:Kb,shimConstraints:Xb,shimCreateOfferLegacy:Zb,shimGetUserMedia:Yb,shimLocalStreamsAPI:Hb,shimRTCIceServerUrls:Qb,shimRemoteStreamsAPI:Gb,shimTrackEventTransceiver:Jb}),Tf={exports:{}},eS;function iO(){return eS||(eS=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(`
|
|
11
|
+
`).map(a=>a.trim())},e.splitSections=function(n){return n.split(`
|
|
12
|
+
m=`).map((r,c)=>(c>0?"m="+r:r).trim()+`\r
|
|
13
|
+
`)},e.getDescription=function(n){const a=e.splitSections(n);return a&&a[0]},e.getMediaSections=function(n){const a=e.splitSections(n);return a.shift(),a},e.matchPrefix=function(n,a){return e.splitLines(n).filter(r=>r.indexOf(a)===0)},e.parseCandidate=function(n){let a;n.indexOf("a=candidate:")===0?a=n.substring(12).split(" "):a=n.substring(10).split(" ");const r={foundation:a[0],component:{1:"rtp",2:"rtcp"}[a[1]]||a[1],protocol:a[2].toLowerCase(),priority:parseInt(a[3],10),ip:a[4],address:a[4],port:parseInt(a[5],10),type:a[7]};for(let c=8;c<a.length;c+=2)switch(a[c]){case"raddr":r.relatedAddress=a[c+1];break;case"rport":r.relatedPort=parseInt(a[c+1],10);break;case"tcptype":r.tcpType=a[c+1];break;case"ufrag":r.ufrag=a[c+1],r.usernameFragment=a[c+1];break;default:r[a[c]]===void 0&&(r[a[c]]=a[c+1]);break}return r},e.writeCandidate=function(n){const a=[];a.push(n.foundation);const r=n.component;r==="rtp"?a.push(1):r==="rtcp"?a.push(2):a.push(r),a.push(n.protocol.toUpperCase()),a.push(n.priority),a.push(n.address||n.ip),a.push(n.port);const c=n.type;return a.push("typ"),a.push(c),c!=="host"&&n.relatedAddress&&n.relatedPort&&(a.push("raddr"),a.push(n.relatedAddress),a.push("rport"),a.push(n.relatedPort)),n.tcpType&&n.protocol.toLowerCase()==="tcp"&&(a.push("tcptype"),a.push(n.tcpType)),(n.usernameFragment||n.ufrag)&&(a.push("ufrag"),a.push(n.usernameFragment||n.ufrag)),"candidate:"+a.join(" ")},e.parseIceOptions=function(n){return n.substring(14).split(" ")},e.parseRtpMap=function(n){let a=n.substring(9).split(" ");const r={payloadType:parseInt(a.shift(),10)};return a=a[0].split("/"),r.name=a[0],r.clockRate=parseInt(a[1],10),r.channels=a.length===3?parseInt(a[2],10):1,r.numChannels=r.channels,r},e.writeRtpMap=function(n){let a=n.payloadType;n.preferredPayloadType!==void 0&&(a=n.preferredPayloadType);const r=n.channels||n.numChannels||1;return"a=rtpmap:"+a+" "+n.name+"/"+n.clockRate+(r!==1?"/"+r:"")+`\r
|
|
14
|
+
`},e.parseExtmap=function(n){const a=n.substring(9).split(" ");return{id:parseInt(a[0],10),direction:a[0].indexOf("/")>0?a[0].split("/")[1]:"sendrecv",uri:a[1],attributes:a.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
|
|
15
|
+
`},e.parseFmtp=function(n){const a={};let r;const c=n.substring(n.indexOf(" ")+1).split(";");for(let l=0;l<c.length;l++)r=c[l].trim().split("="),a[r[0].trim()]=r[1];return a},e.writeFmtp=function(n){let a="",r=n.payloadType;if(n.preferredPayloadType!==void 0&&(r=n.preferredPayloadType),n.parameters&&Object.keys(n.parameters).length){const c=[];Object.keys(n.parameters).forEach(l=>{n.parameters[l]!==void 0?c.push(l+"="+n.parameters[l]):c.push(l)}),a+="a=fmtp:"+r+" "+c.join(";")+`\r
|
|
16
|
+
`}return a},e.parseRtcpFb=function(n){const a=n.substring(n.indexOf(" ")+1).split(" ");return{type:a.shift(),parameter:a.join(" ")}},e.writeRtcpFb=function(n){let a="",r=n.payloadType;return n.preferredPayloadType!==void 0&&(r=n.preferredPayloadType),n.rtcpFeedback&&n.rtcpFeedback.length&&n.rtcpFeedback.forEach(c=>{a+="a=rtcp-fb:"+r+" "+c.type+(c.parameter&&c.parameter.length?" "+c.parameter:"")+`\r
|
|
17
|
+
`}),a},e.parseSsrcMedia=function(n){const a=n.indexOf(" "),r={ssrc:parseInt(n.substring(7,a),10)},c=n.indexOf(":",a);return c>-1?(r.attribute=n.substring(a+1,c),r.value=n.substring(c+1)):r.attribute=n.substring(a+1),r},e.parseSsrcGroup=function(n){const a=n.substring(13).split(" ");return{semantics:a.shift(),ssrcs:a.map(r=>parseInt(r,10))}},e.getMid=function(n){const a=e.matchPrefix(n,"a=mid:")[0];if(a)return a.substring(6)},e.parseFingerprint=function(n){const a=n.substring(14).split(" ");return{algorithm:a[0].toLowerCase(),value:a[1].toUpperCase()}},e.getDtlsParameters=function(n,a){return{role:"auto",fingerprints:e.matchPrefix(n+a,"a=fingerprint:").map(e.parseFingerprint)}},e.writeDtlsParameters=function(n,a){let r="a=setup:"+a+`\r
|
|
18
|
+
`;return n.fingerprints.forEach(c=>{r+="a=fingerprint:"+c.algorithm+" "+c.value+`\r
|
|
19
|
+
`}),r},e.parseCryptoLine=function(n){const a=n.substring(9).split(" ");return{tag:parseInt(a[0],10),cryptoSuite:a[1],keyParams:a[2],sessionParams:a.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
|
|
20
|
+
`},e.parseCryptoKeyParams=function(n){if(n.indexOf("inline:")!==0)return null;const a=n.substring(7).split("|");return{keyMethod:"inline",keySalt:a[0],lifeTime:a[1],mkiValue:a[2]?a[2].split(":")[0]:void 0,mkiLength:a[2]?a[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,a){return e.matchPrefix(n+a,"a=crypto:").map(e.parseCryptoLine)},e.getIceParameters=function(n,a){const r=e.matchPrefix(n+a,"a=ice-ufrag:")[0],c=e.matchPrefix(n+a,"a=ice-pwd:")[0];return r&&c?{usernameFragment:r.substring(12),password:c.substring(10)}:null},e.writeIceParameters=function(n){let a="a=ice-ufrag:"+n.usernameFragment+`\r
|
|
21
|
+
a=ice-pwd:`+n.password+`\r
|
|
22
|
+
`;return n.iceLite&&(a+=`a=ice-lite\r
|
|
23
|
+
`),a},e.parseRtpParameters=function(n){const a={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},c=e.splitLines(n)[0].split(" ");a.profile=c[2];for(let u=3;u<c.length;u++){const f=c[u],h=e.matchPrefix(n,"a=rtpmap:"+f+" ")[0];if(h){const p=e.parseRtpMap(h),v=e.matchPrefix(n,"a=fmtp:"+f+" ");switch(p.parameters=v.length?e.parseFmtp(v[0]):{},p.rtcpFeedback=e.matchPrefix(n,"a=rtcp-fb:"+f+" ").map(e.parseRtcpFb),a.codecs.push(p),p.name.toUpperCase()){case"RED":case"ULPFEC":a.fecMechanisms.push(p.name.toUpperCase());break}}}e.matchPrefix(n,"a=extmap:").forEach(u=>{a.headerExtensions.push(e.parseExtmap(u))});const l=e.matchPrefix(n,"a=rtcp-fb:* ").map(e.parseRtcpFb);return a.codecs.forEach(u=>{l.forEach(f=>{u.rtcpFeedback.find(p=>p.type===f.type&&p.parameter===f.parameter)||u.rtcpFeedback.push(f)})}),a},e.writeRtpDescription=function(n,a){let r="";r+="m="+n+" ",r+=a.codecs.length>0?"9":"0",r+=" "+(a.profile||"UDP/TLS/RTP/SAVPF")+" ",r+=a.codecs.map(l=>l.preferredPayloadType!==void 0?l.preferredPayloadType:l.payloadType).join(" ")+`\r
|
|
24
|
+
`,r+=`c=IN IP4 0.0.0.0\r
|
|
25
|
+
`,r+=`a=rtcp:9 IN IP4 0.0.0.0\r
|
|
26
|
+
`,a.codecs.forEach(l=>{r+=e.writeRtpMap(l),r+=e.writeFmtp(l),r+=e.writeRtcpFb(l)});let c=0;return a.codecs.forEach(l=>{l.maxptime>c&&(c=l.maxptime)}),c>0&&(r+="a=maxptime:"+c+`\r
|
|
27
|
+
`),a.headerExtensions&&a.headerExtensions.forEach(l=>{r+=e.writeExtmap(l)}),r},e.parseRtpEncodingParameters=function(n){const a=[],r=e.parseRtpParameters(n),c=r.fecMechanisms.indexOf("RED")!==-1,l=r.fecMechanisms.indexOf("ULPFEC")!==-1,u=e.matchPrefix(n,"a=ssrc:").map(y=>e.parseSsrcMedia(y)).filter(y=>y.attribute==="cname"),f=u.length>0&&u[0].ssrc;let h;const p=e.matchPrefix(n,"a=ssrc-group:FID").map(y=>y.substring(17).split(" ").map(w=>parseInt(w,10)));p.length>0&&p[0].length>1&&p[0][0]===f&&(h=p[0][1]),r.codecs.forEach(y=>{if(y.name.toUpperCase()==="RTX"&&y.parameters.apt){let S={ssrc:f,codecPayloadType:parseInt(y.parameters.apt,10)};f&&h&&(S.rtx={ssrc:h}),a.push(S),c&&(S=JSON.parse(JSON.stringify(S)),S.fec={ssrc:f,mechanism:l?"red+ulpfec":"red"},a.push(S))}}),a.length===0&&f&&a.push({ssrc:f});let v=e.matchPrefix(n,"b=");return v.length&&(v[0].indexOf("b=TIAS:")===0?v=parseInt(v[0].substring(7),10):v[0].indexOf("b=AS:")===0?v=parseInt(v[0].substring(5),10)*1e3*.95-2e3*8:v=void 0,a.forEach(y=>{y.maxBitrate=v})),a},e.parseRtcpParameters=function(n){const a={},r=e.matchPrefix(n,"a=ssrc:").map(u=>e.parseSsrcMedia(u)).filter(u=>u.attribute==="cname")[0];r&&(a.cname=r.value,a.ssrc=r.ssrc);const c=e.matchPrefix(n,"a=rtcp-rsize");a.reducedSize=c.length>0,a.compound=c.length===0;const l=e.matchPrefix(n,"a=rtcp-mux");return a.mux=l.length>0,a},e.writeRtcpParameters=function(n){let a="";return n.reducedSize&&(a+=`a=rtcp-rsize\r
|
|
28
|
+
`),n.mux&&(a+=`a=rtcp-mux\r
|
|
29
|
+
`),n.ssrc!==void 0&&n.cname&&(a+="a=ssrc:"+n.ssrc+" cname:"+n.cname+`\r
|
|
30
|
+
`),a},e.parseMsid=function(n){let a;const r=e.matchPrefix(n,"a=msid:");if(r.length===1)return a=r[0].substring(7).split(" "),{stream:a[0],track:a[1]};const c=e.matchPrefix(n,"a=ssrc:").map(l=>e.parseSsrcMedia(l)).filter(l=>l.attribute==="msid");if(c.length>0)return a=c[0].value.split(" "),{stream:a[0],track:a[1]}},e.parseSctpDescription=function(n){const a=e.parseMLine(n),r=e.matchPrefix(n,"a=max-message-size:");let c;r.length>0&&(c=parseInt(r[0].substring(19),10)),isNaN(c)&&(c=65536);const l=e.matchPrefix(n,"a=sctp-port:");if(l.length>0)return{port:parseInt(l[0].substring(12),10),protocol:a.fmt,maxMessageSize:c};const u=e.matchPrefix(n,"a=sctpmap:");if(u.length>0){const f=u[0].substring(10).split(" ");return{port:parseInt(f[0],10),protocol:f[1],maxMessageSize:c}}},e.writeSctpDescription=function(n,a){let r=[];return n.protocol!=="DTLS/SCTP"?r=["m="+n.kind+" 9 "+n.protocol+" "+a.protocol+`\r
|
|
31
|
+
`,`c=IN IP4 0.0.0.0\r
|
|
32
|
+
`,"a=sctp-port:"+a.port+`\r
|
|
33
|
+
`]:r=["m="+n.kind+" 9 "+n.protocol+" "+a.port+`\r
|
|
34
|
+
`,`c=IN IP4 0.0.0.0\r
|
|
35
|
+
`,"a=sctpmap:"+a.port+" "+a.protocol+` 65535\r
|
|
36
|
+
`],a.maxMessageSize!==void 0&&r.push("a=max-message-size:"+a.maxMessageSize+`\r
|
|
37
|
+
`),r.join("")},e.generateSessionId=function(){return Math.random().toString().substr(2,22)},e.writeSessionBoilerplate=function(n,a,r){let c;const l=a!==void 0?a:2;return n?c=n:c=e.generateSessionId(),`v=0\r
|
|
38
|
+
o=`+(r||"thisisadapterortc")+" "+c+" "+l+` IN IP4 127.0.0.1\r
|
|
39
|
+
s=-\r
|
|
40
|
+
t=0 0\r
|
|
41
|
+
`},e.getDirection=function(n,a){const r=e.splitLines(n);for(let c=0;c<r.length;c++)switch(r[c]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[c].substring(2)}return a?e.getDirection(a):"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 a=e.splitLines(n);for(let r=0;r<a.length;r++)if(a[r].length<2||a[r].charAt(1)!=="=")return!1;return!0},t.exports=e})(Tf)),Tf.exports}var tS=iO(),ws=GD(tS),aO=hM({__proto__:null,default:ws},[tS]);function Hc(t){if(!t.RTCIceCandidate||t.RTCIceCandidate&&"foundation"in t.RTCIceCandidate.prototype)return;const e=t.RTCIceCandidate;t.RTCIceCandidate=function(a){if(typeof a=="object"&&a.candidate&&a.candidate.indexOf("a=")===0&&(a=JSON.parse(JSON.stringify(a)),a.candidate=a.candidate.substring(2)),a.candidate&&a.candidate.length){const r=new e(a),c=ws.parseCandidate(a.candidate);for(const l in c)l in r||Object.defineProperty(r,l,{value:c[l]});return r.toJSON=function(){return{candidate:r.candidate,sdpMid:r.sdpMid,sdpMLineIndex:r.sdpMLineIndex,usernameFragment:r.usernameFragment}},r}return new e(a)},t.RTCIceCandidate.prototype=e.prototype,ja(t,"icecandidate",n=>(n.candidate&&Object.defineProperty(n,"candidate",{value:new t.RTCIceCandidate(n.candidate),writable:"false"}),n))}function Cf(t){!t.RTCIceCandidate||t.RTCIceCandidate&&"relayProtocol"in t.RTCIceCandidate.prototype||ja(t,"icecandidate",e=>{if(e.candidate){const n=ws.parseCandidate(e.candidate.candidate);n.type==="relay"&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[n.priority>>24])}return e})}function Gc(t,e){if(!t.RTCPeerConnection)return;"sctp"in t.RTCPeerConnection.prototype||Object.defineProperty(t.RTCPeerConnection.prototype,"sctp",{get(){return typeof this._sctp=="undefined"?null:this._sctp}});const n=function(u){if(!u||!u.sdp)return!1;const f=ws.splitSections(u.sdp);return f.shift(),f.some(h=>{const p=ws.parseMLine(h);return p&&p.kind==="application"&&p.protocol.indexOf("SCTP")!==-1})},a=function(u){const f=u.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(f===null||f.length<2)return-1;const h=parseInt(f[1],10);return h!==h?-1:h},r=function(u){let f=65536;return e.browser==="firefox"&&(e.version<57?u===-1?f=16384:f=2147483637:e.version<60?f=e.version===57?65535:65536:f=2147483637),f},c=function(u,f){let h=65536;e.browser==="firefox"&&e.version===57&&(h=65535);const p=ws.matchPrefix(u.sdp,"a=max-message-size:");return p.length>0?h=parseInt(p[0].substring(19),10):e.browser==="firefox"&&f!==-1&&(h=2147483637),h},l=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76){const{sdpSemantics:f}=this.getConfiguration();f==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return typeof this._sctp=="undefined"?null:this._sctp},enumerable:!0,configurable:!0})}if(n(arguments[0])){const f=a(arguments[0]),h=r(f),p=c(arguments[0],f);let v;h===0&&p===0?v=Number.POSITIVE_INFINITY:h===0||p===0?v=Math.max(h,p):v=Math.min(h,p);const y={};Object.defineProperty(y,"maxMessageSize",{get(){return v}}),this._sctp=y}return l.apply(this,arguments)}}function Kc(t){if(!(t.RTCPeerConnection&&"createDataChannel"in t.RTCPeerConnection.prototype))return;function e(a,r){const c=a.send;a.send=function(){const u=arguments[0],f=u.length||u.size||u.byteLength;if(a.readyState==="open"&&r.sctp&&f>r.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+r.sctp.maxMessageSize+" bytes)");return c.apply(a,arguments)}}const n=t.RTCPeerConnection.prototype.createDataChannel;t.RTCPeerConnection.prototype.createDataChannel=function(){const r=n.apply(this,arguments);return e(r,this),r},ja(t,"datachannel",a=>(e(a.channel,a.target),a))}function kf(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 a=e[n];e[n]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=r=>{const c=r.target;if(c._lastConnectionState!==c.connectionState){c._lastConnectionState=c.connectionState;const l=new Event("connectionstatechange",r);c.dispatchEvent(l)}return r},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),a.apply(this,arguments)}})}function Ef(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(`
|
|
42
|
+
a=extmap-allow-mixed`)!==-1){const c=r.sdp.split(`
|
|
43
|
+
`).filter(l=>l.trim()!=="a=extmap-allow-mixed").join(`
|
|
44
|
+
`);t.RTCSessionDescription&&r instanceof t.RTCSessionDescription?arguments[0]=new t.RTCSessionDescription({type:r.type,sdp:c}):r.sdp=c}return n.apply(this,arguments)}}function Yc(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 Xc(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(l=>n.apply(this,[l]))})}var sO=Object.freeze({__proto__:null,removeExtmapAllowMixed:Ef,shimAddIceCandidateNullOrEmpty:Yc,shimConnectionState:kf,shimMaxMessageSize:Gc,shimParameterlessSetLocalDescription:Xc,shimRTCIceCandidate:Hc,shimRTCIceCandidateRelayProtocol:Cf,shimSendThrowTypeError:Kc});function rO(){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=bb,a=tO(t),r={browserDetails:a,commonShim:sO,extractVersion:Jr,disableLog:$D,disableWarnings:eO,sdp:aO};switch(a.browser){case"chrome":if(!Ob||!bf||!e.shimChrome)return n("Chrome shim is not included in this adapter release."),r;if(a.version===null)return n("Chrome shim can not determine version, not shimming."),r;n("adapter.js shimming chrome."),r.browserShim=Ob,Yc(t,a),Xc(t),Eb(t,a),wb(t),bf(t,a),Rb(t),Mb(t,a),_b(t),xb(t),Db(t,a),Hc(t),Cf(t),kf(t),Gc(t,a),Kc(t),Ef(t,a);break;case"firefox":if(!qb||!Sf||!e.shimFirefox)return n("Firefox shim is not included in this adapter release."),r;n("adapter.js shimming firefox."),r.browserShim=qb,Yc(t,a),Xc(t),Pb(t,a),Sf(t,a),Nb(t),Ub(t),Lb(t),Ib(t),Bb(t),jb(t),Vb(t),zb(t),Fb(t),Hc(t),kf(t),Gc(t,a),Kc(t);break;case"safari":if(!$b||!e.shimSafari)return n("Safari shim is not included in this adapter release."),r;n("adapter.js shimming safari."),r.browserShim=$b,Yc(t,a),Xc(t),Qb(t),Zb(t),Kb(t),Hb(t),Gb(t),Jb(t),Yb(t),Wb(t),Hc(t),Cf(t),Gc(t,a),Kc(t),Ef(t,a);break;default:n("Unsupported browser!");break}return r}rO({window:typeof window=="undefined"?void 0:window});class Yt extends Promise{constructor(e){super(e)}catch(e){return super.catch(e)}static reject(e){return super.reject(e)}static all(e){return super.all(e)}static race(e){return super.race(e)}}const oO=/version\/(\d+(\.?_?\d+)+)/i;let wf;function Xt(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(typeof navigator=="undefined")return;const n=navigator.userAgent.toLowerCase();if(wf===void 0||e){const a=cO.find(r=>{let{test:c}=r;return c.test(n)});wf=a==null?void 0:a.describe(n)}return wf}const cO=[{test:/firefox|iceweasel|fxios/i,describe(t){return{name:"Firefox",version:Qc(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t),os:t.toLowerCase().includes("fxios")?"iOS":void 0,osVersion:Rf(t)}}},{test:/chrom|crios|crmo/i,describe(t){return{name:"Chrome",version:Qc(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t),os:t.toLowerCase().includes("crios")?"iOS":void 0,osVersion:Rf(t)}}},{test:/safari|applewebkit/i,describe(t){return{name:"Safari",version:Qc(oO,t),os:t.includes("mobile/")?"iOS":"macOS",osVersion:Rf(t)}}}];function Qc(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;const a=e.match(t);return a&&a.length>=n&&a[n]||""}function Rf(t){return t.includes("mac os")?Qc(/\(.+?(\d+_\d+(:?_\d+)?)/,t,1).replace(/_/g,"."):void 0}var lO="2.17.0";const uO=lO,dO=16;class Wn extends Error{constructor(e,n){super(n||"an error has occured"),this.name="LiveKitError",this.code=e}}var Ye;(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",t[t.WebSocket=6]="WebSocket",t[t.ServiceNotFound=7]="ServiceNotFound"})(Ye||(Ye={}));class pe extends Wn{constructor(e,n,a,r){super(1,e),this.name="ConnectionError",this.status=a,this.reason=n,this.context=r,this.reasonName=Ye[n]}static notAllowed(e,n,a){return new pe(e,Ye.NotAllowed,n,a)}static timeout(e){return new pe(e,Ye.Timeout)}static leaveRequest(e,n){return new pe(e,Ye.LeaveRequest,void 0,n)}static internal(e,n){return new pe(e,Ye.InternalError,void 0,n)}static cancelled(e){return new pe(e,Ye.Cancelled)}static serverUnreachable(e,n){return new pe(e,Ye.ServerUnreachable,n)}static websocket(e,n,a){return new pe(e,Ye.WebSocket,n,a)}static serviceNotFound(e,n){return new pe(e,Ye.ServiceNotFound,void 0,n)}}class _f extends Wn{constructor(e){super(21,e!=null?e:"device is unsupported"),this.name="DeviceUnsupportedError"}}class mi extends Wn{constructor(e){super(20,e!=null?e:"track is invalid"),this.name="TrackInvalidError"}}class fO extends Wn{constructor(e){super(10,e!=null?e:"unsupported server"),this.name="UnsupportedServer"}}class dt extends Wn{constructor(e){super(12,e!=null?e:"unexpected connection state"),this.name="UnexpectedConnectionState"}}class Rs extends Wn{constructor(e){super(13,e!=null?e:"unable to negotiate"),this.name="NegotiationError"}}class nS extends Wn{constructor(e,n){super(15,e),this.name="PublishTrackError",this.status=n}}class iS extends Wn{constructor(e,n){super(15,e),this.name="SignalRequestError",this.reason=n,this.reasonName=typeof n=="string"?n:pf[n]}}var qt;(function(t){t[t.AlreadyOpened=0]="AlreadyOpened",t[t.AbnormalEnd=1]="AbnormalEnd",t[t.DecodeFailed=2]="DecodeFailed",t[t.LengthExceeded=3]="LengthExceeded",t[t.Incomplete=4]="Incomplete",t[t.HandlerAlreadyRegistered=7]="HandlerAlreadyRegistered",t[t.EncryptionTypeMismatch=8]="EncryptionTypeMismatch"})(qt||(qt={}));class Sn extends Wn{constructor(e,n){super(16,e),this.name="DataStreamError",this.reason=n,this.reasonName=qt[n]}}class _s extends Wn{constructor(e){super(18,e),this.name="SignalReconnectError"}}var Jc;(function(t){t.PermissionDenied="PermissionDenied",t.NotFound="NotFound",t.DeviceInUse="DeviceInUse",t.Other="Other"})(Jc||(Jc={})),(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})(Jc||(Jc={}));class Mt{}Mt.setTimeout=function(){return setTimeout(...arguments)},Mt.setInterval=function(){return setInterval(...arguments)},Mt.clearTimeout=function(){return clearTimeout(...arguments)},Mt.clearInterval=function(){return clearInterval(...arguments)};var X;(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"})(X||(X={}));var ee;(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.LocalTrackCpuConstrained="localTrackCpuConstrained",t.LocalSenderCreated="localSenderCreated",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.TrackCpuConstrained="trackCpuConstrained",t.MediaDevicesError="mediaDevicesError",t.AudioStreamAcquired="audioStreamAcquired",t.ParticipantPermissionsChanged="participantPermissionsChanged",t.PCTrackAdded="pcTrackAdded",t.AttributesChanged="attributesChanged",t.LocalTrackSubscribed="localTrackSubscribed",t.ChatMessage="chatMessage",t.Active="active"})(ee||(ee={}));var se;(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"})(se||(se={}));var ae;(function(t){t.Message="message",t.Muted="muted",t.Unmuted="unmuted",t.Restarted="restarted",t.Ended="ended",t.Subscribed="subscribed",t.Unsubscribed="unsubscribed",t.CpuConstrained="cpuConstrained",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"})(ae||(ae={}));function hO(t){return typeof t=="undefined"?t:typeof structuredClone=="function"?typeof t=="object"&&t!==null?structuredClone(Object.assign({},t)):structuredClone(t):JSON.parse(JSON.stringify(t))}class Fe{constructor(e,n,a,r,c){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&&a!==void 0)this.width=e,this.height=n,this.aspectRatio=e/n,this.encoding={maxBitrate:a,maxFramerate:r,priority:c};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 mO=["vp8","h264"],pO=["vp8","h264","vp9","av1","h265"];function gO(t){return!!mO.find(e=>e===t)}const vO=gO;var aS;(function(t){t[t.PREFER_REGRESSION=0]="PREFER_REGRESSION",t[t.SIMULCAST=1]="SIMULCAST",t[t.REGRESSION=2]="REGRESSION"})(aS||(aS={}));var xf;(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}})(xf||(xf={}));const Zr={h90:new Fe(160,90,9e4,20),h180:new Fe(320,180,16e4,20),h216:new Fe(384,216,18e4,20),h360:new Fe(640,360,45e4,20),h540:new Fe(960,540,8e5,25),h720:new Fe(1280,720,17e5,30),h1080:new Fe(1920,1080,3e6,30),h1440:new Fe(2560,1440,5e6,30),h2160:new Fe(3840,2160,8e6,30)},Af={h120:new Fe(160,120,7e4,20),h180:new Fe(240,180,125e3,20),h240:new Fe(320,240,14e4,20),h360:new Fe(480,360,33e4,20),h480:new Fe(640,480,5e5,20),h540:new Fe(720,540,6e5,25),h720:new Fe(960,720,13e5,30),h1080:new Fe(1440,1080,23e5,30),h1440:new Fe(1920,1440,38e5,30)},Mf={h360fps3:new Fe(640,360,2e5,3,"medium"),h360fps15:new Fe(640,360,4e5,15,"medium"),h720fps5:new Fe(1280,720,8e5,5,"medium"),h720fps15:new Fe(1280,720,15e5,15,"medium"),h720fps30:new Fe(1280,720,2e6,30,"medium"),h1080fps15:new Fe(1920,1080,25e5,15,"medium"),h1080fps30:new Fe(1920,1080,5e6,30,"medium"),original:new Fe(0,0,7e6,30,"medium")};function sS(t,e,n){var a,r,c,l;const{optionsWithoutProcessor:u,audioProcessor:f,videoProcessor:h}=oS(t!=null?t:{}),p=e==null?void 0:e.processor,v=n==null?void 0:n.processor,y=u!=null?u:{};return y.audio===!0&&(y.audio={}),y.video===!0&&(y.video={}),y.audio&&(Df(y.audio,e),(a=(c=y.audio).deviceId)!==null&&a!==void 0||(c.deviceId={ideal:"default"}),(f||p)&&(y.audio.processor=f!=null?f:p)),y.video&&(Df(y.video,n),(r=(l=y.video).deviceId)!==null&&r!==void 0||(l.deviceId={ideal:"default"}),(h||v)&&(y.video.processor=h!=null?h:v)),y}function Df(t,e){return Object.keys(e).forEach(n=>{t[n]===void 0&&(t[n]=e[n])}),t}function Of(t){var e,n,a,r;const c={};if(t.video)if(typeof t.video=="object"){const l={},u=l,f=t.video;Object.keys(f).forEach(h=>{h==="resolution"?Df(u,f.resolution):u[h]=f[h]}),c.video=l,(e=(a=c.video).deviceId)!==null&&e!==void 0||(a.deviceId={ideal:"default"})}else c.video=t.video?{deviceId:{ideal:"default"}}:!1;else c.video=!1;return t.audio?typeof t.audio=="object"?(c.audio=t.audio,(n=(r=c.audio).deviceId)!==null&&n!==void 0||(r.deviceId={ideal:"default"})):c.audio={deviceId:{ideal:"default"}}:c.audio=!1,c}function rS(t){return A(this,arguments,void 0,function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:200;return(function*(){const a=Pf();if(a){const r=a.createAnalyser();r.fftSize=2048;const c=r.frequencyBinCount,l=new Uint8Array(c);a.createMediaStreamSource(new MediaStream([e.mediaStreamTrack])).connect(r),yield Dt(n),r.getByteTimeDomainData(l);const f=l.some(h=>h!==128&&h!==0);return a.close(),!f}return!1})()})}function Pf(){var t;const e=typeof window!="undefined"&&(window.AudioContext||window.webkitAudioContext);if(e){const n=new e({latencyHint:"interactive"});if(n.state==="suspended"&&typeof window!="undefined"&&(!((t=window.document)===null||t===void 0)&&t.body)){const a=()=>A(this,void 0,void 0,function*(){var r;try{n.state==="suspended"&&(yield n.resume())}catch(c){console.warn("Error trying to auto-resume audio context",c)}finally{(r=window.document.body)===null||r===void 0||r.removeEventListener("click",a)}});n.addEventListener("statechange",()=>{var r;n.state==="closed"&&((r=window.document.body)===null||r===void 0||r.removeEventListener("click",a))}),window.document.body.addEventListener("click",a)}return n}}function yO(t){return t==="audioinput"?Q.Source.Microphone:t==="videoinput"?Q.Source.Camera:Q.Source.Unknown}function Nf(t){return t===Q.Source.Microphone?"audioinput":t===Q.Source.Camera?"videoinput":void 0}function bO(t){var e,n;let a=(e=t.video)!==null&&e!==void 0?e:!0;return t.resolution&&t.resolution.width>0&&t.resolution.height>0&&(a=typeof a=="boolean"?{}:a,za()?a=Object.assign(Object.assign({},a),{width:{max:t.resolution.width},height:{max:t.resolution.height},frameRate:t.resolution.frameRate}):a=Object.assign(Object.assign({},a),{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:a,controller:t.controller,selfBrowserSurface:t.selfBrowserSurface,surfaceSwitching:t.surfaceSwitching,systemAudio:t.systemAudio,preferCurrentTab:t.preferCurrentTab}}function Wr(t){return t.split("/")[1].toLowerCase()}function SO(t){const e=[];return t.forEach(n=>{n.track!==void 0&&e.push(new uf({cid:n.track.mediaStreamID,track:n.trackInfo}))}),e}function xe(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?xe(t.track):{})}}function TO(){return typeof RTCRtpReceiver!="undefined"&&"getSynchronizationSources"in RTCRtpReceiver}function CO(t,e){var n;t===void 0&&(t={}),e===void 0&&(e={});const a=[...Object.keys(e),...Object.keys(t)],r={};for(const c of a)t[c]!==e[c]&&(r[c]=(n=e[c])!==null&&n!==void 0?n:"");return r}function oS(t){const e=Object.assign({},t);let n,a;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&&(a=e.video.processor,e.video=Object.assign(Object.assign({},e.video),{processor:void 0})),{audioProcessor:n,videoProcessor:a,optionsWithoutProcessor:hO(e)}}function kO(t){switch(t){case pt.CAMERA:return Q.Source.Camera;case pt.MICROPHONE:return Q.Source.Microphone;case pt.SCREEN_SHARE:return Q.Source.ScreenShare;case pt.SCREEN_SHARE_AUDIO:return Q.Source.ScreenShareAudio;default:return Q.Source.Unknown}}function cS(t,e){return t.width*t.height<e.width*e.height}function EO(t,e){var n;return(n=t.layers)===null||n===void 0?void 0:n.find(a=>a.quality===e)}const wO=5e3,$r=[];var an;(function(t){t[t.LOW=0]="LOW",t[t.MEDIUM=1]="MEDIUM",t[t.HIGH=2]="HIGH"})(an||(an={}));class Q extends Zn.EventEmitter{get streamState(){return this._streamState}setStreamState(e){this._streamState=e}constructor(e,n){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var r;super(),this.attachedElements=[],this.isMuted=!1,this._streamState=Q.StreamState.Active,this.isInBackground=!1,this._currentBitrate=0,this.log=Ee,this.appVisibilityChangedListener=()=>{this.backgroundTimeout&&clearTimeout(this.backgroundTimeout),document.visibilityState==="hidden"?this.backgroundTimeout=setTimeout(()=>this.handleAppVisibilityChanged(),wO):this.handleAppVisibilityChanged()},this.log=fi((r=a.loggerName)!==null&&r!==void 0?r:jn.Track),this.loggerContextCb=a.loggerContextCb,this.setMaxListeners(100),this.kind=n,this._mediaStreamTrack=e,this._mediaStreamID=e.id,this.source=Q.Source.Unknown}get logContext(){var e;return Object.assign(Object.assign({},(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this)),xe(this))}get currentBitrate(){return this._currentBitrate}get mediaStreamTrack(){return this._mediaStreamTrack}get mediaStreamID(){return this._mediaStreamID}attach(e){let n="audio";this.kind===Q.Kind.Video&&(n="video"),this.attachedElements.length===0&&this.kind===Q.Kind.Video&&this.addAppVisibilityListener(),e||(n==="audio"&&($r.forEach(c=>{c.parentElement===null&&!e&&(e=c)}),e&&$r.splice($r.indexOf(e),1)),e||(e=document.createElement(n))),this.attachedElements.includes(e)||this.attachedElements.push(e),xs(this.mediaStreamTrack,e);const a=e.srcObject.getTracks(),r=a.some(c=>c.kind==="audio");return e.play().then(()=>{this.emit(r?ae.AudioPlaybackStarted:ae.VideoPlaybackStarted)}).catch(c=>{c.name==="NotAllowedError"?this.emit(r?ae.AudioPlaybackFailed:ae.VideoPlaybackFailed,c):c.name==="AbortError"?Ee.debug("".concat(r?"audio":"video"," playback aborted, likely due to new play request")):Ee.warn("could not playback ".concat(r?"audio":"video"),c),r&&e&&a.some(l=>l.kind==="video")&&c.name==="NotAllowedError"&&(e.muted=!0,e.play().catch(()=>{}))}),this.emit(ae.ElementAttached,e),e}detach(e){try{if(e){As(this.mediaStreamTrack,e);const a=this.attachedElements.indexOf(e);return a>=0&&(this.attachedElements.splice(a,1),this.recycleElement(e),this.emit(ae.ElementDetached,e)),e}const n=[];return this.attachedElements.forEach(a=>{As(this.mediaStreamTrack,a),n.push(a),this.recycleElement(a),this.emit(ae.ElementDetached,a)}),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=fi(e.loggerName)),e.loggerContextCb&&(this.loggerContextCb=e.loggerContextCb)}recycleElement(e){if(e instanceof HTMLAudioElement){let n=!0;e.pause(),$r.forEach(a=>{a.parentElement||(n=!1)}),n&&$r.push(e)}}handleAppVisibilityChanged(){return A(this,void 0,void 0,function*(){this.isInBackground=document.visibilityState==="hidden",!this.isInBackground&&this.kind===Q.Kind.Video&&setTimeout(()=>this.attachedElements.forEach(e=>e.play().catch(()=>{})),0)})}addAppVisibilityListener(){Qt()?(this.isInBackground=document.visibilityState==="hidden",document.addEventListener("visibilitychange",this.appVisibilityChangedListener)):this.isInBackground=!1}removeAppVisibilityListener(){Qt()&&document.removeEventListener("visibilitychange",this.appVisibilityChangedListener)}}function xs(t,e){let n;e.srcObject instanceof MediaStream?n=e.srcObject:n=new MediaStream;let a;t.kind==="audio"?a=n.getAudioTracks():a=n.getVideoTracks(),a.includes(t)||(a.forEach(r=>{n.removeTrack(r)}),n.addTrack(t)),(!za()||!(e instanceof HTMLVideoElement))&&(e.autoplay=!0),e.muted=n.getAudioTracks().length===0,e instanceof HTMLVideoElement&&(e.playsInline=!0),e.srcObject!==n&&(e.srcObject=n,(za()||Va())&&e instanceof HTMLVideoElement&&setTimeout(()=>{e.srcObject=n,e.play().catch(()=>{})},0))}function As(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(h){h.Audio="audio",h.Video="video",h.Unknown="unknown"})(e=t.Kind||(t.Kind={}));let n;(function(h){h.Camera="camera",h.Microphone="microphone",h.ScreenShare="screen_share",h.ScreenShareAudio="screen_share_audio",h.Unknown="unknown"})(n=t.Source||(t.Source={}));let a;(function(h){h.Active="active",h.Paused="paused",h.Unknown="unknown"})(a=t.StreamState||(t.StreamState={}));function r(h){switch(h){case e.Audio:return In.AUDIO;case e.Video:return In.VIDEO;default:return In.DATA}}t.kindToProto=r;function c(h){switch(h){case In.AUDIO:return e.Audio;case In.VIDEO:return e.Video;default:return e.Unknown}}t.kindFromProto=c;function l(h){switch(h){case n.Camera:return pt.CAMERA;case n.Microphone:return pt.MICROPHONE;case n.ScreenShare:return pt.SCREEN_SHARE;case n.ScreenShareAudio:return pt.SCREEN_SHARE_AUDIO;default:return pt.UNKNOWN}}t.sourceToProto=l;function u(h){switch(h){case pt.CAMERA:return n.Camera;case pt.MICROPHONE:return n.Microphone;case pt.SCREEN_SHARE:return n.ScreenShare;case pt.SCREEN_SHARE_AUDIO:return n.ScreenShareAudio;default:return n.Unknown}}t.sourceFromProto=u;function f(h){switch(h){case cf.ACTIVE:return a.Active;case cf.PAUSED:return a.Paused;default:return a.Unknown}}t.streamStateFromProto=f})(Q||(Q={}));const RO="|",lS="https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension";function _O(t){const e=t.split(RO);return e.length>1?[e[0],t.substr(e[0].length+1)]:[t,""]}function Dt(t){return new Yt(e=>Mt.setTimeout(e,t))}function Lf(){return"addTransceiver"in RTCPeerConnection.prototype}function If(){return"addTrack"in RTCPeerConnection.prototype}function xO(){if(!("getCapabilities"in RTCRtpSender)||za()||Va())return!1;const t=RTCRtpSender.getCapabilities("video");let e=!1;if(t){for(const n of t.codecs)if(n.mimeType.toLowerCase()==="video/av1"){e=!0;break}}return e}function AO(){if(!("getCapabilities"in RTCRtpSender)||Va())return!1;if(za()){const n=Xt();if(n!=null&&n.version&&zn(n.version,"16")<0||(n==null?void 0:n.os)==="iOS"&&(n!=null&&n.osVersion)&&zn(n.osVersion,"16")<0)return!1}const t=RTCRtpSender.getCapabilities("video");let e=!1;if(t){for(const n of t.codecs)if(n.mimeType.toLowerCase()==="video/vp9"){e=!0;break}}return e}function Vn(t){return t==="av1"||t==="vp9"}function Uf(t){return!document||eo()?!1:(t||(t=document.createElement("audio")),"setSinkId"in t)}function MO(){return typeof RTCPeerConnection=="undefined"?!1:Lf()||If()}function Va(){var t;return((t=Xt())===null||t===void 0?void 0:t.name)==="Firefox"}function uS(){const t=Xt();return!!t&&t.name==="Chrome"&&t.os!=="iOS"}function za(){var t;return((t=Xt())===null||t===void 0?void 0:t.name)==="Safari"}function eo(){const t=Xt();return(t==null?void 0:t.name)==="Safari"||(t==null?void 0:t.os)==="iOS"}function DO(){const t=Xt();return(t==null?void 0:t.name)==="Safari"&&t.version.startsWith("17.")||(t==null?void 0:t.os)==="iOS"&&!!(t!=null&&t.osVersion)&&zn(t.osVersion,"17")>=0}function OO(t){return t||(t=Xt()),(t==null?void 0:t.name)==="Safari"&&zn(t.version,"18.3")>0||(t==null?void 0:t.os)==="iOS"&&!!(t!=null&&t.osVersion)&&zn(t.osVersion,"18.3")>0}function dS(){var t,e;return Qt()?(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 PO(){const t=Xt(),e="17.2";if(t)return t.name!=="Safari"&&t.os!=="iOS"||t.os==="iOS"&&t.osVersion&&zn(t.osVersion,e)>=0?!0:t.name==="Safari"&&zn(t.version,e)>=0}function Qt(){return typeof document!="undefined"}function $n(){return navigator.product=="ReactNative"}function Ms(t){return t.hostname.endsWith(".livekit.cloud")||t.hostname.endsWith(".livekit.run")}function Bf(t){return Ms(t)?t.hostname.split(".")[0]:null}function fS(){if(globalThis&&globalThis.LiveKitReactNativeGlobal)return globalThis.LiveKitReactNativeGlobal}function hS(){if(!$n())return;let t=fS();if(t)return t.platform}function mS(){if(Qt())return window.devicePixelRatio;if($n()){let t=fS();if(t)return t.devicePixelRatio}return 1}function zn(t,e){const n=t.split("."),a=e.split("."),r=Math.min(n.length,a.length);for(let c=0;c<r;++c){const l=parseInt(n[c],10),u=parseInt(a[c],10);if(l>u)return 1;if(l<u)return-1;if(c===r-1&&l===u)return 0}return t===""&&e!==""?-1:e===""?1:n.length==a.length?0:n.length<a.length?-1:1}function NO(t){for(const e of t)e.target.handleResize(e)}function LO(t){for(const e of t)e.target.handleVisibilityChanged(e)}let jf=null;const pS=()=>(jf||(jf=new ResizeObserver(NO)),jf);let Vf=null;const gS=()=>(Vf||(Vf=new IntersectionObserver(LO,{root:null,rootMargin:"0px"})),Vf);function IO(){var t;const e=new J0({sdk:Z0.JS,protocol:dO,version:uO});return $n()&&(e.os=(t=hS())!==null&&t!==void 0?t:""),e}function vS(){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,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;const r=document.createElement("canvas");r.width=t,r.height=e;const c=r.getContext("2d");c==null||c.fillRect(0,0,r.width,r.height),a&&c&&(c.beginPath(),c.arc(t/2,e/2,50,0,Math.PI*2,!0),c.closePath(),c.fillStyle="grey",c.fill());const l=r.captureStream(),[u]=l.getTracks();if(!u)throw Error("Could not get empty media stream video track");return u.enabled=n,u}let to;function zf(){if(!to){const t=new AudioContext,e=t.createOscillator(),n=t.createGain();n.gain.setValueAtTime(0,0);const a=t.createMediaStreamDestination();if(e.connect(n),n.connect(a),e.start(),[to]=a.stream.getAudioTracks(),!to)throw Error("Could not get empty media stream audio track");to.enabled=!1}return to.clone()}class Tn{get isResolved(){return this._isResolved}constructor(e,n){this._isResolved=!1,this.onFinally=n,this.promise=new Promise((a,r)=>A(this,void 0,void 0,function*(){this.resolve=a,this.reject=r,e&&(yield e(a,r))})).finally(()=>{var a;this._isResolved=!0,(a=this.onFinally)===null||a===void 0||a.call(this)})}}function UO(t,e){const n=Object.assign({cloneTrack:!1,fftSize:2048,smoothingTimeConstant:.8,minDecibels:-100,maxDecibels:-80},e),a=Pf();if(!a)throw new Error("Audio Context not supported on this browser");const r=n.cloneTrack?t.mediaStreamTrack.clone():t.mediaStreamTrack,c=a.createMediaStreamSource(new MediaStream([r])),l=a.createAnalyser();l.minDecibels=n.minDecibels,l.maxDecibels=n.maxDecibels,l.fftSize=n.fftSize,l.smoothingTimeConstant=n.smoothingTimeConstant,c.connect(l);const u=new Uint8Array(l.frequencyBinCount);return{calculateVolume:()=>{l.getByteFrequencyData(u);let p=0;for(const y of u)p+=Math.pow(y/255,2);return Math.sqrt(p/u.length)},analyser:l,cleanup:()=>A(this,void 0,void 0,function*(){yield a.close(),n.cloneTrack&&r.stop()})}}function BO(t){return pO.includes(t)}function Gi(t){if(typeof t=="string"||typeof t=="number")return t;if(Array.isArray(t))return t[0];if(t.exact!==void 0)return Array.isArray(t.exact)?t.exact[0]:t.exact;if(t.ideal!==void 0)return Array.isArray(t.ideal)?t.ideal[0]:t.ideal;throw Error("could not unwrap constraint")}function jO(t){return t.startsWith("http")?t.replace(/^(http)/,"ws"):t}function no(t){return t.startsWith("ws")?t.replace(/^(ws)/,"http"):t}function VO(t,e){return t.segments.map(n=>{let{id:a,text:r,language:c,startTime:l,endTime:u,final:f}=n;var h;const p=(h=e.get(a))!==null&&h!==void 0?h:Date.now(),v=Date.now();return f?e.delete(a):e.set(a,p),{id:a,text:r,startTime:Number.parseInt(l.toString()),endTime:Number.parseInt(u.toString()),final:f,language:c,firstReceivedTime:p,lastReceivedTime:v}})}function zO(t){const{id:e,timestamp:n,message:a,editTimestamp:r}=t;return{id:e,timestamp:Number.parseInt(n.toString()),editTimestamp:r?Number.parseInt(r.toString()):void 0,message:a}}function yS(t){switch(t.reason){case Ye.LeaveRequest:return t.context;case Ye.Cancelled:return Un.CLIENT_INITIATED;case Ye.NotAllowed:return Un.USER_REJECTED;case Ye.ServerUnreachable:return Un.JOIN_FAILURE;default:return Un.UNKNOWN_REASON}}function Zc(t){return t!==void 0?Number(t):void 0}function Fa(t){return t!==void 0?BigInt(t):void 0}function Ds(t){return!!t&&!(t instanceof MediaStreamTrack)&&t.isLocal}function ei(t){return!!t&&t.kind==Q.Kind.Audio}function Ki(t){return!!t&&t.kind==Q.Kind.Video}function Yi(t){return Ds(t)&&Ki(t)}function pi(t){return Ds(t)&&ei(t)}function Ff(t){return!!t&&!t.isLocal}function FO(t){return!!t&&!t.isLocal}function qf(t){return Ff(t)&&Ki(t)}function qO(t){return t.isLocal}function HO(t,e){const n=[];let a=new TextEncoder().encode(t);for(;a.length>e;){let r=e;for(;r>0;){const c=a[r];if(c!==void 0&&(c&192)!==128)break;r--}n.push(a.slice(0,r)),a=a.slice(r)}return a.length>0&&n.push(a),n}function GO(t){var e;const n=t.get("Cache-Control");if(n){const a=(e=n.match(/(?:^|[,\s])max-age=(\d+)/))===null||e===void 0?void 0:e[1];if(a)return parseInt(a,10)}}function KO(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const a=YO(t,e);return n?a:Hf(a,"v1")}function YO(t,e){const n=new URL(jO(t));return e.forEach((a,r)=>{n.searchParams.set(r,a)}),Hf(n,"rtc")}function XO(t){const e=new URL(no(t));return Hf(e,"validate")}function bS(t){return t.endsWith("/")?t:"".concat(t,"/")}function Hf(t,e){return t.pathname="".concat(bS(t.pathname)).concat(e),t}function SS(t){if(typeof t=="string")return ib.fromJson(JSON.parse(t),{ignoreUnknownFields:!0});if(t instanceof ArrayBuffer)return ib.fromBinary(new Uint8Array(t));throw new Error("could not decode websocket message: ".concat(typeof t))}function QO(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Unknown reason";if(!(t instanceof AbortSignal))return e;const n=t.reason;switch(typeof n){case"string":return n;case"object":return n instanceof Error?n.message:e;default:return"toString"in n?n.toString():e}}const JO=10,io="lk_e2ee",ZO={sharedKey:!1,ratchetSalt:"LKFrameEncryptionKey",ratchetWindowSize:8,failureTolerance:JO,keyringSize:16};var Xi;(function(t){t.SetKey="setKey",t.RatchetRequest="ratchetRequest",t.KeyRatcheted="keyRatcheted"})(Xi||(Xi={}));var TS;(function(t){t.KeyRatcheted="keyRatcheted"})(TS||(TS={}));var Qi;(function(t){t.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",t.EncryptionError="encryptionError"})(Qi||(Qi={}));var CS;(function(t){t.Error="cryptorError"})(CS||(CS={}));function WO(){return $O()||Gf()}function Gf(){return typeof window.RTCRtpScriptTransform!="undefined"}function $O(){return typeof window.RTCRtpSender!="undefined"&&typeof window.RTCRtpSender.prototype.createEncodedStreams!="undefined"}function eP(t){var e,n,a,r,c;if(((e=t.value)===null||e===void 0?void 0:e.case)!=="sipDtmf"&&((n=t.value)===null||n===void 0?void 0:n.case)!=="metrics"&&((a=t.value)===null||a===void 0?void 0:a.case)!=="speaker"&&((r=t.value)===null||r===void 0?void 0:r.case)!=="transcription"&&((c=t.value)===null||c===void 0?void 0:c.case)!=="encryptedPacket")return new q0({value:t.value})}class B5 extends Zn.EventEmitter{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),this.onKeyRatcheted=(n,a,r)=>{Ee.debug("key ratcheted event received",{ratchetResult:n,participantId:a,keyIndex:r})},this.keyInfoMap=new Map,this.options=Object.assign(Object.assign({},ZO),e),this.on(Xi.KeyRatcheted,this.onKeyRatcheted)}onSetEncryptionKey(e,n,a){const r={key:e,participantIdentity:n,keyIndex:a};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!=null?n:"shared","-").concat(a!=null?a:0),r),this.emit(Xi.SetKey,r)}getKeys(){return Array.from(this.keyInfoMap.values())}getOptions(){return this.options}ratchetKey(e,n){this.emit(Xi.RatchetRequest,e,n)}}var kS;(function(t){t[t.InvalidKey=0]="InvalidKey",t[t.MissingKey=1]="MissingKey",t[t.InternalError=2]="InternalError"})(kS||(kS={}));class tP extends Zn.EventEmitter{constructor(e,n){super(),this.decryptDataRequests=new Map,this.encryptDataRequests=new Map,this.onWorkerMessage=a=>{var r,c;const{kind:l,data:u}=a.data;switch(l){case"error":if(Ee.error(u.error.message),u.uuid){const p=this.decryptDataRequests.get(u.uuid);if(p!=null&&p.reject){p.reject(u.error);break}const v=this.encryptDataRequests.get(u.uuid);if(v!=null&&v.reject){v.reject(u.error);break}}this.emit(Qi.EncryptionError,u.error,u.participantIdentity);break;case"initAck":u.enabled&&this.keyProvider.getKeys().forEach(p=>{this.postKey(p)});break;case"enable":if(u.enabled&&this.keyProvider.getKeys().forEach(p=>{this.postKey(p)}),this.encryptionEnabled!==u.enabled&&u.participantIdentity===((r=this.room)===null||r===void 0?void 0:r.localParticipant.identity))this.emit(Qi.ParticipantEncryptionStatusChanged,u.enabled,this.room.localParticipant),this.encryptionEnabled=u.enabled;else if(u.participantIdentity){const p=(c=this.room)===null||c===void 0?void 0:c.getParticipantByIdentity(u.participantIdentity);if(!p)throw TypeError("couldn't set encryption status, participant not found".concat(u.participantIdentity));this.emit(Qi.ParticipantEncryptionStatusChanged,u.enabled,p)}break;case"ratchetKey":this.keyProvider.emit(Xi.KeyRatcheted,u.ratchetResult,u.participantIdentity,u.keyIndex);break;case"decryptDataResponse":const f=this.decryptDataRequests.get(u.uuid);f!=null&&f.resolve&&f.resolve(u);break;case"encryptDataResponse":const h=this.encryptDataRequests.get(u.uuid);h!=null&&h.resolve&&h.resolve(u);break}},this.onWorkerError=a=>{Ee.error("e2ee worker encountered an error:",{error:a.error}),this.emit(Qi.EncryptionError,a.error,void 0)},this.keyProvider=e.keyProvider,this.worker=e.worker,this.encryptionEnabled=!1,this.dataChannelEncryptionEnabled=n}get isEnabled(){return this.encryptionEnabled}get isDataChannelEncryptionEnabled(){return this.isEnabled&&this.dataChannelEncryptionEnabled}setup(e){if(!WO())throw new _f("tried to setup end-to-end encryption on an unsupported browser");if(Ee.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:XD.getLevel()}};this.worker&&(Ee.info("initializing worker",{worker:this.worker}),this.worker.onmessage=this.onWorkerMessage,this.worker.onerror=this.onWorkerError,this.worker.postMessage(n))}}setParticipantCryptorEnabled(e,n){Ee.debug("set e2ee to ".concat(e," for participant ").concat(n)),this.postEnable(e,n)}setSifTrailer(e){!e||e.length===0?Ee.warn("ignoring server sent trailer as it's empty"):this.postSifTrailer(e)}setupEngine(e){e.on(se.RTPVideoMapUpdate,n=>{this.postRTPMap(n)})}setupEventListeners(e,n){e.on(X.TrackPublished,(a,r)=>this.setParticipantCryptorEnabled(a.trackInfo.encryption!==Ct.NONE,r.identity)),e.on(X.ConnectionStateChanged,a=>{a===Ne.Connected&&e.remoteParticipants.forEach(r=>{r.trackPublications.forEach(c=>{this.setParticipantCryptorEnabled(c.trackInfo.encryption!==Ct.NONE,r.identity)})})}).on(X.TrackUnsubscribed,(a,r,c)=>{var l;const u={kind:"removeTransform",data:{participantIdentity:c.identity,trackId:a.mediaStreamID}};(l=this.worker)===null||l===void 0||l.postMessage(u)}).on(X.TrackSubscribed,(a,r,c)=>{this.setupE2EEReceiver(a,c.identity,r.trackInfo)}).on(X.SignalConnected,()=>{if(!this.room)throw new TypeError("expected room to be present on signal connect");n.getKeys().forEach(a=>{this.postKey(a)}),this.setParticipantCryptorEnabled(this.room.localParticipant.isE2EEEnabled,this.room.localParticipant.identity)}),e.localParticipant.on(ee.LocalSenderCreated,(a,r)=>A(this,void 0,void 0,function*(){this.setupE2EESender(r,a)})),e.localParticipant.on(ee.LocalTrackPublished,a=>{if(!Ki(a.track)||!eo())return;const r={kind:"updateCodec",data:{trackId:a.track.mediaStreamID,codec:Wr(a.trackInfo.codecs[0].mimeType),participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(r)}),n.on(Xi.SetKey,a=>this.postKey(a)).on(Xi.RatchetRequest,(a,r)=>this.postRatchetRequest(a,r))}encryptData(e){return A(this,void 0,void 0,function*(){if(!this.worker)throw Error("could not encrypt data, worker is missing");const n=crypto.randomUUID(),a={kind:"encryptDataRequest",data:{uuid:n,payload:e,participantIdentity:this.room.localParticipant.identity}},r=new Tn;return r.onFinally=()=>{this.encryptDataRequests.delete(n)},this.encryptDataRequests.set(n,r),this.worker.postMessage(a),r.promise})}handleEncryptedData(e,n,a,r){if(!this.worker)throw Error("could not handle encrypted data, worker is missing");const c=crypto.randomUUID(),l={kind:"decryptDataRequest",data:{uuid:c,payload:e,iv:n,participantIdentity:a,keyIndex:r}},u=new Tn;return u.onFinally=()=>{this.decryptDataRequests.delete(c)},this.decryptDataRequests.set(c,u),this.worker.postMessage(l),u.promise}postRatchetRequest(e,n){if(!this.worker)throw Error("could not ratchet key, worker is missing");const a={kind:"ratchetRequest",data:{participantIdentity:e,keyIndex:n}};this.worker.postMessage(a)}postKey(e){let{key:n,participantIdentity:a,keyIndex:r}=e;var c;if(!this.worker)throw Error("could not set key, worker is missing");const l={kind:"setKey",data:{participantIdentity:a,isPublisher:a===((c=this.room)===null||c===void 0?void 0:c.localParticipant.identity),key:n,keyIndex:r}};this.worker.postMessage(l)}postEnable(e,n){if(this.worker){const a={kind:"enable",data:{enabled:e,participantIdentity:n}};this.worker.postMessage(a)}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 a={kind:"setRTPMap",data:{map:e,participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(a)}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,a){if(e.receiver){if(!(a!=null&&a.mimeType)||a.mimeType==="")throw new TypeError("MimeType missing from trackInfo, cannot set up E2EE cryptor");this.handleReceiver(e.receiver,e.mediaStreamID,n,e.kind==="video"?Wr(a.mimeType):void 0)}}setupE2EESender(e,n){if(!Ds(e)||!n){n||Ee.warn("early return because sender is not ready");return}this.handleSender(n,e.mediaStreamID,void 0)}handleReceiver(e,n,a,r){return A(this,void 0,void 0,function*(){if(this.worker){if(Gf()&&!uS()){const c={kind:"decode",participantIdentity:a,trackId:n,codec:r};e.transform=new RTCRtpScriptTransform(this.worker,c)}else{if(io in e&&r){const f={kind:"updateCodec",data:{trackId:n,codec:r,participantIdentity:a}};this.worker.postMessage(f);return}let c=e.writableStream,l=e.readableStream;if(!c||!l){const f=e.createEncodedStreams();e.writableStream=f.writable,c=f.writable,e.readableStream=f.readable,l=f.readable}const u={kind:"decode",data:{readableStream:l,writableStream:c,trackId:n,codec:r,participantIdentity:a,isReuse:io in e}};this.worker.postMessage(u,[l,c])}e[io]=!0}})}handleSender(e,n,a){var r;if(!(io 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(Gf()&&!uS()){Ee.info("initialize script transform");const c={kind:"encode",participantIdentity:this.room.localParticipant.identity,trackId:n,codec:a};e.transform=new RTCRtpScriptTransform(this.worker,c)}else{Ee.info("initialize encoded streams");const c=e.createEncodedStreams(),l={kind:"encode",data:{readableStream:c.readable,writableStream:c.writable,codec:a,trackId:n,participantIdentity:this.room.localParticipant.identity,isReuse:!1}};this.worker.postMessage(l,[c.readable,c.writable])}e[io]=!0}}}const nP=500,iP=15e3;class Os{constructor(){this.failedConnectionAttempts=new Map,this.backOffPromises=new Map}static getInstance(){return this._instance||(this._instance=new Os),this._instance}addFailedConnectionAttempt(e){var n;const a=new URL(e),r=Bf(a);if(!r)return;let c=(n=this.failedConnectionAttempts.get(r))!==null&&n!==void 0?n:0;this.failedConnectionAttempts.set(r,c+1),this.backOffPromises.set(r,Dt(Math.min(nP*Math.pow(2,c),iP)))}getBackOffPromise(e){const n=new URL(e),a=n&&Bf(n);return a&&this.backOffPromises.get(a)||Promise.resolve()}resetFailedConnectionAttempts(e){const n=new URL(e),a=n&&Bf(n);a&&(this.failedConnectionAttempts.set(a,0),this.backOffPromises.set(a,Promise.resolve()))}resetAll(){this.backOffPromises.clear(),this.failedConnectionAttempts.clear()}}Os._instance=null;const Kf="default";class Rt{constructor(){this._previousDevices=[]}static getInstance(){return this.instance===void 0&&(this.instance=new Rt),this.instance}get previousDevices(){return this._previousDevices}getDevices(e){return A(this,arguments,void 0,function(n){var a=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return(function*(){var c;if(((c=Rt.userMediaPromiseMap)===null||c===void 0?void 0:c.size)>0){Ee.debug("awaiting getUserMedia promise");try{n?yield Rt.userMediaPromiseMap.get(n):yield Promise.all(Rt.userMediaPromiseMap.values())}catch{Ee.warn("error waiting for media permissons")}}let l=yield navigator.mediaDevices.enumerateDevices();if(r&&!(za()&&a.hasDeviceInUse(n))&&(l.filter(f=>f.kind===n).length===0||l.some(f=>{const h=f.label==="",p=n?f.kind===n:!0;return h&&p}))){const f={video:n!=="audioinput"&&n!=="audiooutput",audio:n!=="videoinput"&&{deviceId:{ideal:"default"}}},h=yield navigator.mediaDevices.getUserMedia(f);l=yield navigator.mediaDevices.enumerateDevices(),h.getTracks().forEach(p=>{p.stop()})}return a._previousDevices=l,n&&(l=l.filter(u=>u.kind===n)),l})()})}normalizeDeviceId(e,n,a){return A(this,void 0,void 0,function*(){if(n!==Kf)return n;const r=yield this.getDevices(e),c=r.find(u=>u.deviceId===Kf);if(!c){Ee.warn("could not reliably determine default device");return}const l=r.find(u=>u.deviceId!==Kf&&u.groupId===(a!=null?a:c.groupId));if(!l){Ee.warn("could not reliably determine default device");return}return l==null?void 0:l.deviceId})}hasDeviceInUse(e){return e?Rt.userMediaPromiseMap.has(e):Rt.userMediaPromiseMap.size>0}}Rt.mediaDeviceKinds=["audioinput","audiooutput","videoinput"],Rt.userMediaPromiseMap=new Map;var ao;(function(t){t[t.WAITING=0]="WAITING",t[t.RUNNING=1]="RUNNING",t[t.COMPLETED=2]="COMPLETED"})(ao||(ao={}));class aP{constructor(){this.pendingTasks=new Map,this.taskMutex=new zt,this.nextTaskIndex=0}run(e){return A(this,void 0,void 0,function*(){const n={id:this.nextTaskIndex++,enqueuedAt:Date.now(),status:ao.WAITING};this.pendingTasks.set(n.id,n);const a=yield this.taskMutex.lock();try{return n.executedAt=Date.now(),n.status=ao.RUNNING,yield e()}finally{n.status=ao.COMPLETED,this.pendingTasks.delete(n.id),a()}})}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())}}class sP{get readyState(){return this.ws.readyState}constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var a,r;if(!((a=n.signal)===null||a===void 0)&&a.aborted)throw new DOMException("This operation was aborted","AbortError");this.url=e;const c=new WebSocket(e,(r=n.protocols)!==null&&r!==void 0?r:[]);c.binaryType="arraybuffer",this.ws=c;const l=function(){let{closeCode:u,reason:f}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return c.close(u,f)};this.opened=new Yt((u,f)=>{const h=()=>{f(pe.websocket("Encountered websocket error during connection establishment"))};c.onopen=()=>{u({readable:new ReadableStream({start(p){c.onmessage=v=>{let{data:y}=v;return p.enqueue(y)},c.onerror=v=>p.error(v)},cancel:l}),writable:new WritableStream({write(p){c.send(p)},abort(){c.close()},close:l}),protocol:c.protocol,extensions:c.extensions}),c.removeEventListener("error",h)},c.addEventListener("error",h)}),this.closed=new Yt((u,f)=>{const h=()=>A(this,void 0,void 0,function*(){const p=new Yt(y=>{c.readyState!==WebSocket.CLOSED&&c.addEventListener("close",S=>{y(S)},{once:!0})}),v=yield Yt.race([Dt(250),p]);v?u(v):f(pe.websocket("Encountered unspecified websocket error without a timely close event"))});c.onclose=p=>{let{code:v,reason:y}=p;u({closeCode:v,reason:y}),c.removeEventListener("error",h)},c.addEventListener("error",h)}),n.signal&&(n.signal.onabort=()=>c.close()),this.close=l}}const rP=["syncState","trickle","offer","answer","simulate","leave"];function oP(t){const e=rP.indexOf(t.case)>=0;return Ee.trace("request allowed to bypass queue:",{canPass:e,req:t}),e}var Xe;(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"})(Xe||(Xe={}));const cP=250;class Yf{get currentState(){return this.state}get isDisconnected(){return this.state===Xe.DISCONNECTING||this.state===Xe.DISCONNECTED}get isEstablishingConnection(){return this.state===Xe.CONNECTING||this.state===Xe.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 a;this.rtt=0,this.state=Xe.DISCONNECTED,this.log=Ee,this._requestId=0,this.useV0SignalPath=!1,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.onMediaSectionsRequirement=void 0},this.log=fi((a=n.loggerName)!==null&&a!==void 0?a:jn.Signal),this.loggerContextCb=n.loggerContextCb,this.useJSON=e,this.requestQueue=new aP,this.queuedRequests=[],this.closingLock=new zt,this.connectionLock=new zt,this.state=Xe.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,a,r){return A(this,arguments,void 0,function(c,l,u,f){var h=this;let p=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;return(function*(){return h.state=Xe.CONNECTING,h.options=u,yield h.connect(c,l,u,f,p)})()})}reconnect(e,n,a,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=Xe.RECONNECTING,this.clearPingInterval(),yield this.connect(e,n,Object.assign(Object.assign({},this.options),{reconnect:!0,sid:a,reconnectReason:r}),void 0,this.useV0SignalPath)})}connect(e,n,a,r){return A(this,arguments,void 0,function(c,l,u,f){var h=this;let p=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;return(function*(){const v=yield h.connectionLock.lock();h.connectOptions=u,h.useV0SignalPath=p;const y=IO(),S=p?lP(l,y,u):uP(l,y,u),w=KO(c,S,p).toString(),T=XO(w).toString();return new Promise((x,R)=>A(h,void 0,void 0,function*(){var P,L;try{let E=!1;const k=V=>A(this,void 0,void 0,function*(){if(E)return;E=!0;const Y=V instanceof Event?V.currentTarget:V,ie=QO(Y,"Abort handler called");this.streamWriter&&!this.isDisconnected?this.sendLeave().then(()=>this.close(ie)).catch(he=>{this.log.error(he),this.close()}):this.close(),_(),R(pe.cancelled(ie))});f==null||f.addEventListener("abort",k);const _=()=>{clearTimeout(N),f==null||f.removeEventListener("abort",k)},N=setTimeout(()=>{k(pe.timeout("room connection has timed out (signal)"))},u.websocketTimeout),U=(V,Y)=>{this.handleSignalConnected(V,N,Y)},G=new URL(w);G.searchParams.has("access_token")&&G.searchParams.set("access_token","<redacted>"),this.log.debug("connecting to ".concat(G),Object.assign({reconnect:u.reconnect,reconnectReason:u.reconnectReason},this.logContext)),this.ws&&(yield this.close(!1)),this.ws=new sP(w);try{this.ws.closed.then(H=>{var ne;this.isEstablishingConnection&&R(pe.internal("Websocket got closed during a (re)connection attempt: ".concat(H.reason))),H.closeCode!==1e3&&(this.log.warn("websocket closed",Object.assign(Object.assign({},this.logContext),{reason:H.reason,code:H.closeCode,wasClean:H.closeCode===1e3,state:this.state})),this.state===Xe.CONNECTED&&this.handleOnClose((ne=H.reason)!==null&&ne!==void 0?ne:"Unexpected WS error"))}).catch(H=>{this.isEstablishingConnection&&R(pe.internal("Websocket error during a (re)connection attempt: ".concat(H)))});const V=yield this.ws.opened.catch(H=>A(this,void 0,void 0,function*(){if(this.state!==Xe.CONNECTED){this.state=Xe.DISCONNECTED,clearTimeout(N);const ne=yield this.handleConnectionError(H,T);R(ne);return}this.handleWSError(H),R(H)}));if(clearTimeout(N),!V)return;const Y=V.readable.getReader();this.streamWriter=V.writable.getWriter();const ie=yield Y.read();if(Y.releaseLock(),!ie.value)throw pe.internal("no message received as first message");const he=SS(ie.value),be=this.validateFirstMessage(he,(P=u.reconnect)!==null&&P!==void 0?P:!1);if(!be.isValid){R(be.error);return}((L=he.message)===null||L===void 0?void 0:L.case)==="join"&&(this.pingTimeoutDuration=he.message.value.pingTimeout,this.pingIntervalDuration=he.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})));const qe=be.shouldProcessFirstMessage?he:void 0;U(V,qe),x(be.response)}catch(V){R(V)}finally{_()}}finally{v()}}))})()})}startReadingLoop(e,n){return A(this,void 0,void 0,function*(){for(n&&this.handleSignalResponse(n);;){this.signalLatency&&(yield Dt(this.signalLatency));const{done:a,value:r}=yield e.read();if(a)break;const c=SS(r);this.handleSignalResponse(c)}})}close(){return A(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Close method called on signal client";return(function*(){if([Xe.DISCONNECTING||Xe.DISCONNECTED].includes(e.state)){e.log.debug("ignoring signal close as it's already in disconnecting state");return}const r=yield e.closingLock.lock();try{if(e.clearPingInterval(),n&&(e.state=Xe.DISCONNECTING),e.ws){e.ws.close({closeCode:1e3,reason:a});const c=e.ws.closed;e.ws=void 0,e.streamWriter=void 0,yield Promise.race([c,Dt(cP)])}}catch(c){e.log.debug("websocket error while closing",Object.assign(Object.assign({},e.logContext),{error:c}))}finally{n&&(e.state=Xe.DISCONNECTED),r()}})()})}sendOffer(e,n){this.log.debug("sending offer",Object.assign(Object.assign({},this.logContext),{offerSdp:e.sdp})),this.sendRequest({case:"offer",value:Ps(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:Ps(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 Uc({candidateInit:JSON.stringify(e),target:n})})}sendMuteTrack(e,n){return this.sendRequest({case:"mute",value:new Bc({sid:e,muted:n})})}sendAddTrack(e){return this.sendRequest({case:"addTrack",value:e})}sendUpdateLocalMetadata(e,n){return A(this,arguments,void 0,function(a,r){var c=this;let l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){const u=c.getNextRequestId();return yield c.sendRequest({case:"updateMetadata",value:new ff({requestId:u,metadata:a,name:r,attributes:l})}),u})()})}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 rb({trackSid:e,layers:n})})}sendUpdateSubscriptionPermissions(e,n){return this.sendRequest({case:"subscriptionPermission",value:new lb({allParticipants:e,trackPermissions:n})})}sendSimulateScenario(e){return this.sendRequest({case:"simulate",value:e})}sendPing(){return Promise.all([this.sendRequest({case:"ping",value:et.parse(Date.now())}),this.sendRequest({case:"pingReq",value:new fb({timestamp:et.parse(Date.now()),rtt:et.parse(this.rtt)})})])}sendUpdateLocalAudioTrack(e,n){return this.sendRequest({case:"updateAudioTrack",value:new df({trackSid:e,features:n})})}sendLeave(){return this.sendRequest({case:"leave",value:new Vc({reason:Un.CLIENT_INITIATED,action:Es.DISCONNECT})})}sendRequest(e){return A(this,arguments,void 0,function(n){var a=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return(function*(){if(!r&&!oP(n)&&a.state===Xe.RECONNECTING){a.queuedRequests.push(()=>A(a,void 0,void 0,function*(){yield this.sendRequest(n,!0)}));return}if(r||(yield a.requestQueue.flush()),a.signalLatency&&(yield Dt(a.signalLatency)),a.isDisconnected){a.log.debug("skipping signal request (type: ".concat(n.case,") - SignalClient disconnected"));return}if(!a.streamWriter){a.log.error("cannot send signal request before connected, type: ".concat(n==null?void 0:n.case),a.logContext);return}const l=new bD({message:n});try{a.useJSON?yield a.streamWriter.write(l.toJsonString()):yield a.streamWriter.write(l.toBinary())}catch(u){a.log.error("error sending signal message",Object.assign(Object.assign({},a.logContext),{error:u}))}})()})}handleSignalResponse(e){var n,a;const r=e.message;if(r==null){this.log.debug("received unsupported message",this.logContext);return}let c=!1;if(r.case==="answer"){const l=ES(r.value);this.onAnswer&&this.onAnswer(l,r.value.id,r.value.midToTrackId)}else if(r.case==="offer"){const l=ES(r.value);this.onOffer&&this.onOffer(l,r.value.id,r.value.midToTrackId)}else if(r.case==="trickle"){const l=JSON.parse(r.value.candidateInit);this.onTrickle&&this.onTrickle(l,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((a=r.value.speakers)!==null&&a!==void 0?a:[]):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(),c=!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)):r.case==="mediaSectionsRequirement"?this.onMediaSectionsRequirement&&this.onMediaSectionsRequirement(r.value):this.log.debug("unsupported message",Object.assign(Object.assign({},this.logContext),{msgCase:r.case})));c||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===Xe.DISCONNECTED)return;const n=this.onClose;yield this.close(void 0,e),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=Mt.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&&Mt.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=Mt.setInterval(()=>{this.sendPing()},this.pingIntervalDuration*1e3)}clearPingInterval(){this.log.debug("clearing ping interval",this.logContext),this.clearPingTimeout(),this.pingInterval&&Mt.clearInterval(this.pingInterval)}handleSignalConnected(e,n,a){this.state=Xe.CONNECTED,clearTimeout(n),this.startPingInterval(),this.startReadingLoop(e.readable.getReader(),a)}validateFirstMessage(e,n){var a,r,c,l,u;return((a=e.message)===null||a===void 0?void 0:a.case)==="join"?{isValid:!0,response:e.message.value}:this.state===Xe.RECONNECTING&&((r=e.message)===null||r===void 0?void 0:r.case)!=="leave"?((c=e.message)===null||c===void 0?void 0:c.case)==="reconnect"?{isValid:!0,response:e.message.value}:(this.log.debug("declaring signal reconnected without reconnect response received",this.logContext),{isValid:!0,response:void 0,shouldProcessFirstMessage:!0}):this.isEstablishingConnection&&((l=e.message)===null||l===void 0?void 0:l.case)==="leave"?{isValid:!1,error:pe.leaveRequest("Received leave request while trying to (re)connect",e.message.value.reason)}:n?{isValid:!1,error:pe.internal("Unexpected first message")}:{isValid:!1,error:pe.internal("did not receive join response, got ".concat((u=e.message)===null||u===void 0?void 0:u.case," instead"))}}handleConnectionError(e,n){return A(this,void 0,void 0,function*(){try{const a=yield fetch(n);switch(a.status){case 404:return pe.serviceNotFound("v1 RTC path not found. Consider upgrading your LiveKit server version","v0-rtc");case 401:case 403:const r=yield a.text();return pe.notAllowed(r,a.status);default:break}return e instanceof pe?e:pe.internal("Encountered unknown websocket error during connection: ".concat(e),{status:a.status,statusText:a.statusText})}catch(a){return a instanceof pe?a:pe.serverUnreachable(a instanceof Error?a.message:"server was not reachable")}})}}function ES(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 Ps(t,e){return new Hi({sdp:t.sdp,type:t.type,id:e})}function lP(t,e,n){var a;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",$n()?"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()),!((a=navigator.connection)===null||a===void 0)&&a.type&&r.set("network",navigator.connection.type),r}function uP(t,e,n){const a=new URLSearchParams;a.set("access_token",t);const r=new zD({clientInfo:e,connectionSettings:new hb({autoSubscribe:!!n.autoSubscribe,adaptiveStream:!!n.adaptiveStream}),reconnect:!!n.reconnect,participantSid:n.sid?n.sid:void 0});n.reconnectReason&&(r.reconnectReason=n.reconnectReason);const c=new FD({joinRequest:r.toBinary()});return a.set("join_request",btoa(new TextDecoder("utf-8").decode(c.toBinary()))),a}class wS{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 dP{constructor(e){this._map=new Map,this._lastCleanup=0,this.ttl=e}set(e,n){const a=Date.now();a-this._lastCleanup>this.ttl/2&&this.cleanup();const r=a+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,a]of this._map.entries())a.expiresAt<e&&this._map.delete(n);this._lastCleanup=e}get size(){return this.cleanup(),this._map.size}forEach(e){this.cleanup();for(const[n,a]of this._map.entries())a.expiresAt>=Date.now()&&e(a.value,n,this.asValueMap())}map(e){this.cleanup();const n=[],a=this.asValueMap();for(const[r,c]of a.entries())n.push(e(c,r,a));return n}asValueMap(){const e=new Map;for(const[n,a]of this._map.entries())a.expiresAt>=Date.now()&&e.set(n,a.value);return e}}var Fn={},Xf={},Qf={exports:{}},RS;function Jf(){if(RS)return Qf.exports;RS=1;var t=Qf.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(a){a.reg||(a.reg=/(.*)/),a.format||(a.format="%s")})}),Qf.exports}var _S;function fP(){return _S||(_S=1,(function(t){var e=function(u){return String(Number(u))===u?Number(u):u},n=function(u,f,h,p){if(p&&!h)f[p]=e(u[1]);else for(var v=0;v<h.length;v+=1)u[v+1]!=null&&(f[h[v]]=e(u[v+1]))},a=function(u,f,h){var p=u.name&&u.names;u.push&&!f[u.push]?f[u.push]=[]:p&&!f[u.name]&&(f[u.name]={});var v=u.push?{}:p?f[u.name]:f;n(h.match(u.reg),v,u.names,u.name),u.push&&f[u.push].push(v)},r=Jf(),c=RegExp.prototype.test.bind(/^([a-z])=(.*)/);t.parse=function(u){var f={},h=[],p=f;return u.split(/(\r\n|\r|\n)/).filter(c).forEach(function(v){var y=v[0],S=v.slice(2);y==="m"&&(h.push({rtp:[],fmtp:[]}),p=h[h.length-1]);for(var w=0;w<(r[y]||[]).length;w+=1){var T=r[y][w];if(T.reg.test(S))return a(T,p,S)}}),f.media=h,f};var l=function(u,f){var h=f.split(/=(.+)/,2);return h.length===2?u[h[0]]=e(h[1]):h.length===1&&f.length>1&&(u[h[0]]=void 0),u};t.parseParams=function(u){return u.split(/;\s?/).reduce(l,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(u){return u.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(u){for(var f=[],h=u.split(" ").map(e),p=0;p<h.length;p+=3)f.push({component:h[p],ip:h[p+1],port:h[p+2]});return f},t.parseImageAttributes=function(u){return u.split(" ").map(function(f){return f.substring(1,f.length-1).split(",").reduce(l,{})})},t.parseSimulcastStreamList=function(u){return u.split(";").map(function(f){return f.split(",").map(function(h){var p,v=!1;return h[0]!=="~"?p=e(h):(p=e(h.substring(1,h.length)),v=!0),{scid:p,paused:v}})})}})(Xf)),Xf}var Zf,xS;function hP(){if(xS)return Zf;xS=1;var t=Jf(),e=/%[sdv%]/g,n=function(l){var u=1,f=arguments,h=f.length;return l.replace(e,function(p){if(u>=h)return p;var v=f[u];switch(u+=1,p){case"%%":return"%";case"%s":return String(v);case"%d":return Number(v);case"%v":return""}})},a=function(l,u,f){var h=u.format instanceof Function?u.format(u.push?f:f[u.name]):u.format,p=[l+"="+h];if(u.names)for(var v=0;v<u.names.length;v+=1){var y=u.names[v];u.name?p.push(f[u.name][y]):p.push(f[u.names[v]])}else p.push(f[u.name]);return n.apply(null,p)},r=["v","o","s","i","u","e","p","c","b","t","r","z","a"],c=["i","c","b","a"];return Zf=function(l,u){u=u||{},l.version==null&&(l.version=0),l.name==null&&(l.name=" "),l.media.forEach(function(v){v.payloads==null&&(v.payloads="")});var f=u.outerOrder||r,h=u.innerOrder||c,p=[];return f.forEach(function(v){t[v].forEach(function(y){y.name in l&&l[y.name]!=null?p.push(a(v,y,l)):y.push in l&&l[y.push]!=null&&l[y.push].forEach(function(S){p.push(a(v,y,S))})})}),l.media.forEach(function(v){p.push(a("m",t.m[0],v)),h.forEach(function(y){t[y].forEach(function(S){S.name in v&&v[S.name]!=null?p.push(a(y,S,v)):S.push in v&&v[S.push]!=null&&v[S.push].forEach(function(w){p.push(a(y,S,w))})})})}),p.join(`\r
|
|
45
|
+
`)+`\r
|
|
46
|
+
`},Zf}var AS;function mP(){if(AS)return Fn;AS=1;var t=fP(),e=hP(),n=Jf();return Fn.grammar=n,Fn.write=e,Fn.parse=t.parse,Fn.parseParams=t.parseParams,Fn.parseFmtpConfig=t.parseFmtpConfig,Fn.parsePayloads=t.parsePayloads,Fn.parseRemoteCandidates=t.parseRemoteCandidates,Fn.parseImageAttributes=t.parseImageAttributes,Fn.parseSimulcastStreamList=t.parseSimulcastStreamList,Fn}var Ji=mP();function Wf(t,e,n){var a,r,c;e===void 0&&(e=50),n===void 0&&(n={});var l=(a=n.isImmediate)!=null&&a,u=(r=n.callback)!=null&&r,f=n.maxWait,h=Date.now(),p=[];function v(){if(f!==void 0){var S=Date.now()-h;if(S+e>=f)return f-S}return e}var y=function(){var S=[].slice.call(arguments),w=this;return new Promise(function(T,x){var R=l&&c===void 0;if(c!==void 0&&clearTimeout(c),c=setTimeout(function(){if(c=void 0,h=Date.now(),!l){var L=t.apply(w,S);u&&u(L),p.forEach(function(E){return(0,E.resolve)(L)}),p=[]}},v()),R){var P=t.apply(w,S);return u&&u(P),T(P)}p.push({resolve:T,reject:x})})};return y.cancel=function(S){c!==void 0&&clearTimeout(c),p.forEach(function(w){return(0,w.reject)(S)}),p=[]},y}const pP=.7,gP=20,Ns={NegotiationStarted:"negotiationStarted",NegotiationComplete:"negotiationComplete",RTPVideoPayloadTypes:"rtpVideoPayloadTypes"};class MS extends Zn.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 a;super(),this.log=Ee,this.ddExtID=0,this.latestOfferId=0,this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate=!1,this.trackBitrates=[],this.remoteStereoMids=[],this.remoteNackMids=[],this.negotiate=Wf(r=>A(this,void 0,void 0,function*(){this.emit(Ns.NegotiationStarted);try{yield this.createAndSendOffer()}catch(c){if(r)r(c);else throw c}}),gP),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=fi((a=n.loggerName)!==null&&a!==void 0?a:jn.PCTransport),this.loggerOptions=n,this.config=e,this._pc=this.createPC(),this.offerLock=new zt}createPC(){const e=new RTCPeerConnection(this.config);return e.onicecandidate=n=>{var a;n.candidate&&((a=this.onIceCandidate)===null||a===void 0||a.call(this,n.candidate))},e.onicecandidateerror=n=>{var a;(a=this.onIceCandidateError)===null||a===void 0||a.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 a;(a=this.onDataChannel)===null||a===void 0||a.call(this,n)},e.ontrack=n=>{var a;(a=this.onTrack)===null||a===void 0||a.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 a;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:c,nackMids:l}=vP(e);this.remoteStereoMids=c,this.remoteNackMids=l}else if(e.type==="answer"){const c=Ji.parse((a=e.sdp)!==null&&a!==void 0?a:"");c.media.forEach(l=>{const u=$f(l.mid);l.type==="audio"&&this.trackBitrates.some(f=>{if(!f.transceiver||u!=f.transceiver.mid)return!1;let h=0;if(l.rtp.some(v=>v.codec.toUpperCase()===f.codec.toUpperCase()?(h=v.payload,!0):!1),h===0)return!0;let p=!1;for(const v of l.fmtp)if(v.payload===h){v.config=v.config.split(";").filter(y=>!y.includes("maxaveragebitrate")).join(";"),f.maxbr>0&&(v.config+=";maxaveragebitrate=".concat(f.maxbr*1e3)),p=!0;break}return p||f.maxbr>0&&l.fmtp.push({payload:h,config:"maxaveragebitrate=".concat(f.maxbr*1e3)}),!0})}),r=Ji.write(c)}return yield this.setMungedSDP(e,r,!0),this.pendingCandidates.forEach(c=>{this.pc.addIceCandidate(c)}),this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate?(this.renegotiate=!1,yield this.createAndSendOffer()):e.type==="answer"&&(this.emit(Ns.NegotiationComplete),e.sdp&&Ji.parse(e.sdp).media.forEach(l=>{l.type==="video"&&this.emit(Ns.RTPVideoPayloadTypes,l.rtp)})),!0})}createAndSendOffer(e){return A(this,void 0,void 0,function*(){var n;const a=yield this.offerLock.lock();try{if(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 u=this._pc.remoteDescription;if(e!=null&&e.iceRestart&&u)yield this._pc.setRemoteDescription(u);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=this.latestOfferId+1;this.latestOfferId=r;const c=yield this.pc.createOffer(e);this.log.debug("original offer",Object.assign({sdp:c.sdp},this.logContext));const l=Ji.parse((n=c.sdp)!==null&&n!==void 0?n:"");if(l.media.forEach(u=>{OS(u),u.type==="audio"?DS(u,["all"],[]):u.type==="video"&&this.trackBitrates.some(f=>{if(!u.msid||!f.cid||!u.msid.includes(f.cid))return!1;let h=0;if(u.rtp.some(v=>v.codec.toUpperCase()===f.codec.toUpperCase()?(h=v.payload,!0):!1),h===0||(Vn(f.codec)&&!za()&&this.ensureVideoDDExtensionForSVC(u,l),!Vn(f.codec)))return!0;const p=Math.round(f.maxbr*pP);for(const v of u.fmtp)if(v.payload===h){v.config.includes("x-google-start-bitrate")||(v.config+=";x-google-start-bitrate=".concat(p));break}return!0})}),this.latestOfferId>r){this.log.warn("latestOfferId mismatch",Object.assign(Object.assign({},this.logContext),{latestOfferId:this.latestOfferId,offerId:r}));return}yield this.setMungedSDP(c,Ji.write(l)),this.onOffer(c,this.latestOfferId)}finally{a()}})}createAndSetAnswer(){return A(this,void 0,void 0,function*(){var e;const n=yield this.pc.createAnswer(),a=Ji.parse((e=n.sdp)!==null&&e!==void 0?e:"");return a.media.forEach(r=>{OS(r),r.type==="audio"&&DS(r,this.remoteStereoMids,this.remoteNackMids)}),yield this.setMungedSDP(n,Ji.write(a)),n})}createDataChannel(e,n){return this.pc.createDataChannel(e,n)}addTransceiver(e,n){return this.pc.addTransceiver(e,n)}addTransceiverOfKind(e,n){return this.pc.addTransceiver(e,n)}addTrack(e){if(!this._pc)throw new dt("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 dt("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 a=new Map,r=new Map;if((yield this._pc.getStats()).forEach(u=>{switch(u.type){case"transport":n=u.selectedCandidatePairId;break;case"candidate-pair":n===""&&u.selected&&(n=u.id),a.set(u.id,u);break;case"remote-candidate":r.set(u.id,"".concat(u.address,":").concat(u.port));break}}),n==="")return;const l=(e=a.get(n))===null||e===void 0?void 0:e.remoteCandidateId;if(l!==void 0)return r.get(l)})}setMungedSDP(e,n,a){return A(this,void 0,void 0,function*(){if(n){const r=e.sdp;e.sdp=n;try{this.log.debug("setting munged ".concat(a?"remote":"local"," description"),this.logContext),a?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e);return}catch(c){this.log.warn("not able to set ".concat(e.type,", falling back to unmodified sdp"),Object.assign(Object.assign({},this.logContext),{error:c,sdp:n})),e.sdp=r}}try{a?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e)}catch(r){let c="unknown error";r instanceof Error?c=r.message:typeof r=="string"&&(c=r);const l={error:c,sdp:e.sdp};throw!a&&this.pc.remoteDescription&&(l.remoteSdp=this.pc.remoteDescription),this.log.error("unable to set ".concat(e.type),Object.assign(Object.assign({},this.logContext),{fields:l})),new Rs(c)}})}ensureVideoDDExtensionForSVC(e,n){var a,r;if(!((a=e.ext)===null||a===void 0?void 0:a.some(l=>l.uri===lS))){if(this.ddExtID===0){let l=0;n.media.forEach(u=>{var f;u.type==="video"&&((f=u.ext)===null||f===void 0||f.forEach(h=>{h.value>l&&(l=h.value)}))}),this.ddExtID=l+1}(r=e.ext)===null||r===void 0||r.push({value:this.ddExtID,uri:lS})}}}function DS(t,e,n){const a=$f(t.mid);let r=0;t.rtp.some(c=>c.codec==="opus"?(r=c.payload,!0):!1),r>0&&(t.rtcpFb||(t.rtcpFb=[]),n.includes(a)&&!t.rtcpFb.some(c=>c.payload===r&&c.type==="nack")&&t.rtcpFb.push({payload:r,type:"nack"}),(e.includes(a)||e.length===1&&e[0]==="all")&&t.fmtp.some(c=>c.payload===r?(c.config.includes("stereo=1")||(c.config+=";stereo=1"),!0):!1))}function vP(t){var e;const n=[],a=[],r=Ji.parse((e=t.sdp)!==null&&e!==void 0?e:"");let c=0;return r.media.forEach(l=>{var u;const f=$f(l.mid);l.type==="audio"&&(l.rtp.some(h=>h.codec==="opus"?(c=h.payload,!0):!1),!((u=l.rtcpFb)===null||u===void 0)&&u.some(h=>h.payload===c&&h.type==="nack")&&a.push(f),l.fmtp.some(h=>h.payload===c?(h.config.includes("sprop-stereo=1")&&n.push(f),!0):!1))}),{stereoMids:n,nackMids:a}}function OS(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)}}function $f(t){return typeof t=="number"?t.toFixed(0):t}const eh="vp8",yP={audioPreset:xf.music,dtx:!0,red:!0,forceStereo:!1,simulcast:!0,screenShareEncoding:Mf.h1080fps15.encoding,stopMicTrackOnMute:!1,videoCodec:eh,backupCodec:!0,preConnectBuffer:!1},PS={deviceId:{ideal:"default"},autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,voiceIsolation:!0},NS={deviceId:{ideal:"default"},resolution:Zr.h720.resolution},bP={adaptiveStream:!1,dynacast:!1,stopLocalTrackOnUnpublish:!0,reconnectPolicy:new JD,disconnectOnPageLeave:!0,webAudioMix:!1,singlePeerConnection:!0},th={autoSubscribe:!0,maxRetries:1,peerConnectionTimeout:15e3,websocketTimeout:15e3};var rt;(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"})(rt||(rt={}));class SP{get needsPublisher(){return this.isPublisherConnectionRequired}get needsSubscriber(){return this.isSubscriberConnectionRequired}get currentState(){return this.state}get mode(){return this._mode}constructor(e,n,a){var r;this.peerConnectionTimeout=th.peerConnectionTimeout,this.log=Ee,this.updateState=()=>{var c,l;const u=this.state,f=this.requiredTransports.map(h=>h.getConnectionState());f.every(h=>h==="connected")?this.state=rt.CONNECTED:f.some(h=>h==="failed")?this.state=rt.FAILED:f.some(h=>h==="connecting")?this.state=rt.CONNECTING:f.every(h=>h==="closed")?this.state=rt.CLOSED:f.some(h=>h==="closed")?this.state=rt.CLOSING:f.every(h=>h==="new")&&(this.state=rt.NEW),u!==this.state&&(this.log.debug("pc state change: from ".concat(rt[u]," to ").concat(rt[this.state]),this.logContext),(c=this.onStateChange)===null||c===void 0||c.call(this,this.state,this.publisher.getConnectionState(),(l=this.subscriber)===null||l===void 0?void 0:l.getConnectionState()))},this.log=fi((r=a.loggerName)!==null&&r!==void 0?r:jn.PCManager),this.loggerOptions=a,this.isPublisherConnectionRequired=n!=="subscriber-primary",this.isSubscriberConnectionRequired=n==="subscriber-primary",this.publisher=new MS(e,a),this._mode=n,n!=="publisher-only"&&(this.subscriber=new MS(e,a),this.subscriber.onConnectionStateChange=this.updateState,this.subscriber.onIceConnectionStateChange=this.updateState,this.subscriber.onSignalingStatechange=this.updateState,this.subscriber.onIceCandidate=c=>{var l;(l=this.onIceCandidate)===null||l===void 0||l.call(this,c,Bn.SUBSCRIBER)},this.subscriber.onDataChannel=c=>{var l;(l=this.onDataChannel)===null||l===void 0||l.call(this,c)},this.subscriber.onTrack=c=>{var l;(l=this.onTrack)===null||l===void 0||l.call(this,c)}),this.publisher.onConnectionStateChange=this.updateState,this.publisher.onIceConnectionStateChange=this.updateState,this.publisher.onSignalingStatechange=this.updateState,this.publisher.onIceCandidate=c=>{var l;(l=this.onIceCandidate)===null||l===void 0||l.call(this,c,Bn.PUBLISHER)},this.publisher.onTrack=c=>{var l;(l=this.onTrack)===null||l===void 0||l.call(this,c)},this.publisher.onOffer=(c,l)=>{var u;(u=this.onPublisherOffer)===null||u===void 0||u.call(this,c,l)},this.state=rt.NEW,this.connectionLock=new zt,this.remoteOfferLock=new zt}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()}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*(){var e;if(this.publisher&&this.publisher.getSignallingState()!=="closed"){const n=this.publisher;for(const a of n.getSenders())try{n.canRemoveTrack()&&n.removeTrack(a)}catch(r){this.log.warn("could not removeTrack",Object.assign(Object.assign({},this.logContext),{error:r}))}}yield Promise.all([this.publisher.close(),(e=this.subscriber)===null||e===void 0?void 0:e.close()]),this.updateState()})}triggerIceRestart(){return A(this,void 0,void 0,function*(){this.subscriber&&(this.subscriber.restartingIce=!0),this.needsPublisher&&(yield this.createAndSendPublisherOffer({iceRestart:!0}))})}addIceCandidate(e,n){return A(this,void 0,void 0,function*(){var a;n===Bn.PUBLISHER?yield this.publisher.addIceCandidate(e):yield(a=this.subscriber)===null||a===void 0?void 0:a.addIceCandidate(e)})}createSubscriberAnswerFromOffer(e,n){return A(this,void 0,void 0,function*(){var a,r,c;this.log.debug("received server offer",Object.assign(Object.assign({},this.logContext),{RTCSdpType:e.type,sdp:e.sdp,signalingState:(a=this.subscriber)===null||a===void 0?void 0:a.getSignallingState().toString()}));const l=yield this.remoteOfferLock.lock();try{return(yield(r=this.subscriber)===null||r===void 0?void 0:r.setRemoteDescription(e,n))?yield(c=this.subscriber)===null||c===void 0?void 0:c.createAndSetAnswer():void 0}finally{l()}})}updateConfiguration(e,n){var a;this.publisher.setConfiguration(e),(a=this.subscriber)===null||a===void 0||a.setConfiguration(e),n&&this.triggerIceRestart()}ensurePCTransportConnection(e,n){return A(this,void 0,void 0,function*(){var a;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((a=this.requiredTransports)===null||a===void 0?void 0:a.map(c=>this.ensureTransportConnected(c,e,n)))}finally{r()}})}negotiate(e){return A(this,void 0,void 0,function*(){return new Yt((n,a)=>A(this,void 0,void 0,function*(){const r=setTimeout(()=>{a(new Rs("negotiation timed out"))},this.peerConnectionTimeout),c=()=>{clearTimeout(r),a(new Rs("negotiation aborted"))};e.signal.addEventListener("abort",c),this.publisher.once(Ns.NegotiationStarted,()=>{e.signal.aborted||this.publisher.once(Ns.NegotiationComplete,()=>{clearTimeout(r),n()})}),yield this.publisher.negotiate(l=>{clearTimeout(r),l instanceof Error?a(l):a(new Error(String(l)))})}))})}addPublisherTransceiver(e,n){return this.publisher.addTransceiver(e,n)}addPublisherTransceiverOfKind(e,n){return this.publisher.addTransceiverOfKind(e,n)}getMidForReceiver(e){const a=(this.subscriber?this.subscriber.getTransceivers():this.publisher.getTransceivers()).find(r=>r.receiver===e);return a==null?void 0:a.mid}addPublisherTrack(e){return this.publisher.addTrack(e)}createPublisherDataChannel(e,n){return this.publisher.createDataChannel(e,n)}getConnectedAddress(e){return e===Bn.PUBLISHER?this.publisher.getConnectedAddress():e===Bn.SUBSCRIBER?this.publisher.getConnectedAddress():this.requiredTransports[0].getConnectedAddress()}get requiredTransports(){const e=[];return this.isPublisherConnectionRequired&&e.push(this.publisher),this.isSubscriberConnectionRequired&&this.subscriber&&e.push(this.subscriber),e}ensureTransportConnected(e,n){return A(this,arguments,void 0,function(a,r){var c=this;let l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.peerConnectionTimeout;return(function*(){if(a.getConnectionState()!=="connected")return new Promise((f,h)=>A(c,void 0,void 0,function*(){const p=()=>{this.log.warn("abort transport connection",this.logContext),Mt.clearTimeout(v),h(pe.cancelled("room connection has been cancelled"))};r!=null&&r.signal.aborted&&p(),r==null||r.signal.addEventListener("abort",p);const v=Mt.setTimeout(()=>{r==null||r.signal.removeEventListener("abort",p),h(pe.internal("could not establish pc connection"))},l);for(;this.state!==rt.CONNECTED;)if(yield Dt(50),r!=null&&r.signal.aborted){h(pe.cancelled("room connection has been cancelled"));return}Mt.clearTimeout(v),r==null||r.signal.removeEventListener("abort",p),f()}))})()})}}const LS=5e3,TP=3e4;class Ie{static fetchRegionSettings(e,n,a){return A(this,void 0,void 0,function*(){const r=yield Ie.fetchLock.lock();try{const c=yield fetch("".concat(CP(e),"/regions"),{headers:{authorization:"Bearer ".concat(n)},signal:a});if(c.ok){const l=GO(c.headers),u=l?l*1e3:LS;return{regionSettings:yield c.json(),updatedAtInMs:Date.now(),maxAgeInMs:u}}else throw c.status===401?pe.notAllowed("Could not fetch region settings: ".concat(c.statusText),c.status):pe.internal("Could not fetch region settings: ".concat(c.statusText))}catch(c){throw c instanceof pe?c:a!=null&&a.aborted?pe.cancelled("Region fetching was aborted"):pe.serverUnreachable("Could not fetch region settings, ".concat(c instanceof Error?"".concat(c.name,": ").concat(c.message):c))}finally{r()}})}static scheduleRefetch(e,n,a){return A(this,void 0,void 0,function*(){const r=Ie.settingsTimeouts.get(e.hostname);clearTimeout(r),Ie.settingsTimeouts.set(e.hostname,setTimeout(()=>A(this,void 0,void 0,function*(){try{const c=yield Ie.fetchRegionSettings(e,n);Ie.updateCachedRegionSettings(e,n,c)}catch(c){if(c instanceof pe&&c.reason===Ye.NotAllowed){Ee.debug("token is not valid, cancelling auto region refresh");return}Ee.debug("auto refetching of region settings failed",{error:c}),Ie.scheduleRefetch(e,n,a)}}),a))})}static updateCachedRegionSettings(e,n,a){Ie.cache.set(e.hostname,a),Ie.scheduleRefetch(e,n,a.maxAgeInMs)}static stopRefetch(e){const n=Ie.settingsTimeouts.get(e);n&&(clearTimeout(n),Ie.settingsTimeouts.delete(e))}static scheduleCleanup(e){let n=Ie.connectionTrackers.get(e);n&&(n.cleanupTimeout&&clearTimeout(n.cleanupTimeout),n.cleanupTimeout=setTimeout(()=>{const a=Ie.connectionTrackers.get(e);a&&a.connectionCount===0&&(Ee.debug("stopping region refetch after disconnect delay",{hostname:e}),Ie.stopRefetch(e)),a&&(a.cleanupTimeout=void 0)},TP))}static cancelCleanup(e){const n=Ie.connectionTrackers.get(e);n!=null&&n.cleanupTimeout&&(clearTimeout(n.cleanupTimeout),n.cleanupTimeout=void 0)}notifyConnected(){const e=this.serverUrl.hostname;let n=Ie.connectionTrackers.get(e);n||(n={connectionCount:0},Ie.connectionTrackers.set(e,n)),n.connectionCount++,Ie.cancelCleanup(e)}notifyDisconnected(){const e=this.serverUrl.hostname,n=Ie.connectionTrackers.get(e);n&&(n.connectionCount=Math.max(0,n.connectionCount-1),n.connectionCount===0&&Ie.scheduleCleanup(e))}constructor(e,n){this.attemptedRegions=[],this.serverUrl=new URL(e),this.token=n}updateToken(e){this.token=e}isCloud(){return Ms(this.serverUrl)}getServerUrl(){return this.serverUrl}fetchRegionSettings(e){return A(this,void 0,void 0,function*(){return Ie.fetchRegionSettings(this.serverUrl,this.token,e)})}getNextBestRegionUrl(e){return A(this,void 0,void 0,function*(){if(!this.isCloud())throw Error("region availability is only supported for LiveKit Cloud domains");let n=Ie.cache.get(this.serverUrl.hostname);(!n||Date.now()-n.updatedAtInMs>n.maxAgeInMs)&&(n=yield this.fetchRegionSettings(e),Ie.updateCachedRegionSettings(this.serverUrl,this.token,n));const a=n.regionSettings.regions.filter(r=>!this.attemptedRegions.find(c=>c.url===r.url));if(a.length>0){const r=a[0];return this.attemptedRegions.push(r),Ee.debug("next region: ".concat(r.region)),r.url}else return null})}resetAttempts(){this.attemptedRegions=[]}setServerReportedRegions(e){Ie.updateCachedRegionSettings(this.serverUrl,this.token,e)}}Ie.cache=new Map,Ie.settingsTimeouts=new Map,Ie.connectionTrackers=new Map,Ie.fetchLock=new zt;function CP(t){return"".concat(t.protocol.replace("ws","http"),"//").concat(t.host,"/settings")}class ot extends Error{constructor(e,n,a){super(n),this.code=e,this.message=US(n,ot.MAX_MESSAGE_BYTES),this.data=a?US(a,ot.MAX_DATA_BYTES):void 0}static fromProto(e){return new ot(e.code,e.message,e.data)}toProto(){return new K0({code:this.code,message:this.message,data:this.data})}static builtIn(e,n){return new ot(ot.ErrorCode[e],ot.ErrorMessage[e],n)}}ot.MAX_MESSAGE_BYTES=256,ot.MAX_DATA_BYTES=15360,ot.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},ot.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 IS=15360;function nh(t){return new TextEncoder().encode(t).length}function US(t,e){if(nh(t)<=e)return t;let n=0,a=t.length;const r=new TextEncoder;for(;n<a;){const c=Math.floor((n+a+1)/2);r.encode(t.slice(0,c)).length<=e?n=c:a=c-1}return t.slice(0,n)}const ih=2e3;function Wc(t,e){if(!e)return 0;let n,a;return"bytesReceived"in t?(n=t.bytesReceived,a=e.bytesReceived):"bytesSent"in t&&(n=t.bytesSent,a=e.bytesSent),n===void 0||a===void 0||t.timestamp===void 0||e.timestamp===void 0?0:(n-a)*8*1e3/(t.timestamp-e.timestamp)}const ah=typeof MediaRecorder!="undefined";class kP{constructor(){throw new Error("MediaRecorder is not available in this environment")}}const EP=ah?MediaRecorder:kP;class wP extends EP{constructor(e,n){if(!ah)throw new Error("MediaRecorder is not available in this environment");super(new MediaStream([e.mediaStreamTrack]),n);let a,r;const c=()=>r===void 0,l=()=>{this.removeEventListener("dataavailable",a),this.removeEventListener("stop",l),this.removeEventListener("error",u),r==null||r.close(),r=void 0},u=f=>{r==null||r.error(f),this.removeEventListener("dataavailable",a),this.removeEventListener("stop",l),this.removeEventListener("error",u),r=void 0};this.byteStream=new ReadableStream({start:f=>{r=f,a=h=>A(this,void 0,void 0,function*(){let p;if(h.data.arrayBuffer){const v=yield h.data.arrayBuffer();p=new Uint8Array(v)}else if(h.data.byteArray)p=h.data.byteArray;else throw new Error("no data available!");c()||f.enqueue(p)}),this.addEventListener("dataavailable",a)},cancel:()=>{l()}}),this.addEventListener("stop",l),this.addEventListener("error",u)}}function RP(){return ah}const _P=1e3,xP=1e4;class BS extends Q{get sender(){return this._sender}set sender(e){this._sender=e}get constraints(){return this._constraints}get hasPreConnectBuffer(){return!!this.localTrackRecorder}constructor(e,n,a){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,c=arguments.length>4?arguments[4]:void 0;super(e,n,c),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=Wf(()=>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(ae.Ended,this)},this.reacquireTrack=!1,this.providedByUser=r,this.muteLock=new zt,this.pauseUpstreamLock=new zt,this.trackChangeLock=new zt,this.trackChangeLock.lock().then(l=>A(this,void 0,void 0,function*(){try{yield this.setMediaStreamTrack(e,!0)}finally{l()}})),this._constraints=e.getConstraints(),a&&(this._constraints=a)}get id(){return this._mediaStreamTrack.id}get dimensions(){if(this.kind!==Q.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 a;if(e===this._mediaStreamTrack&&!n)return;this._mediaStreamTrack&&(this.attachedElements.forEach(c=>{As(this._mediaStreamTrack,c)}),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){if(this.log.debug("restarting processor",this.logContext),this.kind==="unknown")throw TypeError("cannot set processor on track of unknown kind");this.processorElement&&(xs(e,this.processorElement),this.processorElement.muted=!0),yield this.processor.restart({track:e,kind:this.kind,element:this.processorElement}),r=this.processor.processedTrack}this.sender&&((a=this.sender.transport)===null||a===void 0?void 0:a.state)!=="closed"&&(yield this.sender.replaceTrack(r!=null?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(c=>{xs(r!=null?r:e,c)}))})}waitForDimensions(){return A(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_P;return(function*(){var a;if(e.kind===Q.Kind.Audio)throw new Error("cannot get dimensions for audio tracks");((a=Xt())===null||a===void 0?void 0:a.os)==="iOS"&&(yield Dt(10));const r=Date.now();for(;Date.now()-r<n;){const c=e.dimensions;if(c)return c;yield Dt(50)}throw new mi("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===Gi(e)||(this._constraints.deviceId=e,this.isMuted)?!0:(yield this.restartTrack(),Gi(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===Q.Source.ScreenShare)return;const{deviceId:a,groupId:r}=e._mediaStreamTrack.getSettings(),c=e.kind===Q.Kind.Audio?"audioinput":"videoinput";return n?Rt.getInstance().normalizeDeviceId(c,a,r):a})()})}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*(){const a=yield this.trackChangeLock.lock();try{if(!this.sender)throw new mi("unable to replace an unpublished track");let r,c;return typeof n=="boolean"?r=n:n!==void 0&&(r=n.userProvidedTrack,c=n.stopProcessor),this.providedByUser=r!=null?r:!0,this.log.debug("replace MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(e),c&&this.processor&&(yield this.internalStopProcessor()),this}finally{a()}})}restart(e){return A(this,void 0,void 0,function*(){this.manuallyStopped=!1;const n=yield this.trackChangeLock.lock();try{e||(e=this._constraints);const{deviceId:a,facingMode:r}=e,c=ZD(e,["deviceId","facingMode"]);this.log.debug("restarting track with constraints",Object.assign(Object.assign({},this.logContext),{constraints:e}));const l={audio:!1,video:!1};this.kind===Q.Kind.Video?l.video=a||r?{deviceId:a,facingMode:r}:!0:l.audio=a?Object.assign({deviceId:a},c):!0,this.attachedElements.forEach(h=>{As(this.mediaStreamTrack,h)}),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.stop();const f=(yield navigator.mediaDevices.getUserMedia(l)).getTracks()[0];return this.kind===Q.Kind.Video&&(yield f.applyConstraints(c)),f.addEventListener("ended",this.handleEnded),this.log.debug("re-acquired MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(f),this._constraints=e,this.emit(ae.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?ae.Muted:ae.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),dS()&&(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(ae.UpstreamPaused,this);const a=Xt();if((a==null?void 0:a.name)==="Safari"&&zn(a.version,"12.0")<0)throw new _f("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(ae.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 a=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return(function*(){var c;const l=yield a.trackChangeLock.lock();try{a.log.debug("setting up processor",a.logContext);const u=document.createElement(a.kind),f={kind:a.kind,track:a._mediaStreamTrack,element:u,audioContext:a.audioContext};if(yield n.init(f),a.log.debug("processor initialized",a.logContext),a.processor&&(yield a.internalStopProcessor()),a.kind==="unknown")throw TypeError("cannot set processor on track of unknown kind");if(xs(a._mediaStreamTrack,u),u.muted=!0,u.play().catch(h=>{h instanceof DOMException&&h.name==="AbortError"?(a.log.warn("failed to play processor element, retrying",Object.assign(Object.assign({},a.logContext),{error:h})),setTimeout(()=>{u.play().catch(p=>{a.log.error("failed to play processor element",Object.assign(Object.assign({},a.logContext),{err:p}))})},100)):a.log.error("failed to play processor element",Object.assign(Object.assign({},a.logContext),{error:h}))}),a.processor=n,a.processorElement=u,a.processor.processedTrack){for(const h of a.attachedElements)h!==a.processorElement&&r&&(As(a._mediaStreamTrack,h),xs(a.processor.processedTrack,h));yield(c=a.sender)===null||c===void 0?void 0:c.replaceTrack(a.processor.processedTrack)}a.emit(ae.TrackProcessorUpdate,a.processor)}finally{l()}})()})}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*(){const a=yield e.trackChangeLock.lock();try{yield e.internalStopProcessor(n)}finally{a()}})()})}internalStopProcessor(){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 a,r;e.processor&&(e.log.debug("stopping processor",e.logContext),(a=e.processor.processedTrack)===null||a===void 0||a.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(ae.TrackProcessorUpdate))})()})}startPreConnectBuffer(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:100;if(!RP()){this.log.warn("MediaRecorder is not available, cannot start preconnect buffer",this.logContext);return}if(this.localTrackRecorder){this.log.warn("preconnect buffer already started");return}else{let n="audio/webm;codecs=opus";MediaRecorder.isTypeSupported(n)||(n="video/mp4"),this.localTrackRecorder=new wP(this,{mimeType:n})}this.localTrackRecorder.start(e),this.autoStopPreConnectBuffer=setTimeout(()=>{this.log.warn("preconnect buffer timed out, stopping recording automatically",this.logContext),this.stopPreConnectBuffer()},xP)}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}getPreConnectBufferMimeType(){var e;return(e=this.localTrackRecorder)===null||e===void 0?void 0:e.mimeType}}class $c extends BS{get enhancedNoiseCancellation(){return this.isKrispNoiseFilterEnabled}constructor(e,n){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=arguments.length>3?arguments[3]:void 0,c=arguments.length>4?arguments[4]:void 0;super(e,Q.Kind.Audio,n,a,c),this.stopOnMute=!1,this.isKrispNoiseFilterEnabled=!1,this.monitorSender=()=>A(this,void 0,void 0,function*(){if(!this.sender){this._currentBitrate=0;return}let l;try{l=yield this.getSenderStats()}catch(u){this.log.error("could not get audio sender stats",Object.assign(Object.assign({},this.logContext),{error:u}));return}l&&this.prevStats&&(this._currentBitrate=Wc(l,this.prevStats)),this.prevStats=l}),this.handleKrispNoiseFilterEnable=()=>{this.isKrispNoiseFilterEnabled=!0,this.log.debug("Krisp noise filter enabled",this.logContext),this.emit(ae.AudioTrackFeatureUpdate,this,wt.TF_ENHANCED_NOISE_CANCELLATION,!0)},this.handleKrispNoiseFilterDisable=()=>{this.isKrispNoiseFilterEnabled=!1,this.log.debug("Krisp noise filter disabled",this.logContext),this.emit(ae.AudioTrackFeatureUpdate,this,wt.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===Q.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 a=this._constraints.deviceId&&this._mediaStreamTrack.getSettings().deviceId!==Gi(this._constraints.deviceId);return this.source===Q.Source.Microphone&&(this.stopOnMute||this._mediaStreamTrack.readyState==="ended"||a)&&!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 a=Of({audio:e});typeof a.audio!="boolean"&&(n=a.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 a=yield n.restart.call(this,e);return this.checkForSilence(),a})}startMonitor(){Qt()&&(this.monitorInterval||(this.monitorInterval=setInterval(()=>{this.monitorSender()},ih)))}setProcessor(e){return A(this,void 0,void 0,function*(){var n;const a=yield this.trackChangeLock.lock();try{if(!$n()&&!this.audioContext)throw Error("Audio context needs to be set on LocalAudioTrack in order to enable processors");this.processor&&(yield this.internalStopProcessor());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(ae.TrackProcessorUpdate,this.processor)}finally{a()}})}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 a;return n.forEach(r=>{r.type==="outbound-rtp"&&(a={type:"audio",streamId:r.id,packetsSent:r.packetsSent,packetsLost:r.packetsLost,bytesSent:r.bytesSent,timestamp:r.timestamp,roundTripTime:r.roundTripTime,jitter:r.jitter})}),a})}checkForSilence(){return A(this,void 0,void 0,function*(){const e=yield rS(this);return e&&(this.isMuted||this.log.debug("silence detected on local audio track",this.logContext),this.emit(ae.AudioSilenceDetected)),e})}}function AP(t,e,n){switch(t.kind){case"audio":return new $c(t,e,!1,void 0,n);case"video":return new el(t,e,!1,n);default:throw new mi("unsupported track type: ".concat(t.kind))}}const MP=Object.values(Zr),DP=Object.values(Af),OP=Object.values(Mf),PP=[Zr.h180,Zr.h360],NP=[Af.h180,Af.h360],LP=t=>[{scaleResolutionDownBy:2,fps:t.encoding.maxFramerate}].map(n=>{var a,r;return new Fe(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)*(((a=t.encoding.maxFramerate)!==null&&a!==void 0?a:30)/((r=n.fps)!==null&&r!==void 0?r:30))))),n.fps,t.encoding.priority)}),sh=["q","h","f"];function rh(t,e,n,a){var r,c;let l=a==null?void 0:a.videoEncoding;t&&(l=a==null?void 0:a.screenShareEncoding);const u=a==null?void 0:a.simulcast,f=a==null?void 0:a.scalabilityMode,h=a==null?void 0:a.videoCodec;if(!l&&!u&&!f||!e||!n)return[{}];l||(l=UP(t,e,n,h),Ee.debug("using video encoding",l));const p=l.maxFramerate,v=new Fe(e,n,l.maxBitrate,l.maxFramerate,l.priority);if(f&&Vn(h)){const w=new zS(f),T=[];if(w.spatial>3)throw new Error("unsupported scalabilityMode: ".concat(f));const x=Xt();if(eo()||$n()||(x==null?void 0:x.name)==="Chrome"&&zn(x==null?void 0:x.version,"113")<0){const R=w.suffix=="h"?2:3,P=OO(x);for(let L=0;L<w.spatial;L+=1)T.push({rid:sh[2-L],maxBitrate:l.maxBitrate/Math.pow(R,L),maxFramerate:v.encoding.maxFramerate,scaleResolutionDownBy:P?Math.pow(2,L):void 0});T[0].scalabilityMode=f}else T.push({maxBitrate:l.maxBitrate,maxFramerate:v.encoding.maxFramerate,scalabilityMode:f});return v.encoding.priority&&(T[0].priority=v.encoding.priority,T[0].networkPriority=v.encoding.priority),Ee.debug("using svc encoding",{encodings:T}),T}if(!u)return[l];let y=[];t?y=(r=VS(a==null?void 0:a.screenShareSimulcastLayers))!==null&&r!==void 0?r:jS(t,v):y=(c=VS(a==null?void 0:a.videoSimulcastLayers))!==null&&c!==void 0?c:jS(t,v);let S;if(y.length>0){const w=y[0];y.length>1&&([,S]=y);const T=Math.max(e,n);if(T>=960&&S)return oh(e,n,[w,S,v],p);if(T>=480)return oh(e,n,[w,v],p)}return oh(e,n,[v])}function IP(t,e,n){var a,r,c,l;if(!n.backupCodec||n.backupCodec===!0||n.backupCodec.codec===n.videoCodec)return;e!==n.backupCodec.codec&&Ee.warn("requested a different codec than specified as backup",{serverRequested:e,backup:n.backupCodec.codec}),n.videoCodec=e,n.videoEncoding=n.backupCodec.encoding;const u=t.mediaStreamTrack.getSettings(),f=(a=u.width)!==null&&a!==void 0?a:(r=t.dimensions)===null||r===void 0?void 0:r.width,h=(c=u.height)!==null&&c!==void 0?c:(l=t.dimensions)===null||l===void 0?void 0:l.height;return t.source===Q.Source.ScreenShare&&n.simulcast&&(n.simulcast=!1),rh(t.source===Q.Source.ScreenShare,f,h,n)}function UP(t,e,n,a){const r=BP(t,e,n);let{encoding:c}=r[0];const l=Math.max(e,n);for(let u=0;u<r.length;u+=1){const f=r[u];if(c=f.encoding,f.width>=l)break}if(a)switch(a){case"av1":case"h265":c=Object.assign({},c),c.maxBitrate=c.maxBitrate*.7;break;case"vp9":c=Object.assign({},c),c.maxBitrate=c.maxBitrate*.85;break}return c}function BP(t,e,n){if(t)return OP;const a=e>n?e/n:n/e;return Math.abs(a-16/9)<Math.abs(a-4/3)?MP:DP}function jS(t,e){if(t)return LP(e);const{width:n,height:a}=e,r=n>a?n/a:a/n;return Math.abs(r-16/9)<Math.abs(r-4/3)?PP:NP}function oh(t,e,n,a){const r=[];if(n.forEach((c,l)=>{if(l>=sh.length)return;const u=Math.min(t,e),h={rid:sh[l],scaleResolutionDownBy:Math.max(1,u/Math.min(c.width,c.height)),maxBitrate:c.encoding.maxBitrate},p=a&&c.encoding.maxFramerate?Math.min(a,c.encoding.maxFramerate):c.encoding.maxFramerate;p&&(h.maxFramerate=p);const v=Va()||l===0;c.encoding.priority&&v&&(h.priority=c.encoding.priority,h.networkPriority=c.encoding.priority),r.push(h)}),$n()&&hS()==="ios"){let c;r.forEach(u=>{c?u.maxFramerate&&u.maxFramerate>c&&(c=u.maxFramerate):c=u.maxFramerate});let l=!0;r.forEach(u=>{var f;u.maxFramerate!=c&&(l&&(l=!1,Ee.info("Simulcast on iOS React-Native requires all encodings to share the same framerate.")),Ee.info('Setting framerate of encoding "'.concat((f=u.rid)!==null&&f!==void 0?f:"",'" to ').concat(c)),u.maxFramerate=c)})}return r}function VS(t){if(t)return t.sort((e,n)=>{const{encoding:a}=e,{encoding:r}=n;return a.maxBitrate>r.maxBitrate?1:a.maxBitrate<r.maxBitrate?-1:a.maxBitrate===r.maxBitrate&&a.maxFramerate&&r.maxFramerate?a.maxFramerate>r.maxFramerate?1:-1:0})}class zS{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 jP(t){return t.source===Q.Source.ScreenShare||t.constraints.height&&Gi(t.constraints.height)>=1080?"maintain-resolution":"balanced"}const VP=5e3;class el extends BS{get sender(){return this._sender}set sender(e){this._sender=e,this.degradationPreference&&this.setDegradationPreference(this.degradationPreference)}constructor(e,n){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=arguments.length>3?arguments[3]:void 0;super(e,Q.Kind.Video,n,a,r),this.simulcastCodecs=new Map,this.degradationPreference="balanced",this.isCpuConstrained=!1,this.optimizeForPerformance=!1,this.monitorSender=()=>A(this,void 0,void 0,function*(){if(!this.sender){this._currentBitrate=0;return}let c;try{c=yield this.getSenderStats()}catch(f){this.log.error("could not get video sender stats",Object.assign(Object.assign({},this.logContext),{error:f}));return}const l=new Map(c.map(f=>[f.rid,f])),u=c.some(f=>f.qualityLimitationReason==="cpu");if(u!==this.isCpuConstrained&&(this.isCpuConstrained=u,this.isCpuConstrained&&this.emit(ae.CpuConstrained)),this.prevStats){let f=0;l.forEach((h,p)=>{var v;const y=(v=this.prevStats)===null||v===void 0?void 0:v.get(p);f+=Wc(h,y)}),this._currentBitrate=f}this.prevStats=l}),this.senderLock=new zt}get isSimulcast(){return!!(this.sender&&this.sender.getParameters().encodings.length>1)}startMonitor(e){var n;if(this.signalClient=e,!Qt())return;const a=(n=this.sender)===null||n===void 0?void 0:n.getParameters();a&&(this.encodings=a.encodings),!this.monitorInterval&&(this.monitorInterval=setInterval(()=>{this.monitorSender()},ih))}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,a,r,c,l;yield e.pauseUpstream.call(this);try{for(var u=!0,f=hi(this.simulcastCodecs.values()),h;h=yield f.next(),n=h.done,!n;u=!0)c=h.value,u=!1,yield(l=c.sender)===null||l===void 0?void 0:l.replaceTrack(null)}catch(p){a={error:p}}finally{try{!u&&!n&&(r=f.return)&&(yield r.call(f))}finally{if(a)throw a.error}}})}resumeUpstream(){const e=Object.create(null,{resumeUpstream:{get:()=>super.resumeUpstream}});return A(this,void 0,void 0,function*(){var n,a,r,c,l;yield e.resumeUpstream.call(this);try{for(var u=!0,f=hi(this.simulcastCodecs.values()),h;h=yield f.next(),n=h.done,!n;u=!0){c=h.value,u=!1;const p=c;yield(l=p.sender)===null||l===void 0?void 0:l.replaceTrack(p.mediaStreamTrack)}}catch(p){a={error:p}}finally{try{!u&&!n&&(r=f.return)&&(yield r.call(f))}finally{if(a)throw a.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===Q.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===Q.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=[],a=yield this.sender.getStats();return a.forEach(r=>{var c;if(r.type==="outbound-rtp"){const l={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:(c=r.rid)!==null&&c!==void 0?c:r.id,retransmittedPacketsSent:r.retransmittedPacketsSent,targetBitrate:r.targetBitrate,timestamp:r.timestamp},u=a.get(r.remoteId);u&&(l.jitter=u.jitter,l.packetsLost=u.packetsLost,l.roundTripTime=u.roundTripTime),n.push(l)}}),n.sort((r,c)=>{var l,u;return((l=c.frameWidth)!==null&&l!==void 0?l:0)-((u=r.frameWidth)!==null&&u!==void 0?u:0)}),n})}setPublishingQuality(e){const n=[];for(let a=an.LOW;a<=an.HIGH;a+=1)n.push(new hf({quality:a,enabled:a<=e}));this.log.debug("setting publishing quality. max quality ".concat(e),this.logContext),this.setPublishingLayers(Vn(this.codec),n)}restartTrack(e){return A(this,void 0,void 0,function*(){var n,a,r,c,l;let u;if(e){const v=Of({video:e});typeof v.video!="boolean"&&(u=v.video)}yield this.restart(u),this.isCpuConstrained=!1;try{for(var f=!0,h=hi(this.simulcastCodecs.values()),p;p=yield h.next(),n=p.done,!n;f=!0){c=p.value,f=!1;const v=c;v.sender&&((l=v.sender.transport)===null||l===void 0?void 0:l.state)!=="closed"&&(v.mediaStreamTrack=this.mediaStreamTrack.clone(),yield v.sender.replaceTrack(v.mediaStreamTrack))}}catch(v){a={error:v}}finally{try{!f&&!n&&(r=h.return)&&(yield r.call(h))}finally{if(a)throw a.error}}})}setProcessor(e){const n=Object.create(null,{setProcessor:{get:()=>super.setProcessor}});return A(this,arguments,void 0,function(a){var r=this;let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return(function*(){var l,u,f,h,p,v;if(yield n.setProcessor.call(r,a,c),!((p=r.processor)===null||p===void 0)&&p.processedTrack)try{for(var y=!0,S=hi(r.simulcastCodecs.values()),w;w=yield S.next(),l=w.done,!l;y=!0)h=w.value,y=!1,yield(v=h.sender)===null||v===void 0?void 0:v.replaceTrack(r.processor.processedTrack)}catch(T){u={error:T}}finally{try{!y&&!l&&(f=S.return)&&(yield f.call(S))}finally{if(u)throw u.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 a={codec:e,mediaStreamTrack:this.mediaStreamTrack.clone(),sender:void 0,encodings:n};return this.simulcastCodecs.set(e,a),a}setSimulcastTrackSender(e,n){const a=this.simulcastCodecs.get(e);a&&(a.sender=n,setTimeout(()=>{this.subscribedCodecs&&this.setPublishingCodecs(this.subscribedCodecs)},VP))}setPublishingCodecs(e){return A(this,void 0,void 0,function*(){var n,a,r,c,l,u,f;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(Vn(e[0].codec),e[0].qualities),[];this.subscribedCodecs=e;const h=[];try{for(n=!0,a=hi(e);r=yield a.next(),c=r.done,!c;n=!0){f=r.value,n=!1;const p=f;if(!this.codec||this.codec===p.codec)yield this.setPublishingLayers(Vn(p.codec),p.qualities);else{const v=this.simulcastCodecs.get(p.codec);if(this.log.debug("try setPublishingCodec for ".concat(p.codec),Object.assign(Object.assign({},this.logContext),{simulcastCodecInfo:v})),!v||!v.sender){for(const y of p.qualities)if(y.enabled){h.push(p.codec);break}}else v.encodings&&(this.log.debug("try setPublishingLayersForSender ".concat(p.codec),this.logContext),yield FS(v.sender,v.encodings,p.qualities,this.senderLock,Vn(p.codec),this.log,this.logContext))}}}catch(p){l={error:p}}finally{try{!n&&!c&&(u=a.return)&&(yield u.call(a))}finally{if(l)throw l.error}}return h})}setPublishingLayers(e,n){return A(this,void 0,void 0,function*(){if(this.optimizeForPerformance){this.log.info("skipping setPublishingLayers due to optimized publishing performance",Object.assign(Object.assign({},this.logContext),{qualities:n}));return}this.log.debug("setting publishing layers",Object.assign(Object.assign({},this.logContext),{qualities:n})),!(!this.sender||!this.encodings)&&(yield FS(this.sender,this.encodings,n,this.senderLock,e,this.log,this.logContext))})}prioritizePerformance(){return A(this,void 0,void 0,function*(){if(!this.sender)throw new Error("sender not found");const e=yield this.senderLock.lock();try{this.optimizeForPerformance=!0;const n=this.sender.getParameters();n.encodings=n.encodings.map((a,r)=>{var c;return Object.assign(Object.assign({},a),{active:r===0,scaleResolutionDownBy:Math.max(1,Math.ceil(((c=this.mediaStreamTrack.getSettings().height)!==null&&c!==void 0?c:360)/360)),scalabilityMode:r===0&&Vn(this.codec)?"L1T3":void 0,maxFramerate:r===0?15:0,maxBitrate:r===0?a.maxBitrate:0})}),this.log.debug("setting performance optimised encodings",Object.assign(Object.assign({},this.logContext),{encodings:n.encodings})),this.encodings=n.encodings,yield this.sender.setParameters(n)}catch(n){this.log.error("failed to set performance optimised encodings",Object.assign(Object.assign({},this.logContext),{error:n})),this.optimizeForPerformance=!1}finally{e()}})}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return A(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),dS()&&this.isInBackground&&this.source===Q.Source.Camera&&(this._mediaStreamTrack.enabled=!1)})}}function FS(t,e,n,a,r,c,l){return A(this,void 0,void 0,function*(){const u=yield a.lock();c.debug("setPublishingLayersForSender",Object.assign(Object.assign({},l),{sender:t,qualities:n,senderEncodings:e}));try{const f=t.getParameters(),{encodings:h}=f;if(!h)return;if(h.length!==e.length){c.warn("cannot set publishing layers, encodings mismatch",Object.assign(Object.assign({},l),{encodings:h,senderEncodings:e}));return}let p=!1;!1&&h[0].scalabilityMode||(r&&n.some(S=>S.enabled)&&n.forEach(S=>S.enabled=!0),h.forEach((y,S)=>{var w;let T=(w=y.rid)!==null&&w!==void 0?w:"";T===""&&(T="q");const x=qS(T),R=n.find(P=>P.quality===x);R&&y.active!==R.enabled&&(p=!0,y.active=R.enabled,c.debug("setting layer ".concat(R.quality," to ").concat(y.active?"enabled":"disabled"),l),Va()&&(R.enabled?(y.scaleResolutionDownBy=e[S].scaleResolutionDownBy,y.maxBitrate=e[S].maxBitrate,y.maxFrameRate=e[S].maxFrameRate):(y.scaleResolutionDownBy=4,y.maxBitrate=10,y.maxFrameRate=2)))})),p&&(f.encodings=h,c.debug("setting encodings",Object.assign(Object.assign({},l),{encodings:f.encodings})),yield t.setParameters(f))}finally{u()}})}function qS(t){switch(t){case"f":return an.HIGH;case"h":return an.MEDIUM;case"q":return an.LOW;default:return an.HIGH}}function HS(t,e,n,a){if(!n)return[new qi({quality:an.HIGH,width:t,height:e,bitrate:0,ssrc:0})];if(a){const r=n[0].scalabilityMode,c=new zS(r),l=[],u=c.suffix=="h"?1.5:2,f=c.suffix=="h"?2:3;for(let h=0;h<c.spatial;h+=1)l.push(new qi({quality:Math.min(an.HIGH,c.spatial-1)-h,width:Math.ceil(t/Math.pow(u,h)),height:Math.ceil(e/Math.pow(u,h)),bitrate:n[0].maxBitrate?Math.ceil(n[0].maxBitrate/Math.pow(f,h)):0,ssrc:0}));return l}return n.map(r=>{var c,l,u;const f=(c=r.scaleResolutionDownBy)!==null&&c!==void 0?c:1;let h=qS((l=r.rid)!==null&&l!==void 0?l:"");return new qi({quality:h,width:Math.ceil(t/f),height:Math.ceil(e/f),bitrate:(u=r.maxBitrate)!==null&&u!==void 0?u:0,ssrc:0})})}const GS="_lossy",KS="_reliable",zP=2*1e3,ch="leave-reconnect",FP=3e4,qP=8*1024,HP=256*1024;var Cn;(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"})(Cn||(Cn={}));class GP extends Zn.EventEmitter{get isClosed(){return this._isClosed}get pendingReconnect(){return!!this.reconnectTimeout}constructor(e){var n;super(),this.options=e,this.rtcConfig={},this.peerConnectionTimeout=th.peerConnectionTimeout,this.fullReconnectOnNext=!1,this.latestRemoteOfferId=0,this.subscriberPrimary=!1,this.pcState=Cn.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=Ee,this.reliableDataSequence=1,this.reliableMessageBuffer=new wS,this.reliableReceivedState=new dP(FP),this.lossyDataStatCurrentBytes=0,this.lossyDataStatByterate=0,this.lossyDataDropCount=0,this.midToTrackId={},this.isWaitingForNetworkReconnect=!1,this.handleDataChannel=a=>A(this,[a],void 0,function(r){var c=this;let{channel:l}=r;return(function*(){if(l){if(l.label===KS)c.reliableDCSub=l;else if(l.label===GS)c.lossyDCSub=l;else return;c.log.debug("on data channel ".concat(l.id,", ").concat(l.label),c.logContext),l.onmessage=c.handleDataMessage}})()}),this.handleDataMessage=a=>A(this,void 0,void 0,function*(){var r,c,l,u,f;const h=yield this.dataProcessLock.lock();try{let p;if(a.data instanceof ArrayBuffer)p=a.data;else if(a.data instanceof Blob)p=yield a.data.arrayBuffer();else{this.log.error("unsupported data type",Object.assign(Object.assign({},this.logContext),{data:a.data}));return}const v=Ft.fromBinary(new Uint8Array(p));if(v.sequence>0&&v.participantSid!==""){const y=this.reliableReceivedState.get(v.participantSid);if(y&&v.sequence<=y)return;this.reliableReceivedState.set(v.participantSid,v.sequence)}if(((r=v.value)===null||r===void 0?void 0:r.case)==="speaker")this.emit(se.ActiveSpeakersUpdate,v.value.value.speakers);else if(((c=v.value)===null||c===void 0?void 0:c.case)==="encryptedPacket"){if(!this.e2eeManager){this.log.error("Received encrypted packet but E2EE not set up",this.logContext);return}const y=yield(l=this.e2eeManager)===null||l===void 0?void 0:l.handleEncryptedData(v.value.value.encryptedValue,v.value.value.iv,v.participantIdentity,v.value.value.keyIndex),S=q0.fromBinary(y.payload),w=new Ft({value:S.value,participantIdentity:v.participantIdentity,participantSid:v.participantSid});((u=w.value)===null||u===void 0?void 0:u.case)==="user"&&YS(w,w.value.value),this.emit(se.DataPacketReceived,w,v.value.value.encryptionType)}else((f=v.value)===null||f===void 0?void 0:f.case)==="user"&&YS(v,v.value.value),this.emit(se.DataPacketReceived,v,Ct.NONE)}finally{h()}}),this.handleDataError=a=>{const c=a.currentTarget.maxRetransmits===0?"lossy":"reliable";if(a instanceof ErrorEvent&&a.error){const{error:l}=a.error;this.log.error("DataChannel error on ".concat(c,": ").concat(a.message),Object.assign(Object.assign({},this.logContext),{error:l}))}else this.log.error("Unknown DataChannel error on ".concat(c),Object.assign(Object.assign({},this.logContext),{event:a}))},this.handleBufferedAmountLow=a=>{const c=a.currentTarget.maxRetransmits===0?_e.LOSSY:_e.RELIABLE;this.updateAndEmitDCBufferStatus(c)},this.handleDisconnect=(a,r)=>{if(this._isClosed)return;this.log.warn("".concat(a," disconnected"),this.logContext),this.reconnectAttempts===0&&(this.reconnectStart=Date.now());const c=f=>{this.log.warn("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(f,"ms. giving up"),this.logContext),this.emit(se.Disconnected),this.close()},l=Date.now()-this.reconnectStart;let u=this.getNextRetryDelay({elapsedMs:l,retryCount:this.reconnectAttempts});if(u===null){c(l);return}a===ch&&(u=0),this.log.debug("reconnecting in ".concat(u,"ms"),this.logContext),this.clearReconnectTimeout(),this.token&&this.regionUrlProvider&&this.regionUrlProvider.updateToken(this.token),this.reconnectTimeout=Mt.setTimeout(()=>this.attemptReconnect(r).finally(()=>this.reconnectTimeout=void 0),u)},this.waitForRestarted=()=>new Promise((a,r)=>{this.pcState===Cn.Connected&&a();const c=()=>{this.off(se.Disconnected,l),a()},l=()=>{this.off(se.Restarted,c),r()};this.once(se.Restarted,c),this.once(se.Disconnected,l)}),this.updateAndEmitDCBufferStatus=a=>{if(a===_e.RELIABLE){const c=this.dataChannelForKind(a);c&&this.reliableMessageBuffer.alignBufferedAmount(c.bufferedAmount)}const r=this.isBufferStatusLow(a);typeof r!="undefined"&&r!==this.dcBufferStatus.get(a)&&(this.dcBufferStatus.set(a,r),this.emit(se.DCBufferStatusChanged,r,a))},this.isBufferStatusLow=a=>{const r=this.dataChannelForKind(a);if(r)return r.bufferedAmount<=r.bufferedAmountLowThreshold},this.handleBrowserOnLine=()=>A(this,void 0,void 0,function*(){!this.url||!(yield fetch(no(this.url),{method:"HEAD"}).then(r=>r.ok).catch(()=>!1))||(this.log.info("detected network reconnected"),(this.client.currentState===Xe.RECONNECTING||this.isWaitingForNetworkReconnect&&this.client.currentState===Xe.CONNECTED)&&(this.clearReconnectTimeout(),this.attemptReconnect(Ia.RR_SIGNAL_DISCONNECTED),this.isWaitingForNetworkReconnect=!1))}),this.handleBrowserOffline=()=>A(this,void 0,void 0,function*(){if(this.url)try{yield Promise.race([fetch(no(this.url),{method:"HEAD"}),Dt(4e3).then(()=>Promise.reject())])}catch{window.navigator.onLine===!1&&(this.log.info("detected network interruption"),this.isWaitingForNetworkReconnect=!0)}}),this.log=fi((n=e.loggerName)!==null&&n!==void 0?n:jn.Engine),this.loggerOptions={loggerName:e.loggerName,loggerContextCb:()=>this.logContext},this.client=new Yf(void 0,this.loggerOptions),this.client.signalLatency=this.options.expSignalLatency,this.reconnectPolicy=this.options.reconnectPolicy,this.closingLock=new zt,this.dataProcessLock=new zt,this.dcBufferStatus=new Map([[_e.LOSSY,!0],[_e.RELIABLE,!0]]),this.client.onParticipantUpdate=a=>this.emit(se.ParticipantUpdate,a),this.client.onConnectionQuality=a=>this.emit(se.ConnectionQualityUpdate,a),this.client.onRoomUpdate=a=>this.emit(se.RoomUpdate,a),this.client.onSubscriptionError=a=>this.emit(se.SubscriptionError,a),this.client.onSubscriptionPermissionUpdate=a=>this.emit(se.SubscriptionPermissionUpdate,a),this.client.onSpeakersChanged=a=>this.emit(se.SpeakersChanged,a),this.client.onStreamStateUpdate=a=>this.emit(se.StreamStateChanged,a),this.client.onRequestResponse=a=>this.emit(se.SignalRequestResponse,a)}get logContext(){var e,n,a,r,c,l;return{room:(n=(e=this.latestJoinResponse)===null||e===void 0?void 0:e.room)===null||n===void 0?void 0:n.name,roomID:(r=(a=this.latestJoinResponse)===null||a===void 0?void 0:a.room)===null||r===void 0?void 0:r.sid,participant:(l=(c=this.latestJoinResponse)===null||c===void 0?void 0:c.participant)===null||l===void 0?void 0:l.identity,pID:this.participantSid}}join(e,n,a,r){return A(this,arguments,void 0,function(c,l,u,f){var h=this;let p=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;return(function*(){h.url=c,h.token=l,h.signalOpts=u,h.maxJoinAttempts=u.maxRetries;try{h.joinAttempts+=1,h.setupSignalClientCallbacks();const v=yield h.client.join(c,l,u,f,p);return h._isClosed=!1,h.latestJoinResponse=v,h.subscriberPrimary=v.subscriberPrimary,h.pcManager||(yield h.configure(v,!p)),(!h.subscriberPrimary||v.fastPublish)&&h.negotiate().catch(y=>{Ee.error(y,h.logContext)}),h.registerOnLineListener(),h.clientConfiguration=v.clientConfiguration,h.emit(se.SignalConnected,v),v}catch(v){if(v instanceof pe){if(v.reason===Ye.ServerUnreachable){if(h.log.warn("Couldn't connect to server, attempt ".concat(h.joinAttempts," of ").concat(h.maxJoinAttempts),h.logContext),h.joinAttempts<h.maxJoinAttempts)return h.join(c,l,u,f,p)}else if(v.reason===Ye.ServiceNotFound)return h.log.warn("Initial connection failed: ".concat(v.message," – Retrying")),h.join(c,l,u,f,!0)}throw v}})()})}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(se.Closing),this.removeAllListeners(),this.deregisterOnLineListener(),this.clearPendingReconnect(),this.cleanupLossyDataStats(),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=a=>{a&&(a.close(),a.onbufferedamountlow=null,a.onclose=null,a.onclosing=null,a.onerror=null,a.onmessage=null,a.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 wS,this.reliableDataSequence=1,this.reliableReceivedState.clear()})}cleanupLossyDataStats(){this.lossyDataStatByterate=0,this.lossyDataStatCurrentBytes=0,this.lossyDataStatInterval&&(clearInterval(this.lossyDataStatInterval),this.lossyDataStatInterval=void 0),this.lossyDataDropCount=0}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 mi("a track with the same ID has already been published");return new Promise((n,a)=>{const r=setTimeout(()=>{delete this.pendingTrackResolvers[e.cid],a(pe.timeout("publication of local track timed out, no response from server"))},1e4);this.pendingTrackResolvers[e.cid]={resolve:c=>{clearTimeout(r),n(c)},reject:()=>{clearTimeout(r),a(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,n){return A(this,void 0,void 0,function*(){var a,r;if(this.pcManager&&this.pcManager.currentState!==rt.NEW)return;this.participantSid=(a=e.participant)===null||a===void 0?void 0:a.sid;const c=this.makeRTCConfiguration(e);this.pcManager=new SP(c,n?"publisher-only":e.subscriberPrimary?"subscriber-primary":"publisher-primary",this.loggerOptions),this.emit(se.TransportsCreated,this.pcManager.publisher,this.pcManager.subscriber),this.pcManager.onIceCandidate=(l,u)=>{this.client.sendIceCandidate(l,u)},this.pcManager.onPublisherOffer=(l,u)=>{this.client.sendOffer(l,u)},this.pcManager.onDataChannel=this.handleDataChannel,this.pcManager.onStateChange=(l,u,f)=>A(this,void 0,void 0,function*(){if(this.log.debug("primary PC state changed ".concat(l),this.logContext),["closed","disconnected","failed"].includes(u)&&(this.publisherConnectionPromise=void 0),l===rt.CONNECTED){const v=this.pcState===Cn.New;this.pcState=Cn.Connected,v&&this.emit(se.Connected,e)}else l===rt.FAILED&&(this.pcState===Cn.Connected||this.pcState===Cn.Reconnecting)&&(this.pcState=Cn.Disconnected,this.handleDisconnect("peerconnection failed",f==="failed"?Ia.RR_SUBSCRIBER_FAILED:Ia.RR_PUBLISHER_FAILED));const h=this.client.isDisconnected||this.client.currentState===Xe.RECONNECTING,p=[rt.FAILED,rt.CLOSING,rt.CLOSED].includes(l);h&&p&&!this._isClosed&&this.emit(se.Offline)}),this.pcManager.onTrack=l=>{l.streams.length!==0&&this.emit(se.MediaTrackAdded,l.track,l.streams[0],l.receiver)},KP((r=e.serverInfo)===null||r===void 0?void 0:r.protocol)||this.createDataChannels()})}setupSignalClientCallbacks(){this.client.onAnswer=(e,n,a)=>A(this,void 0,void 0,function*(){this.pcManager&&(this.log.debug("received server answer",Object.assign(Object.assign({},this.logContext),{RTCSdpType:e.type,sdp:e.sdp,midToTrackId:a})),this.midToTrackId=a,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)=>A(this,void 0,void 0,function*(){if(this.latestRemoteOfferId=n,!this.pcManager)return;this.midToTrackId=a;const r=yield this.pcManager.createSubscriberAnswerFromOffer(e,n);r&&this.client.sendAnswer(r,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:a}=this.pendingTrackResolvers[e.cid];delete this.pendingTrackResolvers[e.cid],a(e.track)},this.client.onLocalTrackUnpublished=e=>{this.emit(se.LocalTrackUnpublished,e)},this.client.onLocalTrackSubscribed=e=>{this.emit(se.LocalTrackSubscribed,e)},this.client.onTokenRefresh=e=>{var n;this.token=e,(n=this.regionUrlProvider)===null||n===void 0||n.updateToken(e)},this.client.onRemoteMuteChanged=(e,n)=>{this.emit(se.RemoteMute,e,n)},this.client.onSubscribedQualityUpdate=e=>{this.emit(se.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(se.RoomMoved,e)},this.client.onMediaSectionsRequirement=e=>{var n,a;const r={direction:"recvonly"};for(let c=0;c<e.numAudios;c++)(n=this.pcManager)===null||n===void 0||n.addPublisherTransceiverOfKind("audio",r);for(let c=0;c<e.numVideos;c++)(a=this.pcManager)===null||a===void 0||a.addPublisherTransceiverOfKind("video",r);this.negotiate()},this.client.onClose=()=>{this.handleDisconnect("signal",Ia.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({updatedAtInMs:Date.now(),maxAgeInMs:LS,regionSettings:e.regions})),e.action){case Es.DISCONNECT:this.emit(se.Disconnected,e==null?void 0:e.reason),this.close();break;case Es.RECONNECT:this.fullReconnectOnNext=!0,this.handleDisconnect(ch);break;case Es.RESUME:this.handleDisconnect(ch)}}}makeRTCConfiguration(e){var n;const a=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),a.encodedInsertableStreams=!0),e.iceServers&&!a.iceServers){const r=[];e.iceServers.forEach(c=>{const l={urls:c.urls};c.username&&(l.username=c.username),c.credential&&(l.credential=c.credential),r.push(l)}),a.iceServers=r}return e.clientConfiguration&&e.clientConfiguration.forceRelay===Yr.ENABLED&&(a.iceTransportPolicy="relay"),a.sdpSemantics="unified-plan",a.continualGatheringPolicy="gather_continually",a}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(GS,{ordered:!1,maxRetransmits:0}),this.reliableDC=this.pcManager.createPublisherDataChannel(KS,{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,this.cleanupLossyDataStats(),this.lossyDataStatInterval=setInterval(()=>{this.lossyDataStatByterate=this.lossyDataStatCurrentBytes,this.lossyDataStatCurrentBytes=0;const e=this.dataChannelForKind(_e.LOSSY);if(e){const n=this.lossyDataStatByterate/10;e.bufferedAmountLowThreshold=Math.min(Math.max(n,qP),HP)}},1e3))}createSender(e,n,a){return A(this,void 0,void 0,function*(){if(Lf())return yield this.createTransceiverRTCRtpSender(e,n,a);if(If())return this.log.warn("using add-track fallback",this.logContext),yield this.createRTCRtpSender(e.mediaStreamTrack);throw new dt("Required webRTC APIs not supported on this device")})}createSimulcastSender(e,n,a,r){return A(this,void 0,void 0,function*(){if(Lf())return this.createSimulcastTransceiverSender(e,n,a,r);if(If())return this.log.debug("using add-track fallback",this.logContext),this.createRTCRtpSender(e.mediaStreamTrack);throw new dt("Cannot stream on this device")})}createTransceiverRTCRtpSender(e,n,a){return A(this,void 0,void 0,function*(){if(!this.pcManager)throw new dt("publisher is closed");const r=[];e.mediaStream&&r.push(e.mediaStream),Ki(e)&&(e.codec=n.videoCodec);const c={direction:"sendonly",streams:r};return a&&(c.sendEncodings=a),(yield this.pcManager.addPublisherTransceiver(e.mediaStreamTrack,c)).sender})}createSimulcastTransceiverSender(e,n,a,r){return A(this,void 0,void 0,function*(){if(!this.pcManager)throw new dt("publisher is closed");const c={direction:"sendonly"};r&&(c.sendEncodings=r);const l=yield this.pcManager.addPublisherTransceiver(n.mediaStreamTrack,c);if(a.videoCodec)return e.setSimulcastTrackSender(a.videoCodec,l.sender),l.sender})}createRTCRtpSender(e){return A(this,void 0,void 0,function*(){if(!this.pcManager)throw new dt("publisher is closed");return this.pcManager.addPublisherTrack(e)})}attemptReconnect(e){return A(this,void 0,void 0,function*(){var n,a,r;if(!this._isClosed){if(this.attemptingReconnect){Ee.warn("already attempting reconnect, returning early",this.logContext);return}(((n=this.clientConfiguration)===null||n===void 0?void 0:n.resumeConnection)===Yr.DISABLED||((r=(a=this.pcManager)===null||a===void 0?void 0:a.currentState)!==null&&r!==void 0?r:rt.NEW)===rt.NEW)&&(this.fullReconnectOnNext=!0);try{this.attemptingReconnect=!0,this.fullReconnectOnNext?yield this.restartConnection():yield this.resumeConnection(e),this.clearPendingReconnect(),this.fullReconnectOnNext=!1}catch(c){this.reconnectAttempts+=1;let l=!0;c instanceof dt?(this.log.debug("received unrecoverable error",Object.assign(Object.assign({},this.logContext),{error:c})),l=!1):c instanceof _s||(this.fullReconnectOnNext=!0),l?this.handleDisconnect("reconnect",Ia.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(se.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,a,r;try{if(!this.url||!this.token)throw new dt("could not reconnect, url or token not saved");this.log.info("reconnecting, attempt: ".concat(this.reconnectAttempts),this.logContext),this.emit(se.Restarting),this.client.isDisconnected||(yield this.client.sendLeave()),yield this.cleanupPeerConnections(),yield this.cleanupClient();let c;try{if(!this.signalOpts)throw this.log.warn("attempted connection restart, without signal options present",this.logContext),new _s;c=yield this.join(e!=null?e:this.url,this.token,this.signalOpts,void 0,!this.options.singlePeerConnection)}catch(l){throw l instanceof pe&&l.reason===Ye.NotAllowed?new dt("could not reconnect, token might be expired"):new _s}if(this.shouldFailNext)throw this.shouldFailNext=!1,new Error("simulated failure");if(this.client.setReconnected(),this.emit(se.SignalRestarted,c),yield this.waitForPCReconnected(),this.client.currentState!==Xe.CONNECTED)throw new _s("Signal connection got severed during reconnect");(n=this.regionUrlProvider)===null||n===void 0||n.resetAttempts(),this.emit(se.Restarted)}catch(c){const l=yield(a=this.regionUrlProvider)===null||a===void 0?void 0:a.getNextBestRegionUrl();if(l){yield this.restartConnection(l);return}else throw(r=this.regionUrlProvider)===null||r===void 0||r.resetAttempts(),c}})}resumeConnection(e){return A(this,void 0,void 0,function*(){var n;if(!this.url||!this.token)throw new dt("could not reconnect, url or token not saved");if(!this.pcManager)throw new dt("publisher and subscriber connections unset");this.log.info("resuming signal connection, attempt ".concat(this.reconnectAttempts),this.logContext),this.emit(se.Resuming);let a;try{this.setupSignalClientCallbacks(),a=yield this.client.reconnect(this.url,this.token,this.participantSid,e)}catch(r){let c="";throw r instanceof Error&&(c=r.message,this.log.error(r.message,Object.assign(Object.assign({},this.logContext),{error:r}))),r instanceof pe&&r.reason===Ye.NotAllowed?new dt("could not reconnect, token might be expired"):r instanceof pe&&r.reason===Ye.LeaveRequest?r:new _s(c)}if(this.emit(se.SignalResumed),a){const r=this.makeRTCConfiguration(a);this.pcManager.updateConfiguration(r),this.latestJoinResponse&&(this.latestJoinResponse.serverInfo=a.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!==Xe.CONNECTED)throw new _s("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(),a!=null&&a.lastMessageSeq&&this.resendReliableMessagesForResume(a.lastMessageSeq),this.emit(se.Resumed)})}waitForPCInitialConnection(e,n){return A(this,void 0,void 0,function*(){if(!this.pcManager)throw new dt("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(n,e)})}waitForPCReconnected(){return A(this,void 0,void 0,function*(){this.pcState=Cn.Reconnecting,this.log.debug("waiting for peer connection to reconnect",this.logContext);try{if(yield Dt(zP),!this.pcManager)throw new dt("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(void 0,this.peerConnectionTimeout),this.pcState=Cn.Connected}catch(e){throw this.pcState=Cn.Disconnected,pe.internal("could not establish PC connection, ".concat(e.message))}})}publishRpcResponse(e,n,a,r){return A(this,void 0,void 0,function*(){const c=new Ft({destinationIdentities:[e],kind:_e.RELIABLE,value:{case:"rpcResponse",value:new rf({requestId:n,value:r?{case:"error",value:r.toProto()}:{case:"payload",value:a!=null?a:""}})}});yield this.sendDataPacket(c,_e.RELIABLE)})}publishRpcAck(e,n){return A(this,void 0,void 0,function*(){const a=new Ft({destinationIdentities:[e],kind:_e.RELIABLE,value:{case:"rpcAck",value:new sf({requestId:n})}});yield this.sendDataPacket(a,_e.RELIABLE)})}sendDataPacket(e,n){return A(this,void 0,void 0,function*(){if(yield this.ensurePublisherConnected(n),this.e2eeManager&&this.e2eeManager.isDataChannelEncryptionEnabled){const c=eP(e);if(c){const l=yield this.e2eeManager.encryptData(c.toBinary());e.value={case:"encryptedPacket",value:new F0({encryptedValue:l.payload,iv:l.iv,keyIndex:l.keyIndex})}}}n===_e.RELIABLE&&(e.sequence=this.reliableDataSequence,this.reliableDataSequence+=1);const a=e.toBinary(),r=this.dataChannelForKind(n);if(r){if(n===_e.RELIABLE)yield this.waitForBufferStatusLow(n),this.reliableMessageBuffer.push({data:a,sequence:e.sequence});else{if(!this.isBufferStatusLow(n)){this.lossyDataDropCount+=1,this.lossyDataDropCount%100===0&&this.log.warn("dropping lossy data channel messages, total dropped: ".concat(this.lossyDataDropCount),this.logContext);return}this.lossyDataStatCurrentBytes+=a.byteLength}if(this.attemptingReconnect)return;r.send(a)}this.updateAndEmitDCBufferStatus(n)})}resendReliableMessagesForResume(e){return A(this,void 0,void 0,function*(){yield this.ensurePublisherConnected(_e.RELIABLE);const n=this.dataChannelForKind(_e.RELIABLE);n&&(this.reliableMessageBuffer.popToSequence(e),this.reliableMessageBuffer.getAll().forEach(a=>{n.send(a.data)})),this.updateAndEmitDCBufferStatus(_e.RELIABLE)})}waitForBufferStatusLow(e){return new Yt((n,a)=>A(this,void 0,void 0,function*(){if(this.isBufferStatusLow(e))n();else{const r=()=>a(new dt("engine closed"));for(this.once(se.Closing,r);!this.dcBufferStatus.get(e);)yield Dt(10);this.off(se.Closing,r),n()}}))}ensureDataTransportConnected(e){return A(this,arguments,void 0,function(n){var a=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.subscriberPrimary;return(function*(){var c;if(!a.pcManager)throw new dt("PC manager is closed");const l=r?a.pcManager.subscriber:a.pcManager.publisher,u=r?"Subscriber":"Publisher";if(!l)throw pe.internal("".concat(u," connection not set"));let f=!1;!r&&!a.dataChannelForKind(n,r)&&(a.createDataChannels(),f=!0),!f&&!r&&!a.pcManager.publisher.isICEConnected&&a.pcManager.publisher.getICEConnectionState()!=="checking"&&(f=!0),f&&a.negotiate().catch(v=>{Ee.error(v,a.logContext)});const h=a.dataChannelForKind(n,r);if((h==null?void 0:h.readyState)==="open")return;const p=new Date().getTime()+a.peerConnectionTimeout;for(;new Date().getTime()<p;){if(l.isICEConnected&&((c=a.dataChannelForKind(n,r))===null||c===void 0?void 0:c.readyState)==="open")return;yield Dt(50)}throw pe.internal("could not establish ".concat(u," connection, state: ").concat(l.getICEConnectionState()))})()})}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!==rt.CONNECTED||!this.client.ws||this.client.ws.readyState===WebSocket.CLOSED)}negotiate(){return A(this,void 0,void 0,function*(){return new Yt((e,n)=>A(this,void 0,void 0,function*(){if(!this.pcManager){n(new Rs("PC manager is closed"));return}this.pcManager.requirePublisher(),this.pcManager.publisher.getTransceivers().length==0&&!this.lossyDC&&!this.reliableDC&&this.createDataChannels();const a=new AbortController,r=()=>{a.abort(),this.log.debug("engine disconnected while negotiation was ongoing",this.logContext),e()};this.isClosed&&n(new Rs("cannot negotiate on closed engine")),this.on(se.Closing,r),this.pcManager.publisher.once(Ns.RTPVideoPayloadTypes,c=>{const l=new Map;c.forEach(u=>{const f=u.codec.toLowerCase();BO(f)&&l.set(u.payload,f)}),this.emit(se.RTPVideoMapUpdate,l)});try{yield this.pcManager.negotiate(a),e()}catch(c){c instanceof Rs&&(this.fullReconnectOnNext=!0),this.handleDisconnect("negotiation",Ia.RR_UNKNOWN),c instanceof Error?n(c):n(new Error(String(c)))}finally{this.off(se.Closing,r)}}))})}dataChannelForKind(e,n){if(n){if(e===_e.LOSSY)return this.lossyDCSub;if(e===_e.RELIABLE)return this.reliableDCSub}else{if(e===_e.LOSSY)return this.lossyDC;if(e===_e.RELIABLE)return this.reliableDC}}sendSyncState(e,n){var a,r,c,l;if(!this.pcManager){this.log.warn("sync state cannot be sent without peer connection setup",this.logContext);return}const u=this.pcManager.publisher.getLocalDescription(),f=this.pcManager.publisher.getRemoteDescription(),h=(a=this.pcManager.subscriber)===null||a===void 0?void 0:a.getRemoteDescription(),p=(r=this.pcManager.subscriber)===null||r===void 0?void 0:r.getLocalDescription(),v=(l=(c=this.signalOpts)===null||c===void 0?void 0:c.autoSubscribe)!==null&&l!==void 0?l:!0,y=new Array,S=new Array;e.forEach(w=>{w.isDesired!==v&&y.push(w.trackSid),w.isEnabled||S.push(w.trackSid)}),this.client.sendSyncState(new mf({answer:this.pcManager.mode==="publisher-only"?f?Ps({sdp:f.sdp,type:f.type}):void 0:p?Ps({sdp:p.sdp,type:p.type}):void 0,offer:this.pcManager.mode==="publisher-only"?u?Ps({sdp:u.sdp,type:u.type}):void 0:h?Ps({sdp:h.sdp,type:h.type}):void 0,subscription:new jc({trackSids:y,subscribe:!v,participantTracks:[]}),publishTracks:SO(n),dataChannels:this.dataChannelsInfo(),trackSidsDisabled:S,datachannelReceiveStates:this.reliableReceivedState.map((w,T)=>new ub({publisherSid:T,lastSeq:w}))}))}failNext(){this.shouldFailNext=!0}dataChannelsInfo(){const e=[],n=(a,r)=>{(a==null?void 0:a.id)!==void 0&&a.id!==null&&e.push(new db({label:a.label,id:a.id,target:r}))};return n(this.dataChannelForKind(_e.LOSSY),Bn.PUBLISHER),n(this.dataChannelForKind(_e.RELIABLE),Bn.PUBLISHER),n(this.dataChannelForKind(_e.LOSSY,!0),Bn.SUBSCRIBER),n(this.dataChannelForKind(_e.RELIABLE,!0),Bn.SUBSCRIBER),e}clearReconnectTimeout(){this.reconnectTimeout&&Mt.clearTimeout(this.reconnectTimeout)}clearPendingReconnect(){this.clearReconnectTimeout(),this.reconnectAttempts=0}registerOnLineListener(){Qt()&&(window.addEventListener("online",this.handleBrowserOnLine),window.addEventListener("offline",this.handleBrowserOffline))}deregisterOnLineListener(){Qt()&&(window.removeEventListener("online",this.handleBrowserOnLine),window.removeEventListener("offline",this.handleBrowserOffline))}getTrackIdForReceiver(e){var n;const a=(n=this.pcManager)===null||n===void 0?void 0:n.getMidForReceiver(e);if(a){const r=Object.entries(this.midToTrackId).find(c=>{let[l]=c;return l===a});if(r)return r[1]}}}function KP(t){return t!==void 0&&t>13}function YS(t,e){const n=t.participantIdentity?t.participantIdentity:e.participantIdentity;t.participantIdentity=n,e.participantIdentity=n;const a=t.destinationIdentities.length!==0?t.destinationIdentities:e.destinationIdentities;t.destinationIdentities=a,e.destinationIdentities=a}class XS{get info(){return this._info}validateBytesReceived(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;if(!(typeof this.totalByteSize!="number"||this.totalByteSize===0)){if(e&&this.bytesReceived<this.totalByteSize)throw new Sn("Not enough chunk(s) received - expected ".concat(this.totalByteSize," bytes of data total, only received ").concat(this.bytesReceived," bytes"),qt.Incomplete);if(this.bytesReceived>this.totalByteSize)throw new Sn("Extra chunk(s) received - expected ".concat(this.totalByteSize," bytes of data total, received ").concat(this.bytesReceived," bytes"),qt.LengthExceeded)}}constructor(e,n,a,r){this.reader=n,this.totalByteSize=a,this._info=e,this.bytesReceived=0,this.outOfBandFailureRejectingFuture=r}}class YP extends XS{handleChunkReceived(e){var n;this.bytesReceived+=e.content.byteLength,this.validateBytesReceived();const a=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;(n=this.onProgress)===null||n===void 0||n.call(this,a)}[Symbol.asyncIterator](){const e=this.reader.getReader();let n=new Tn,a=null,r=null;if(this.signal){const l=this.signal;r=()=>{var u;(u=n.reject)===null||u===void 0||u.call(n,l.reason)},l.addEventListener("abort",r),a=l}const c=()=>{e.releaseLock(),a&&r&&a.removeEventListener("abort",r),this.signal=void 0};return{next:()=>A(this,void 0,void 0,function*(){var l,u;try{const{done:f,value:h}=yield Promise.race([e.read(),n.promise,(u=(l=this.outOfBandFailureRejectingFuture)===null||l===void 0?void 0:l.promise)!==null&&u!==void 0?u:new Promise(()=>{})]);return f?(this.validateBytesReceived(!0),{done:!0,value:void 0}):(this.handleChunkReceived(h),{done:!1,value:h.content})}catch(f){throw c(),f}}),return(){return A(this,void 0,void 0,function*(){return c(),{done:!0,value:void 0}})}}}withAbortSignal(e){return this.signal=e,this}readAll(){return A(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return(function*(){var a,r,c,l;let u=new Set;const f=n.signal?e.withAbortSignal(n.signal):e;try{for(var h=!0,p=hi(f),v;v=yield p.next(),a=v.done,!a;h=!0){l=v.value,h=!1;const y=l;u.add(y)}}catch(y){r={error:y}}finally{try{!h&&!a&&(c=p.return)&&(yield c.call(p))}finally{if(r)throw r.error}}return Array.from(u)})()})}}class XP extends XS{constructor(e,n,a,r){super(e,n,a,r),this.receivedChunks=new Map}handleChunkReceived(e){var n;const a=Zc(e.chunkIndex),r=this.receivedChunks.get(a);if(r&&r.version>e.version)return;this.receivedChunks.set(a,e),this.bytesReceived+=e.content.byteLength,this.validateBytesReceived();const c=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;(n=this.onProgress)===null||n===void 0||n.call(this,c)}[Symbol.asyncIterator](){const e=this.reader.getReader(),n=new TextDecoder("utf-8",{fatal:!0});let a=new Tn,r=null,c=null;if(this.signal){const u=this.signal;c=()=>{var f;(f=a.reject)===null||f===void 0||f.call(a,u.reason)},u.addEventListener("abort",c),r=u}const l=()=>{e.releaseLock(),r&&c&&r.removeEventListener("abort",c),this.signal=void 0};return{next:()=>A(this,void 0,void 0,function*(){var u,f;try{const{done:h,value:p}=yield Promise.race([e.read(),a.promise,(f=(u=this.outOfBandFailureRejectingFuture)===null||u===void 0?void 0:u.promise)!==null&&f!==void 0?f:new Promise(()=>{})]);if(h)return this.validateBytesReceived(!0),{done:!0,value:void 0};{this.handleChunkReceived(p);let v;try{v=n.decode(p.content)}catch(y){throw new Sn("Cannot decode datastream chunk ".concat(p.chunkIndex," as text: ").concat(y),qt.DecodeFailed)}return{done:!1,value:v}}}catch(h){throw l(),h}}),return(){return A(this,void 0,void 0,function*(){return l(),{done:!0,value:void 0}})}}}withAbortSignal(e){return this.signal=e,this}readAll(){return A(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return(function*(){var a,r,c,l;let u="";const f=n.signal?e.withAbortSignal(n.signal):e;try{for(var h=!0,p=hi(f),v;v=yield p.next(),a=v.done,!a;h=!0)l=v.value,h=!1,u+=l}catch(y){r={error:y}}finally{try{!h&&!a&&(c=p.return)&&(yield c.call(p))}finally{if(r)throw r.error}}return u})()})}}class QP{constructor(){this.log=Ee,this.byteStreamControllers=new Map,this.textStreamControllers=new Map,this.byteStreamHandlers=new Map,this.textStreamHandlers=new Map}registerTextStreamHandler(e,n){if(this.textStreamHandlers.has(e))throw new Sn('A text stream handler for topic "'.concat(e,'" has already been set.'),qt.HandlerAlreadyRegistered);this.textStreamHandlers.set(e,n)}unregisterTextStreamHandler(e){this.textStreamHandlers.delete(e)}registerByteStreamHandler(e,n){if(this.byteStreamHandlers.has(e))throw new Sn('A byte stream handler for topic "'.concat(e,'" has already been set.'),qt.HandlerAlreadyRegistered);this.byteStreamHandlers.set(e,n)}unregisterByteStreamHandler(e){this.byteStreamHandlers.delete(e)}clearControllers(){this.byteStreamControllers.clear(),this.textStreamControllers.clear()}validateParticipantHasNoActiveDataStreams(e){var n,a,r,c;const l=Array.from(this.textStreamControllers.entries()).filter(f=>f[1].sendingParticipantIdentity===e),u=Array.from(this.byteStreamControllers.entries()).filter(f=>f[1].sendingParticipantIdentity===e);if(l.length>0||u.length>0){const f=new Sn("Participant ".concat(e," unexpectedly disconnected in the middle of sending data"),qt.AbnormalEnd);for(const[h,p]of u)(a=(n=p.outOfBandFailureRejectingFuture).reject)===null||a===void 0||a.call(n,f),this.byteStreamControllers.delete(h);for(const[h,p]of l)(c=(r=p.outOfBandFailureRejectingFuture).reject)===null||c===void 0||c.call(r,f),this.textStreamControllers.delete(h)}}handleDataStreamPacket(e,n){return A(this,void 0,void 0,function*(){switch(e.value.case){case"streamHeader":return this.handleStreamHeader(e.value.value,e.participantIdentity,n);case"streamChunk":return this.handleStreamChunk(e.value.value,n);case"streamTrailer":return this.handleStreamTrailer(e.value.value,n);default:throw new Error('DataPacket of value "'.concat(e.value.case,'" is not data stream related!'))}})}handleStreamHeader(e,n,a){return A(this,void 0,void 0,function*(){var r;if(e.contentHeader.case==="byteHeader"){const c=this.byteStreamHandlers.get(e.topic);if(!c){this.log.debug("ignoring incoming byte stream due to no handler for topic",e.topic);return}let l;const u=new Tn;u.promise.catch(p=>{this.log.error(p)});const f={id:e.streamId,name:(r=e.contentHeader.value.name)!==null&&r!==void 0?r:"unknown",mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:Zc(e.timestamp),attributes:e.attributes,encryptionType:a},h=new ReadableStream({start:p=>{if(l=p,this.textStreamControllers.has(e.streamId))throw new Sn("A data stream read is already in progress for a stream with id ".concat(e.streamId,"."),qt.AlreadyOpened);this.byteStreamControllers.set(e.streamId,{info:f,controller:l,startTime:Date.now(),sendingParticipantIdentity:n,outOfBandFailureRejectingFuture:u})}});c(new YP(f,h,Zc(e.totalLength),u),{identity:n})}else if(e.contentHeader.case==="textHeader"){const c=this.textStreamHandlers.get(e.topic);if(!c){this.log.debug("ignoring incoming text stream due to no handler for topic",e.topic);return}let l;const u=new Tn;u.promise.catch(p=>{this.log.error(p)});const f={id:e.streamId,mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:Number(e.timestamp),attributes:e.attributes,encryptionType:a},h=new ReadableStream({start:p=>{if(l=p,this.textStreamControllers.has(e.streamId))throw new Sn("A data stream read is already in progress for a stream with id ".concat(e.streamId,"."),qt.AlreadyOpened);this.textStreamControllers.set(e.streamId,{info:f,controller:l,startTime:Date.now(),sendingParticipantIdentity:n,outOfBandFailureRejectingFuture:u})}});c(new XP(f,h,Zc(e.totalLength),u),{identity:n})}})}handleStreamChunk(e,n){const a=this.byteStreamControllers.get(e.streamId);a&&(a.info.encryptionType!==n?(a.controller.error(new Sn("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(n,", got ").concat(a.info.encryptionType),qt.EncryptionTypeMismatch)),this.byteStreamControllers.delete(e.streamId)):e.content.length>0&&a.controller.enqueue(e));const r=this.textStreamControllers.get(e.streamId);r&&(r.info.encryptionType!==n?(r.controller.error(new Sn("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(n,", got ").concat(r.info.encryptionType),qt.EncryptionTypeMismatch)),this.textStreamControllers.delete(e.streamId)):e.content.length>0&&r.controller.enqueue(e))}handleStreamTrailer(e,n){const a=this.textStreamControllers.get(e.streamId);a&&(a.info.encryptionType!==n?a.controller.error(new Sn("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(n,", got ").concat(a.info.encryptionType),qt.EncryptionTypeMismatch)):(a.info.attributes=Object.assign(Object.assign({},a.info.attributes),e.attributes),a.controller.close(),this.textStreamControllers.delete(e.streamId)));const r=this.byteStreamControllers.get(e.streamId);r&&(r.info.encryptionType!==n?r.controller.error(new Sn("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(n,", got ").concat(r.info.encryptionType),qt.EncryptionTypeMismatch)):(r.info.attributes=Object.assign(Object.assign({},r.info.attributes),e.attributes),r.controller.close()),this.byteStreamControllers.delete(e.streamId))}}class QS{constructor(e,n,a){this.writableStream=e,this.defaultWriter=e.getWriter(),this.onClose=a,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 JP extends QS{}class ZP extends QS{}const JS=15e3;class WP{constructor(e,n){this.engine=e,this.log=n}setupEngine(e){this.engine=e}sendText(e,n){return A(this,void 0,void 0,function*(){var a;const r=crypto.randomUUID(),l=new TextEncoder().encode(e).byteLength,u=(a=n==null?void 0:n.attachments)===null||a===void 0?void 0:a.map(()=>crypto.randomUUID()),f=new Array(u?u.length+1:1).fill(0),h=(v,y)=>{var S;f[y]=v;const w=f.reduce((T,x)=>T+x,0);(S=n==null?void 0:n.onProgress)===null||S===void 0||S.call(n,w)},p=yield this.streamText({streamId:r,totalSize:l,destinationIdentities:n==null?void 0:n.destinationIdentities,topic:n==null?void 0:n.topic,attachedStreamIds:u,attributes:n==null?void 0:n.attributes});return yield p.write(e),h(1,0),yield p.close(),n!=null&&n.attachments&&u&&(yield Promise.all(n.attachments.map((v,y)=>A(this,void 0,void 0,function*(){return this._sendFile(u[y],v,{topic:n.topic,mimeType:v.type,onProgress:S=>{h(S,y+1)}})})))),p.info})}streamText(e){return A(this,void 0,void 0,function*(){var n,a,r;const c=(n=e==null?void 0:e.streamId)!==null&&n!==void 0?n:crypto.randomUUID(),l={id:c,mimeType:"text/plain",timestamp:Date.now(),topic:(a=e==null?void 0:e.topic)!==null&&a!==void 0?a:"",size:e==null?void 0:e.totalSize,attributes:e==null?void 0:e.attributes,encryptionType:!((r=this.engine.e2eeManager)===null||r===void 0)&&r.isDataChannelEncryptionEnabled?Ct.GCM:Ct.NONE},u=new Nc({streamId:c,mimeType:l.mimeType,topic:l.topic,timestamp:Fa(l.timestamp),totalLength:Fa(e==null?void 0:e.totalSize),attributes:l.attributes,contentHeader:{case:"textHeader",value:new tb({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"?of.UPDATE:of.CREATE})}}),f=e==null?void 0:e.destinationIdentities,h=new Ft({destinationIdentities:f,value:{case:"streamHeader",value:u}});yield this.engine.sendDataPacket(h,_e.RELIABLE);let p=0;const v=this.engine,y=new WritableStream({write(T){return A(this,void 0,void 0,function*(){for(const x of HO(T,JS)){const R=new Lc({content:x,streamId:c,chunkIndex:Fa(p)}),P=new Ft({destinationIdentities:f,value:{case:"streamChunk",value:R}});yield v.sendDataPacket(P,_e.RELIABLE),p+=1}})},close(){return A(this,void 0,void 0,function*(){const T=new Ic({streamId:c}),x=new Ft({destinationIdentities:f,value:{case:"streamTrailer",value:T}});yield v.sendDataPacket(x,_e.RELIABLE)})},abort(T){console.log("Sink error:",T)}});let S=()=>A(this,void 0,void 0,function*(){yield w.close()});v.once(se.Closing,S);const w=new JP(y,l,()=>this.engine.off(se.Closing,S));return w})}sendFile(e,n){return A(this,void 0,void 0,function*(){const a=crypto.randomUUID();return yield this._sendFile(a,e,n),{id:a}})}_sendFile(e,n,a){return A(this,void 0,void 0,function*(){var r;const c=yield this.streamBytes({streamId:e,totalSize:n.size,name:n.name,mimeType:(r=a==null?void 0:a.mimeType)!==null&&r!==void 0?r:n.type,topic:a==null?void 0:a.topic,destinationIdentities:a==null?void 0:a.destinationIdentities}),l=n.stream().getReader();for(;;){const{done:u,value:f}=yield l.read();if(u)break;yield c.write(f)}return yield c.close(),c.info})}streamBytes(e){return A(this,void 0,void 0,function*(){var n,a,r,c,l,u;const f=(n=e==null?void 0:e.streamId)!==null&&n!==void 0?n:crypto.randomUUID(),h=e==null?void 0:e.destinationIdentities,p={id:f,mimeType:(a=e==null?void 0:e.mimeType)!==null&&a!==void 0?a:"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:(c=e==null?void 0:e.name)!==null&&c!==void 0?c:"unknown",encryptionType:!((l=this.engine.e2eeManager)===null||l===void 0)&&l.isDataChannelEncryptionEnabled?Ct.GCM:Ct.NONE},v=new Nc({totalLength:Fa((u=p.size)!==null&&u!==void 0?u:0),mimeType:p.mimeType,streamId:f,topic:p.topic,timestamp:Fa(Date.now()),attributes:p.attributes,contentHeader:{case:"byteHeader",value:new nb({name:p.name})}}),y=new Ft({destinationIdentities:h,value:{case:"streamHeader",value:v}});yield this.engine.sendDataPacket(y,_e.RELIABLE);let S=0;const w=new zt,T=this.engine,x=this.log,R=new WritableStream({write(L){return A(this,void 0,void 0,function*(){const E=yield w.lock();let k=0;try{for(;k<L.byteLength;){const _=L.slice(k,k+JS),N=new Ft({destinationIdentities:h,value:{case:"streamChunk",value:new Lc({content:_,streamId:f,chunkIndex:Fa(S)})}});yield T.sendDataPacket(N,_e.RELIABLE),S+=1,k+=_.byteLength}}finally{E()}})},close(){return A(this,void 0,void 0,function*(){const L=new Ic({streamId:f}),E=new Ft({destinationIdentities:h,value:{case:"streamTrailer",value:L}});yield T.sendDataPacket(E,_e.RELIABLE)})},abort(L){x.error("Sink error:",L)}});return new ZP(R,p)})}}class ZS extends Q{constructor(e,n,a,r,c){super(e,a,c),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?ae.Muted:ae.Unmuted,this))}setMediaStream(e){this.mediaStream=e;const n=a=>{a.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(ae.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(),ih)),TO()&&this.registerTimeSyncUpdate()}registerTimeSyncUpdate(){const e=()=>{var n;this.timeSyncHandle=requestAnimationFrame(()=>e());const a=(n=this.receiver)===null||n===void 0?void 0:n.getSynchronizationSources()[0];if(a){const{timestamp:r,rtpTimestamp:c}=a;c&&this.rtpTimestamp!==c&&(this.emit(ae.TimeSyncUpdate,{timestamp:r,rtpTimestamp:c}),this.rtpTimestamp=c)}};e()}}class WS extends ZS{constructor(e,n,a,r,c,l){super(e,n,Q.Kind.Audio,a,l),this.monitorReceiver=()=>A(this,void 0,void 0,function*(){if(!this.receiver){this._currentBitrate=0;return}const u=yield this.getReceiverStats();u&&this.prevStats&&this.receiver&&(this._currentBitrate=Wc(u,this.prevStats)),this.prevStats=u}),this.audioContext=r,this.webAudioPluginNodes=[],c&&(this.sinkId=c.deviceId)}setVolume(e){var n;for(const a of this.attachedElements)this.audioContext?(n=this.gainNode)===null||n===void 0||n.gain.setTargetAtTime(e,0,.1):a.volume=e;$n()&&this._mediaStreamTrack._setVolume(e),this.elementVolume=e}getVolume(){if(this.elementVolume)return this.elementVolume;if($n())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(Uf(n))return n.setSinkId(e)}))})}attach(e){const n=this.attachedElements.length===0;return e?super.attach(e):e=super.attach(),this.sinkId&&Uf(e)&&e.setSinkId(this.sinkId).catch(a=>{this.log.error("Failed to set sink id on remote audio track",a,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 a=this.sourceNode;this.webAudioPluginNodes.forEach(r=>{a.connect(r),a=r}),this.gainNode=e.createGain(),a.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(ae.AudioPlaybackFailed,new Error("Audio Context couldn't be started automatically"))}).catch(r=>{this.emit(ae.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(a=>{a.type==="inbound-rtp"&&(n={type:"audio",streamId:a.id,timestamp:a.timestamp,jitter:a.jitter,bytesReceived:a.bytesReceived,concealedSamples:a.concealedSamples,concealmentEvents:a.concealmentEvents,silentConcealedSamples:a.silentConcealedSamples,silentConcealmentEvents:a.silentConcealmentEvents,totalAudioEnergy:a.totalAudioEnergy,totalSamplesDuration:a.totalSamplesDuration})}),n})}}const lh=100;class $P extends ZS{constructor(e,n,a,r,c){super(e,n,Q.Kind.Video,a,c),this.elementInfos=[],this.monitorReceiver=()=>A(this,void 0,void 0,function*(){if(!this.receiver){this._currentBitrate=0;return}const l=yield this.getReceiverStats();l&&this.prevStats&&this.receiver&&(this._currentBitrate=Wc(l,this.prevStats)),this.prevStats=l}),this.debouncedHandleResize=Wf(()=>{this.updateDimensions()},lh),this.adaptiveStreamSettings=r}get isAdaptiveStream(){return this.adaptiveStreamSettings!==void 0}setStreamState(e){super.setStreamState(e),this.log.debug("setStreamState",e),this.isAdaptiveStream&&e===Q.StreamState.Active&&this.updateVisibility()}get mediaStreamTrack(){return this._mediaStreamTrack}setMuted(e){super.setMuted(e),this.attachedElements.forEach(n=>{e?As(this._mediaStreamTrack,n):xs(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 eN(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(a=>a===e);for(const a of n)a.stopObserving();this.elementInfos=this.elementInfos.filter(a=>a!==e),this.updateVisibility(),this.debouncedHandleResize()}detach(e){let n=[];if(e)return this.stopObservingElement(e),super.detach(e);n=super.detach();for(const a of n)this.stopObservingElement(a);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,a="",r=new Map;return e.forEach(c=>{c.type==="inbound-rtp"?(a=c.codecId,n={type:"video",streamId:c.id,framesDecoded:c.framesDecoded,framesDropped:c.framesDropped,framesReceived:c.framesReceived,packetsReceived:c.packetsReceived,packetsLost:c.packetsLost,frameWidth:c.frameWidth,frameHeight:c.frameHeight,pliCount:c.pliCount,firCount:c.firCount,nackCount:c.nackCount,jitter:c.jitter,timestamp:c.timestamp,bytesReceived:c.bytesReceived,decoderImplementation:c.decoderImplementation}):c.type==="codec"&&r.set(c.id,c)}),n&&a!==""&&r.get(a)&&(n.mimeType=r.get(a).mimeType),n})}stopObservingElement(e){const n=this.elementInfos.filter(a=>a.element===e);for(const a of n)this.stopObservingElementInfo(a)}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(e){var n,a;const r=this.elementInfos.reduce((f,h)=>Math.max(f,h.visibilityChangedAt||0),0),c=!((a=(n=this.adaptiveStreamSettings)===null||n===void 0?void 0:n.pauseVideoInBackground)!==null&&a!==void 0)||a?this.isInBackground:!1,l=this.elementInfos.some(f=>f.pictureInPicture),u=this.elementInfos.some(f=>f.visible)&&!c||l;if(!(this.lastVisible===u&&!e)){if(!u&&Date.now()-r<lh){Mt.setTimeout(()=>{this.updateVisibility()},lh);return}this.lastVisible=u,this.emit(ae.VisibilityChanged,u,this)}}updateDimensions(){var e,n;let a=0,r=0;const c=this.getPixelDensity();for(const l of this.elementInfos){const u=l.width()*c,f=l.height()*c;u+f>a+r&&(a=u,r=f)}((e=this.lastDimensions)===null||e===void 0?void 0:e.width)===a&&((n=this.lastDimensions)===null||n===void 0?void 0:n.height)===r||(this.lastDimensions={width:a,height:r},this.emit(ae.VideoDimensionsChanged,this.lastDimensions,this))}getPixelDensity(){var e;const n=(e=this.adaptiveStreamSettings)===null||e===void 0?void 0:e.pixelDensity;return n==="screen"?mS():n||(mS()>2?2:1)}}class eN{get visible(){return this.isPiP||this.isIntersecting}get pictureInPicture(){return this.isPiP}constructor(e,n){this.onVisibilityChanged=a=>{var r;const{target:c,isIntersecting:l}=a;c===this.element&&(this.isIntersecting=l,this.isPiP=so(this.element),this.visibilityChangedAt=Date.now(),(r=this.handleVisibilityChanged)===null||r===void 0||r.call(this))},this.onEnterPiP=()=>{var a,r,c;(r=(a=window.documentPictureInPicture)===null||a===void 0?void 0:a.window)===null||r===void 0||r.addEventListener("pagehide",this.onLeavePiP),this.isPiP=so(this.element),(c=this.handleVisibilityChanged)===null||c===void 0||c.call(this)},this.onLeavePiP=()=>{var a;this.isPiP=so(this.element),(a=this.handleVisibilityChanged)===null||a===void 0||a.call(this)},this.element=e,this.isIntersecting=n!=null?n:uh(e),this.isPiP=Qt()&&so(e),this.visibilityChangedAt=0}width(){return this.element.clientWidth}height(){return this.element.clientHeight}observe(){var e,n,a;this.isIntersecting=uh(this.element),this.isPiP=so(this.element),this.element.handleResize=()=>{var r;(r=this.handleResize)===null||r===void 0||r.call(this)},this.element.handleVisibilityChanged=this.onVisibilityChanged,gS().observe(this.element),pS().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),(a=(n=window.documentPictureInPicture)===null||n===void 0?void 0:n.window)===null||a===void 0||a.addEventListener("pagehide",this.onLeavePiP)}stopObserving(){var e,n,a,r,c;(e=gS())===null||e===void 0||e.unobserve(this.element),(n=pS())===null||n===void 0||n.unobserve(this.element),this.element.removeEventListener("enterpictureinpicture",this.onEnterPiP),this.element.removeEventListener("leavepictureinpicture",this.onLeavePiP),(a=window.documentPictureInPicture)===null||a===void 0||a.removeEventListener("enter",this.onEnterPiP),(c=(r=window.documentPictureInPicture)===null||r===void 0?void 0:r.window)===null||c===void 0||c.removeEventListener("pagehide",this.onLeavePiP)}}function so(t){var e,n;return document.pictureInPictureElement===t?!0:!((e=window.documentPictureInPicture)===null||e===void 0)&&e.window?uh(t,(n=window.documentPictureInPicture)===null||n===void 0?void 0:n.window):!1}function uh(t,e){const n=e||window;let a=t.offsetTop,r=t.offsetLeft;const c=t.offsetWidth,l=t.offsetHeight,{hidden:u}=t,{display:f}=getComputedStyle(t);for(;t.offsetParent;)t=t.offsetParent,a+=t.offsetTop,r+=t.offsetLeft;return a<n.pageYOffset+n.innerHeight&&r<n.pageXOffset+n.innerWidth&&a+l>n.pageYOffset&&r+c>n.pageXOffset&&!u&&f!=="none"}class gi extends Zn.EventEmitter{constructor(e,n,a,r){var c;super(),this.metadataMuted=!1,this.encryption=Ct.NONE,this.log=Ee,this.handleMuted=()=>{this.emit(ae.Muted)},this.handleUnmuted=()=>{this.emit(ae.Unmuted)},this.log=fi((c=r==null?void 0:r.loggerName)!==null&&c!==void 0?c:jn.Publication),this.loggerContextCb=this.loggerContextCb,this.setMaxListeners(100),this.kind=e,this.trackSid=n,this.trackName=a,this.source=Q.Source.Unknown}setTrack(e){this.track&&(this.track.off(ae.Muted,this.handleMuted),this.track.off(ae.Unmuted,this.handleUnmuted)),this.track=e,e&&(e.on(ae.Muted,this.handleMuted),e.on(ae.Unmuted,this.handleUnmuted))}get logContext(){var e;return Object.assign(Object.assign({},(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this)),xe(this))}get isMuted(){return this.metadataMuted}get isEnabled(){return!0}get isSubscribed(){return this.track!==void 0}get isEncrypted(){return this.encryption!==Ct.NONE}get audioTrack(){if(ei(this.track))return this.track}get videoTrack(){if(Ki(this.track))return this.track}updateInfo(e){this.trackSid=e.sid,this.trackName=e.name,this.source=Q.sourceFromProto(e.source),this.mimeType=e.mimeType,this.kind===Q.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={}))})(gi||(gi={}));class dh extends gi{get isUpstreamPaused(){var e;return(e=this.track)===null||e===void 0?void 0:e.isUpstreamPaused}constructor(e,n,a,r){super(e,n.sid,n.name,r),this.track=void 0,this.handleTrackEnded=()=>{this.emit(ae.Ended)},this.handleCpuConstrained=()=>{this.track&&Ki(this.track)&&this.emit(ae.CpuConstrained,this.track)},this.updateInfo(n),this.setTrack(a)}setTrack(e){this.track&&(this.track.off(ae.Ended,this.handleTrackEnded),this.track.off(ae.CpuConstrained,this.handleCpuConstrained)),super.setTrack(e),e&&(e.on(ae.Ended,this.handleTrackEnded),e.on(ae.CpuConstrained,this.handleCpuConstrained))}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(ei(this.track)){const n=this.track.getSourceTrackSettings(),a=new Set;return n.autoGainControl&&a.add(wt.TF_AUTO_GAIN_CONTROL),n.echoCancellation&&a.add(wt.TF_ECHO_CANCELLATION),n.noiseSuppression&&a.add(wt.TF_NOISE_SUPPRESSION),n.channelCount&&n.channelCount>1&&a.add(wt.TF_STEREO),!((e=this.options)===null||e===void 0)&&e.dtx||a.add(wt.TF_NO_DTX),this.track.enhancedNoiseCancellation&&a.add(wt.TF_ENHANCED_NOISE_CANCELLATION),Array.from(a.values())}else return[]}}function tl(t,e){return A(this,void 0,void 0,function*(){t!=null||(t={});let n=!1;const{audioProcessor:a,videoProcessor:r,optionsWithoutProcessor:c}=oS(t);let l=c.audio,u=c.video;if(a&&typeof c.audio=="object"&&(c.audio.processor=a),r&&typeof c.video=="object"&&(c.video.processor=r),t.audio&&typeof c.audio=="object"&&typeof c.audio.deviceId=="string"){const v=c.audio.deviceId;c.audio.deviceId={exact:v},n=!0,l=Object.assign(Object.assign({},c.audio),{deviceId:{ideal:v}})}if(c.video&&typeof c.video=="object"&&typeof c.video.deviceId=="string"){const v=c.video.deviceId;c.video.deviceId={exact:v},n=!0,u=Object.assign(Object.assign({},c.video),{deviceId:{ideal:v}})}c.audio===!0?c.audio={deviceId:"default"}:typeof c.audio=="object"&&c.audio!==null&&(c.audio=Object.assign(Object.assign({},c.audio),{deviceId:c.audio.deviceId||"default"})),c.video===!0?c.video={deviceId:"default"}:typeof c.video=="object"&&!c.video.deviceId&&(c.video.deviceId="default");const f=sS(c,PS,NS),h=Of(f),p=navigator.mediaDevices.getUserMedia(h);c.audio&&(Rt.userMediaPromiseMap.set("audioinput",p),p.catch(()=>Rt.userMediaPromiseMap.delete("audioinput"))),c.video&&(Rt.userMediaPromiseMap.set("videoinput",p),p.catch(()=>Rt.userMediaPromiseMap.delete("videoinput")));try{const v=yield p;return yield Promise.all(v.getTracks().map(y=>A(this,void 0,void 0,function*(){const S=y.kind==="audio";let w=S?f.audio:f.video;(typeof w=="boolean"||!w)&&(w={});let T;const x=S?h.audio:h.video;typeof x!="boolean"&&(T=x);const R=y.getSettings().deviceId;T!=null&&T.deviceId&&Gi(T.deviceId)!==R?T.deviceId=R:T||(T={deviceId:R});const P=AP(y,T,e);return P.kind===Q.Kind.Video?P.source=Q.Source.Camera:P.kind===Q.Kind.Audio&&(P.source=Q.Source.Microphone),P.mediaStream=v,ei(P)&&a?yield P.setProcessor(a):Ki(P)&&r&&(yield P.setProcessor(r)),P})))}catch(v){if(!n)throw v;return tl(Object.assign(Object.assign({},t),{audio:l,video:u}),e)}})}function tN(t){return A(this,void 0,void 0,function*(){return(yield tl({audio:!1,video:!0}))[0]})}function nN(t){return A(this,void 0,void 0,function*(){return(yield tl({audio:!0,video:!1}))[0]})}var Zi;(function(t){t.Excellent="excellent",t.Good="good",t.Poor="poor",t.Lost="lost",t.Unknown="unknown"})(Zi||(Zi={}));function iN(t){switch(t){case Kr.EXCELLENT:return Zi.Excellent;case Kr.GOOD:return Zi.Good;case Kr.POOR:return Zi.Poor;case Kr.LOST:return Zi.Lost;default:return Zi.Unknown}}class $S extends Zn.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===Ba.AGENT}get isActive(){var e;return((e=this.participantInfo)===null||e===void 0?void 0:e.state)===Cs.ACTIVE}get kind(){return this._kind}get attributes(){return Object.freeze(Object.assign({},this._attributes))}constructor(e,n,a,r,c,l){let u=arguments.length>6&&arguments[6]!==void 0?arguments[6]:Ba.STANDARD;var f;super(),this.audioLevel=0,this.isSpeaking=!1,this._connectionQuality=Zi.Unknown,this.log=Ee,this.log=fi((f=l==null?void 0:l.loggerName)!==null&&f!==void 0?f:jn.Participant),this.loggerOptions=l,this.setMaxListeners(100),this.sid=e,this.identity=n,this.name=a,this.metadata=r,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this._kind=u,this._attributes=c!=null?c:{}}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 Tn,this.once(ee.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(Q.Source.Camera);return!(!((e=n==null?void 0:n.isMuted)!==null&&e!==void 0)||e)}get isMicrophoneEnabled(){var e;const n=this.getTrackPublication(Q.Source.Microphone);return!(!((e=n==null?void 0:n.isMuted)!==null&&e!==void 0)||e)}get isScreenShareEnabled(){return!!this.getTrackPublication(Q.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===Cs.ACTIVE&&((n=this.participantInfo)===null||n===void 0?void 0:n.state)!==Cs.ACTIVE&&this.emit(ee.Active),e.permission&&this.setPermissions(e.permission),this.participantInfo=e,!0)}_setMetadata(e){const n=this.metadata!==e,a=this.metadata;this.metadata=e,n&&this.emit(ee.ParticipantMetadataChanged,a)}_setName(e){const n=this.name!==e;this.name=e,n&&this.emit(ee.ParticipantNameChanged,e)}_setAttributes(e){const n=CO(this.attributes,e);this._attributes=e,Object.keys(n).length>0&&this.emit(ee.AttributesChanged,n)}setPermissions(e){var n,a,r,c,l,u;const f=this.permissions,h=e.canPublish!==((n=this.permissions)===null||n===void 0?void 0:n.canPublish)||e.canSubscribe!==((a=this.permissions)===null||a===void 0?void 0:a.canSubscribe)||e.canPublishData!==((r=this.permissions)===null||r===void 0?void 0:r.canPublishData)||e.hidden!==((c=this.permissions)===null||c===void 0?void 0:c.hidden)||e.recorder!==((l=this.permissions)===null||l===void 0?void 0:l.recorder)||e.canPublishSources.length!==this.permissions.canPublishSources.length||e.canPublishSources.some((p,v)=>{var y;return p!==((y=this.permissions)===null||y===void 0?void 0:y.canPublishSources[v])})||e.canSubscribeMetrics!==((u=this.permissions)===null||u===void 0?void 0:u.canSubscribeMetrics);return this.permissions=e,h&&this.emit(ee.ParticipantPermissionsChanged,f),h}setIsSpeaking(e){e!==this.isSpeaking&&(this.isSpeaking=e,e&&(this.lastSpokeAt=new Date),this.emit(ee.IsSpeakingChanged,e))}setConnectionQuality(e){const n=this._connectionQuality;this._connectionQuality=iN(e),n!==this._connectionQuality&&this.emit(ee.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=>ei(n.track)&&n.track.setAudioContext(e))}addTrackPublication(e){e.on(ae.Muted,()=>{this.emit(ee.TrackMuted,e)}),e.on(ae.Unmuted,()=>{this.emit(ee.TrackUnmuted,e)});const n=e;switch(n.track&&(n.track.sid=e.trackSid),this.trackPublications.set(e.trackSid,e),e.kind){case Q.Kind.Audio:this.audioTrackPublications.set(e.trackSid,e);break;case Q.Kind.Video:this.videoTrackPublications.set(e.trackSid,e);break}}}function aN(t){var e,n,a;if(!t.participantSid&&!t.participantIdentity)throw new Error("Invalid track permission, must provide at least one of participantIdentity and participantSid");return new cb({participantIdentity:(e=t.participantIdentity)!==null&&e!==void 0?e:"",participantSid:(n=t.participantSid)!==null&&n!==void 0?n:"",allTracks:(a=t.allowAll)!==null&&a!==void 0?a:!1,trackSids:t.allowedTrackSids||[]})}class sN extends $S{constructor(e,n,a,r,c,l){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=Ct.NONE,this.enabledPublishVideoCodecs=[],this.pendingAcks=new Map,this.pendingResponses=new Map,this.handleReconnecting=()=>{this.reconnectFuture||(this.reconnectFuture=new Tn)},this.handleReconnected=()=>{var u,f;(f=(u=this.reconnectFuture)===null||u===void 0?void 0:u.resolve)===null||f===void 0||f.call(u),this.reconnectFuture=void 0,this.updateTrackSubscriptionPermissions()},this.handleClosing=()=>{var u,f,h,p,v,y;this.reconnectFuture&&(this.reconnectFuture.promise.catch(S=>this.log.warn(S.message,this.logContext)),(f=(u=this.reconnectFuture)===null||u===void 0?void 0:u.reject)===null||f===void 0||f.call(u,new Error("Got disconnected during reconnection attempt")),this.reconnectFuture=void 0),this.signalConnectedFuture&&((p=(h=this.signalConnectedFuture).reject)===null||p===void 0||p.call(h,new Error("Got disconnected without signal connected")),this.signalConnectedFuture=void 0),(y=(v=this.activeAgentFuture)===null||v===void 0?void 0:v.reject)===null||y===void 0||y.call(v,new Error("Got disconnected without active agent present")),this.activeAgentFuture=void 0,this.firstActiveAgent=void 0},this.handleSignalConnected=u=>{var f,h;u.participant&&this.updateInfo(u.participant),this.signalConnectedFuture||(this.signalConnectedFuture=new Tn),(h=(f=this.signalConnectedFuture).resolve)===null||h===void 0||h.call(f)},this.handleSignalRequestResponse=u=>{const{requestId:f,reason:h,message:p}=u,v=this.pendingSignalRequests.get(f);v&&(h!==pf.OK&&v.reject(new iS(p,h)),this.pendingSignalRequests.delete(f))},this.handleDataPacket=u=>{switch(u.value.case){case"rpcResponse":let f=u.value.value,h=null,p=null;f.value.case==="payload"?h=f.value.value:f.value.case==="error"&&(p=ot.fromProto(f.value.value)),this.handleIncomingRpcResponse(f.requestId,h,p);break;case"rpcAck":let v=u.value.value;this.handleIncomingRpcAck(v.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(u=>aN(u)))},this.onTrackUnmuted=u=>{this.onTrackMuted(u,u.isUpstreamPaused)},this.onTrackMuted=(u,f)=>{if(f===void 0&&(f=!0),!u.sid){this.log.error("could not update mute status for unpublished track",Object.assign(Object.assign({},this.logContext),xe(u)));return}this.engine.updateMuteStatus(u.sid,f)},this.onTrackUpstreamPaused=u=>{this.log.debug("upstream paused",Object.assign(Object.assign({},this.logContext),xe(u))),this.onTrackMuted(u,!0)},this.onTrackUpstreamResumed=u=>{this.log.debug("upstream resumed",Object.assign(Object.assign({},this.logContext),xe(u))),this.onTrackMuted(u,u.isMuted)},this.onTrackFeatureUpdate=u=>{const f=this.audioTrackPublications.get(u.sid);if(!f){this.log.warn("Could not update local audio track settings, missing publication for track ".concat(u.sid),this.logContext);return}this.engine.client.sendUpdateLocalAudioTrack(f.trackSid,f.getTrackFeatures())},this.onTrackCpuConstrained=(u,f)=>{this.log.debug("track cpu constrained",Object.assign(Object.assign({},this.logContext),xe(f))),this.emit(ee.LocalTrackCpuConstrained,u,f)},this.handleSubscribedQualityUpdate=u=>A(this,void 0,void 0,function*(){var f,h,p,v,y;if(!(!((y=this.roomOptions)===null||y===void 0)&&y.dynacast))return;const S=this.videoTrackPublications.get(u.trackSid);if(!S){this.log.warn("received subscribed quality update for unknown track",Object.assign(Object.assign({},this.logContext),{trackSid:u.trackSid}));return}if(!S.videoTrack)return;const w=yield S.videoTrack.setPublishingCodecs(u.subscribedCodecs);try{for(var T=!0,x=hi(w),R;R=yield x.next(),f=R.done,!f;T=!0){v=R.value,T=!1;const P=v;vO(P)&&(this.log.debug("publish ".concat(P," for ").concat(S.videoTrack.sid),Object.assign(Object.assign({},this.logContext),xe(S))),yield this.publishAdditionalCodecForTrack(S.videoTrack,P,S.options))}}catch(P){h={error:P}}finally{try{!T&&!f&&(p=x.return)&&(yield p.call(x))}finally{if(h)throw h.error}}}),this.handleLocalTrackUnpublished=u=>{const f=this.trackPublications.get(u.trackSid);if(!f){this.log.warn("received unpublished event for unknown track",Object.assign(Object.assign({},this.logContext),{trackSid:u.trackSid}));return}this.unpublishTrack(f.track)},this.handleTrackEnded=u=>A(this,void 0,void 0,function*(){if(u.source===Q.Source.ScreenShare||u.source===Q.Source.ScreenShareAudio)this.log.debug("unpublishing local track due to TrackEnded",Object.assign(Object.assign({},this.logContext),xe(u))),this.unpublishTrack(u);else if(u.isUserProvided)yield u.mute();else if(pi(u)||Yi(u))try{if(Qt())try{const f=yield navigator==null?void 0:navigator.permissions.query({name:u.source===Q.Source.Camera?"camera":"microphone"});if(f&&f.state==="denied")throw this.log.warn("user has revoked access to ".concat(u.source),Object.assign(Object.assign({},this.logContext),xe(u))),f.onchange=()=>{f.state!=="denied"&&(u.isMuted||u.restartTrack(),f.onchange=null)},new Error("GetUserMedia Permission denied")}catch{}u.isMuted||(this.log.debug("track ended, attempting to use a different device",Object.assign(Object.assign({},this.logContext),xe(u))),pi(u)?yield u.restartTrack({deviceId:"default"}):yield u.restartTrack())}catch{this.log.warn("could not restart track, muting instead",Object.assign(Object.assign({},this.logContext),xe(u))),yield u.mute()}}),this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this.engine=a,this.roomOptions=r,this.setupEngine(a),this.activeDeviceMap=new Map([["audioinput","default"],["videoinput","default"],["audiooutput","default"]]),this.pendingSignalRequests=new Map,this.rpcHandlers=c,this.roomOutgoingDataStreamManager=l}get lastCameraError(){return this.cameraError}get lastMicrophoneError(){return this.microphoneError}get isE2EEEnabled(){return this.encryptionType!==Ct.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){var n;this.engine=e,this.engine.on(se.RemoteMute,(a,r)=>{const c=this.trackPublications.get(a);!c||!c.track||(r?c.mute():c.unmute())}),!((n=this.signalConnectedFuture)===null||n===void 0)&&n.isResolved&&(this.signalConnectedFuture=void 0),this.engine.on(se.Connected,this.handleReconnected).on(se.SignalConnected,this.handleSignalConnected).on(se.SignalRestarted,this.handleReconnected).on(se.SignalResumed,this.handleReconnected).on(se.Restarting,this.handleReconnecting).on(se.Resuming,this.handleReconnecting).on(se.LocalTrackUnpublished,this.handleLocalTrackUnpublished).on(se.SubscribedQualityUpdate,this.handleSubscribedQualityUpdate).on(se.Closing,this.handleClosing).on(se.SignalRequestResponse,this.handleSignalRequestResponse).on(se.DataPacketReceived,this.handleDataPacket)}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 a=this;let{metadata:r,name:c,attributes:l}=n;return(function*(){return new Yt((u,f)=>A(a,void 0,void 0,function*(){var h,p;try{let v=!1;const y=yield this.engine.client.sendUpdateLocalMetadata((h=r!=null?r:this.metadata)!==null&&h!==void 0?h:"",(p=c!=null?c:this.name)!==null&&p!==void 0?p:"",l),S=performance.now();for(this.pendingSignalRequests.set(y,{resolve:u,reject:w=>{f(w),v=!0},values:{name:c,metadata:r,attributes:l}});performance.now()-S<5e3&&!v;){if((!c||this.name===c)&&(!r||this.metadata===r)&&(!l||Object.entries(l).every(w=>{let[T,x]=w;return this.attributes[T]===x||x===""&&!this.attributes[T]}))){this.pendingSignalRequests.delete(y),u();return}yield Dt(50)}f(new iS("Request to update local metadata timed out","TimeoutError"))}catch(v){v instanceof Error?f(v):f(new Error(String(v)))}}))})()})}setCameraEnabled(e,n,a){return this.setTrackEnabled(Q.Source.Camera,e,n,a)}setMicrophoneEnabled(e,n,a){return this.setTrackEnabled(Q.Source.Microphone,e,n,a)}setScreenShareEnabled(e,n,a){return this.setTrackEnabled(Q.Source.ScreenShare,e,n,a)}setE2EEEnabled(e){return A(this,void 0,void 0,function*(){this.encryptionType=e?Ct.GCM:Ct.NONE,yield this.republishAllTracks(void 0,!1)})}setTrackEnabled(e,n,a,r){return A(this,void 0,void 0,function*(){var c,l;this.log.debug("setTrackEnabled",Object.assign(Object.assign({},this.logContext),{source:e,enabled:n})),this.republishPromise&&(yield this.republishPromise);let u=this.getTrackPublication(e);if(n)if(u)yield u.unmute();else{let f;if(this.pendingPublishing.has(e)){const h=yield this.waitForPendingPublicationOfSource(e);return h||this.log.info("waiting for pending publication promise timed out",Object.assign(Object.assign({},this.logContext),{source:e})),yield h==null?void 0:h.unmute(),h}this.pendingPublishing.add(e);try{switch(e){case Q.Source.Camera:f=yield this.createTracks({video:(c=a)!==null&&c!==void 0?c:!0});break;case Q.Source.Microphone:f=yield this.createTracks({audio:(l=a)!==null&&l!==void 0?l:!0});break;case Q.Source.ScreenShare:f=yield this.createScreenTracks(Object.assign({},a));break;default:throw new mi(e)}}catch(h){throw f==null||f.forEach(p=>{p.stop()}),h instanceof Error&&this.emit(ee.MediaDevicesError,h,Nf(e)),this.pendingPublishing.delete(e),h}for(const h of f){const p=Object.assign(Object.assign({},this.roomOptions.publishDefaults),a);e===Q.Source.Microphone&&ei(h)&&p.preConnectBuffer&&(this.log.info("starting preconnect buffer for microphone",Object.assign({},this.logContext)),h.startPreConnectBuffer())}try{const h=[];for(const v of f)this.log.info("publishing track",Object.assign(Object.assign({},this.logContext),xe(v))),h.push(this.publishTrack(v,r));[u]=yield Promise.all(h)}catch(h){throw f==null||f.forEach(p=>{p.stop()}),h}finally{this.pendingPublishing.delete(e)}}else if(!(u!=null&&u.track)&&this.pendingPublishing.has(e)&&(u=yield this.waitForPendingPublicationOfSource(e),u||this.log.info("waiting for pending publication promise timed out",Object.assign(Object.assign({},this.logContext),{source:e}))),u&&u.track)if(e===Q.Source.ScreenShare){u=yield this.unpublishTrack(u.track);const f=this.getTrackPublication(Q.Source.ScreenShareAudio);f&&f.track&&this.unpublishTrack(f.track)}else yield u.mute();return u})}enableCameraAndMicrophone(){return A(this,void 0,void 0,function*(){if(!(this.pendingPublishing.has(Q.Source.Camera)||this.pendingPublishing.has(Q.Source.Microphone))){this.pendingPublishing.add(Q.Source.Camera),this.pendingPublishing.add(Q.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(Q.Source.Camera),this.pendingPublishing.delete(Q.Source.Microphone)}}})}createTracks(e){return A(this,void 0,void 0,function*(){var n,a;e!=null||(e={});const r=sS(e,(n=this.roomOptions)===null||n===void 0?void 0:n.audioCaptureDefaults,(a=this.roomOptions)===null||a===void 0?void 0:a.videoCaptureDefaults);try{return(yield tl(r,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext})).map(u=>(ei(u)&&(this.microphoneError=void 0,u.setAudioContext(this.audioContext),u.source=Q.Source.Microphone,this.emit(ee.AudioStreamAcquired)),Ki(u)&&(this.cameraError=void 0,u.source=Q.Source.Camera),u))}catch(c){throw c instanceof Error&&(e.audio&&(this.microphoneError=c),e.video&&(this.cameraError=c)),c}})}createScreenTracks(e){return A(this,void 0,void 0,function*(){if(e===void 0&&(e={}),navigator.mediaDevices.getDisplayMedia===void 0)throw new _f("getDisplayMedia not supported");e.resolution===void 0&&!DO()&&(e.resolution=Mf.h1080fps30.resolution);const n=bO(e),a=yield navigator.mediaDevices.getDisplayMedia(n),r=a.getVideoTracks();if(r.length===0)throw new mi("no video track found");const c=new el(r[0],void 0,!1,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});c.source=Q.Source.ScreenShare,e.contentHint&&(c.mediaStreamTrack.contentHint=e.contentHint);const l=[c];if(a.getAudioTracks().length>0){this.emit(ee.AudioStreamAcquired);const u=new $c(a.getAudioTracks()[0],void 0,!1,this.audioContext,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});u.source=Q.Source.ScreenShareAudio,l.push(u)}return l})}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(a,r){var c=this;let l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return(function*(){var u,f,h,p;pi(a)&&a.setAudioContext(c.audioContext),yield(u=c.reconnectFuture)===null||u===void 0?void 0:u.promise,c.republishPromise&&!l&&(yield c.republishPromise),Ds(a)&&c.pendingPublishPromises.has(a)&&(yield c.pendingPublishPromises.get(a));let v;if(a instanceof MediaStreamTrack)v=a.getConstraints();else{v=a.constraints;let R;switch(a.source){case Q.Source.Microphone:R="audioinput";break;case Q.Source.Camera:R="videoinput"}R&&c.activeDeviceMap.has(R)&&(v=Object.assign(Object.assign({},v),{deviceId:c.activeDeviceMap.get(R)}))}if(a instanceof MediaStreamTrack)switch(a.kind){case"audio":a=new $c(a,v,!0,c.audioContext,{loggerName:c.roomOptions.loggerName,loggerContextCb:()=>c.logContext});break;case"video":a=new el(a,v,!0,{loggerName:c.roomOptions.loggerName,loggerContextCb:()=>c.logContext});break;default:throw new mi("unsupported MediaStreamTrack kind ".concat(a.kind))}else a.updateLoggerOptions({loggerName:c.roomOptions.loggerName,loggerContextCb:()=>c.logContext});let y;if(c.trackPublications.forEach(R=>{R.track&&R.track===a&&(y=R)}),y)return c.log.warn("track has already been published, skipping",Object.assign(Object.assign({},c.logContext),xe(y))),y;const S=Object.assign(Object.assign({},c.roomOptions.publishDefaults),r),w="channelCount"in a.mediaStreamTrack.getSettings()&&a.mediaStreamTrack.getSettings().channelCount===2||a.mediaStreamTrack.getConstraints().channelCount===2,T=(f=S.forceStereo)!==null&&f!==void 0?f:w;T&&(S.dtx===void 0&&c.log.info("Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work.",Object.assign(Object.assign({},c.logContext),xe(a))),S.red===void 0&&c.log.info("Opus RED will be disabled for stereo tracks by default. Enable them explicitly to make it work."),(h=S.dtx)!==null&&h!==void 0||(S.dtx=!1),(p=S.red)!==null&&p!==void 0||(S.red=!1)),!PO()&&c.roomOptions.e2ee&&(c.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({},c.logContext)),S.simulcast=!1),S.source&&(a.source=S.source);const x=new Promise((R,P)=>A(c,void 0,void 0,function*(){try{if(this.engine.client.currentState!==Xe.CONNECTED){this.log.debug("deferring track publication until signal is connected",Object.assign(Object.assign({},this.logContext),{track:xe(a)}));let L=!1;const E=setTimeout(()=>{L=!0,a.stop(),P(new nS("publishing rejected as engine not connected within timeout",408))},15e3);if(yield this.waitUntilEngineConnected(),clearTimeout(E),L)return;const k=yield this.publish(a,S,T);R(k)}else try{const L=yield this.publish(a,S,T);R(L)}catch(L){P(L)}}catch(L){P(L)}}));c.pendingPublishPromises.set(a,x);try{return yield x}catch(R){throw R}finally{c.pendingPublishPromises.delete(a)}})()})}waitUntilEngineConnected(){return this.signalConnectedFuture||(this.signalConnectedFuture=new Tn),this.signalConnectedFuture.promise}hasPermissionsToPublish(e){if(!this.permissions)return this.log.warn("no permissions present for publishing track",Object.assign(Object.assign({},this.logContext),xe(e))),!1;const{canPublish:n,canPublishSources:a}=this.permissions;return n&&(a.length===0||a.map(r=>kO(r)).includes(e.source))?!0:(this.log.warn("insufficient permissions to publish",Object.assign(Object.assign({},this.logContext),xe(e))),!1)}publish(e,n,a){return A(this,void 0,void 0,function*(){var r,c,l,u,f,h,p,v,y,S;if(!this.hasPermissionsToPublish(e))throw new nS("failed to publish track, insufficient permissions",403);Array.from(this.trackPublications.values()).find(G=>Ds(e)&&G.source===e.source)&&e.source!==Q.Source.Unknown&&this.log.info("publishing a second track with the same source: ".concat(e.source),Object.assign(Object.assign({},this.logContext),xe(e))),n.stopMicTrackOnMute&&ei(e)&&(e.stopOnMute=!0),e.source===Q.Source.ScreenShare&&Va()&&(n.simulcast=!1),n.videoCodec==="av1"&&!xO()&&(n.videoCodec=void 0),n.videoCodec==="vp9"&&!AO()&&(n.videoCodec=void 0),n.videoCodec===void 0&&(n.videoCodec=eh),this.enabledPublishVideoCodecs.length>0&&(this.enabledPublishVideoCodecs.some(G=>n.videoCodec===Wr(G.mime))||(n.videoCodec=Wr(this.enabledPublishVideoCodecs[0].mime)));const T=n.videoCodec;e.on(ae.Muted,this.onTrackMuted),e.on(ae.Unmuted,this.onTrackUnmuted),e.on(ae.Ended,this.handleTrackEnded),e.on(ae.UpstreamPaused,this.onTrackUpstreamPaused),e.on(ae.UpstreamResumed,this.onTrackUpstreamResumed),e.on(ae.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate);const x=[],R=!(!((r=n.dtx)!==null&&r!==void 0)||r),P=e.getSourceTrackSettings();P.autoGainControl&&x.push(wt.TF_AUTO_GAIN_CONTROL),P.echoCancellation&&x.push(wt.TF_ECHO_CANCELLATION),P.noiseSuppression&&x.push(wt.TF_NOISE_SUPPRESSION),P.channelCount&&P.channelCount>1&&x.push(wt.TF_STEREO),R&&x.push(wt.TF_NO_DTX),pi(e)&&e.hasPreConnectBuffer&&x.push(wt.TF_PRECONNECT_BUFFER);const L=new Xr({cid:e.mediaStreamTrack.id,name:n.name,type:Q.kindToProto(e.kind),muted:e.isMuted,source:Q.sourceToProto(e.source),disableDtx:R,encryption:this.encryptionType,stereo:a,disableRed:this.isE2EEEnabled||!(!((c=n.red)!==null&&c!==void 0)||c),stream:n==null?void 0:n.stream,backupCodecPolicy:n==null?void 0:n.backupCodecPolicy,audioFeatures:x});let E;if(e.kind===Q.Kind.Video){let G={width:0,height:0};try{G=yield e.waitForDimensions()}catch{const Y=(u=(l=this.roomOptions.videoCaptureDefaults)===null||l===void 0?void 0:l.resolution)!==null&&u!==void 0?u:Zr.h720.resolution;G={width:Y.width,height:Y.height},this.log.error("could not determine track dimensions, using defaults",Object.assign(Object.assign(Object.assign({},this.logContext),xe(e)),{dims:G}))}L.width=G.width,L.height=G.height,Yi(e)&&(Vn(T)&&(e.source===Q.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),xe(e))))),n.scalabilityMode=(f=n.scalabilityMode)!==null&&f!==void 0?f:"L3T3_KEY"),L.simulcastCodecs=[new lf({codec:T,cid:e.mediaStreamTrack.id})],n.backupCodec===!0&&(n.backupCodec={codec:eh}),n.backupCodec&&T!==n.backupCodec.codec&&L.encryption===Ct.NONE&&(this.roomOptions.dynacast||(this.roomOptions.dynacast=!0),L.simulcastCodecs.push(new lf({codec:n.backupCodec.codec,cid:""})))),E=rh(e.source===Q.Source.ScreenShare,L.width,L.height,n),L.layers=HS(L.width,L.height,E,Vn(n.videoCodec))}else e.kind===Q.Kind.Audio&&(E=[{maxBitrate:(h=n.audioPreset)===null||h===void 0?void 0:h.maxBitrate,priority:(v=(p=n.audioPreset)===null||p===void 0?void 0:p.priority)!==null&&v!==void 0?v:"high",networkPriority:(S=(y=n.audioPreset)===null||y===void 0?void 0:y.priority)!==null&&S!==void 0?S:"high"}]);if(!this.engine||this.engine.isClosed)throw new dt("cannot publish track when not connected");const k=()=>A(this,void 0,void 0,function*(){var G,V,Y;if(!this.engine.pcManager)throw new dt("pcManager is not ready");if(e.sender=yield this.engine.createSender(e,n,E),this.emit(ee.LocalSenderCreated,e.sender,e),Yi(e)&&((G=n.degradationPreference)!==null&&G!==void 0||(n.degradationPreference=jP(e)),e.setDegradationPreference(n.degradationPreference)),E)if(Va()&&e.kind===Q.Kind.Audio){let ie;for(const he of this.engine.pcManager.publisher.getTransceivers())if(he.sender===e.sender){ie=he;break}ie&&this.engine.pcManager.publisher.setTrackCodecBitrate({transceiver:ie,codec:"opus",maxbr:!((V=E[0])===null||V===void 0)&&V.maxBitrate?E[0].maxBitrate/1e3:0})}else e.codec&&Vn(e.codec)&&(!((Y=E[0])===null||Y===void 0)&&Y.maxBitrate)&&this.engine.pcManager.publisher.setTrackCodecBitrate({cid:L.cid,codec:e.codec,maxbr:E[0].maxBitrate/1e3});yield this.engine.negotiate()});let _;const N=new Promise((G,V)=>A(this,void 0,void 0,function*(){var Y;try{_=yield this.engine.addTrack(L),G(_)}catch(ie){e.sender&&(!((Y=this.engine.pcManager)===null||Y===void 0)&&Y.publisher)&&(this.engine.pcManager.publisher.removeTrack(e.sender),yield this.engine.negotiate().catch(he=>{this.log.error("failed to negotiate after removing track due to failed add track request",Object.assign(Object.assign(Object.assign({},this.logContext),xe(e)),{error:he}))})),V(ie)}}));if(this.enabledPublishVideoCodecs.length>0)_=(yield Promise.all([N,k()]))[0];else{_=yield N;let G;if(_.codecs.forEach(V=>{G===void 0&&(G=V.mimeType)}),G&&e.kind===Q.Kind.Video){const V=Wr(G);V!==T&&(this.log.debug("falling back to server selected codec",Object.assign(Object.assign(Object.assign({},this.logContext),xe(e)),{codec:V})),n.videoCodec=V,E=rh(e.source===Q.Source.ScreenShare,L.width,L.height,n))}yield k()}const U=new dh(e.kind,_,e,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});if(U.on(ae.CpuConstrained,G=>this.onTrackCpuConstrained(G,U)),U.options=n,e.sid=_.sid,this.log.debug("publishing ".concat(e.kind," with encodings"),Object.assign(Object.assign({},this.logContext),{encodings:E,trackInfo:_})),Yi(e)?e.startMonitor(this.engine.client):pi(e)&&e.startMonitor(),this.addTrackPublication(U),this.emit(ee.LocalTrackPublished,U),pi(e)&&_.audioFeatures.includes(wt.TF_PRECONNECT_BUFFER)){const G=e.getPreConnectBuffer(),V=e.getPreConnectBufferMimeType();this.on(ee.LocalTrackSubscribed,Y=>{if(Y.trackSid===_.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),xe(e))),e.stopPreConnectBuffer()}}),G&&new Promise((ie,he)=>A(this,void 0,void 0,function*(){var be,qe,H,ne,ce,Ce;try{this.log.debug("waiting for agent",Object.assign(Object.assign({},this.logContext),xe(e)));const re=setTimeout(()=>{he(new Error("agent not active within 10 seconds"))},1e4),le=yield this.waitUntilActiveAgentPresent();clearTimeout(re),this.log.debug("sending preconnect buffer",Object.assign(Object.assign({},this.logContext),xe(e)));const ye=yield this.streamBytes({name:"preconnect-buffer",mimeType:V,topic:"lk.agent.pre-connect-audio-buffer",destinationIdentities:[le.identity],attributes:{trackId:U.trackSid,sampleRate:String((ce=P.sampleRate)!==null&&ce!==void 0?ce:"48000"),channels:String((Ce=P.channelCount)!==null&&Ce!==void 0?Ce:"1")}});try{for(var Re=!0,D=hi(G),Z;Z=yield D.next(),be=Z.done,!be;Re=!0){ne=Z.value,Re=!1;const Se=ne;yield ye.write(Se)}}catch(Se){qe={error:Se}}finally{try{!Re&&!be&&(H=D.return)&&(yield H.call(D))}finally{if(qe)throw qe.error}}yield ye.close(),ie()}catch(re){he(re)}})).then(()=>{this.log.debug("preconnect buffer sent successfully",Object.assign(Object.assign({},this.logContext),xe(e)))}).catch(ie=>{this.log.error("error sending preconnect buffer",Object.assign(Object.assign(Object.assign({},this.logContext),xe(e)),{error:ie}))})}return U})}get isLocal(){return!0}publishAdditionalCodecForTrack(e,n,a){return A(this,void 0,void 0,function*(){var r;if(this.encryptionType!==Ct.NONE)return;let c;if(this.trackPublications.forEach(S=>{S.track&&S.track===e&&(c=S)}),!c)throw new mi("track is not published");if(!Yi(e))throw new mi("track is not a video track");const l=Object.assign(Object.assign({},(r=this.roomOptions)===null||r===void 0?void 0:r.publishDefaults),a),u=IP(e,n,l);if(!u){this.log.info("backup codec has been disabled, ignoring request to add additional codec for track",Object.assign(Object.assign({},this.logContext),xe(e)));return}const f=e.addSimulcastTrack(n,u);if(!f)return;const h=new Xr({cid:f.mediaStreamTrack.id,type:Q.kindToProto(e.kind),muted:e.isMuted,source:Q.sourceToProto(e.source),sid:e.sid,simulcastCodecs:[{codec:l.videoCodec,cid:f.mediaStreamTrack.id}]});if(h.layers=HS(h.width,h.height,u),!this.engine||this.engine.isClosed)throw new dt("cannot publish track when not connected");const p=()=>A(this,void 0,void 0,function*(){yield this.engine.createSimulcastSender(e,f,l,u),yield this.engine.negotiate()}),y=(yield Promise.all([this.engine.addTrack(h),p()]))[0];this.log.debug("published ".concat(n," for track ").concat(e.sid),Object.assign(Object.assign({},this.logContext),{encodings:u,trackInfo:y}))})}unpublishTrack(e,n){return A(this,void 0,void 0,function*(){var a,r;if(Ds(e)){const h=this.pendingPublishPromises.get(e);h&&(this.log.info("awaiting publish promise before attempting to unpublish",Object.assign(Object.assign({},this.logContext),xe(e))),yield h)}const c=this.getPublicationForTrack(e),l=c?xe(c):void 0;if(this.log.debug("unpublishing track",Object.assign(Object.assign({},this.logContext),l)),!c||!c.track){this.log.warn("track was not unpublished because no publication was found",Object.assign(Object.assign({},this.logContext),l));return}e=c.track,e.off(ae.Muted,this.onTrackMuted),e.off(ae.Unmuted,this.onTrackUnmuted),e.off(ae.Ended,this.handleTrackEnded),e.off(ae.UpstreamPaused,this.onTrackUpstreamPaused),e.off(ae.UpstreamResumed,this.onTrackUpstreamResumed),e.off(ae.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate),n===void 0&&(n=(r=(a=this.roomOptions)===null||a===void 0?void 0:a.stopLocalTrackOnUnpublish)!==null&&r!==void 0?r:!0),n?e.stop():e.stopMonitor();let u=!1;const f=e.sender;if(e.sender=void 0,this.engine.pcManager&&this.engine.pcManager.currentState<rt.FAILED&&f)try{for(const h of this.engine.pcManager.publisher.getTransceivers())h.sender===f&&(h.direction="inactive",u=!0);if(this.engine.removeTrack(f)&&(u=!0),Yi(e)){for(const[,h]of e.simulcastCodecs)h.sender&&(this.engine.removeTrack(h.sender)&&(u=!0),h.sender=void 0);e.simulcastCodecs.clear()}}catch(h){this.log.warn("failed to unpublish track",Object.assign(Object.assign(Object.assign({},this.logContext),l),{error:h}))}switch(this.trackPublications.delete(c.trackSid),c.kind){case Q.Kind.Audio:this.audioTrackPublications.delete(c.trackSid);break;case Q.Kind.Video:this.videoTrackPublications.delete(c.trackSid);break}return this.emit(ee.LocalTrackUnpublished,c),c.setTrack(void 0),u&&(yield this.engine.negotiate()),c})}unpublishTracks(e){return A(this,void 0,void 0,function*(){return(yield Promise.all(e.map(a=>this.unpublishTrack(a)))).filter(a=>!!a)})}republishAllTracks(e){return A(this,arguments,void 0,function(n){var a=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return(function*(){a.republishPromise&&(yield a.republishPromise),a.republishPromise=new Yt((c,l)=>A(a,void 0,void 0,function*(){try{const u=[];this.trackPublications.forEach(f=>{f.track&&(n&&(f.options=Object.assign(Object.assign({},f.options),n)),u.push(f))}),yield Promise.all(u.map(f=>A(this,void 0,void 0,function*(){const h=f.track;yield this.unpublishTrack(h,!1),r&&!h.isMuted&&h.source!==Q.Source.ScreenShare&&h.source!==Q.Source.ScreenShareAudio&&(pi(h)||Yi(h))&&!h.isUserProvided&&(this.log.debug("restarting existing track",Object.assign(Object.assign({},this.logContext),{track:f.trackSid})),yield h.restartTrack()),yield this.publishOrRepublishTrack(h,f.options,!0)}))),c()}catch(u){u instanceof Error?l(u):l(new Error(String(u)))}finally{this.republishPromise=void 0}})),yield a.republishPromise})()})}publishData(e){return A(this,arguments,void 0,function(n){var a=this;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){const c=r.reliable?_e.RELIABLE:_e.LOSSY,l=r.destinationIdentities,u=r.topic;let f=new nf({participantIdentity:a.identity,payload:n,destinationIdentities:l,topic:u});const h=new Ft({kind:c,value:{case:"user",value:f}});yield a.engine.sendDataPacket(h,c)})()})}publishDtmf(e,n){return A(this,void 0,void 0,function*(){const a=new Ft({kind:_e.RELIABLE,value:{case:"sipDtmf",value:new G0({code:e,digit:n})}});yield this.engine.sendDataPacket(a,_e.RELIABLE)})}sendChatMessage(e,n){return A(this,void 0,void 0,function*(){const a={id:crypto.randomUUID(),message:e,timestamp:Date.now(),attachedFiles:n==null?void 0:n.attachments},r=new Ft({value:{case:"chatMessage",value:new Pc(Object.assign(Object.assign({},a),{timestamp:et.parse(a.timestamp)}))}});return yield this.engine.sendDataPacket(r,_e.RELIABLE),this.emit(ee.ChatMessage,a),a})}editChatMessage(e,n){return A(this,void 0,void 0,function*(){const a=Object.assign(Object.assign({},n),{message:e,editTimestamp:Date.now()}),r=new Ft({value:{case:"chatMessage",value:new Pc(Object.assign(Object.assign({},a),{timestamp:et.parse(a.timestamp),editTimestamp:et.parse(a.editTimestamp)}))}});return yield this.engine.sendDataPacket(r,_e.RELIABLE),this.emit(ee.ChatMessage,a),a})}sendText(e,n){return A(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.sendText(e,n)})}streamText(e){return A(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.streamText(e)})}sendFile(e,n){return A(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.sendFile(e,n)})}streamBytes(e){return A(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.streamBytes(e)})}performRpc(e){let{destinationIdentity:n,method:a,payload:r,responseTimeout:c=15e3}=e;const l=7e3,u=l+1e3;return new Yt((f,h)=>A(this,void 0,void 0,function*(){var p,v,y,S;if(nh(r)>IS){h(ot.builtIn("REQUEST_PAYLOAD_TOO_LARGE"));return}if(!((v=(p=this.engine.latestJoinResponse)===null||p===void 0?void 0:p.serverInfo)===null||v===void 0)&&v.version&&zn((S=(y=this.engine.latestJoinResponse)===null||y===void 0?void 0:y.serverInfo)===null||S===void 0?void 0:S.version,"1.8.0")<0){h(ot.builtIn("UNSUPPORTED_SERVER"));return}const w=Math.max(c,u),T=crypto.randomUUID();yield this.publishRpcRequest(n,T,a,r,w);const x=setTimeout(()=>{this.pendingAcks.delete(T),h(ot.builtIn("CONNECTION_TIMEOUT")),this.pendingResponses.delete(T),clearTimeout(R)},l);this.pendingAcks.set(T,{resolve:()=>{clearTimeout(x)},participantIdentity:n});const R=setTimeout(()=>{this.pendingResponses.delete(T),h(ot.builtIn("RESPONSE_TIMEOUT"))},c);this.pendingResponses.set(T,{resolve:(P,L)=>{clearTimeout(R),this.pendingAcks.has(T)&&(this.log.warn("RPC response received before ack",T),this.pendingAcks.delete(T),clearTimeout(x)),L?h(L):f(P!=null?P:"")},participantIdentity:n})}))}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,a){const r=this.pendingResponses.get(e);r?(r.resolve(n,a),this.pendingResponses.delete(e)):console.error("Response received for unexpected RPC request",e)}publishRpcRequest(e,n,a,r,c){return A(this,void 0,void 0,function*(){const l=new Ft({destinationIdentities:[e],kind:_e.RELIABLE,value:{case:"rpcRequest",value:new af({id:n,method:a,payload:r,responseTimeoutMs:c,version:1})}});yield this.engine.sendDataPacket(l,_e.RELIABLE)})}handleParticipantDisconnected(e){for(const[n,{participantIdentity:a}]of this.pendingAcks)a===e&&this.pendingAcks.delete(n);for(const[n,{participantIdentity:a,resolve:r}]of this.pendingResponses)a===e&&(r(null,ot.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 a,r;const c=this.trackPublications.get(n.sid);if(c){const l=c.isMuted||((r=(a=c.track)===null||a===void 0?void 0:a.isUpstreamPaused)!==null&&r!==void 0?r:!1);l!==n.muted&&(this.log.debug("updating server mute state after reconcile",Object.assign(Object.assign(Object.assign({},this.logContext),xe(c)),{mutedOnServer:l})),this.engine.client.sendMuteTrack(n.sid,l))}}),!0):!1}setActiveAgent(e){var n,a,r,c;this.firstActiveAgent=e,e&&!this.firstActiveAgent&&(this.firstActiveAgent=e),e?(a=(n=this.activeAgentFuture)===null||n===void 0?void 0:n.resolve)===null||a===void 0||a.call(n,e):(c=(r=this.activeAgentFuture)===null||r===void 0?void 0:r.reject)===null||c===void 0||c.call(r,new Error("Agent disconnected")),this.activeAgentFuture=void 0}waitUntilActiveAgentPresent(){return this.firstActiveAgent?Promise.resolve(this.firstActiveAgent):(this.activeAgentFuture||(this.activeAgentFuture=new Tn),this.activeAgentFuture.promise)}getPublicationForTrack(e){let n;return this.trackPublications.forEach(a=>{const r=a.track;r&&(e instanceof MediaStreamTrack?(pi(r)||Yi(r))&&r.mediaStreamTrack===e&&(n=a):e===r&&(n=a))}),n}waitForPendingPublicationOfSource(e){return A(this,void 0,void 0,function*(){const a=Date.now();for(;Date.now()<a+1e4;){const r=Array.from(this.pendingPublishPromises.entries()).find(c=>{let[l]=c;return l.source===e});if(r)return r[1];yield Dt(20)}})}}class eT extends gi{constructor(e,n,a,r){super(e,n.sid,n.name,r),this.track=void 0,this.allowed=!0,this.requestedDisabled=void 0,this.visible=!0,this.handleEnded=c=>{this.setTrack(void 0),this.emit(ae.Ended,c)},this.handleVisibilityChange=c=>{this.log.debug("adaptivestream video visibility ".concat(this.trackSid,", visible=").concat(c),this.logContext),this.visible=c,this.emitTrackUpdate()},this.handleVideoDimensionsChange=c=>{this.log.debug("adaptivestream video dimensions ".concat(c.width,"x").concat(c.height),this.logContext),this.videoDimensionsAdaptiveStream=c,this.emitTrackUpdate()},this.subscribed=a,this.updateInfo(n)}setSubscribed(e){const n=this.subscriptionStatus,a=this.permissionStatus;this.subscribed=e,e&&(this.allowed=!0);const r=new jc({trackSids:[this.trackSid],subscribe:this.subscribed,participantTracks:[new Y0({participantSid:"",trackSids:[this.trackSid]})]});this.emit(ae.UpdateSubscription,r),this.emitSubscriptionUpdateIfChanged(n),this.emitPermissionUpdateIfChanged(a)}get subscriptionStatus(){return this.subscribed===!1?gi.SubscriptionStatus.Unsubscribed:super.isSubscribed?gi.SubscriptionStatus.Subscribed:gi.SubscriptionStatus.Desired}get permissionStatus(){return this.allowed?gi.PermissionStatus.Allowed:gi.PermissionStatus.NotAllowed}get isSubscribed(){return this.subscribed===!1?!1:super.isSubscribed}get isDesired(){return this.subscribed!==!1}get isEnabled(){return this.requestedDisabled!==void 0?!this.requestedDisabled:this.isAdaptiveStream?this.visible:!0}get isLocal(){return!1}setEnabled(e){!this.isManualOperationAllowed()||this.requestedDisabled===!e||(this.requestedDisabled=!e,this.emitTrackUpdate())}setVideoQuality(e){!this.isManualOperationAllowed()||this.requestedMaxQuality===e||(this.requestedMaxQuality=e,this.requestedVideoDimensions=void 0,this.emitTrackUpdate())}setVideoDimensions(e){var n,a;this.isManualOperationAllowed()&&(((n=this.requestedVideoDimensions)===null||n===void 0?void 0:n.width)===e.width&&((a=this.requestedVideoDimensions)===null||a===void 0?void 0:a.height)===e.height||(qf(this.track)&&(this.requestedVideoDimensions=e),this.requestedMaxQuality=void 0,this.emitTrackUpdate()))}setVideoFPS(e){this.isManualOperationAllowed()&&qf(this.track)&&this.fps!==e&&(this.fps=e,this.emitTrackUpdate())}get videoQuality(){var e;return(e=this.requestedMaxQuality)!==null&&e!==void 0?e:an.HIGH}setTrack(e){const n=this.subscriptionStatus,a=this.permissionStatus,r=this.track;r!==e&&(r&&(r.off(ae.VideoDimensionsChanged,this.handleVideoDimensionsChange),r.off(ae.VisibilityChanged,this.handleVisibilityChange),r.off(ae.Ended,this.handleEnded),r.detach(),r.stopMonitor(),this.emit(ae.Unsubscribed,r)),super.setTrack(e),e&&(e.sid=this.trackSid,e.on(ae.VideoDimensionsChanged,this.handleVideoDimensionsChange),e.on(ae.VisibilityChanged,this.handleVisibilityChange),e.on(ae.Ended,this.handleEnded),this.emit(ae.Subscribed,e)),this.emitPermissionUpdateIfChanged(a),this.emitSubscriptionUpdateIfChanged(n))}setAllowed(e){const n=this.subscriptionStatus,a=this.permissionStatus;this.allowed=e,this.emitPermissionUpdateIfChanged(a),this.emitSubscriptionUpdateIfChanged(n)}setSubscriptionError(e){this.emit(ae.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?ae.Muted:ae.Unmuted)}emitSubscriptionUpdateIfChanged(e){const n=this.subscriptionStatus;e!==n&&this.emit(ae.SubscriptionStatusChanged,n,e)}emitPermissionUpdateIfChanged(e){this.permissionStatus!==e&&this.emit(ae.SubscriptionPermissionChanged,this.permissionStatus,e)}isManualOperationAllowed(){return this.isDesired?!0:(this.log.warn("cannot update track settings when not subscribed",this.logContext),!1)}get isAdaptiveStream(){return qf(this.track)&&this.track.isAdaptiveStream}emitTrackUpdate(){const e=new ab({trackSids:[this.trackSid],disabled:!this.isEnabled,fps:this.fps});if(this.kind===Q.Kind.Video){let n=this.requestedVideoDimensions;if(this.videoDimensionsAdaptiveStream!==void 0)if(n)cS(this.videoDimensionsAdaptiveStream,n)&&(this.log.debug("using adaptive stream dimensions instead of requested",Object.assign(Object.assign({},this.logContext),this.videoDimensionsAdaptiveStream)),n=this.videoDimensionsAdaptiveStream);else if(this.requestedMaxQuality!==void 0&&this.trackInfo){const a=EO(this.trackInfo,this.requestedMaxQuality);a&&cS(this.videoDimensionsAdaptiveStream,a)&&(this.log.debug("using adaptive stream dimensions instead of max quality layer",Object.assign(Object.assign({},this.logContext),this.videoDimensionsAdaptiveStream)),n=this.videoDimensionsAdaptiveStream)}else this.log.debug("using adaptive stream dimensions",Object.assign(Object.assign({},this.logContext),this.videoDimensionsAdaptiveStream)),n=this.videoDimensionsAdaptiveStream;n?(e.width=Math.ceil(n.width),e.height=Math.ceil(n.height)):this.requestedMaxQuality!==void 0?(this.log.debug("using requested max quality",Object.assign(Object.assign({},this.logContext),{quality:this.requestedMaxQuality})),e.quality=this.requestedMaxQuality):(this.log.debug("using default quality",Object.assign(Object.assign({},this.logContext),{quality:an.HIGH})),e.quality=an.HIGH)}this.emit(ae.UpdateSettings,e)}}class nl extends $S{static fromParticipantInfo(e,n,a){return new nl(e,n.sid,n.identity,n.name,n.metadata,n.attributes,a,n.kind)}get logContext(){return Object.assign(Object.assign({},super.logContext),{rpID:this.sid,remoteParticipant:this.identity})}constructor(e,n,a,r,c,l,u){let f=arguments.length>7&&arguments[7]!==void 0?arguments[7]:Ba.STANDARD;super(n,a||"",r,c,l,u,f),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(ae.UpdateSettings,n=>{this.log.debug("send update settings",Object.assign(Object.assign(Object.assign({},this.logContext),xe(e)),{settings:n})),this.signalClient.sendUpdateTrackSettings(n)}),e.on(ae.UpdateSubscription,n=>{n.participantTracks.forEach(a=>{a.participantSid=this.sid}),this.signalClient.sendUpdateSubscription(n)}),e.on(ae.SubscriptionPermissionChanged,n=>{this.emit(ee.TrackSubscriptionPermissionChanged,e,n)}),e.on(ae.SubscriptionStatusChanged,n=>{this.emit(ee.TrackSubscriptionStatusChanged,e,n)}),e.on(ae.Subscribed,n=>{this.emit(ee.TrackSubscribed,n,e)}),e.on(ae.Unsubscribed,n=>{this.emit(ee.TrackUnsubscribed,n,e)}),e.on(ae.SubscriptionFailed,n=>{this.emit(ee.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]:Q.Source.Microphone;this.volumeMap.set(n,e);const a=this.getTrackPublication(n);a&&a.track&&a.track.setVolume(e)}getVolume(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Q.Source.Microphone;const n=this.getTrackPublication(e);return n&&n.track?n.track.getVolume():this.volumeMap.get(e)}addSubscribedMediaTrack(e,n,a,r,c,l){let u=this.getTrackPublicationBySid(n);if(u||n.startsWith("TR")||this.trackPublications.forEach(p=>{!u&&e.kind===p.kind.toString()&&(u=p)}),!u){if(l===0){this.log.error("could not find published track",Object.assign(Object.assign({},this.logContext),{trackSid:n})),this.emit(ee.TrackSubscriptionFailed,n);return}l===void 0&&(l=20),setTimeout(()=>{this.addSubscribedMediaTrack(e,n,a,r,c,l-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),xe(u))),this.emit(ee.TrackSubscriptionFailed,n);return}const f=e.kind==="video";let h;return f?h=new $P(e,n,r,c):h=new WS(e,n,r,this.audioContext,this.audioOutput),h.source=u.source,h.isMuted=u.isMuted,h.setMediaStream(a),h.start(),u.setTrack(h),this.volumeMap.has(u.source)&&Ff(h)&&ei(h)&&h.setVolume(this.volumeMap.get(u.source)),u}get hasMetadata(){return!!this.participantInfo}getTrackPublicationBySid(e){return this.trackPublications.get(e)}updateInfo(e){if(!super.updateInfo(e))return!1;const n=new Map,a=new Map;return e.tracks.forEach(r=>{var c,l;let u=this.getTrackPublicationBySid(r.sid);if(u)u.updateInfo(r);else{const f=Q.kindFromProto(r.type);if(!f)return;u=new eT(f,r,(c=this.signalClient.connectOptions)===null||c===void 0?void 0:c.autoSubscribe,{loggerContextCb:()=>this.logContext,loggerName:(l=this.loggerOptions)===null||l===void 0?void 0:l.loggerName}),u.updateInfo(r),a.set(r.sid,u);const h=Array.from(this.trackPublications.values()).find(p=>p.source===(u==null?void 0:u.source));h&&u.source!==Q.Source.Unknown&&this.log.debug("received a second track publication for ".concat(this.identity," with the same source: ").concat(u.source),Object.assign(Object.assign({},this.logContext),{oldTrack:xe(h),newTrack:xe(u)})),this.addTrackPublication(u)}n.set(r.sid,u)}),this.trackPublications.forEach(r=>{n.has(r.trackSid)||(this.log.trace("detected removed track on remote participant, unpublishing",Object.assign(Object.assign({},this.logContext),xe(r))),this.unpublishTrack(r.trackSid,!0))}),a.forEach(r=>{this.emit(ee.TrackPublished,r)}),!0}unpublishTrack(e,n){const a=this.trackPublications.get(e);if(!a)return;const{track:r}=a;switch(r&&(r.stop(),a.setTrack(void 0)),this.trackPublications.delete(e),a.kind){case Q.Kind.Audio:this.audioTrackPublications.delete(e);break;case Q.Kind.Video:this.videoTrackPublications.delete(e);break}n&&this.emit(ee.TrackUnpublished,a)}setAudioOutput(e){return A(this,void 0,void 0,function*(){this.audioOutput=e;const n=[];this.audioTrackPublications.forEach(a=>{var r;ei(a.track)&&Ff(a.track)&&n.push(a.track.setSinkId((r=e.deviceId)!==null&&r!==void 0?r:"default"))}),yield Promise.all(n)})}emit(e){for(var n=arguments.length,a=new Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];return this.log.trace("participant event",Object.assign(Object.assign({},this.logContext),{event:e,args:a})),super.emit(e,...a)}}var Ne;(function(t){t.Disconnected="disconnected",t.Connecting="connecting",t.Connected="connected",t.Reconnecting="reconnecting",t.SignalReconnecting="signalReconnecting"})(Ne||(Ne={}));const rN=4*1e3;class Ls extends Zn.EventEmitter{get hasE2EESetup(){return this.e2eeManager!==void 0}constructor(e){var n,a,r,c,l;if(super(),n=this,this.state=Ne.Disconnected,this.activeSpeakers=[],this.isE2EEEnabled=!1,this.audioEnabled=!0,this.isVideoPlaybackBlocked=!1,this.log=Ee,this.bufferedEvents=[],this.isResuming=!1,this.rpcHandlers=new Map,this.connect=(u,f,h)=>A(this,void 0,void 0,function*(){var p;if(!MO())throw $n()?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 v=yield this.disconnectLock.lock();if(this.state===Ne.Connected)return this.log.info("already connected to room ".concat(this.name),this.logContext),v(),Promise.resolve();if(this.connectFuture)return v(),this.connectFuture.promise;this.setAndEmitConnectionState(Ne.Connecting),((p=this.regionUrlProvider)===null||p===void 0?void 0:p.getServerUrl().toString())!==bS(u)&&(this.regionUrl=void 0,this.regionUrlProvider=void 0),Ms(new URL(u))&&(this.regionUrlProvider===void 0?this.regionUrlProvider=new Ie(u,f):this.regionUrlProvider.updateToken(f),this.regionUrlProvider.fetchRegionSettings().then(w=>{var T;(T=this.regionUrlProvider)===null||T===void 0||T.setServerReportedRegions(w)}).catch(w=>{this.log.warn("could not fetch region settings",Object.assign(Object.assign({},this.logContext),{error:w}))}));const y=(w,T,x)=>A(this,void 0,void 0,function*(){var R,P;this.abortController&&this.abortController.abort();const L=new AbortController;this.abortController=L,v==null||v();try{if(yield Os.getInstance().getBackOffPromise(u),L.signal.aborted)throw pe.cancelled("Connection attempt aborted");yield this.attemptConnection(x!=null?x:u,f,h,L),this.abortController=void 0,w()}catch(E){if(this.regionUrlProvider&&E instanceof pe&&E.reason!==Ye.Cancelled&&E.reason!==Ye.NotAllowed){let k=null;try{this.log.debug("Fetching next region"),k=yield this.regionUrlProvider.getNextBestRegionUrl((R=this.abortController)===null||R===void 0?void 0:R.signal)}catch(_){if(_ instanceof pe&&(_.status===401||_.reason===Ye.Cancelled)){this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),T(_);return}}[Ye.InternalError,Ye.ServerUnreachable,Ye.Timeout].includes(E.reason)&&(this.log.debug("Adding failed connection attempt to back off"),Os.getInstance().addFailedConnectionAttempt(u)),k&&!(!((P=this.abortController)===null||P===void 0)&&P.signal.aborted)?(this.log.info("Initial connection failed with ConnectionError: ".concat(E.message,". Retrying with another region: ").concat(k),this.logContext),this.recreateEngine(),yield y(w,T,k)):(this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,yS(E)),T(E))}else{let k=Un.UNKNOWN_REASON;E instanceof pe&&(k=yS(E)),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,k),T(E)}}}),S=this.regionUrl;return this.regionUrl=void 0,this.connectFuture=new Tn((w,T)=>{y(w,T,S)},()=>{this.clearConnectionFutures()}),this.connectFuture.promise}),this.connectSignal=(u,f,h,p,v,y)=>A(this,void 0,void 0,function*(){var S,w,T;const x=yield h.join(u,f,{autoSubscribe:p.autoSubscribe,adaptiveStream:typeof v.adaptiveStream=="object"?!0:v.adaptiveStream,maxRetries:p.maxRetries,e2eeEnabled:!!this.e2eeManager,websocketTimeout:p.websocketTimeout},y.signal,!v.singlePeerConnection);let R=x.serverInfo;if(R||(R={version:x.serverVersion,region:x.serverRegion}),this.serverInfo=R,this.log.debug("connected to Livekit Server ".concat(Object.entries(R).map(P=>{let[L,E]=P;return"".concat(L,": ").concat(E)}).join(", ")),{room:(S=x.room)===null||S===void 0?void 0:S.name,roomSid:(w=x.room)===null||w===void 0?void 0:w.sid,identity:(T=x.participant)===null||T===void 0?void 0:T.identity}),!R.version)throw new fO("unknown server version");return R.version==="0.15.1"&&this.options.dynacast&&(this.log.debug("disabling dynacast due to server version",this.logContext),v.dynacast=!1),x}),this.applyJoinResponse=u=>{const f=u.participant;if(this.localParticipant.sid=f.sid,this.localParticipant.identity=f.identity,this.localParticipant.setEnabledPublishCodecs(u.enabledPublishCodecs),this.e2eeManager)try{this.e2eeManager.setSifTrailer(u.sifTrailer)}catch(h){this.log.error(h instanceof Error?h.message:"Could not set SifTrailer",Object.assign(Object.assign({},this.logContext),{error:h}))}this.handleParticipantUpdates([f,...u.otherParticipants]),u.room&&this.handleRoomUpdate(u.room)},this.attemptConnection=(u,f,h,p)=>A(this,void 0,void 0,function*(){var v,y;this.state===Ne.Reconnecting||this.isResuming||!((v=this.engine)===null||v===void 0)&&v.pendingReconnect?(this.log.info("Reconnection attempt replaced by new connection attempt",this.logContext),this.recreateEngine()):this.maybeCreateEngine(),!((y=this.regionUrlProvider)===null||y===void 0)&&y.isCloud()&&this.engine.setRegionUrlProvider(this.regionUrlProvider),this.acquireAudioContext(),this.connOptions=Object.assign(Object.assign({},th),h),this.connOptions.rtcConfig&&(this.engine.rtcConfig=this.connOptions.rtcConfig),this.connOptions.peerConnectionTimeout&&(this.engine.peerConnectionTimeout=this.connOptions.peerConnectionTimeout);try{const S=yield this.connectSignal(u,f,this.engine,this.connOptions,this.options,p);this.applyJoinResponse(S),this.setupLocalParticipantEvents(),this.emit(X.SignalConnected)}catch(S){yield this.engine.close(),this.recreateEngine();const w=p.signal.aborted?pe.cancelled("Signal connection aborted"):pe.serverUnreachable("could not establish signal connection");throw S instanceof Error&&(w.message="".concat(w.message,": ").concat(S.message)),S instanceof pe&&(w.reason=S.reason,w.status=S.status),this.log.debug("error trying to establish signal connection",Object.assign(Object.assign({},this.logContext),{error:S})),w}if(p.signal.aborted)throw yield this.engine.close(),this.recreateEngine(),pe.cancelled("Connection attempt aborted");try{yield this.engine.waitForPCInitialConnection(this.connOptions.peerConnectionTimeout,p)}catch(S){throw yield this.engine.close(),this.recreateEngine(),S}Qt()&&this.options.disconnectOnPageLeave&&(window.addEventListener("pagehide",this.onPageLeave),window.addEventListener("beforeunload",this.onPageLeave)),Qt()&&window.addEventListener("freeze",this.onPageLeave),this.setAndEmitConnectionState(Ne.Connected),this.emit(X.Connected),Os.getInstance().resetFailedConnectionAttempts(u),this.registerConnectionReconcile(),this.regionUrlProvider&&this.regionUrlProvider.notifyConnected()}),this.disconnect=function(){for(var u=arguments.length,f=new Array(u),h=0;h<u;h++)f[h]=arguments[h];return A(n,[...f],void 0,function(){var p=this;let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return(function*(){var y,S,w;const T=yield p.disconnectLock.lock();try{if(p.state===Ne.Disconnected){p.log.debug("already disconnected",p.logContext);return}if(p.log.info("disconnect from room",Object.assign({},p.logContext)),p.state===Ne.Connecting||p.state===Ne.Reconnecting||p.isResuming){const x="Abort connection attempt due to user initiated disconnect";p.log.warn(x,p.logContext),(y=p.abortController)===null||y===void 0||y.abort(x),(w=(S=p.connectFuture)===null||S===void 0?void 0:S.reject)===null||w===void 0||w.call(S,pe.cancelled("Client initiated disconnect")),p.connectFuture=void 0}p.engine&&(p.engine.client.isDisconnected||(yield p.engine.client.sendLeave()),yield p.engine.close()),p.handleDisconnect(v,Un.CLIENT_INITIATED),p.engine=void 0}finally{T()}})()})},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 u=[],f=Xt();if(f&&f.os==="iOS"){const h="livekit-dummy-audio-el";let p=document.getElementById(h);if(!p){p=document.createElement("audio"),p.id=h,p.autoplay=!0,p.hidden=!0;const v=zf();v.enabled=!0;const y=new MediaStream([v]);p.srcObject=y,document.addEventListener("visibilitychange",()=>{p&&(p.srcObject=document.hidden?null:y,document.hidden||(this.log.debug("page visible again, triggering startAudio to resume playback and update playback status",this.logContext),this.startAudio()))}),document.body.append(p),this.once(X.Disconnected,()=>{p==null||p.remove(),p=null})}u.push(p)}this.remoteParticipants.forEach(h=>{h.audioTrackPublications.forEach(p=>{p.track&&p.track.attachedElements.forEach(v=>{u.push(v)})})});try{yield Promise.all([this.acquireAudioContext(),...u.map(h=>(h.muted=!1,h.play()))]),this.handleAudioPlaybackStarted()}catch(h){throw this.handleAudioPlaybackFailed(h),h}}),this.startVideo=()=>A(this,void 0,void 0,function*(){const u=[];for(const f of this.remoteParticipants.values())f.videoTrackPublications.forEach(h=>{var p;(p=h.track)===null||p===void 0||p.attachedElements.forEach(v=>{u.includes(v)||u.push(v)})});yield Promise.all(u.map(f=>f.play())).then(()=>{this.handleVideoPlaybackStarted()}).catch(f=>{f.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 u of this.remoteParticipants.values())this.handleParticipantDisconnected(u.identity,u);this.setAndEmitConnectionState(Ne.Reconnecting)&&this.emit(X.Reconnecting)},this.handleSignalRestarted=u=>A(this,void 0,void 0,function*(){this.log.debug("signal reconnected to server, region ".concat(u.serverRegion),Object.assign(Object.assign({},this.logContext),{region:u.serverRegion})),this.bufferedEvents=[],this.applyJoinResponse(u);try{yield this.localParticipant.republishAllTracks(void 0,!0)}catch(f){this.log.error("error trying to re-publish tracks after reconnection",Object.assign(Object.assign({},this.logContext),{error:f}))}try{yield this.engine.waitForRestarted(),this.log.debug("fully reconnected to server",Object.assign(Object.assign({},this.logContext),{region:u.serverRegion}))}catch{return}this.setAndEmitConnectionState(Ne.Connected),this.emit(X.Reconnected),this.registerConnectionReconcile(),this.emitBufferedEvents()}),this.handleParticipantUpdates=u=>{u.forEach(f=>{var h;if(f.identity===this.localParticipant.identity){this.localParticipant.updateInfo(f);return}f.identity===""&&(f.identity=(h=this.sidToIdentity.get(f.sid))!==null&&h!==void 0?h:"");let p=this.remoteParticipants.get(f.identity);f.state===Cs.DISCONNECTED?this.handleParticipantDisconnected(f.identity,p):p=this.getOrCreateParticipant(f.identity,f)})},this.handleActiveSpeakersUpdate=u=>{const f=[],h={};u.forEach(p=>{if(h[p.sid]=!0,p.sid===this.localParticipant.sid)this.localParticipant.audioLevel=p.level,this.localParticipant.setIsSpeaking(!0),f.push(this.localParticipant);else{const v=this.getRemoteParticipantBySid(p.sid);v&&(v.audioLevel=p.level,v.setIsSpeaking(!0),f.push(v))}}),h[this.localParticipant.sid]||(this.localParticipant.audioLevel=0,this.localParticipant.setIsSpeaking(!1)),this.remoteParticipants.forEach(p=>{h[p.sid]||(p.audioLevel=0,p.setIsSpeaking(!1))}),this.activeSpeakers=f,this.emitWhenConnected(X.ActiveSpeakersChanged,f)},this.handleSpeakersChanged=u=>{const f=new Map;this.activeSpeakers.forEach(p=>{const v=this.remoteParticipants.get(p.identity);v&&v.sid!==p.sid||f.set(p.sid,p)}),u.forEach(p=>{let v=this.getRemoteParticipantBySid(p.sid);p.sid===this.localParticipant.sid&&(v=this.localParticipant),v&&(v.audioLevel=p.level,v.setIsSpeaking(p.active),p.active?f.set(p.sid,v):f.delete(p.sid))});const h=Array.from(f.values());h.sort((p,v)=>v.audioLevel-p.audioLevel),this.activeSpeakers=h,this.emitWhenConnected(X.ActiveSpeakersChanged,h)},this.handleStreamStateUpdate=u=>{u.streamStates.forEach(f=>{const h=this.getRemoteParticipantBySid(f.participantSid);if(!h)return;const p=h.getTrackPublicationBySid(f.trackSid);if(!p||!p.track)return;const v=Q.streamStateFromProto(f.state);p.track.setStreamState(v),v!==p.track.streamState&&(h.emit(ee.TrackStreamStateChanged,p,p.track.streamState),this.emitWhenConnected(X.TrackStreamStateChanged,p,p.track.streamState,h))})},this.handleSubscriptionPermissionUpdate=u=>{const f=this.getRemoteParticipantBySid(u.participantSid);if(!f)return;const h=f.getTrackPublicationBySid(u.trackSid);h&&h.setAllowed(u.allowed)},this.handleSubscriptionError=u=>{const f=Array.from(this.remoteParticipants.values()).find(p=>p.trackPublications.has(u.trackSid));if(!f)return;const h=f.getTrackPublicationBySid(u.trackSid);h&&h.setSubscriptionError(u.err)},this.handleDataPacket=(u,f)=>{const h=this.remoteParticipants.get(u.participantIdentity);if(u.value.case==="user")this.handleUserPacket(h,u.value.value,u.kind,f);else if(u.value.case==="transcription")this.handleTranscription(h,u.value.value);else if(u.value.case==="sipDtmf")this.handleSipDtmf(h,u.value.value);else if(u.value.case==="chatMessage")this.handleChatMessage(h,u.value.value);else if(u.value.case==="metrics")this.handleMetrics(u.value.value,h);else if(u.value.case==="streamHeader"||u.value.case==="streamChunk"||u.value.case==="streamTrailer")this.handleDataStream(u,f);else if(u.value.case==="rpcRequest"){const p=u.value.value;this.handleIncomingRpcRequest(u.participantIdentity,p.id,p.method,p.payload,p.responseTimeoutMs,p.version)}},this.handleUserPacket=(u,f,h,p)=>{this.emit(X.DataReceived,f.payload,u,h,f.topic,p),u==null||u.emit(ee.DataReceived,f.payload,h,p)},this.handleSipDtmf=(u,f)=>{this.emit(X.SipDTMFReceived,f,u),u==null||u.emit(ee.SipDTMFReceived,f)},this.handleTranscription=(u,f)=>{const h=f.transcribedParticipantIdentity===this.localParticipant.identity?this.localParticipant:this.getParticipantByIdentity(f.transcribedParticipantIdentity),p=h==null?void 0:h.trackPublications.get(f.trackId),v=VO(f,this.transcriptionReceivedTimes);p==null||p.emit(ae.TranscriptionReceived,v),h==null||h.emit(ee.TranscriptionReceived,v,p),this.emit(X.TranscriptionReceived,v,h,p)},this.handleChatMessage=(u,f)=>{const h=zO(f);this.emit(X.ChatMessage,h,u)},this.handleMetrics=(u,f)=>{this.emit(X.MetricsReceived,u,f)},this.handleDataStream=(u,f)=>{this.incomingDataStreamManager.handleDataStreamPacket(u,f)},this.bufferedSegments=new Map,this.handleAudioPlaybackStarted=()=>{this.canPlaybackAudio||(this.audioEnabled=!0,this.emit(X.AudioPlaybackStatusChanged,!0))},this.handleAudioPlaybackFailed=u=>{this.log.warn("could not playback audio",Object.assign(Object.assign({},this.logContext),{error:u})),this.canPlaybackAudio&&(this.audioEnabled=!1,this.emit(X.AudioPlaybackStatusChanged,!1))},this.handleVideoPlaybackStarted=()=>{this.isVideoPlaybackBlocked&&(this.isVideoPlaybackBlocked=!1,this.emit(X.VideoPlaybackStatusChanged,!0))},this.handleVideoPlaybackFailed=()=>{this.isVideoPlaybackBlocked||(this.isVideoPlaybackBlocked=!0,this.emit(X.VideoPlaybackStatusChanged,!1))},this.handleDeviceChange=()=>A(this,void 0,void 0,function*(){var u;((u=Xt())===null||u===void 0?void 0:u.os)!=="iOS"&&(yield this.selectDefaultDevices()),this.emit(X.MediaDevicesChanged)}),this.handleRoomUpdate=u=>{const f=this.roomInfo;this.roomInfo=u,f&&f.metadata!==u.metadata&&this.emitWhenConnected(X.RoomMetadataChanged,u.metadata),(f==null?void 0:f.activeRecording)!==u.activeRecording&&this.emitWhenConnected(X.RecordingStatusChanged,u.activeRecording)},this.handleConnectionQualityUpdate=u=>{u.updates.forEach(f=>{if(f.participantSid===this.localParticipant.sid){this.localParticipant.setConnectionQuality(f.quality);return}const h=this.getRemoteParticipantBySid(f.participantSid);h&&h.setConnectionQuality(f.quality)})},this.onLocalParticipantMetadataChanged=u=>{this.emit(X.ParticipantMetadataChanged,u,this.localParticipant)},this.onLocalParticipantNameChanged=u=>{this.emit(X.ParticipantNameChanged,u,this.localParticipant)},this.onLocalAttributesChanged=u=>{this.emit(X.ParticipantAttributesChanged,u,this.localParticipant)},this.onLocalTrackMuted=u=>{this.emit(X.TrackMuted,u,this.localParticipant)},this.onLocalTrackUnmuted=u=>{this.emit(X.TrackUnmuted,u,this.localParticipant)},this.onTrackProcessorUpdate=u=>{var f;(f=u==null?void 0:u.onPublish)===null||f===void 0||f.call(u,this)},this.onLocalTrackPublished=u=>A(this,void 0,void 0,function*(){var f,h,p,v,y,S;(f=u.track)===null||f===void 0||f.on(ae.TrackProcessorUpdate,this.onTrackProcessorUpdate),(h=u.track)===null||h===void 0||h.on(ae.Restarted,this.onLocalTrackRestarted),(y=(v=(p=u.track)===null||p===void 0?void 0:p.getProcessor())===null||v===void 0?void 0:v.onPublish)===null||y===void 0||y.call(v,this),this.emit(X.LocalTrackPublished,u,this.localParticipant),pi(u.track)&&(yield u.track.checkForSilence())&&this.emit(X.LocalAudioSilenceDetected,u);const w=yield(S=u.track)===null||S===void 0?void 0:S.getDeviceId(!1),T=Nf(u.source);T&&w&&w!==this.localParticipant.activeDeviceMap.get(T)&&(this.localParticipant.activeDeviceMap.set(T,w),this.emit(X.ActiveDeviceChanged,T,w))}),this.onLocalTrackUnpublished=u=>{var f,h;(f=u.track)===null||f===void 0||f.off(ae.TrackProcessorUpdate,this.onTrackProcessorUpdate),(h=u.track)===null||h===void 0||h.off(ae.Restarted,this.onLocalTrackRestarted),this.emit(X.LocalTrackUnpublished,u,this.localParticipant)},this.onLocalTrackRestarted=u=>A(this,void 0,void 0,function*(){const f=yield u.getDeviceId(!1),h=Nf(u.source);h&&f&&f!==this.localParticipant.activeDeviceMap.get(h)&&(this.log.debug("local track restarted, setting ".concat(h," ").concat(f," active"),this.logContext),this.localParticipant.activeDeviceMap.set(h,f),this.emit(X.ActiveDeviceChanged,h,f))}),this.onLocalConnectionQualityChanged=u=>{this.emit(X.ConnectionQualityChanged,u,this.localParticipant)},this.onMediaDevicesError=(u,f)=>{this.emit(X.MediaDevicesError,u,f)},this.onLocalParticipantPermissionsChanged=u=>{this.emit(X.ParticipantPermissionsChanged,u,this.localParticipant)},this.onLocalChatMessageSent=u=>{this.emit(X.ChatMessage,u,this.localParticipant)},this.setMaxListeners(100),this.remoteParticipants=new Map,this.sidToIdentity=new Map,this.options=Object.assign(Object.assign({},bP),e),this.log=fi((a=this.options.loggerName)!==null&&a!==void 0?a:jn.Room),this.transcriptionReceivedTimes=new Map,this.options.audioCaptureDefaults=Object.assign(Object.assign({},PS),e==null?void 0:e.audioCaptureDefaults),this.options.videoCaptureDefaults=Object.assign(Object.assign({},NS),e==null?void 0:e.videoCaptureDefaults),this.options.publishDefaults=Object.assign(Object.assign({},yP),e==null?void 0:e.publishDefaults),this.maybeCreateEngine(),this.incomingDataStreamManager=new QP,this.outgoingDataStreamManager=new WP(this.engine,this.log),this.disconnectLock=new zt,this.localParticipant=new sN("","",this.engine,this.options,this.rpcHandlers,this.outgoingDataStreamManager),(this.options.e2ee||this.options.encryption)&&this.setupE2EE(),this.engine.e2eeManager=this.e2eeManager,this.options.videoCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("videoinput",Gi(this.options.videoCaptureDefaults.deviceId)),this.options.audioCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("audioinput",Gi(this.options.audioCaptureDefaults.deviceId)),!((r=this.options.audioOutput)===null||r===void 0)&&r.deviceId&&this.switchActiveDevice("audiooutput",Gi(this.options.audioOutput.deviceId)).catch(u=>this.log.warn("Could not set audio output: ".concat(u.message),this.logContext)),Qt()){const u=new AbortController;(l=(c=navigator.mediaDevices)===null||c===void 0?void 0:c.addEventListener)===null||l===void 0||l.call(c,"devicechange",this.handleDeviceChange,{signal:u.signal}),Ls.cleanupRegistry&&Ls.cleanupRegistry.register(this,()=>{u.abort()})}}registerTextStreamHandler(e,n){return this.incomingDataStreamManager.registerTextStreamHandler(e,n)}unregisterTextStreamHandler(e){return this.incomingDataStreamManager.unregisterTextStreamHandler(e)}registerByteStreamHandler(e,n){return this.incomingDataStreamManager.registerByteStreamHandler(e,n)}unregisterByteStreamHandler(e){return this.incomingDataStreamManager.unregisterByteStreamHandler(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)}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;const n=!!this.options.encryption,a=this.options.encryption||this.options.e2ee;a&&("e2eeManager"in a?(this.e2eeManager=a.e2eeManager,this.e2eeManager.isDataChannelEncryptionEnabled=n):this.e2eeManager=new tP(a,n),this.e2eeManager.on(Qi.ParticipantEncryptionStatusChanged,(r,c)=>{qO(c)&&(this.isE2EEEnabled=r),this.emit(X.ParticipantEncryptionStatusChanged,r,c)}),this.e2eeManager.on(Qi.EncryptionError,(r,c)=>{const l=c?this.getParticipantByIdentity(c):void 0;this.emit(X.EncryptionError,r,l)}),(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 this.state===Ne.Disconnected?Yt.resolve(""):this.roomInfo&&this.roomInfo.sid!==""?Yt.resolve(this.roomInfo.sid):new Yt((e,n)=>{const a=r=>{r.sid!==""&&(this.engine.off(se.RoomUpdate,a),e(r.sid))};this.engine.on(se.RoomUpdate,a),this.once(X.Disconnected,()=>{this.engine.off(se.RoomUpdate,a),n(new dt("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 GP(this.options),this.engine.e2eeManager=this.e2eeManager,this.engine.on(se.ParticipantUpdate,this.handleParticipantUpdates).on(se.RoomUpdate,this.handleRoomUpdate).on(se.SpeakersChanged,this.handleSpeakersChanged).on(se.StreamStateChanged,this.handleStreamStateUpdate).on(se.ConnectionQualityUpdate,this.handleConnectionQualityUpdate).on(se.SubscriptionError,this.handleSubscriptionError).on(se.SubscriptionPermissionUpdate,this.handleSubscriptionPermissionUpdate).on(se.MediaTrackAdded,(e,n,a)=>{this.onTrackAdded(e,n,a)}).on(se.Disconnected,e=>{this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,e)}).on(se.ActiveSpeakersUpdate,this.handleActiveSpeakersUpdate).on(se.DataPacketReceived,this.handleDataPacket).on(se.Resuming,()=>{this.clearConnectionReconcile(),this.isResuming=!0,this.log.info("Resuming signal connection",this.logContext),this.setAndEmitConnectionState(Ne.SignalReconnecting)&&this.emit(X.SignalReconnecting)}).on(se.Resumed,()=>{this.registerConnectionReconcile(),this.isResuming=!1,this.log.info("Resumed signal connection",this.logContext),this.updateSubscriptions(),this.emitBufferedEvents(),this.setAndEmitConnectionState(Ne.Connected)&&this.emit(X.Reconnected)}).on(se.SignalResumed,()=>{this.bufferedEvents=[],(this.state===Ne.Reconnecting||this.isResuming)&&this.sendSyncState()}).on(se.Restarting,this.handleRestarting).on(se.SignalRestarted,this.handleSignalRestarted).on(se.Offline,()=>{this.setAndEmitConnectionState(Ne.Reconnecting)&&this.emit(X.Reconnecting)}).on(se.DCBufferStatusChanged,(e,n)=>{this.emit(X.DCBufferStatusChanged,e,n)}).on(se.LocalTrackSubscribed,e=>{const n=this.localParticipant.getTrackPublications().find(a=>{let{trackSid:r}=a;return r===e});if(!n){this.log.warn("could not find local track subscription for subscribed event",this.logContext);return}this.localParticipant.emit(ee.LocalTrackSubscribed,n),this.emitWhenConnected(X.LocalTrackSubscribed,n,this.localParticipant)}).on(se.RoomMoved,e=>{this.log.debug("room moved",e),e.room&&this.handleRoomUpdate(e.room),this.remoteParticipants.forEach((n,a)=>{this.handleParticipantDisconnected(a,n)}),this.emit(X.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),this.outgoingDataStreamManager&&this.outgoingDataStreamManager.setupEngine(this.engine))}static getLocalDevices(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return Rt.getInstance().getDevices(e,n)}prepareConnection(e,n){return A(this,void 0,void 0,function*(){if(this.state===Ne.Disconnected){this.log.debug("prepareConnection to ".concat(e),this.logContext);try{if(Ms(new URL(e))&&n){this.regionUrlProvider=new Ie(e,n);const a=yield this.regionUrlProvider.getNextBestRegionUrl();a&&this.state===Ne.Disconnected&&(this.regionUrl=a,yield fetch(no(a),{method:"HEAD"}),this.log.debug("prepared connection to ".concat(a),this.logContext))}else yield fetch(no(e),{method:"HEAD"})}catch(a){this.log.warn("could not prepare connection",Object.assign(Object.assign({},this.logContext),{error:a}))}}})}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 a=()=>A(this,void 0,void 0,function*(){}),r;switch(e){case"signal-reconnect":yield this.engine.client.handleOnClose("simulate disconnect");break;case"speaker":r=new Jn({scenario:{case:"speakerUpdate",value:3}});break;case"node-failure":r=new Jn({scenario:{case:"nodeFailure",value:!0}});break;case"server-leave":r=new Jn({scenario:{case:"serverLeave",value:!0}});break;case"migration":r=new Jn({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":a=()=>A(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),r=new Jn({scenario:{case:"disconnectSignalOnResume",value:!0}});break;case"disconnect-signal-on-resume-no-messages":a=()=>A(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),r=new Jn({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 Jn({scenario:{case:"switchCandidateProtocol",value:e==="force-tls"?2:1}}),a=()=>A(this,void 0,void 0,function*(){const c=this.engine.client.onLeave;c&&c(new Vc({reason:Un.CLIENT_INITIATED,action:Es.RECONNECT}))});break;case"subscriber-bandwidth":if(n===void 0||typeof n!="number")throw new Error("subscriber-bandwidth requires a number as argument");r=new Jn({scenario:{case:"subscriberBandwidth",value:Fa(n)}});break;case"leave-full-reconnect":r=new Jn({scenario:{case:"leaveRequestFullReconnect",value:!0}})}r&&(yield this.engine.client.sendSimulateScenario(r),yield a())})}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(a,r){var c=this;let l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return(function*(){var u,f,h,p,v,y,S;let w=!0,T=!1;const x=l?{exact:r}:r;if(a==="audioinput"){T=c.localParticipant.audioTrackPublications.size===0;const R=(u=c.getActiveDevice(a))!==null&&u!==void 0?u:c.options.audioCaptureDefaults.deviceId;c.options.audioCaptureDefaults.deviceId=x;const P=Array.from(c.localParticipant.audioTrackPublications.values()).filter(E=>E.source===Q.Source.Microphone);try{w=(yield Promise.all(P.map(E=>{var k;return(k=E.audioTrack)===null||k===void 0?void 0:k.setDeviceId(x)}))).every(E=>E===!0)}catch(E){throw c.options.audioCaptureDefaults.deviceId=R,E}const L=P.some(E=>{var k,_;return(_=(k=E.track)===null||k===void 0?void 0:k.isMuted)!==null&&_!==void 0?_:!1});w&&L&&(T=!0)}else if(a==="videoinput"){T=c.localParticipant.videoTrackPublications.size===0;const R=(f=c.getActiveDevice(a))!==null&&f!==void 0?f:c.options.videoCaptureDefaults.deviceId;c.options.videoCaptureDefaults.deviceId=x;const P=Array.from(c.localParticipant.videoTrackPublications.values()).filter(E=>E.source===Q.Source.Camera);try{w=(yield Promise.all(P.map(E=>{var k;return(k=E.videoTrack)===null||k===void 0?void 0:k.setDeviceId(x)}))).every(E=>E===!0)}catch(E){throw c.options.videoCaptureDefaults.deviceId=R,E}const L=P.some(E=>{var k,_;return(_=(k=E.track)===null||k===void 0?void 0:k.isMuted)!==null&&_!==void 0?_:!1});w&&L&&(T=!0)}else if(a==="audiooutput"){if(T=!0,!Uf()&&!c.options.webAudioMix||c.options.webAudioMix&&c.audioContext&&!("setSinkId"in c.audioContext))throw new Error("cannot switch audio output, the current browser does not support it");c.options.webAudioMix&&(r=(h=yield Rt.getInstance().normalizeDeviceId("audiooutput",r))!==null&&h!==void 0?h:""),(p=(S=c.options).audioOutput)!==null&&p!==void 0||(S.audioOutput={});const R=(v=c.getActiveDevice(a))!==null&&v!==void 0?v:c.options.audioOutput.deviceId;c.options.audioOutput.deviceId=r;try{c.options.webAudioMix&&((y=c.audioContext)===null||y===void 0||y.setSinkId(r)),yield Promise.all(Array.from(c.remoteParticipants.values()).map(P=>P.setAudioOutput({deviceId:r})))}catch(P){throw c.options.audioOutput.deviceId=R,P}}return T&&(c.localParticipant.activeDeviceMap.set(a,r),c.emit(X.ActiveDeviceChanged,a,r)),w})()})}setupLocalParticipantEvents(){this.localParticipant.on(ee.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).on(ee.ParticipantNameChanged,this.onLocalParticipantNameChanged).on(ee.AttributesChanged,this.onLocalAttributesChanged).on(ee.TrackMuted,this.onLocalTrackMuted).on(ee.TrackUnmuted,this.onLocalTrackUnmuted).on(ee.LocalTrackPublished,this.onLocalTrackPublished).on(ee.LocalTrackUnpublished,this.onLocalTrackUnpublished).on(ee.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).on(ee.MediaDevicesError,this.onMediaDevicesError).on(ee.AudioStreamAcquired,this.startAudio).on(ee.ChatMessage,this.onLocalChatMessageSent).on(ee.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,a){if(this.state===Ne.Connecting||this.state===Ne.Reconnecting){const v=()=>{this.log.debug("deferring on track for later",{mediaTrackId:e.id,mediaStreamId:n.id,tracksInStream:n.getTracks().map(S=>S.id)}),this.onTrackAdded(e,n,a),y()},y=()=>{this.off(X.Reconnected,v),this.off(X.Connected,v),this.off(X.Disconnected,y)};this.once(X.Reconnected,v),this.once(X.Connected,v),this.once(X.Disconnected,y);return}if(this.state===Ne.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=_O(n.id),c=r[0];let l=r[1],u=e.id;if(l&&l.startsWith("TR")&&(u=l),c===this.localParticipant.sid){this.log.warn("tried to create RemoteParticipant for local participant",this.logContext);return}const f=Array.from(this.remoteParticipants.values()).find(v=>v.sid===c);if(!f){this.log.error("Tried to add a track for a participant, that's not present. Sid: ".concat(c),this.logContext);return}if(!u.startsWith("TR")){const v=this.engine.getTrackIdForReceiver(a);if(!v){this.log.error("Tried to add a track whose 'sid' could not be found for a participant, that's not present. Sid: ".concat(c),this.logContext);return}u=v}u.startsWith("TR")||this.log.warn("Tried to add a track whose 'sid' could not be determined for a participant, that's not present. Sid: ".concat(c,", streamId: ").concat(l,", trackId: ").concat(u),Object.assign(Object.assign({},this.logContext),{rpID:c,streamId:l,trackId:u}));let h;this.options.adaptiveStream&&(typeof this.options.adaptiveStream=="object"?h=this.options.adaptiveStream:h={});const p=f.addSubscribedMediaTrack(e,u,n,a,h);p!=null&&p.isEncrypted&&!this.e2eeManager&&this.emit(X.EncryptionError,new Error("Encrypted ".concat(p.source," track received from participant ").concat(f.sid,", but room does not have encryption enabled!")))}handleDisconnect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,n=arguments.length>1?arguments[1]:void 0;var a,r;if(this.clearConnectionReconcile(),this.isResuming=!1,this.bufferedEvents=[],this.transcriptionReceivedTimes.clear(),this.incomingDataStreamManager.clearControllers(),this.state!==Ne.Disconnected){this.regionUrl=void 0,this.regionUrlProvider&&this.regionUrlProvider.notifyDisconnected();try{this.remoteParticipants.forEach(c=>{c.trackPublications.forEach(l=>{c.unpublishTrack(l.trackSid)})}),this.localParticipant.trackPublications.forEach(c=>{var l,u,f;c.track&&this.localParticipant.unpublishTrack(c.track,e),e?((l=c.track)===null||l===void 0||l.detach(),(u=c.track)===null||u===void 0||u.stop()):(f=c.track)===null||f===void 0||f.stopMonitor()}),this.localParticipant.off(ee.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).off(ee.ParticipantNameChanged,this.onLocalParticipantNameChanged).off(ee.AttributesChanged,this.onLocalAttributesChanged).off(ee.TrackMuted,this.onLocalTrackMuted).off(ee.TrackUnmuted,this.onLocalTrackUnmuted).off(ee.LocalTrackPublished,this.onLocalTrackPublished).off(ee.LocalTrackUnpublished,this.onLocalTrackUnpublished).off(ee.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).off(ee.MediaDevicesError,this.onMediaDevicesError).off(ee.AudioStreamAcquired,this.startAudio).off(ee.ChatMessage,this.onLocalChatMessageSent).off(ee.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),Qt()&&(window.removeEventListener("beforeunload",this.onPageLeave),window.removeEventListener("pagehide",this.onPageLeave),window.removeEventListener("freeze",this.onPageLeave),(r=(a=navigator.mediaDevices)===null||a===void 0?void 0:a.removeEventListener)===null||r===void 0||r.call(a,"devicechange",this.handleDeviceChange))}finally{this.setAndEmitConnectionState(Ne.Disconnected),this.emit(X.Disconnected,n)}}}handleParticipantDisconnected(e,n){var a;this.remoteParticipants.delete(e),n&&(this.incomingDataStreamManager.validateParticipantHasNoActiveDataStreams(e),n.trackPublications.forEach(r=>{n.unpublishTrack(r.trackSid,!0)}),this.emit(X.ParticipantDisconnected,n),n.setDisconnected(),(a=this.localParticipant)===null||a===void 0||a.handleParticipantDisconnected(n.identity))}handleIncomingRpcRequest(e,n,a,r,c,l){return A(this,void 0,void 0,function*(){if(yield this.engine.publishRpcAck(e,n),l!==1){yield this.engine.publishRpcResponse(e,n,null,ot.builtIn("UNSUPPORTED_VERSION"));return}const u=this.rpcHandlers.get(a);if(!u){yield this.engine.publishRpcResponse(e,n,null,ot.builtIn("UNSUPPORTED_METHOD"));return}let f=null,h=null;try{const p=yield u({requestId:n,callerIdentity:e,payload:r,responseTimeout:c});nh(p)>IS?(f=ot.builtIn("RESPONSE_PAYLOAD_TOO_LARGE"),this.log.warn("RPC Response payload too large for ".concat(a))):h=p}catch(p){p instanceof ot?f=p:(this.log.warn("Uncaught error returned by RPC handler for ".concat(a,". Returning APPLICATION_ERROR instead."),p),f=ot.builtIn("APPLICATION_ERROR"))}yield this.engine.publishRpcResponse(e,n,h,f)})}selectDefaultDevices(){return A(this,void 0,void 0,function*(){var e,n,a;const r=Rt.getInstance().previousDevices,c=yield Rt.getInstance().getDevices(void 0,!1),l=Xt();if((l==null?void 0:l.name)==="Chrome"&&l.os!=="iOS")for(let f of c){const h=r.find(p=>p.deviceId===f.deviceId);h&&h.label!==""&&h.kind===f.kind&&h.label!==f.label&&this.getActiveDevice(f.kind)==="default"&&this.emit(X.ActiveDeviceChanged,f.kind,f.deviceId)}const u=["audiooutput","audioinput","videoinput"];for(let f of u){const h=yO(f),p=this.localParticipant.getTrackPublication(h);if(p&&(!((e=p.track)===null||e===void 0)&&e.isUserProvided))continue;const v=c.filter(S=>S.kind===f),y=this.getActiveDevice(f);if(y===((n=r.filter(S=>S.kind===f)[0])===null||n===void 0?void 0:n.deviceId)&&v.length>0&&((a=v[0])===null||a===void 0?void 0:a.deviceId)!==y){yield this.switchActiveDevice(f,v[0].deviceId);continue}f==="audioinput"&&!eo()||f==="videoinput"||v.length>0&&!v.find(S=>S.deviceId===this.getActiveDevice(f))&&(f!=="audiooutput"||!eo())&&(yield this.switchActiveDevice(f,v[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=Pf())!==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(),Dt(200)])}catch(r){this.log.warn("Could not resume audio context",Object.assign(Object.assign({},this.logContext),{error:r}))}const a=((n=this.audioContext)===null||n===void 0?void 0:n.state)==="running";a!==this.canPlaybackAudio&&(this.audioEnabled=a,this.emit(X.AudioPlaybackStatusChanged,a))})}createParticipant(e,n){var a;let r;return n?r=nl.fromParticipantInfo(this.engine.client,n,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName}):r=new nl(this.engine.client,"",e,void 0,void 0,void 0,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName}),this.options.webAudioMix&&r.setAudioContext(this.audioContext),!((a=this.options.audioOutput)===null||a===void 0)&&a.deviceId&&r.setAudioOutput(this.options.audioOutput).catch(c=>this.log.warn("Could not set audio output: ".concat(c.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 a=this.createParticipant(e,n);return this.remoteParticipants.set(e,a),this.sidToIdentity.set(n.sid,n.identity),this.emitWhenConnected(X.ParticipantConnected,a),a.on(ee.TrackPublished,r=>{this.emitWhenConnected(X.TrackPublished,r,a)}).on(ee.TrackSubscribed,(r,c)=>{r.kind===Q.Kind.Audio?(r.on(ae.AudioPlaybackStarted,this.handleAudioPlaybackStarted),r.on(ae.AudioPlaybackFailed,this.handleAudioPlaybackFailed)):r.kind===Q.Kind.Video&&(r.on(ae.VideoPlaybackFailed,this.handleVideoPlaybackFailed),r.on(ae.VideoPlaybackStarted,this.handleVideoPlaybackStarted)),this.emit(X.TrackSubscribed,r,c,a)}).on(ee.TrackUnpublished,r=>{this.emit(X.TrackUnpublished,r,a)}).on(ee.TrackUnsubscribed,(r,c)=>{this.emit(X.TrackUnsubscribed,r,c,a)}).on(ee.TrackMuted,r=>{this.emitWhenConnected(X.TrackMuted,r,a)}).on(ee.TrackUnmuted,r=>{this.emitWhenConnected(X.TrackUnmuted,r,a)}).on(ee.ParticipantMetadataChanged,r=>{this.emitWhenConnected(X.ParticipantMetadataChanged,r,a)}).on(ee.ParticipantNameChanged,r=>{this.emitWhenConnected(X.ParticipantNameChanged,r,a)}).on(ee.AttributesChanged,r=>{this.emitWhenConnected(X.ParticipantAttributesChanged,r,a)}).on(ee.ConnectionQualityChanged,r=>{this.emitWhenConnected(X.ConnectionQualityChanged,r,a)}).on(ee.ParticipantPermissionsChanged,r=>{this.emitWhenConnected(X.ParticipantPermissionsChanged,r,a)}).on(ee.TrackSubscriptionStatusChanged,(r,c)=>{this.emitWhenConnected(X.TrackSubscriptionStatusChanged,r,c,a)}).on(ee.TrackSubscriptionFailed,(r,c)=>{this.emit(X.TrackSubscriptionFailed,r,a,c)}).on(ee.TrackSubscriptionPermissionChanged,(r,c)=>{this.emitWhenConnected(X.TrackSubscriptionPermissionChanged,r,c,a)}).on(ee.Active,()=>{this.emitWhenConnected(X.ParticipantActive,a),a.kind===Ba.AGENT&&this.localParticipant.setActiveAgent(a)}),n&&a.updateInfo(n),a}sendSyncState(){const e=Array.from(this.remoteParticipants.values()).reduce((a,r)=>(a.push(...r.getTrackPublications()),a),[]),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&&FO(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=Mt.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,Un.STATE_MISMATCH))):e=0},rN)}clearConnectionReconcile(){this.connectionReconcileInterval&&Mt.clearInterval(this.connectionReconcileInterval)}setAndEmitConnectionState(e){return e===this.state?!1:(this.state=e,this.emit(X.ConnectionStateChanged,this.state),!0)}emitBufferedEvents(){this.bufferedEvents.forEach(e=>{let[n,a]=e;this.emit(n,...a)}),this.bufferedEvents=[]}emitWhenConnected(e){for(var n=arguments.length,a=new Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];if(this.state===Ne.Reconnecting||this.isResuming||!this.engine||this.engine.pendingReconnect)this.bufferedEvents.push([e,a]);else if(this.state===Ne.Connected)return this.emit(e,...a);return!1}simulateParticipants(e){return A(this,void 0,void 0,function*(){var n,a,r,c;const l=Object.assign({audio:!0,video:!0,useRealTracks:!1},e.publish),u=Object.assign({count:9,audio:!1,video:!0,aspectRatios:[1.66,1.7,1.3]},e.participants);if(this.handleDisconnect(),this.roomInfo=new Dc({sid:"RM_SIMULATED",name:"simulated-room",emptyTimeout:0,maxParticipants:0,creationTime:et.parse(new Date().getTime()),metadata:"",numParticipants:1,numPublishers:1,turnPassword:"",enabledCodecs:[],activeRecording:!1}),this.localParticipant.updateInfo(new Ua({identity:"simulated-local",name:"local-name"})),this.setupLocalParticipantEvents(),this.emit(X.SignalConnected),this.emit(X.Connected),this.setAndEmitConnectionState(Ne.Connected),l.video){const f=new dh(Q.Kind.Video,new ks({source:pt.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:In.AUDIO,name:"video-dummy"}),new el(l.useRealTracks&&(!((n=window.navigator.mediaDevices)===null||n===void 0)&&n.getUserMedia)?(yield window.navigator.mediaDevices.getUserMedia({video:!0})).getVideoTracks()[0]:vS(160*((a=u.aspectRatios[0])!==null&&a!==void 0?a:1),160,!0,!0),void 0,!1,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(f),this.localParticipant.emit(ee.LocalTrackPublished,f)}if(l.audio){const f=new dh(Q.Kind.Audio,new ks({source:pt.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:In.AUDIO}),new $c(l.useRealTracks&&(!((r=navigator.mediaDevices)===null||r===void 0)&&r.getUserMedia)?(yield navigator.mediaDevices.getUserMedia({audio:!0})).getAudioTracks()[0]:zf(),void 0,!1,this.audioContext,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(f),this.localParticipant.emit(ee.LocalTrackPublished,f)}for(let f=0;f<u.count-1;f+=1){let h=new Ua({sid:Math.floor(Math.random()*1e4).toString(),identity:"simulated-".concat(f),state:Cs.ACTIVE,tracks:[],joinedAt:et.parse(Date.now())});const p=this.getOrCreateParticipant(h.identity,h);if(u.video){const v=vS(160*((c=u.aspectRatios[f%u.aspectRatios.length])!==null&&c!==void 0?c:1),160,!1,!0),y=new ks({source:pt.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:In.AUDIO});p.addSubscribedMediaTrack(v,y.sid,new MediaStream([v]),new RTCRtpReceiver),h.tracks=[...h.tracks,y]}if(u.audio){const v=zf(),y=new ks({source:pt.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:In.AUDIO});p.addSubscribedMediaTrack(v,y.sid,new MediaStream([v]),new RTCRtpReceiver),h.tracks=[...h.tracks,y]}p.updateInfo(h)}})}emit(e){for(var n=arguments.length,a=new Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];if(e!==X.ActiveSpeakersChanged&&e!==X.TranscriptionReceived){const c=tT(a).filter(l=>l!==void 0);(e===X.TrackSubscribed||e===X.TrackUnsubscribed)&&this.log.trace("subscribe trace: ".concat(e),Object.assign(Object.assign({},this.logContext),{event:e,args:c})),this.log.debug("room event ".concat(e),Object.assign(Object.assign({},this.logContext),{event:e,args:c}))}return super.emit(e,...a)}}Ls.cleanupRegistry=typeof FinalizationRegistry!="undefined"&&new FinalizationRegistry(t=>{t()});function tT(t){return t.map(e=>{if(e)return Array.isArray(e)?tT(e):typeof e=="object"?"logContext"in e?e.logContext:void 0:e})}var qn;(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"})(qn||(qn={}));class Wi extends Zn.EventEmitter{constructor(e,n){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};super(),this.status=qn.IDLE,this.logs=[],this.options={},this.url=e,this.token=n,this.name=this.constructor.name,this.room=new Ls(a.roomOptions),this.connectOptions=a.connectOptions,this.options=a}run(e){return A(this,void 0,void 0,function*(){if(this.status!==qn.IDLE)throw Error("check is running already");this.setStatus(qn.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!==qn.SKIPPED&&this.setStatus(this.isSuccess()?qn.SUCCESS:qn.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===Ne.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!==Ne.Disconnected&&(yield this.room.disconnect(),yield new Promise(e=>setTimeout(e,500)))})}skip(){this.setStatus(qn.SKIPPED)}switchProtocol(e){return A(this,void 0,void 0,function*(){let n=!1,a=!1;if(this.room.on(X.Reconnecting,()=>{n=!0}),this.room.once(X.Reconnected,()=>{a=!0}),this.room.simulateScenario("force-".concat(e)),yield new Promise(c=>setTimeout(c,1e3)),!n)return;const r=Date.now()+1e4;for(;Date.now()<r;){if(a)return;yield Dt(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 oN extends Wi{get description(){return"Cloud regions"}perform(){return A(this,void 0,void 0,function*(){const e=new Ie(this.url,this.token);if(!e.isCloud()){this.skip();return}const n=[],a=new Set;for(let c=0;c<3;c++){const l=yield e.getNextBestRegionUrl();if(!l)break;if(a.has(l))continue;a.add(l);const u=yield this.checkCloudRegion(l);this.appendMessage("".concat(u.region," RTT: ").concat(u.rtt,"ms, duration: ").concat(u.duration,"ms")),n.push(u)}n.sort((c,l)=>(c.duration-l.duration)*.5+(c.rtt-l.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,a;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 c=yield this.room.localParticipant.streamText({topic:"test"}),l=1e3,f=1e6/l,h="A".repeat(l),p=Date.now();for(let w=0;w<f;w++)yield c.write(h);yield c.close();const v=Date.now(),y=yield(a=this.room.engine.pcManager)===null||a===void 0?void 0:a.publisher.getStats(),S={region:r,rtt:1e4,duration:v-p};return y==null||y.forEach(w=>{w.type==="candidate-pair"&&w.nominated&&(S.rtt=w.currentRoundTripTime*1e3)}),yield this.disconnect(),S})}}const fh=1e4;class cN extends Wi{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 a=this.bestStats;this.appendMessage("upstream bitrate: ".concat((a.bitrateTotal/a.count/1e3/1e3).toFixed(2)," mbps")),this.appendMessage("RTT: ".concat((a.rttTotal/a.count*1e3).toFixed(2)," ms")),this.appendMessage("jitter: ".concat((a.jitterTotal/a.count*1e3).toFixed(2)," ms")),a.packetsLost>0&&this.appendWarning("packets lost: ".concat((a.packetsLost/a.packetsSent*100).toFixed(2),"%")),a.qualityLimitationDurations.bandwidth>1&&this.appendWarning("bandwidth limited ".concat((a.qualityLimitationDurations.bandwidth/(fh/1e3)*100).toFixed(2),"%")),a.qualityLimitationDurations.cpu>0&&this.appendWarning("cpu limited ".concat((a.qualityLimitationDurations.cpu/(fh/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 a=n.getContext("2d");if(!a)throw new Error("Could not get canvas context");let r=0;const c=()=>{r=(r+1)%360,a.fillStyle="hsl(".concat(r,", 100%, 50%)"),a.fillRect(0,0,n.width,n.height),requestAnimationFrame(c)};c();const u=n.captureStream(30).getVideoTracks()[0],h=(yield this.room.localParticipant.publishTrack(u,{simulcast:!1,degradationPreference:"maintain-resolution",videoEncoding:{maxBitrate:2e6}})).track,p={protocol:e,packetsLost:0,packetsSent:0,qualityLimitationDurations:{},rttTotal:0,jitterTotal:0,bitrateTotal:0,count:0},v=setInterval(()=>A(this,void 0,void 0,function*(){const y=yield h.getRTCStatsReport();y==null||y.forEach(S=>{S.type==="outbound-rtp"?(p.packetsSent=S.packetsSent,p.qualityLimitationDurations=S.qualityLimitationDurations,p.bitrateTotal+=S.targetBitrate,p.count++):S.type==="remote-inbound-rtp"&&(p.packetsLost=S.packetsLost,p.rttTotal+=S.roundTripTime,p.jitterTotal+=S.jitter)})}),1e3);return yield new Promise(y=>setTimeout(y,fh)),clearInterval(v),u.stop(),n.remove(),yield this.disconnect(),p})}}class lN extends Wi{get description(){return"Can publish audio"}perform(){return A(this,void 0,void 0,function*(){var e;const n=yield this.connect(),a=yield nN();if(yield rS(a,1e3))throw new Error("unable to detect audio from microphone");this.appendMessage("detected audio from microphone"),n.localParticipant.publishTrack(a),yield new Promise(u=>setTimeout(u,3e3));const c=yield(e=a.sender)===null||e===void 0?void 0:e.getStats();if(!c)throw new Error("Could not get RTCStats");let l=0;if(c.forEach(u=>{u.type==="outbound-rtp"&&(u.kind==="audio"||!u.kind&&u.mediaType==="audio")&&(l=u.packetsSent)}),l===0)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(l," audio packets"))})}}class uN extends Wi{get description(){return"Can publish video"}perform(){return A(this,void 0,void 0,function*(){var e;const n=yield this.connect(),a=yield tN();yield this.checkForVideo(a.mediaStreamTrack),n.localParticipant.publishTrack(a),yield new Promise(l=>setTimeout(l,5e3));const r=yield(e=a.sender)===null||e===void 0?void 0:e.getStats();if(!r)throw new Error("Could not get RTCStats");let c=0;if(r.forEach(l=>{l.type==="outbound-rtp"&&(l.kind==="video"||!l.kind&&l.mediaType==="video")&&(c+=l.packetsSent)}),c===0)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(c," video packets"))})}checkForVideo(e){return A(this,void 0,void 0,function*(){const n=new MediaStream;n.addTrack(e.clone());const a=document.createElement("video");a.srcObject=n,a.muted=!0,a.autoplay=!0,a.playsInline=!0,a.setAttribute("playsinline","true"),document.body.appendChild(a),yield new Promise(r=>{a.onplay=()=>{setTimeout(()=>{var c,l,u,f;const h=document.createElement("canvas"),p=e.getSettings(),v=(l=(c=p.width)!==null&&c!==void 0?c:a.videoWidth)!==null&&l!==void 0?l:1280,y=(f=(u=p.height)!==null&&u!==void 0?u:a.videoHeight)!==null&&f!==void 0?f:720;h.width=v,h.height=y;const S=h.getContext("2d");S.drawImage(a,0,0);const T=S.getImageData(0,0,h.width,h.height).data;let x=!0;for(let R=0;R<T.length;R+=4)if(T[R]!==0||T[R+1]!==0||T[R+2]!==0){x=!1;break}x?this.appendError("camera appears to be producing only black frames"):this.appendMessage("received video frames"),r()},1e3)},a.play()}),n.getTracks().forEach(r=>r.stop()),a.remove()})}}class dN extends Wi{get description(){return"Resuming connection after interruption"}perform(){return A(this,void 0,void 0,function*(){var e;const n=yield this.connect();let a=!1,r=!1,c;const l=new Promise(h=>{setTimeout(h,5e3),c=h}),u=()=>{a=!0};n.on(X.SignalReconnecting,u).on(X.Reconnecting,u).on(X.Reconnected,()=>{r=!0,c(!0)}),(e=n.engine.client.ws)===null||e===void 0||e.close();const f=n.engine.client.onClose;if(f&&f(""),yield l,a){if(!r||n.state!==Ne.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 fN extends Wi{get description(){return"Can connect via TURN"}perform(){return A(this,void 0,void 0,function*(){var e,n,a;Ms(new URL(this.url))&&(this.appendMessage("Using region specific url"),this.url=(e=yield new Ie(this.url,this.token).getNextBestRegionUrl())!==null&&e!==void 0?e:this.url);const r=new Yf,c=yield r.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3},void 0,!0);let l=!1,u=!1,f=!1;for(let h of c.iceServers)for(let p of h.urls)p.startsWith("turn:")?(u=!0,f=!0):p.startsWith("turns:")&&(u=!0,f=!0,l=!0),p.startsWith("stun:")&&(f=!0);f?u&&!l&&this.appendWarning("TURN is configured server side, but TURN/TLS is unavailable."):this.appendWarning("No STUN servers configured on server side."),yield r.close(),!((a=(n=this.connectOptions)===null||n===void 0?void 0:n.rtcConfig)===null||a===void 0)&&a.iceServers||u?yield this.room.connect(this.url,this.token,{rtcConfig:{iceTransportPolicy:"relay"}}):(this.appendWarning("No TURN servers configured."),this.skip(),yield new Promise(h=>setTimeout(h,0)))})}}class hN extends Wi{get description(){return"Establishing WebRTC connection"}perform(){return A(this,void 0,void 0,function*(){let e=!1,n=!1;this.room.on(X.SignalConnected,()=>{var a;const r=this.room.engine.client.onTrickle;this.room.engine.client.onTrickle=(c,l)=>{if(c.candidate){const u=new RTCIceCandidate(c);let f="".concat(u.protocol," ").concat(u.address,":").concat(u.port," ").concat(u.type);u.address&&(mN(u.address)?f+=" (private)":u.protocol==="tcp"&&u.tcpType==="passive"?(e=!0,f+=" (passive)"):u.protocol==="udp"&&(n=!0)),this.appendMessage(f)}r&&r(c,l)},!((a=this.room.engine.pcManager)===null||a===void 0)&&a.subscriber&&(this.room.engine.pcManager.subscriber.onIceCandidateError=c=>{c instanceof RTCPeerConnectionIceErrorEvent&&this.appendWarning("error with ICE candidate: ".concat(c.errorCode," ").concat(c.errorText," ").concat(c.url))})});try{yield this.connect(),Ee.info("now the room is connected")}catch(a){throw this.appendWarning("ports need to be open on firewall in order to connect."),a}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 mN(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 pN extends Wi{get description(){return"Connecting to signal connection via WebSocket"}perform(){return A(this,void 0,void 0,function*(){var e,n,a;(this.url.startsWith("ws:")||this.url.startsWith("http:"))&&this.appendWarning("Server is insecure, clients may block connections to it");let r=new Yf,c;try{c=yield r.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3},void 0,!0)}catch(l){if(Ms(new URL(this.url))){this.appendMessage("Initial connection failed with error ".concat(l.message,". Retrying with region fallback"));const f=yield new Ie(this.url,this.token).getNextBestRegionUrl();f&&(c=yield r.join(f,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3},void 0,!0),this.appendMessage("Fallback to region worked. To avoid initial connections failing, ensure you're calling room.prepareConnection() ahead of time"))}}c?(this.appendMessage("Connected to server, version ".concat(c.serverVersion,".")),((e=c.serverInfo)===null||e===void 0?void 0:e.edition)===Q0.Cloud&&(!((n=c.serverInfo)===null||n===void 0)&&n.region)&&this.appendMessage("LiveKit Cloud: ".concat((a=c.serverInfo)===null||a===void 0?void 0:a.region))):this.appendError("Websocket connection could not be established"),yield r.close()})}}class j5 extends Zn.EventEmitter{constructor(e,n){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};super(),this.options={},this.checkResults=new Map,this.url=e,this.token=n,this.options=a}getNextCheckId(){const e=this.checkResults.size;return this.checkResults.set(e,{logs:[],status:qn.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!==qn.FAILED)}getResults(){return Array.from(this.checkResults.values())}createAndRunCheck(e){return A(this,void 0,void 0,function*(){const n=this.getNextCheckId(),a=new e(this.url,this.token,this.options),r=l=>{this.updateCheck(n,l)};a.on("update",r);const c=yield a.run();return a.off("update",r),c})}checkWebsocket(){return A(this,void 0,void 0,function*(){return this.createAndRunCheck(pN)})}checkWebRTC(){return A(this,void 0,void 0,function*(){return this.createAndRunCheck(hN)})}checkTURN(){return A(this,void 0,void 0,function*(){return this.createAndRunCheck(fN)})}checkReconnect(){return A(this,void 0,void 0,function*(){return this.createAndRunCheck(dN)})}checkPublishAudio(){return A(this,void 0,void 0,function*(){return this.createAndRunCheck(lN)})}checkPublishVideo(){return A(this,void 0,void 0,function*(){return this.createAndRunCheck(uN)})}checkConnectionProtocol(){return A(this,void 0,void 0,function*(){const e=yield this.createAndRunCheck(cN);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(oN)})}}function Ae(t,e,n){return(e=vN(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gN(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,e);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function vN(t){var e=gN(t,"string");return typeof e=="symbol"?e:e+""}new TextEncoder,new TextDecoder;class Ht extends Error{constructor(e,n){var a;super(e,n),Ae(this,"code","ERR_JOSE_GENERIC"),this.name=this.constructor.name,(a=Error.captureStackTrace)===null||a===void 0||a.call(Error,this,this.constructor)}}Ae(Ht,"code","ERR_JOSE_GENERIC");class yN extends Ht{constructor(e,n){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"unspecified",r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"unspecified";super(e,{cause:{claim:a,reason:r,payload:n}}),Ae(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED"),Ae(this,"claim",void 0),Ae(this,"reason",void 0),Ae(this,"payload",void 0),this.claim=a,this.reason=r,this.payload=n}}Ae(yN,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");class bN extends Ht{constructor(e,n){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"unspecified",r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"unspecified";super(e,{cause:{claim:a,reason:r,payload:n}}),Ae(this,"code","ERR_JWT_EXPIRED"),Ae(this,"claim",void 0),Ae(this,"reason",void 0),Ae(this,"payload",void 0),this.claim=a,this.reason=r,this.payload=n}}Ae(bN,"code","ERR_JWT_EXPIRED");class SN extends Ht{constructor(){super(...arguments),Ae(this,"code","ERR_JOSE_ALG_NOT_ALLOWED")}}Ae(SN,"code","ERR_JOSE_ALG_NOT_ALLOWED");class TN extends Ht{constructor(){super(...arguments),Ae(this,"code","ERR_JOSE_NOT_SUPPORTED")}}Ae(TN,"code","ERR_JOSE_NOT_SUPPORTED");class CN extends Ht{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"decryption operation failed",n=arguments.length>1?arguments[1]:void 0;super(e,n),Ae(this,"code","ERR_JWE_DECRYPTION_FAILED")}}Ae(CN,"code","ERR_JWE_DECRYPTION_FAILED");class kN extends Ht{constructor(){super(...arguments),Ae(this,"code","ERR_JWE_INVALID")}}Ae(kN,"code","ERR_JWE_INVALID");class EN extends Ht{constructor(){super(...arguments),Ae(this,"code","ERR_JWS_INVALID")}}Ae(EN,"code","ERR_JWS_INVALID");class wN extends Ht{constructor(){super(...arguments),Ae(this,"code","ERR_JWT_INVALID")}}Ae(wN,"code","ERR_JWT_INVALID");class RN extends Ht{constructor(){super(...arguments),Ae(this,"code","ERR_JWK_INVALID")}}Ae(RN,"code","ERR_JWK_INVALID");class _N extends Ht{constructor(){super(...arguments),Ae(this,"code","ERR_JWKS_INVALID")}}Ae(_N,"code","ERR_JWKS_INVALID");class xN extends Ht{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"no applicable key found in the JSON Web Key Set",n=arguments.length>1?arguments[1]:void 0;super(e,n),Ae(this,"code","ERR_JWKS_NO_MATCHING_KEY")}}Ae(xN,"code","ERR_JWKS_NO_MATCHING_KEY");class AN extends Ht{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"multiple matching keys found in the JSON Web Key Set",n=arguments.length>1?arguments[1]:void 0;super(e,n),Ae(this,Symbol.asyncIterator,void 0),Ae(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS")}}Ae(AN,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");class MN extends Ht{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"request timed out",n=arguments.length>1?arguments[1]:void 0;super(e,n),Ae(this,"code","ERR_JWKS_TIMEOUT")}}Ae(MN,"code","ERR_JWKS_TIMEOUT");class DN extends Ht{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"signature verification failed",n=arguments.length>1?arguments[1]:void 0;super(e,n),Ae(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED")}}Ae(DN,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");var il=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};function ON(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var hh={exports:{}},PN=hh.exports,nT;function NN(){return nT||(nT=1,(function(t){(function(e,n){t.exports?t.exports=n():e.log=n()})(PN,function(){var e=function(){},n="undefined",a=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"],c={},l=null;function u(T,x){var R=T[x];if(typeof R.bind=="function")return R.bind(T);try{return Function.prototype.bind.call(R,T)}catch{return function(){return Function.prototype.apply.apply(R,[T,arguments])}}}function f(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function h(T){return T==="debug"&&(T="log"),typeof console===n?!1:T==="trace"&&a?f:console[T]!==void 0?u(console,T):console.log!==void 0?u(console,"log"):e}function p(){for(var T=this.getLevel(),x=0;x<r.length;x++){var R=r[x];this[R]=x<T?e:this.methodFactory(R,T,this.name)}if(this.log=this.debug,typeof console===n&&T<this.levels.SILENT)return"No console available for logging"}function v(T){return function(){typeof console!==n&&(p.call(this),this[T].apply(this,arguments))}}function y(T,x,R){return h(T)||v.apply(this,arguments)}function S(T,x){var R=this,P,L,E,k="loglevel";typeof T=="string"?k+=":"+T:typeof T=="symbol"&&(k=void 0);function _(Y){var ie=(r[Y]||"silent").toUpperCase();if(!(typeof window===n||!k)){try{window.localStorage[k]=ie;return}catch{}try{window.document.cookie=encodeURIComponent(k)+"="+ie+";"}catch{}}}function N(){var Y;if(!(typeof window===n||!k)){try{Y=window.localStorage[k]}catch{}if(typeof Y===n)try{var ie=window.document.cookie,he=encodeURIComponent(k),be=ie.indexOf(he+"=");be!==-1&&(Y=/^([^;]+)/.exec(ie.slice(be+he.length+1))[1])}catch{}return R.levels[Y]===void 0&&(Y=void 0),Y}}function U(){if(!(typeof window===n||!k)){try{window.localStorage.removeItem(k)}catch{}try{window.document.cookie=encodeURIComponent(k)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function G(Y){var ie=Y;if(typeof ie=="string"&&R.levels[ie.toUpperCase()]!==void 0&&(ie=R.levels[ie.toUpperCase()]),typeof ie=="number"&&ie>=0&&ie<=R.levels.SILENT)return ie;throw new TypeError("log.setLevel() called with invalid level: "+Y)}R.name=T,R.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},R.methodFactory=x||y,R.getLevel=function(){var Y;return(Y=E!=null?E:L)!=null?Y:P},R.setLevel=function(Y,ie){return E=G(Y),ie!==!1&&_(E),p.call(R)},R.setDefaultLevel=function(Y){L=G(Y),N()||R.setLevel(Y,!1)},R.resetLevel=function(){E=null,U(),p.call(R)},R.enableAll=function(Y){R.setLevel(R.levels.TRACE,Y)},R.disableAll=function(Y){R.setLevel(R.levels.SILENT,Y)},R.rebuild=function(){if(l!==R&&(P=G(l.getLevel())),p.call(R),l===R)for(var Y in c)c[Y].rebuild()},P=G(l?l.getLevel():"WARN");var V=N();V!=null&&(E=G(V)),p.call(R)}l=new S,l.getLogger=function(T){if(typeof T!="symbol"&&typeof T!="string"||T==="")throw new TypeError("You must supply a name when creating a logger.");var x=c[T];return x||(x=c[T]=new S(T,l.methodFactory)),x};var w=typeof window!==n?window.log:void 0;return l.noConflict=function(){return typeof window!==n&&window.log===l&&(window.log=w),l},l.getLoggers=function(){return c},l.default=l,l})})(hh)),hh.exports}var LN=NN();const IN=ON(LN);var mh=function(t,e){return mh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,a){n.__proto__=a}||function(n,a){for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(n[r]=a[r])},mh(t,e)};function vi(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");mh(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function UN(t,e,n,a){function r(c){return c instanceof n?c:new n(function(l){l(c)})}return new(n||(n=Promise))(function(c,l){function u(p){try{h(a.next(p))}catch(v){l(v)}}function f(p){try{h(a.throw(p))}catch(v){l(v)}}function h(p){p.done?c(p.value):r(p.value).then(u,f)}h((a=a.apply(t,[])).next())})}function iT(t,e){var n={label:0,sent:function(){if(c[0]&1)throw c[1];return c[1]},trys:[],ops:[]},a,r,c,l=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return l.next=u(0),l.throw=u(1),l.return=u(2),typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function u(h){return function(p){return f([h,p])}}function f(h){if(a)throw new TypeError("Generator is already executing.");for(;l&&(l=0,h[0]&&(n=0)),n;)try{if(a=1,r&&(c=h[0]&2?r.return:h[0]?r.throw||((c=r.return)&&c.call(r),0):r.next)&&!(c=c.call(r,h[1])).done)return c;switch(r=0,c&&(h=[h[0]&2,c.value]),h[0]){case 0:case 1:c=h;break;case 4:return n.label++,{value:h[1],done:!1};case 5:n.label++,r=h[1],h=[0];continue;case 7:h=n.ops.pop(),n.trys.pop();continue;default:if(c=n.trys,!(c=c.length>0&&c[c.length-1])&&(h[0]===6||h[0]===2)){n=0;continue}if(h[0]===3&&(!c||h[1]>c[0]&&h[1]<c[3])){n.label=h[1];break}if(h[0]===6&&n.label<c[1]){n.label=c[1],c=h;break}if(c&&n.label<c[2]){n.label=c[2],n.ops.push(h);break}c[2]&&n.ops.pop(),n.trys.pop();continue}h=e.call(t,n)}catch(p){h=[6,p],r=0}finally{a=c=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Is(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],a=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&a>=t.length&&(t=void 0),{value:t&&t[a++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ro(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var a=n.call(t),r,c=[],l;try{for(;(e===void 0||e-- >0)&&!(r=a.next()).done;)c.push(r.value)}catch(u){l={error:u}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(l)throw l.error}}return c}function oo(t,e,n){if(arguments.length===2)for(var a=0,r=e.length,c;a<r;a++)(c||!(a in e))&&(c||(c=Array.prototype.slice.call(e,0,a)),c[a]=e[a]);return t.concat(c||Array.prototype.slice.call(e))}function Us(t){return this instanceof Us?(this.v=t,this):new Us(t)}function BN(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=n.apply(t,e||[]),r,c=[];return r=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",l),r[Symbol.asyncIterator]=function(){return this},r;function l(S){return function(w){return Promise.resolve(w).then(S,v)}}function u(S,w){a[S]&&(r[S]=function(T){return new Promise(function(x,R){c.push([S,T,x,R])>1||f(S,T)})},w&&(r[S]=w(r[S])))}function f(S,w){try{h(a[S](w))}catch(T){y(c[0][3],T)}}function h(S){S.value instanceof Us?Promise.resolve(S.value.v).then(p,v):y(c[0][2],S)}function p(S){f("next",S)}function v(S){f("throw",S)}function y(S,w){S(w),c.shift(),c.length&&f(c[0][0],c[0][1])}}function jN(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 Is=="function"?Is(t):t[Symbol.iterator](),n={},a("next"),a("throw"),a("return"),n[Symbol.asyncIterator]=function(){return this},n);function a(c){n[c]=t[c]&&function(l){return new Promise(function(u,f){l=t[c](l),r(u,f,l.done,l.value)})}}function r(c,l,u,f){Promise.resolve(f).then(function(h){c({value:h,done:u})},l)}}function gt(t){return typeof t=="function"}function ph(t){var e=function(a){Error.call(a),a.stack=new Error().stack},n=t(e);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var gh=ph(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
47
|
+
`+e.map(function(n,a){return a+1+") "+n.toString()}).join(`
|
|
48
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function al(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var co=(function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,n,a,r,c;if(!this.closed){this.closed=!0;var l=this._parentage;if(l)if(this._parentage=null,Array.isArray(l))try{for(var u=Is(l),f=u.next();!f.done;f=u.next()){var h=f.value;h.remove(this)}}catch(T){e={error:T}}finally{try{f&&!f.done&&(n=u.return)&&n.call(u)}finally{if(e)throw e.error}}else l.remove(this);var p=this.initialTeardown;if(gt(p))try{p()}catch(T){c=T instanceof gh?T.errors:[T]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var y=Is(v),S=y.next();!S.done;S=y.next()){var w=S.value;try{rT(w)}catch(T){c=c!=null?c:[],T instanceof gh?c=oo(oo([],ro(c)),ro(T.errors)):c.push(T)}}}catch(T){a={error:T}}finally{try{S&&!S.done&&(r=y.return)&&r.call(y)}finally{if(a)throw a.error}}}if(c)throw new gh(c)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)rT(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)&&al(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&al(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=(function(){var e=new t;return e.closed=!0,e})(),t})(),aT=co.EMPTY;function sT(t){return t instanceof co||t&&"closed"in t&>(t.remove)&>(t.add)&>(t.unsubscribe)}function rT(t){gt(t)?t():t.unsubscribe()}var VN={Promise:void 0},zN={setTimeout:function(t,e){for(var n=[],a=2;a<arguments.length;a++)n[a-2]=arguments[a];return setTimeout.apply(void 0,oo([t,e],ro(n)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function oT(t){zN.setTimeout(function(){throw t})}function vh(){}function sl(t){t()}var yh=(function(t){vi(e,t);function e(n){var a=t.call(this)||this;return a.isStopped=!1,n?(a.destination=n,sT(n)&&n.add(a)):a.destination=HN,a}return e.create=function(n,a,r){return new lo(n,a,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})(co),FN=(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(a){rl(a)}},t.prototype.error=function(e){var n=this.partialObserver;if(n.error)try{n.error(e)}catch(a){rl(a)}else rl(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(n){rl(n)}},t})(),lo=(function(t){vi(e,t);function e(n,a,r){var c=t.call(this)||this,l;return gt(n)||!n?l={next:n!=null?n:void 0,error:a!=null?a:void 0,complete:r!=null?r:void 0}:l=n,c.destination=new FN(l),c}return e})(yh);function rl(t){oT(t)}function qN(t){throw t}var HN={closed:!0,next:vh,error:qN,complete:vh},bh=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Sh(t){return t}function GN(t){return t.length===0?Sh:t.length===1?t[0]:function(e){return t.reduce(function(n,a){return a(n)},e)}}var kt=(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,a){var r=this,c=YN(e)?e:new lo(e,n,a);return sl(function(){var l=r,u=l.operator,f=l.source;c.add(u?u.call(c,f):f?r._subscribe(c):r._trySubscribe(c))}),c},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(n){e.error(n)}},t.prototype.forEach=function(e,n){var a=this;return n=cT(n),new n(function(r,c){var l=new lo({next:function(u){try{e(u)}catch(f){c(f),l.unsubscribe()}},error:c,complete:r});a.subscribe(l)})},t.prototype._subscribe=function(e){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(e)},t.prototype[bh]=function(){return this},t.prototype.pipe=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return GN(e)(this)},t.prototype.toPromise=function(e){var n=this;return e=cT(e),new e(function(a,r){var c;n.subscribe(function(l){return c=l},function(l){return r(l)},function(){return a(c)})})},t.create=function(e){return new t(e)},t})();function cT(t){var e;return(e=t!=null?t:VN.Promise)!==null&&e!==void 0?e:Promise}function KN(t){return t&>(t.next)&>(t.error)&>(t.complete)}function YN(t){return t&&t instanceof yh||KN(t)&&sT(t)}function XN(t){return gt(t==null?void 0:t.lift)}function ti(t){return function(e){if(XN(e))return e.lift(function(n){try{return t(n,this)}catch(a){this.error(a)}});throw new TypeError("Unable to lift unknown Observable type")}}function $i(t,e,n,a,r){return new QN(t,e,n,a,r)}var QN=(function(t){vi(e,t);function e(n,a,r,c,l,u){var f=t.call(this,n)||this;return f.onFinalize=l,f.shouldUnsubscribe=u,f._next=a?function(h){try{a(h)}catch(p){n.error(p)}}:t.prototype._next,f._error=c?function(h){try{c(h)}catch(p){n.error(p)}finally{this.unsubscribe()}}:t.prototype._error,f._complete=r?function(){try{r()}catch(h){n.error(h)}finally{this.unsubscribe()}}:t.prototype._complete,f}return e.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var a=this.closed;t.prototype.unsubscribe.call(this),!a&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},e})(yh),JN=ph(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Bs=(function(t){vi(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 a=new lT(this,this);return a.operator=n,a},e.prototype._throwIfClosed=function(){if(this.closed)throw new JN},e.prototype.next=function(n){var a=this;sl(function(){var r,c;if(a._throwIfClosed(),!a.isStopped){a.currentObservers||(a.currentObservers=Array.from(a.observers));try{for(var l=Is(a.currentObservers),u=l.next();!u.done;u=l.next()){var f=u.value;f.next(n)}}catch(h){r={error:h}}finally{try{u&&!u.done&&(c=l.return)&&c.call(l)}finally{if(r)throw r.error}}}})},e.prototype.error=function(n){var a=this;sl(function(){if(a._throwIfClosed(),!a.isStopped){a.hasError=a.isStopped=!0,a.thrownError=n;for(var r=a.observers;r.length;)r.shift().error(n)}})},e.prototype.complete=function(){var n=this;sl(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var a=n.observers;a.length;)a.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 a=this,r=this,c=r.hasError,l=r.isStopped,u=r.observers;return c||l?aT:(this.currentObservers=null,u.push(n),new co(function(){a.currentObservers=null,al(u,n)}))},e.prototype._checkFinalizedStatuses=function(n){var a=this,r=a.hasError,c=a.thrownError,l=a.isStopped;r?n.error(c):l&&n.complete()},e.prototype.asObservable=function(){var n=new kt;return n.source=this,n},e.create=function(n,a){return new lT(n,a)},e})(kt),lT=(function(t){vi(e,t);function e(n,a){var r=t.call(this)||this;return r.destination=n,r.source=a,r}return e.prototype.next=function(n){var a,r;(r=(a=this.destination)===null||a===void 0?void 0:a.next)===null||r===void 0||r.call(a,n)},e.prototype.error=function(n){var a,r;(r=(a=this.destination)===null||a===void 0?void 0:a.error)===null||r===void 0||r.call(a,n)},e.prototype.complete=function(){var n,a;(a=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||a===void 0||a.call(n)},e.prototype._subscribe=function(n){var a,r;return(r=(a=this.source)===null||a===void 0?void 0:a.subscribe(n))!==null&&r!==void 0?r:aT},e})(Bs),ZN=(function(t){vi(e,t);function e(n){var a=t.call(this)||this;return a._value=n,a}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(n){var a=t.prototype._subscribe.call(this,n);return!a.closed&&n.next(this._value),a},e.prototype.getValue=function(){var n=this,a=n.hasError,r=n.thrownError,c=n._value;if(a)throw r;return this._throwIfClosed(),c},e.prototype.next=function(n){t.prototype.next.call(this,this._value=n)},e})(Bs),WN={now:function(){return Date.now()}},$N=(function(t){vi(e,t);function e(n,a){return t.call(this)||this}return e.prototype.schedule=function(n,a){return this},e})(co),uT={setInterval:function(t,e){for(var n=[],a=2;a<arguments.length;a++)n[a-2]=arguments[a];return setInterval.apply(void 0,oo([t,e],ro(n)))},clearInterval:function(t){return clearInterval(t)},delegate:void 0},e3=(function(t){vi(e,t);function e(n,a){var r=t.call(this,n,a)||this;return r.scheduler=n,r.work=a,r.pending=!1,r}return e.prototype.schedule=function(n,a){var r;if(a===void 0&&(a=0),this.closed)return this;this.state=n;var c=this.id,l=this.scheduler;return c!=null&&(this.id=this.recycleAsyncId(l,c,a)),this.pending=!0,this.delay=a,this.id=(r=this.id)!==null&&r!==void 0?r:this.requestAsyncId(l,this.id,a),this},e.prototype.requestAsyncId=function(n,a,r){return r===void 0&&(r=0),uT.setInterval(n.flush.bind(n,this),r)},e.prototype.recycleAsyncId=function(n,a,r){if(r===void 0&&(r=0),r!=null&&this.delay===r&&this.pending===!1)return a;a!=null&&uT.clearInterval(a)},e.prototype.execute=function(n,a){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(n,a);if(r)return r;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(n,a){var r=!1,c;try{this.work(n)}catch(l){r=!0,c=l||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),c},e.prototype.unsubscribe=function(){if(!this.closed){var n=this,a=n.id,r=n.scheduler,c=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,al(c,this),a!=null&&(this.id=this.recycleAsyncId(r,a,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e})($N),dT=(function(){function t(e,n){n===void 0&&(n=t.now),this.schedulerActionCtor=e,this.now=n}return t.prototype.schedule=function(e,n,a){return n===void 0&&(n=0),new this.schedulerActionCtor(this,e).schedule(a,n)},t.now=WN.now,t})(),t3=(function(t){vi(e,t);function e(n,a){a===void 0&&(a=dT.now);var r=t.call(this,n,a)||this;return r.actions=[],r._active=!1,r}return e.prototype.flush=function(n){var a=this.actions;if(this._active){a.push(n);return}var r;this._active=!0;do if(r=n.execute(n.state,n.delay))break;while(n=a.shift());if(this._active=!1,r){for(;n=a.shift();)n.unsubscribe();throw r}},e})(dT);new t3(e3);function n3(t){return t&>(t.schedule)}function i3(t){return t[t.length-1]}function fT(t){return n3(i3(t))?t.pop():void 0}var hT=(function(t){return t&&typeof t.length=="number"&&typeof t!="function"});function mT(t){return gt(t==null?void 0:t.then)}function pT(t){return gt(t[bh])}function gT(t){return Symbol.asyncIterator&>(t==null?void 0:t[Symbol.asyncIterator])}function vT(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 a3(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var yT=a3();function bT(t){return gt(t==null?void 0:t[yT])}function ST(t){return BN(this,arguments,function(){var e,n,a,r;return iT(this,function(c){switch(c.label){case 0:e=t.getReader(),c.label=1;case 1:c.trys.push([1,,9,10]),c.label=2;case 2:return[4,Us(e.read())];case 3:return n=c.sent(),a=n.value,r=n.done,r?[4,Us(void 0)]:[3,5];case 4:return[2,c.sent()];case 5:return[4,Us(a)];case 6:return[4,c.sent()];case 7:return c.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function TT(t){return gt(t==null?void 0:t.getReader)}function ea(t){if(t instanceof kt)return t;if(t!=null){if(pT(t))return s3(t);if(hT(t))return r3(t);if(mT(t))return o3(t);if(gT(t))return CT(t);if(bT(t))return c3(t);if(TT(t))return l3(t)}throw vT(t)}function s3(t){return new kt(function(e){var n=t[bh]();if(gt(n.subscribe))return n.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function r3(t){return new kt(function(e){for(var n=0;n<t.length&&!e.closed;n++)e.next(t[n]);e.complete()})}function o3(t){return new kt(function(e){t.then(function(n){e.closed||(e.next(n),e.complete())},function(n){return e.error(n)}).then(null,oT)})}function c3(t){return new kt(function(e){var n,a;try{for(var r=Is(t),c=r.next();!c.done;c=r.next()){var l=c.value;if(e.next(l),e.closed)return}}catch(u){n={error:u}}finally{try{c&&!c.done&&(a=r.return)&&a.call(r)}finally{if(n)throw n.error}}e.complete()})}function CT(t){return new kt(function(e){u3(t,e).catch(function(n){return e.error(n)})})}function l3(t){return CT(ST(t))}function u3(t,e){var n,a,r,c;return UN(this,void 0,void 0,function(){var l,u;return iT(this,function(f){switch(f.label){case 0:f.trys.push([0,5,6,11]),n=jN(t),f.label=1;case 1:return[4,n.next()];case 2:if(a=f.sent(),!!a.done)return[3,4];if(l=a.value,e.next(l),e.closed)return[2];f.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return u=f.sent(),r={error:u},[3,11];case 6:return f.trys.push([6,,9,10]),a&&!a.done&&(c=n.return)?[4,c.call(n)]:[3,8];case 7:f.sent(),f.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 qa(t,e,n,a,r){a===void 0&&(a=0),r===void 0&&(r=!1);var c=e.schedule(function(){n(),r?t.add(this.schedule(null,a)):this.unsubscribe()},a);if(t.add(c),!r)return c}function kT(t,e){return e===void 0&&(e=0),ti(function(n,a){n.subscribe($i(a,function(r){return qa(a,t,function(){return a.next(r)},e)},function(){return qa(a,t,function(){return a.complete()},e)},function(r){return qa(a,t,function(){return a.error(r)},e)}))})}function ET(t,e){return e===void 0&&(e=0),ti(function(n,a){a.add(t.schedule(function(){return n.subscribe(a)},e))})}function d3(t,e){return ea(t).pipe(ET(e),kT(e))}function f3(t,e){return ea(t).pipe(ET(e),kT(e))}function h3(t,e){return new kt(function(n){var a=0;return e.schedule(function(){a===t.length?n.complete():(n.next(t[a++]),n.closed||this.schedule())})})}function m3(t,e){return new kt(function(n){var a;return qa(n,e,function(){a=t[yT](),qa(n,e,function(){var r,c,l;try{r=a.next(),c=r.value,l=r.done}catch(u){n.error(u);return}l?n.complete():n.next(c)},0,!0)}),function(){return gt(a==null?void 0:a.return)&&a.return()}})}function wT(t,e){if(!t)throw new Error("Iterable cannot be null");return new kt(function(n){qa(n,e,function(){var a=t[Symbol.asyncIterator]();qa(n,e,function(){a.next().then(function(r){r.done?n.complete():n.next(r.value)})},0,!0)})})}function p3(t,e){return wT(ST(t),e)}function g3(t,e){if(t!=null){if(pT(t))return d3(t,e);if(hT(t))return h3(t,e);if(mT(t))return f3(t,e);if(gT(t))return wT(t,e);if(bT(t))return m3(t,e);if(TT(t))return p3(t,e)}throw vT(t)}function Th(t,e){return e?g3(t,e):ea(t)}ph(function(t){return function(e){e===void 0&&(e=null),t(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=e}});function kn(t,e){return ti(function(n,a){var r=0;n.subscribe($i(a,function(c){a.next(t.call(e,c,r++))}))})}function v3(t,e,n,a,r,c,l,u){var f=[],h=0,p=0,v=!1,y=function(){v&&!f.length&&!h&&e.complete()},S=function(T){return h<a?w(T):f.push(T)},w=function(T){h++;var x=!1;ea(n(T,p++)).subscribe($i(e,function(R){e.next(R)},function(){x=!0},void 0,function(){if(x)try{h--;for(var R=function(){var P=f.shift();l||w(P)};f.length&&h<a;)R();y()}catch(P){e.error(P)}}))};return t.subscribe($i(e,S,function(){v=!0,y()})),function(){}}function RT(t,e,n){return n===void 0&&(n=1/0),gt(e)?RT(function(a,r){return kn(function(c,l){return e(a,c,r,l)})(ea(t(a,r)))},n):(typeof e=="number"&&(n=e),ti(function(a,r){return v3(a,r,t,n)}))}function y3(t){return RT(Sh,t)}function b3(){return y3(1)}function _T(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return b3()(Th(t,fT(t)))}function xT(t,e){return ti(function(n,a){var r=0;n.subscribe($i(a,function(c){return t.call(e,c,r++)&&a.next(c)}))})}function S3(t,e,n,a,r){return function(c,l){var u=n,f=e,h=0;c.subscribe($i(l,function(p){var v=h++;f=u?t(f,p,v):(u=!0,p),l.next(f)},r))}}function Ch(t,e){return ti(S3(t,e,arguments.length>=2,!0))}function T3(t){t===void 0&&(t={});var e=t.connector,n=e===void 0?function(){return new Bs}:e,a=t.resetOnError,r=a===void 0?!0:a,c=t.resetOnComplete,l=c===void 0?!0:c,u=t.resetOnRefCountZero,f=u===void 0?!0:u;return function(h){var p,v,y,S=0,w=!1,T=!1,x=function(){v==null||v.unsubscribe(),v=void 0},R=function(){x(),p=y=void 0,w=T=!1},P=function(){var L=p;R(),L==null||L.unsubscribe()};return ti(function(L,E){S++,!T&&!w&&x();var k=y=y!=null?y:n();E.add(function(){S--,S===0&&!T&&!w&&(v=kh(P,f))}),k.subscribe(E),!p&&S>0&&(p=new lo({next:function(_){return k.next(_)},error:function(_){T=!0,x(),v=kh(R,r,_),k.error(_)},complete:function(){w=!0,x(),v=kh(R,l),k.complete()}}),ea(L).subscribe(p))})(h)}}function kh(t,e){for(var n=[],a=2;a<arguments.length;a++)n[a-2]=arguments[a];if(e===!0){t();return}if(e!==!1){var r=new lo({next:function(){r.unsubscribe(),t()}});return ea(e.apply(void 0,oo([],ro(n)))).subscribe(r)}}function ta(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=fT(t);return ti(function(a,r){(n?_T(t,a,n):_T(t,a)).subscribe(r)})}function AT(t){return ti(function(e,n){ea(t).subscribe($i(n,function(){return n.complete()},vh)),!n.closed&&e.subscribe(n)})}function C3(t,e,n){var a=gt(t)||e||n?{next:t,error:e,complete:n}:t;return a?ti(function(r,c){var l;(l=a.subscribe)===null||l===void 0||l.call(a);var u=!0;r.subscribe($i(c,function(f){var h;(h=a.next)===null||h===void 0||h.call(a,f),c.next(f)},function(){var f;u=!1,(f=a.complete)===null||f===void 0||f.call(a),c.complete()},function(f){var h;u=!1,(h=a.error)===null||h===void 0||h.call(a,f),c.error(f)},function(){var f,h;u&&((f=a.unsubscribe)===null||f===void 0||f.call(a)),(h=a.finalize)===null||h===void 0||h.call(a)}))}):Sh}var k3=Object.defineProperty,E3=Object.defineProperties,w3=Object.getOwnPropertyDescriptors,MT=Object.getOwnPropertySymbols,R3=Object.prototype.hasOwnProperty,_3=Object.prototype.propertyIsEnumerable,DT=(t,e,n)=>e in t?k3(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,na=(t,e)=>{for(var n in e||(e={}))R3.call(e,n)&&DT(t,n,e[n]);if(MT)for(var n of MT(e))_3.call(e,n)&&DT(t,n,e[n]);return t},Ha=(t,e)=>E3(t,w3(e)),js=(t,e,n)=>new Promise((a,r)=>{var c=f=>{try{u(n.next(f))}catch(h){r(h)}},l=f=>{try{u(n.throw(f))}catch(h){r(h)}},u=f=>f.done?a(f.value):Promise.resolve(f.value).then(c,l);u((n=n.apply(t,e)).next())}),x3="lk";function Eh(t){return typeof t>"u"?!1:A3(t)||M3(t)}function A3(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 M3(t){return t?t.hasOwnProperty("participant")&&t.hasOwnProperty("source")&&t.hasOwnProperty("publication")&&typeof t.publication<"u":!1}function D3(t){return t?t.hasOwnProperty("participant")&&t.hasOwnProperty("source")&&typeof t.publication>"u":!1}function OT(t){if(typeof t=="string"||typeof t=="number")return`${t}`;if(D3(t))return`${t.participant.identity}_${t.source}_placeholder`;if(Eh(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 O3=[X.ConnectionStateChanged,X.RoomMetadataChanged,X.ActiveSpeakersChanged,X.ConnectionQualityChanged,X.ParticipantConnected,X.ParticipantDisconnected,X.ParticipantPermissionsChanged,X.ParticipantMetadataChanged,X.ParticipantNameChanged,X.ParticipantAttributesChanged,X.TrackMuted,X.TrackUnmuted,X.TrackPublished,X.TrackUnpublished,X.TrackStreamStateChanged,X.TrackSubscriptionFailed,X.TrackSubscriptionPermissionChanged,X.TrackSubscriptionStatusChanged],PT=[...O3,X.LocalTrackPublished,X.LocalTrackUnpublished],P3=[ee.TrackPublished,ee.TrackUnpublished,ee.TrackMuted,ee.TrackUnmuted,ee.TrackStreamStateChanged,ee.TrackSubscribed,ee.TrackUnsubscribed,ee.TrackSubscriptionPermissionChanged,ee.TrackSubscriptionFailed,ee.LocalTrackPublished,ee.LocalTrackUnpublished],N3=[ee.ConnectionQualityChanged,ee.IsSpeakingChanged,ee.ParticipantMetadataChanged,ee.ParticipantPermissionsChanged,ee.TrackMuted,ee.TrackUnmuted,ee.TrackPublished,ee.TrackUnpublished,ee.TrackStreamStateChanged,ee.TrackSubscriptionFailed,ee.TrackSubscriptionPermissionChanged,ee.TrackSubscriptionStatusChanged];[...N3,ee.LocalTrackPublished,ee.LocalTrackUnpublished];var ni=IN.getLogger("lk-components-js");ni.setDefaultLevel("WARN");function L3(t,e){var n;return Ha(na({},t),{receivedAtMediaTimestamp:(n=e.rtpTimestamp)!=null?n:0,receivedAt:e.timestamp})}function I3(t,e,n){return[...t,...e].reduceRight((a,r)=>(a.find(c=>c.id===r.id)||a.unshift(r),a),[]).slice(0-n)}var uo=(t=>(t.AgentState="lk.agent.state",t.PublishOnBehalf="lk.publish_on_behalf",t.TranscriptionFinal="lk.transcription_final",t.TranscriptionSegmentId="lk.segment_id",t.TranscribedTrackId="lk.transcribed_track_id",t))(uo||{});function NT(t){return typeof t=="object"}function LT(t){return Array.isArray(t)&&t.filter(NT).length>0}function IT(t){return`${x3}-${t}`}function U3(t){const e=wh(t),n=jT(t.participant).pipe(kn(()=>wh(t)),ta(e));return{className:IT(t.source===Q.Source.Camera||t.source===Q.Source.ScreenShare?"participant-media-video":"participant-media-audio"),trackObserver:n}}function wh(t){if(Eh(t))return t.publication;{const{source:e,name:n,participant:a}=t;if(e&&n)return a.getTrackPublications().find(r=>r.source===e&&r.trackName===n);if(n)return a.getTrackPublicationByName(n);if(e)return a.getTrackPublication(e);throw new Error("At least one of source and name needs to be defined")}}function Rh(t,...e){return new kt(n=>{const a=()=>{n.next(t)};return e.forEach(r=>{t.on(r,a)}),()=>{e.forEach(r=>{t.off(r,a)})}}).pipe(ta(t))}function UT(t,e){return new kt(n=>{const a=(...r)=>{n.next(r)};return t.on(e,a),()=>{t.off(e,a)}})}function B3(t){return UT(t,X.ConnectionStateChanged).pipe(kn(([e])=>e),ta(t.state))}function j3(t){return UT(t,X.DataReceived)}function V3(t){return Rh(t,X.AudioPlaybackStatusChanged).pipe(kn(e=>({canPlayAudio:e.canPlaybackAudio})))}function BT(t,...e){return new kt(n=>{const a=()=>{n.next(t)};return e.forEach(r=>{t.on(r,a)}),()=>{e.forEach(r=>{t.off(r,a)})}}).pipe(ta(t))}function jT(t){return BT(t,ee.TrackMuted,ee.TrackUnmuted,ee.ParticipantPermissionsChanged,ee.TrackPublished,ee.TrackUnpublished,ee.LocalTrackPublished,ee.LocalTrackUnpublished,ee.MediaDevicesError,ee.TrackSubscriptionStatusChanged).pipe(kn(e=>{const{isMicrophoneEnabled:n,isCameraEnabled:a,isScreenShareEnabled:r}=e,c=e.getTrackPublication(Q.Source.Microphone),l=e.getTrackPublication(Q.Source.Camera);return{isCameraEnabled:a,isMicrophoneEnabled:n,isScreenShareEnabled:r,cameraTrack:l,microphoneTrack:c,participant:e}}))}function z3(t,e){return new kt(n=>{const a=(...r)=>{n.next(r)};return t.on(e,a),()=>{t.off(e,a)}})}function F3(t,e={}){var n;let a;const r=new kt(f=>(a=f,()=>u.unsubscribe())).pipe(ta(Array.from(t.remoteParticipants.values()))),c=(n=e.additionalRoomEvents)!=null?n:PT,l=Array.from(new Set([X.ParticipantConnected,X.ParticipantDisconnected,X.ConnectionStateChanged,...c])),u=Rh(t,...l).subscribe(f=>a==null?void 0:a.next(Array.from(f.remoteParticipants.values())));return t.remoteParticipants.size>0&&(a==null||a.next(Array.from(t.remoteParticipants.values()))),r}function VT(t){return typeof t>"u"?new kt:z3(t,ee.AttributesChanged).pipe(kn(([e])=>({changed:e,attributes:t.attributes})),ta({changed:t.attributes,attributes:t.attributes}))}var zT={CHAT:"lk.chat",TRANSCRIPTION:"lk.transcription"},q3={CHAT:"lk-chat-topic"};function FT(t,e){return js(this,arguments,function*(n,a,r={}){const{reliable:c,destinationIdentities:l,topic:u}=r;yield n.publishData(a,{destinationIdentities:l,topic:u,reliable:c})})}function H3(t,e,n){const a=Array.isArray(e)?e:[e],r=j3(t).pipe(xT(([,,,u])=>e===void 0||u!==void 0&&a.includes(u)),kn(([u,f,,h])=>({payload:u,topic:h,from:f})));let c;const l=new kt(u=>{c=u});return{messageObservable:r,isSendingObservable:l,send:(u,...f)=>js(this,[u,...f],function*(h,p={}){c.next(!0);try{yield FT(t.localParticipant,h,na({topic:a[0]},p))}finally{c.next(!1)}})}}var ol=new WeakMap;function G3(t){return t.ignoreLegacy==!0}var K3=t=>JSON.parse(new TextDecoder().decode(t)),Y3=t=>new TextEncoder().encode(JSON.stringify(t));function X3(t,e){var n,a,r,c,l,u;const f=()=>{var k,_,N;return((k=t.serverInfo)==null?void 0:k.edition)===1||!!((_=t.serverInfo)!=null&&_.version)&&zn((N=t.serverInfo)==null?void 0:N.version,"1.8.2")>0},h=new Bs,p=(n=void 0)!=null?n:zT.CHAT,v=(a=void 0)!=null?a:q3.CHAT;let y=!1;ol.has(t)||(y=!0);const S=(r=ol.get(t))!=null?r:new Map,w=(c=S.get(p))!=null?c:new Bs;S.set(p,w),ol.set(t,S);const T=(l=void 0)!=null?l:K3;if(y){t.registerTextStreamHandler(p,(_,N)=>js(this,null,function*(){const{id:U,timestamp:G}=_.info;Th(_).pipe(Ch((V,Y)=>V+Y),kn(V=>({id:U,timestamp:G,message:V,from:t.getParticipantByIdentity(N.identity),type:"chatMessage"}))).subscribe({next:V=>w.next(V)})}));const{messageObservable:k}=H3(t,[v]);k.pipe(kn(_=>{const N=T(_.payload);return G3(N)?void 0:Ha(na({},N),{type:"chatMessage",from:_.from})}),xT(_=>!!_),AT(h)).subscribe(w)}const x=w.pipe(Ch((k,_)=>{if("id"in _&&k.find(N=>{var U,G;return((U=N.from)==null?void 0:U.identity)===((G=_.from)==null?void 0:G.identity)&&N.id===_.id})){const N=k.findIndex(U=>U.id===_.id);if(N>-1){const U=k[N];k[N]=Ha(na({},_),{timestamp:U.timestamp,editTimestamp:_.timestamp})}return[...k]}return[...k,_]},[]),AT(h)),R=new ZN(!1),P=(u=void 0)!=null?u:Y3,L=(k,_)=>js(this,null,function*(){_||(_={}),_.topic!=null||(_.topic=p),R.next(!0);try{const N={id:(yield t.localParticipant.sendText(k,_)).id,timestamp:Date.now(),message:k},U=Ha(na({},N),{attachedFiles:_.attachments}),G=Ha(na({},U),{type:"chatMessage",from:t.localParticipant,attributes:_.attributes});w.next(G);const V=P(Ha(na({},N),{ignoreLegacy:f()}));try{yield FT(t.localParticipant,V,{reliable:!0,topic:v})}catch(Y){ni.info("could not send message in legacy chat format",Y)}return G}finally{R.next(!1)}});function E(){h.next(),h.complete(),w.complete(),ol.delete(t),t.unregisterTextStreamHandler(p)}return t.once(X.Disconnected,E),{messageObservable:x,isSendingObservable:R,send:L}}function Q3(){const t=e=>js(this,null,function*(){ni.info("Start Audio for room: ",e),yield e.startAudio()});return{className:IT("start-audio-button"),roomAudioPlaybackAllowedObservable:V3,handleStartAudioPlayback:t}}function qT(t,e,n=!0){const a=[t.localParticipant,...Array.from(t.remoteParticipants.values())],r=[];return a.forEach(c=>{e.forEach(l=>{const u=Array.from(c.trackPublications.values()).filter(f=>f.source===l&&(!n||f.track)).map(f=>({participant:c,publication:f,source:f.source}));r.push(...u)})}),{trackReferences:r,participants:a}}function HT(t,e,n=!1){const{sources:a,kind:r,name:c}=e;return Array.from(t.trackPublications.values()).filter(l=>(!a||a.includes(l.source))&&(!r||l.kind===r)&&(!c||l.trackName===c)&&(!n||l.track)).map(l=>({participant:t,publication:l,source:l.source}))}function J3(t,e,n){var a,r;const c=(a=n.additionalRoomEvents)!=null?a:PT,l=(r=n.onlySubscribed)!=null?r:!0,u=Array.from(new Set([X.ParticipantConnected,X.ParticipantDisconnected,X.ConnectionStateChanged,X.LocalTrackPublished,X.LocalTrackUnpublished,X.TrackPublished,X.TrackUnpublished,X.TrackSubscriptionStatusChanged,...c]).values());return Rh(t,...u).pipe(kn(f=>{const h=qT(f,e,l);return ni.debug(`TrackReference[] was updated. (length ${h.trackReferences.length})`,h),h}),ta(qT(t,e,l)))}function Z3(t,e){return BT(t,...P3).pipe(kn(n=>{const a=HT(n,e);return ni.debug(`TrackReference[] was updated. (length ${a.length})`,a),a}),ta(HT(t,e)))}function GT(t,e){return new kt(n=>{const a=(...r)=>{n.next(r)};return t.on(e,a),()=>{t.off(e,a)}})}function W3(t){return GT(t,ae.TranscriptionReceived)}function $3(t){return GT(t,ae.TimeSyncUpdate).pipe(kn(([e])=>e))}var _h=null,xh=null,eL=0;function KT(){return _h||(_h=new Map),_h}function tL(){return xh||(xh=new WeakMap),xh}function nL(t,e){const n=tL();let a=n.get(t);return a||(a=`room_${eL++}`,n.set(t,a)),`${a}:${e}`}function iL(t,e){const n=nL(t,e),a=KT(),r=a.get(n);if(r)return r;const c=new Bs;let l=[];const u="lk.segment_id",f=c.pipe(C3({subscribe:()=>{t.registerTextStreamHandler(e,(h,p)=>js(this,null,function*(){var v;const y=Th(h).pipe(Ch((w,T)=>w+T,"")),S=!!((v=h.info.attributes)!=null&&v[u]);y.subscribe(w=>{const T=l.findIndex(x=>{var R,P;return x.streamInfo.id===h.info.id||S&&((R=x.streamInfo.attributes)==null?void 0:R[u])===((P=h.info.attributes)==null?void 0:P[u])});T!==-1?(l[T]=Ha(na({},l[T]),{text:w}),c.next([...l])):(l.push({text:w,participantInfo:p,streamInfo:h.info}),c.next([...l]))})}))},finalize:()=>{t.unregisterTextStreamHandler(e)}}),T3());return a.set(n,f),t.on(X.Disconnected,()=>{KT().delete(n),l=[],c.next([])}),f}q.createContext(void 0);const aL=q.createContext(void 0);function YT(){return q.useContext(aL)}function sL(t){const e=YT(),n=t!=null?t:e;if(!n)throw new Error("No TrackRef, make sure you are inside a TrackRefContext or pass the TrackRef explicitly");return n}const rL=q.createContext(void 0);function XT(){return q.useContext(rL)}const Ah=q.createContext(void 0);function QT(){const t=q.useContext(Ah);if(!t)throw Error("tried to access room context outside of livekit room component");return t}function oL(){return q.useContext(Ah)}function ia(t){const e=oL(),n=t!=null?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}q.createContext(void 0),q.createContext(void 0);function JT(t){var e,n,a="";if(typeof t=="string"||typeof t=="number")a+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(e=0;e<r;e++)t[e]&&(n=JT(t[e]))&&(a&&(a+=" "),a+=n)}else for(n in t)t[n]&&(a&&(a+=" "),a+=n);return a}function ZT(){for(var t,e,n=0,a="",r=arguments.length;n<r;n++)(t=arguments[n])&&(e=JT(t))&&(a&&(a+=" "),a+=e);return a}function cL(...t){return(...e)=>{for(const n of t)if(typeof n=="function")try{n(...e)}catch(a){console.error(a)}}}function WT(...t){const e={...t[0]};for(let n=1;n<t.length;n++){const a=t[n];for(const r in a){const c=e[r],l=a[r];typeof c=="function"&&typeof l=="function"&&r[0]==="o"&&r[1]==="n"&&r.charCodeAt(2)>=65&&r.charCodeAt(2)<=90?e[r]=cL(c,l):(r==="className"||r==="UNSAFE_className")&&typeof c=="string"&&typeof l=="string"?e[r]=ZT(c,l):e[r]=l!==void 0?l:c}}return e}function lL(t){return t!==void 0}function $T(...t){return WT(...t.filter(lL))}function uL(t,e,n){return q.Children.map(t,a=>q.isValidElement(a)&&q.Children.only(t)?(a.props.className&&(e!=null||(e={}),e.className=ZT(a.props.className,e.className),e.style={...a.props.style,...e.style}),q.cloneElement(a,{...e,key:n})):a)}function aa(t,e,n=!0){const[a,r]=q.useState(e);return q.useEffect(()=>{if(n&&r(e),typeof window>"u"||!t)return;const c=t.subscribe(r);return()=>c.unsubscribe()},[t,n]),a}function Mh(t){const e=ia(t),n=q.useMemo(()=>B3(e),[e]);return aa(n,e.state)}function dL(t={}){const e=ia(t.room),[n,a]=q.useState(e.localParticipant),[r,c]=q.useState(n.isMicrophoneEnabled),[l,u]=q.useState(n.isCameraEnabled),[f,h]=q.useState(n.isScreenShareEnabled),[p,v]=q.useState(n.lastMicrophoneError),[y,S]=q.useState(n.lastCameraError),[w,T]=q.useState(void 0),[x,R]=q.useState(void 0),P=L=>{u(L.isCameraEnabled),c(L.isMicrophoneEnabled),h(L.isScreenShareEnabled),R(L.cameraTrack),T(L.microphoneTrack),v(L.participant.lastMicrophoneError),S(L.participant.lastCameraError),a(L.participant)};return q.useEffect(()=>{const L=jT(e.localParticipant).subscribe(P);return()=>L.unsubscribe()},[e]),{isMicrophoneEnabled:r,isScreenShareEnabled:f,isCameraEnabled:l,microphoneTrack:w,cameraTrack:x,lastMicrophoneError:p,lastCameraError:y,localParticipant:n}}function eC(t={}){const e=ia(t.room),[n,a]=q.useState([]);return q.useEffect(()=>{const r=F3(e,{additionalRoomEvents:t.updateOnlyOn}).subscribe(a);return()=>r.unsubscribe()},[e,JSON.stringify(t.updateOnlyOn)]),n}function fL(t={}){const e=eC(t),{localParticipant:n}=dL(t);return q.useMemo(()=>[n,...e],[n,e])}function hL({room:t,props:e}){const n=ia(t),{className:a,roomAudioPlaybackAllowedObservable:r,handleStartAudioPlayback:c}=q.useMemo(()=>Q3(),[]),l=q.useMemo(()=>r(n),[n,r]),{canPlayAudio:u}=aa(l,{canPlayAudio:n.canPlaybackAudio});return{mergedProps:q.useMemo(()=>WT(e,{className:a,onClick:()=>{c(n)},style:{display:u?"none":"block"}}),[e,a,u,c,n]),canPlayAudio:u}}function mL(t=[Q.Source.Camera,Q.Source.Microphone,Q.Source.ScreenShare,Q.Source.ScreenShareAudio,Q.Source.Unknown],e={}){const n=ia(e.room),[a,r]=q.useState([]),[c,l]=q.useState([]),u=q.useMemo(()=>t.map(f=>NT(f)?f.source:f),[JSON.stringify(t)]);return q.useEffect(()=>{const f=J3(n,u,{additionalRoomEvents:e.updateOnlyOn,onlySubscribed:e.onlySubscribed}).subscribe(({trackReferences:h,participants:p})=>{ni.debug("setting track bundles",h,p),r(h),l(p)});return()=>f.unsubscribe()},[n,JSON.stringify(e.onlySubscribed),JSON.stringify(e.updateOnlyOn),JSON.stringify(t)]),q.useMemo(()=>{if(LT(t)){const f=gL(t,c),h=Array.from(a);return c.forEach(p=>{var v;f.has(p.identity)&&((v=f.get(p.identity))!=null?v:[]).forEach(y=>{if(a.find(({participant:w,publication:T})=>p.identity===w.identity&&T.source===y))return;ni.debug(`Add ${y} placeholder for participant ${p.identity}.`);const S={participant:p,source:y};h.push(S)})}),h}else return a},[a,c,t])}function pL(t,e){const n=new Set(t);for(const a of e)n.delete(a);return n}function gL(t,e){const n=new Map;if(LT(t)){const a=t.filter(r=>r.withPlaceholder).map(r=>r.source);e.forEach(r=>{const c=r.getTrackPublications().map(u=>{var f;return(f=u.track)==null?void 0:f.source}).filter(u=>u!==void 0),l=Array.from(pL(new Set(a),new Set(c)));l.length>0&&n.set(r.identity,l)})}return n}function vL(t){const e=ia(void 0),n=Mh(e),a=q.useMemo(()=>n===Ne.Disconnected,[n]),r=q.useMemo(()=>X3(e),[e,t,a]),c=aa(r.isSendingObservable,!1),l=aa(r.messageObservable,[]);return{send:r.send,chatMessages:l,isSending:c}}const yL=t=>{const e=n=>{let a=1-Math.max(-100,Math.min(-10,n))*-1/100;return a=Math.sqrt(a),a};return t.map(n=>n===-1/0?0:e(n))},bL={bands:5,loPass:100,hiPass:600,updateInterval:32,analyserOptions:{fftSize:2048}};function SL(t,e={}){var n;const a=t instanceof Q?t:(n=t==null?void 0:t.publication)==null?void 0:n.track,r={...bL,...e},[c,l]=q.useState(new Array(r.bands).fill(0));return q.useEffect(()=>{if(!a||!(a!=null&&a.mediaStream)){l(y=>y.slice().fill(0));return}const{analyser:u,cleanup:f}=UO(a,r.analyserOptions),h=u.frequencyBinCount,p=new Float32Array(h),v=setInterval(()=>{u.getFloatFrequencyData(p);let y=new Float32Array(p.length);for(let x=0;x<p.length;x++)y[x]=p[x];y=y.slice(r.loPass,r.hiPass);const S=yL(y),w=S.length,T=[];for(let x=0;x<r.bands;x++){const R=Math.floor(x*w/r.bands),P=Math.floor((x+1)*w/r.bands),L=S.slice(R,P),E=L.length;if(E===0)T.push(0);else{const k=L.reduce((_,N)=>_+=N,0);T.push(k/E)}}l(T)},r.updateInterval);return()=>{f(),clearInterval(v)}},[a,a==null?void 0:a.mediaStream,JSON.stringify(e)]),c}function tC(t,e={}){let n,a;typeof e=="string"?n=e:(n=e==null?void 0:e.participantIdentity,a=e==null?void 0:e.room);const r=XT(),c=fL({room:a,updateOnlyOn:[]}),l=q.useMemo(()=>n?c.find(f=>f.identity===n):r,[n,c,r]),u=q.useMemo(()=>{if(l)return Z3(l,{sources:t})},[l,JSON.stringify(t)]);return aa(u,[])}function TL(t){var e,n,a;const r=q.useMemo(()=>{var c;return(c=t==null?void 0:t.publication)!=null&&c.track?$3(t==null?void 0:t.publication.track):void 0},[(e=t==null?void 0:t.publication)==null?void 0:e.track]);return aa(r,{timestamp:Date.now(),rtpTimestamp:(a=(n=t==null?void 0:t.publication)==null?void 0:n.track)==null?void 0:a.rtpTimestamp})}const CL={bufferSize:100};function kL(t,e){const n={...CL,...e},[a,r]=q.useState([]),c=TL(t),l=u=>{var f;(f=n.onTranscription)==null||f.call(n,u),r(h=>I3(h,u.map(p=>L3(p,c)),n.bufferSize))};return q.useEffect(()=>{if(!(t!=null&&t.publication))return;const u=W3(t.publication).subscribe(f=>{l(...f)});return()=>{u.unsubscribe()}},[t&&OT(t),l]),{segments:a}}function EL(t={}){var r;const e=XT(),n=(r=t.participant)!=null?r:e,a=q.useMemo(()=>VT(n),[n]);return aa(a,{attributes:n==null?void 0:n.attributes})}const nC=uo.AgentState;function iC(){var v,y;const t=eC(),e=t.find(S=>S.kind===Ba.AGENT&&!(uo.PublishOnBehalf in S.attributes)),n=t.find(S=>S.kind===Ba.AGENT&&S.attributes[uo.PublishOnBehalf]===(e==null?void 0:e.identity)),a=tC([Q.Source.Microphone,Q.Source.Camera],e==null?void 0:e.identity),r=tC([Q.Source.Microphone,Q.Source.Camera],n==null?void 0:n.identity),c=(v=a.find(S=>S.source===Q.Source.Microphone))!=null?v:r.find(S=>S.source===Q.Source.Microphone),l=(y=a.find(S=>S.source===Q.Source.Camera))!=null?y:r.find(S=>S.source===Q.Source.Camera),{segments:u}=kL(c),f=Mh(),{attributes:h}=EL({participant:e}),p=q.useMemo(()=>f===Ne.Disconnected?"disconnected":f===Ne.Connecting||!e||!(h!=null&&h[nC])?"connecting":h[nC],[h,e,f]);return{agent:e,state:p,audioTrack:c,videoTrack:l,agentTranscriptions:u,agentAttributes:h}}function wL(t,e){const n=ia(e==null?void 0:e.room),a=Mh(n)===Ne.Disconnected,r=q.useMemo(()=>iL(n,t),[n,t]);return{textStreams:aa(a?void 0:r,[])}}function RL(t){const{participantIdentities:e,trackSids:n}={},{textStreams:a}=wL(zT.TRANSCRIPTION,{room:void 0});return q.useMemo(()=>a.filter(r=>e?e.includes(r.participantInfo.identity):!0).filter(r=>{var l;var c;return n?n.includes((l=(c=r.streamInfo.attributes)==null?void 0:c[uo.TranscribedTrackId])!=null?l:""):!0}),[a,e,n])}var cl={exports:{}},aC;function _L(){if(aC)return cl.exports;aC=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(E,k,_){return Function.prototype.apply.call(E,k,_)},n;t&&typeof t.ownKeys=="function"?n=t.ownKeys:Object.getOwnPropertySymbols?n=function(E){return Object.getOwnPropertyNames(E).concat(Object.getOwnPropertySymbols(E))}:n=function(E){return Object.getOwnPropertyNames(E)};function a(E){console&&console.warn&&console.warn(E)}var r=Number.isNaN||function(E){return E!==E};function c(){c.init.call(this)}cl.exports=c,cl.exports.once=R,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var l=10;function u(E){if(typeof E!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof E)}Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return l},set:function(E){if(typeof E!="number"||E<0||r(E))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+E+".");l=E}}),c.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},c.prototype.setMaxListeners=function(E){if(typeof E!="number"||E<0||r(E))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+E+".");return this._maxListeners=E,this};function f(E){return E._maxListeners===void 0?c.defaultMaxListeners:E._maxListeners}c.prototype.getMaxListeners=function(){return f(this)},c.prototype.emit=function(E){for(var k=[],_=1;_<arguments.length;_++)k.push(arguments[_]);var N=E==="error",U=this._events;if(U!==void 0)N=N&&U.error===void 0;else if(!N)return!1;if(N){var G;if(k.length>0&&(G=k[0]),G instanceof Error)throw G;var V=new Error("Unhandled error."+(G?" ("+G.message+")":""));throw V.context=G,V}var Y=U[E];if(Y===void 0)return!1;if(typeof Y=="function")e(Y,this,k);else for(var ie=Y.length,he=w(Y,ie),_=0;_<ie;++_)e(he[_],this,k);return!0};function h(E,k,_,N){var U,G,V;if(u(_),G=E._events,G===void 0?(G=E._events=Object.create(null),E._eventsCount=0):(G.newListener!==void 0&&(E.emit("newListener",k,_.listener?_.listener:_),G=E._events),V=G[k]),V===void 0)V=G[k]=_,++E._eventsCount;else if(typeof V=="function"?V=G[k]=N?[_,V]:[V,_]:N?V.unshift(_):V.push(_),U=f(E),U>0&&V.length>U&&!V.warned){V.warned=!0;var Y=new Error("Possible EventEmitter memory leak detected. "+V.length+" "+String(k)+" listeners added. Use emitter.setMaxListeners() to increase limit");Y.name="MaxListenersExceededWarning",Y.emitter=E,Y.type=k,Y.count=V.length,a(Y)}return E}c.prototype.addListener=function(E,k){return h(this,E,k,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(E,k){return h(this,E,k,!0)};function p(){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 v(E,k,_){var N={fired:!1,wrapFn:void 0,target:E,type:k,listener:_},U=p.bind(N);return U.listener=_,N.wrapFn=U,U}c.prototype.once=function(E,k){return u(k),this.on(E,v(this,E,k)),this},c.prototype.prependOnceListener=function(E,k){return u(k),this.prependListener(E,v(this,E,k)),this},c.prototype.removeListener=function(E,k){var _,N,U,G,V;if(u(k),N=this._events,N===void 0)return this;if(_=N[E],_===void 0)return this;if(_===k||_.listener===k)--this._eventsCount===0?this._events=Object.create(null):(delete N[E],N.removeListener&&this.emit("removeListener",E,_.listener||k));else if(typeof _!="function"){for(U=-1,G=_.length-1;G>=0;G--)if(_[G]===k||_[G].listener===k){V=_[G].listener,U=G;break}if(U<0)return this;U===0?_.shift():T(_,U),_.length===1&&(N[E]=_[0]),N.removeListener!==void 0&&this.emit("removeListener",E,V||k)}return this},c.prototype.off=c.prototype.removeListener,c.prototype.removeAllListeners=function(E){var k,_,N;if(_=this._events,_===void 0)return this;if(_.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):_[E]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete _[E]),this;if(arguments.length===0){var U=Object.keys(_),G;for(N=0;N<U.length;++N)G=U[N],G!=="removeListener"&&this.removeAllListeners(G);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(k=_[E],typeof k=="function")this.removeListener(E,k);else if(k!==void 0)for(N=k.length-1;N>=0;N--)this.removeListener(E,k[N]);return this};function y(E,k,_){var N=E._events;if(N===void 0)return[];var U=N[k];return U===void 0?[]:typeof U=="function"?_?[U.listener||U]:[U]:_?x(U):w(U,U.length)}c.prototype.listeners=function(E){return y(this,E,!0)},c.prototype.rawListeners=function(E){return y(this,E,!1)},c.listenerCount=function(E,k){return typeof E.listenerCount=="function"?E.listenerCount(k):S.call(E,k)},c.prototype.listenerCount=S;function S(E){var k=this._events;if(k!==void 0){var _=k[E];if(typeof _=="function")return 1;if(_!==void 0)return _.length}return 0}c.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function w(E,k){for(var _=new Array(k),N=0;N<k;++N)_[N]=E[N];return _}function T(E,k){for(;k+1<E.length;k++)E[k]=E[k+1];E.pop()}function x(E){for(var k=new Array(E.length),_=0;_<k.length;++_)k[_]=E[_].listener||E[_];return k}function R(E,k){return new Promise(function(_,N){function U(V){E.removeListener(k,G),N(V)}function G(){typeof E.removeListener=="function"&&E.removeListener("error",U),_([].slice.call(arguments))}L(E,k,G,{once:!0}),k!=="error"&&P(E,U,{once:!0})})}function P(E,k,_){typeof E.on=="function"&&L(E,"error",k,_)}function L(E,k,_,N){if(typeof E.on=="function")N.once?E.once(k,_):E.on(k,_);else if(typeof E.addEventListener=="function")E.addEventListener(k,function U(G){N.once&&E.removeEventListener(k,U),_(G)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof E)}return cl.exports}_L();const xL=q.forwardRef(function({label:t="Allow Audio",...e},n){const a=ia(e.room),{mergedProps:r}=hL({room:a,props:e});return q.createElement("button",{ref:n,...r},t)});function AL(t,e={}){var T;const[n,a]=q.useState(wh(t)),[r,c]=q.useState(n==null?void 0:n.isMuted),[l,u]=q.useState(n==null?void 0:n.isSubscribed),[f,h]=q.useState(n==null?void 0:n.track),[p,v]=q.useState("landscape"),y=q.useRef(),{className:S,trackObserver:w}=q.useMemo(()=>U3(t),[(T=t.participant.sid)!=null?T:t.participant.identity,t.source,Eh(t)&&t.publication.trackSid]);return q.useEffect(()=>{const x=w.subscribe(R=>{ni.debug("update track",R),a(R),c(R==null?void 0:R.isMuted),u(R==null?void 0:R.isSubscribed),h(R==null?void 0:R.track)});return()=>x==null?void 0:x.unsubscribe()},[w]),q.useEffect(()=>{var x,R;return f&&(y.current&&f.detach(y.current),(x=e.element)!=null&&x.current&&!(t.participant.isLocal&&(f==null?void 0:f.kind)==="audio")&&f.attach(e.element.current)),y.current=(R=e.element)==null?void 0:R.current,()=>{y.current&&(f==null||f.detach(y.current))}},[f,e.element]),q.useEffect(()=>{var x,R;if(typeof((x=n==null?void 0:n.dimensions)==null?void 0:x.width)=="number"&&typeof((R=n==null?void 0:n.dimensions)==null?void 0:R.height)=="number"){const P=n.dimensions.width>n.dimensions.height?"landscape":"portrait";v(P)}},[n]),{publication:n,isMuted:r,isSubscribed:l,track:f,elementProps:$T(e.props,{className:S,"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":p}})}}var Dh,sC;function ML(){if(sC)return Dh;sC=1;var t="Expected a function",e=NaN,n="[object Symbol]",a=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,l=/^0o[0-7]+$/i,u=parseInt,f=typeof il=="object"&&il&&il.Object===Object&&il,h=typeof self=="object"&&self&&self.Object===Object&&self,p=f||h||Function("return this")(),v=Object.prototype,y=v.toString,S=Math.max,w=Math.min,T=function(){return p.Date.now()};function x(k,_,N){var U,G,V,Y,ie,he,be=0,qe=!1,H=!1,ne=!0;if(typeof k!="function")throw new TypeError(t);_=E(_)||0,R(N)&&(qe=!!N.leading,H="maxWait"in N,V=H?S(E(N.maxWait)||0,_):V,ne="trailing"in N?!!N.trailing:ne);function ce(ve){var tt=U,Qe=G;return U=G=void 0,be=ve,Y=k.apply(Qe,tt),Y}function Ce(ve){return be=ve,ie=setTimeout(Z,_),qe?ce(ve):Y}function Re(ve){var tt=ve-he,Qe=ve-be,sa=_-tt;return H?w(sa,V-Qe):sa}function D(ve){var tt=ve-he,Qe=ve-be;return he===void 0||tt>=_||tt<0||H&&Qe>=V}function Z(){var ve=T();if(D(ve))return re(ve);ie=setTimeout(Z,Re(ve))}function re(ve){return ie=void 0,ne&&U?ce(ve):(U=G=void 0,Y)}function le(){ie!==void 0&&clearTimeout(ie),be=0,U=he=G=ie=void 0}function ye(){return ie===void 0?Y:re(T())}function Se(){var ve=T(),tt=D(ve);if(U=arguments,G=this,he=ve,tt){if(ie===void 0)return Ce(he);if(H)return ie=setTimeout(Z,_),ce(he)}return ie===void 0&&(ie=setTimeout(Z,_)),Y}return Se.cancel=le,Se.flush=ye,Se}function R(k){var _=typeof k;return!!k&&(_=="object"||_=="function")}function P(k){return!!k&&typeof k=="object"}function L(k){return typeof k=="symbol"||P(k)&&y.call(k)==n}function E(k){if(typeof k=="number")return k;if(L(k))return e;if(R(k)){var _=typeof k.valueOf=="function"?k.valueOf():k;k=R(_)?_+"":_}if(typeof k!="string")return k===0?k:+k;k=k.replace(a,"");var N=c.test(k);return N||l.test(k)?u(k.slice(2),N?2:8):r.test(k)?e:+k}return Dh=x,Dh}ML();const DL=q.forwardRef(function({trackRef:t,onSubscriptionStatusChanged:e,volume:n,...a},r){const c=sL(t),l=q.useRef(null);q.useImperativeHandle(r,()=>l.current);const{elementProps:u,isSubscribed:f,track:h,publication:p}=AL(c,{element:l,props:a});return q.useEffect(()=>{e==null||e(!!f)},[f,e]),q.useEffect(()=>{h===void 0||n===void 0||(h instanceof WS?h.setVolume(n):ni.warn("Volume can only be set on remote audio tracks."))},[n,h]),q.useEffect(()=>{p===void 0||a.muted===void 0||(p instanceof eT?p.setEnabled(!a.muted):ni.warn("Can only call setEnabled on remote track publications."))},[a.muted,p,h]),q.createElement("audio",{ref:l,...u})});function OL({room:t,volume:e,muted:n}){const a=mL([Q.Source.Microphone,Q.Source.ScreenShareAudio,Q.Source.Unknown],{updateOnlyOn:[],onlySubscribed:!0,room:t}).filter(r=>!r.participant.isLocal&&r.publication.kind===Q.Kind.Audio);return q.createElement("div",{style:{display:"none"}},a.map(r=>q.createElement(DL,{key:OT(r),trackRef:r,volume:e,muted:n})))}const PL=t=>{const e=[];for(let n=0;n<t;n++)e.push([n,t-1-n]);return e},rC=t=>[[Math.floor(t/2)],[-1]],NL=(t,e,n)=>{const[a,r]=q.useState(0),[c,l]=q.useState([[]]);q.useEffect(()=>{if(t==="thinking")l(rC(e));else if(t==="connecting"||t==="initializing"){const f=[...PL(e)];l(f)}else l(t==="listening"?rC(e):t===void 0||t==="speaking"?[new Array(e).fill(0).map((f,h)=>h)]:[[]]);r(0)},[t,e]);const u=q.useRef(null);return q.useEffect(()=>{let f=performance.now();const h=p=>{p-f>=n&&(r(v=>v+1),f=p),u.current=requestAnimationFrame(h)};return u.current=requestAnimationFrame(h),()=>{u.current!==null&&cancelAnimationFrame(u.current)}},[n,e,t,c.length]),c[a%c.length]},LL=new Map([["connecting",2e3],["initializing",2e3],["listening",500],["thinking",150]]),IL=(t,e)=>{if(t===void 0)return 1e3;let n=LL.get(t);return n&&t==="connecting"&&(n/=e),n},UL=q.forwardRef(function({state:t,options:e,barCount:n=15,trackRef:a,track:r,children:c,...l},u){var w,T,x;const f=$T(l,{className:"lk-audio-bar-visualizer"});let h=YT();(a||r)&&(h=a||r);const p=SL(h,{bands:n,loPass:100,hiPass:200}),v=(w=e==null?void 0:e.minHeight)!=null?w:20,y=(T=e==null?void 0:e.maxHeight)!=null?T:100,S=NL(t,n,(x=IL(t,n))!=null?x:100);return q.createElement("div",{ref:u,...f,"data-lk-va-state":t},p.map((R,P)=>c?uL(c,{"data-lk-highlighted":S.includes(P),"data-lk-bar-index":P,className:"lk-audio-bar",style:{height:`${Math.min(y,Math.max(v,R*100+5))}%`}}):q.createElement("span",{key:P,"data-lk-highlighted":S.includes(P),"data-lk-bar-index":P,className:`lk-audio-bar ${S.includes(P)&&"lk-highlighted"}`,style:{height:`${Math.min(y,Math.max(v,R*100+5))}%`}})))});var sn={},oC;function BL(){if(oC)return sn;oC=1,Object.defineProperty(sn,"__esModule",{value:!0});var t=ac();function e(V){return V&&typeof V=="object"&&"default"in V?V:{default:V}}var n=e(t);function a(V,Y){Y===void 0&&(Y={});var ie=Y.insertAt;if(typeof document!="undefined"){var he=document.head||document.getElementsByTagName("head")[0],be=document.createElement("style");be.type="text/css",ie==="top"&&he.firstChild?he.insertBefore(be,he.firstChild):he.appendChild(be),be.styleSheet?be.styleSheet.cssText=V:be.appendChild(document.createTextNode(V))}}var r=".orb-main{animation:var(--main-hue-animation);background-image:radial-gradient(circle at 50% 30%,var(--main-bg-start) 0,var(--main-bg-end) 70%);border-radius:50%;box-shadow:var(--main-shadow);cursor:pointer;display:flex;height:var(--react-ai-orb-size);overflow:hidden;position:relative;width:var(--react-ai-orb-size)}.loc-a{position:absolute}.loc-b{left:10%}.loc-b,.loc-c{position:absolute;top:5%}.loc-c,.loc-d{left:5%}.loc-d{position:absolute;top:5%}.loc-glass{left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}.shape-a{animation:rotateDiagonal var(--animation-rotation-speed-base) linear infinite,hueShift var(--animation-hue-speed-base) linear infinite;background-image:radial-gradient(circle at 50% 90%,var(--shape-a-start) 0,var(--shape-a-end) 70%)}.shape-a,.shape-b{border-radius:50%;height:var(--shapes-size);transform-style:preserve-3d;width:var(--shapes-size)}.shape-b{animation:rotateDiagonal calc(var(--animation-rotation-speed-base) + var(--animation-rotation-speed-base)*.5) linear infinite,hueShift calc(var(--animation-hue-speed-base) + var(--animation-hue-speed-base)*.5) linear infinite;background:radial-gradient(circle at 33% 12%,var(--shape-b-start) 0,var(--shape-b-middle) 26%,var(--shape-b-end) 63%);filter:blur(2px);mix-blend-mode:soft-light;will-change:transform}.shape-c{animation:rotateDiagonal calc(var(--animation-rotation-speed-base) + var(--animation-rotation-speed-base)*1) linear infinite,hueShift calc(var(--animation-hue-speed-base) + var(--animation-hue-speed-base)*1) linear infinite;background-image:radial-gradient(circle at 31% 12%,var(--shape-c-start) 0,var(--shape-c-middle) 31%,var(--shape-c-end) 77%);mix-blend-mode:color-dodge;opacity:.65}.shape-c,.shape-d{border-radius:50%;filter:blur(1px);height:var(--shapes-size);transform-style:preserve-3d;width:var(--shapes-size)}.shape-d{animation:rotateDiagonal calc(var(--animation-rotation-speed-base) + var(--animation-rotation-speed-base)*1.5) linear infinite,hueShift calc(var(--animation-hue-speed-base) + var(--animation-hue-speed-base)*1.5) linear infinite;background-image:radial-gradient(circle at 12% 80%,var(--shape-d-start) 0,var(--shape-d-middle) 31%,var(--shape-d-end) 77%);mix-blend-mode:color;opacity:.55}.glass{background:transparent;border-radius:50%;box-shadow:inset 0 -1px 6px 1px hsla(0,0%,100%,.5),inset 0 3px 4px 0 hsla(0,0%,100%,.5);height:var(--shapes-size);opacity:.8;width:var(--shapes-size)}.blob-a{animation:rotateDiagonal calc(var(--animation-rotation-speed-base) + var(--animation-rotation-speed-base)*2) linear infinite,hueShift calc(var(--animation-hue-speed-base) + var(--animation-hue-speed-base)*2) linear infinite;mix-blend-mode:screen;opacity:var(--blob-a-opacity)}.blob-b{animation:rotateDiagonal calc(var(--animation-rotation-speed-base) + var(--animation-rotation-speed-base)*2.5) linear infinite,hueShift calc(var(--animation-hue-speed-base) + var(--animation-hue-speed-base)*2.5) linear infinite;mix-blend-mode:lighten;opacity:var(--blob-b-opacity)}.blob-b,.blob-shine{position:absolute;top:0}.blob-shine{fill:#fff;animation:expand 3.5s linear infinite;filter:blur(15px);mix-blend-mode:hard-light;opacity:.9;transform:scale(.4)}.shine-b{animation:expand-b 5s ease-in-out infinite;left:15%;mix-blend-mode:plus-lighter;opacity:.3}@keyframes expand{0%{transform:scale(.4)}50%{transform:scale(.1)}to{transform:scale(.4)}}@keyframes expand-b{0%{transform:scale(.6)}50%{transform:scale(.1)}to{transform:scale(.6)}}@keyframes rotateDiagonal{0%{transform:rotate3d(1,1,1,0deg)}to{transform:rotate3d(1,1,1,1turn)}}@keyframes hueShift{0%{filter:hue-rotate(0deg)}50%{filter:hue-rotate(var(--hue-rotation))}to{filter:hue-rotate(0deg)}}@keyframes circleAnimation{0%{transform:rotate(-120deg)}50%{transform:rotate(0)}to{transform:rotate(-120deg)}}";a(r);const c=({color1:V,color2:Y})=>n.default.createElement(n.default.Fragment,null,n.default.createElement("svg",{id:"sw-js-blob-svg",viewBox:"0 0 100 100",xmlns:"http://www.w3.org/2000/svg",version:"1.1",className:"blob-a"},n.default.createElement("defs",null,n.default.createElement("linearGradient",{id:"blob-a-gradient",x1:"0",x2:"1",y1:"1",y2:"0"},n.default.createElement("stop",{id:"stop1",stopColor:V,offset:"0%"}),n.default.createElement("stop",{id:"stop2",stopColor:Y,offset:"100%"}))),n.default.createElement("path",{fill:"url(#blob-a-gradient)",d:"M23.3,-31.9C28.4,-28.4,29.5,-19.2,31.1,-10.9C32.6,-2.6,34.7,4.7,33.5,11.7C32.3,18.6,27.8,25.3,21.6,28.8C15.5,32.3,7.8,32.6,-0.6,33.5C-9,34.4,-18.1,35.8,-24.8,32.5C-31.5,29.2,-35.9,21.2,-36.5,13.3C-37.2,5.4,-34.1,-2.4,-31.6,-10.4C-29.1,-18.3,-27.2,-26.6,-22.1,-30.1C-16.9,-33.6,-8.4,-32.3,0.3,-32.8C9.1,-33.3,18.2,-35.4,23.3,-31.9Z",width:"100%",height:"100%",transform:"translate(50 50)",strokeWidth:"0",style:{transition:"0.3s"}})),n.default.createElement("svg",{id:"sw-js-blob-svg",viewBox:"0 0 100 100",xmlns:"http://www.w3.org/2000/svg",version:"1.1",className:"blob-b"},n.default.createElement("defs",null,n.default.createElement("linearGradient",{id:"blob-b-gradient",x1:"0",x2:"1",y1:"1",y2:"0"},n.default.createElement("stop",{id:"stop1",stopColor:V,offset:"0%"}),n.default.createElement("stop",{id:"stop2",stopColor:Y,offset:"100%"}))),n.default.createElement("path",{fill:"url(#blob-b-gradient)",d:"M19.2,-27.1C25.6,-29.4,32.3,-26,33.8,-20.5C35.3,-15,31.7,-7.5,27.8,-2.2C23.9,3,19.8,6,16.8,8.9C13.8,11.8,11.9,14.6,9.3,18.8C6.7,23,3.3,28.6,-0.7,29.8C-4.7,31,-9.4,27.8,-16.7,26.2C-23.9,24.7,-33.6,24.8,-39.3,20.7C-45.1,16.7,-47,8.3,-45.4,0.9C-43.8,-6.5,-38.8,-13,-32.6,-16.3C-26.4,-19.6,-18.9,-19.7,-13.3,-17.9C-7.6,-16,-3.8,-12.2,1.3,-14.4C6.3,-16.6,12.7,-24.8,19.2,-27.1Z",width:"100%",height:"100%",transform:"translate(50 50)",strokeWidth:"0",style:{transition:"0.3s"}})),n.default.createElement("svg",{id:"sw-js-blob-svg",viewBox:"0 0 100 100",xmlns:"http://www.w3.org/2000/svg",version:"1.1",className:"blob-shine"},n.default.createElement("defs",null,n.default.createElement("linearGradient",{id:"blob-shine-gradient",x1:"0",x2:"1",y1:"1",y2:"0"},n.default.createElement("stop",{id:"stop1",stopColor:"white",offset:"0%"}))),n.default.createElement("path",{fill:"url(#blob-shine-gradient)",d:"M12.3,-22.8C17.4,-18.4,23.8,-17.9,26.8,-14.8C29.8,-11.6,29.5,-5.8,29,-0.3C28.6,5.3,28,10.6,26.9,17.1C25.9,23.7,24.3,31.5,19.7,32.2C15.2,32.8,7.6,26.3,0.6,25.3C-6.4,24.3,-12.9,28.9,-16.8,27.9C-20.8,26.9,-22.3,20.3,-23.8,14.7C-25.3,9.2,-26.9,4.6,-30.1,-1.8C-33.3,-8.3,-38.1,-16.5,-35.4,-20.1C-32.7,-23.6,-22.5,-22.4,-15.3,-25.5C-8.2,-28.6,-4.1,-36,-0.2,-35.6C3.6,-35.2,7.3,-27.1,12.3,-22.8Z",width:"100%",height:"100%",transform:"translate(50 50)",strokeWidth:"0",style:{transition:"0.3s"}})),n.default.createElement("svg",{id:"sw-js-blob-svg",viewBox:"0 0 100 100",xmlns:"http://www.w3.org/2000/svg",version:"1.1",className:"blob-shine shine-b"},n.default.createElement("defs",null,n.default.createElement("linearGradient",{id:"blob-shine-gradient",x1:"0",x2:"1",y1:"1",y2:"0"},n.default.createElement("stop",{id:"stop1",stopColor:"white",offset:"0%"}))),n.default.createElement("path",{fill:"url(#blob-shine-gradient)",d:"M12.3,-22.8C17.4,-18.4,23.8,-17.9,26.8,-14.8C29.8,-11.6,29.5,-5.8,29,-0.3C28.6,5.3,28,10.6,26.9,17.1C25.9,23.7,24.3,31.5,19.7,32.2C15.2,32.8,7.6,26.3,0.6,25.3C-6.4,24.3,-12.9,28.9,-16.8,27.9C-20.8,26.9,-22.3,20.3,-23.8,14.7C-25.3,9.2,-26.9,4.6,-30.1,-1.8C-33.3,-8.3,-38.1,-16.5,-35.4,-20.1C-32.7,-23.6,-22.5,-22.4,-15.3,-25.5C-8.2,-28.6,-4.1,-36,-0.2,-35.6C3.6,-35.2,7.3,-27.1,12.3,-22.8Z",width:"100%",height:"100%",transform:"translate(50 50)",strokeWidth:"0",style:{transition:"0.3s"}}))),l={cosmicNebula:{mainBgStart:"rgb(236, 133, 255)",mainBgEnd:"rgb(49, 138, 255)",shadowColor1:"rgba(166, 35, 248, 0)",shadowColor2:"rgba(121, 19, 255, 0.5)",shadowColor3:"rgba(255, 255, 255, 0.9)",shadowColor4:"rgb(253, 164, 250)",shapeAStart:"rgb(133, 210, 255)",shapeAEnd:"rgba(115, 49, 255, 0)",shapeBStart:"rgb(254, 245, 254)",shapeBMiddle:"rgb(253, 109, 255)",shapeBEnd:"rgba(203, 56, 255, 0)",shapeCStart:"rgba(254, 254, 254, 0)",shapeCMiddle:"rgba(254, 111, 255, 0)",shapeCEnd:"#7006fe",shapeDStart:"rgba(254, 254, 254, 0)",shapeDMiddle:"rgba(142, 111, 255, 0)",shapeDEnd:"#00eeff"},caribean:{mainBgStart:"rgb(64, 224, 208)",mainBgEnd:"rgb(76, 189, 255)",shadowColor1:"rgba(8, 226, 255, 0)",shadowColor2:"rgba(43, 173, 216, 0.5)",shadowColor3:"rgba(255, 255, 255, 0.9)",shadowColor4:"rgb(72, 209, 204)",shapeAStart:"rgb(127, 255, 212)",shapeAEnd:"rgba(0, 105, 148, 0)",shapeBStart:"rgb(240, 241, 255)",shapeBMiddle:"rgb(64, 224, 208)",shapeBEnd:"rgba(0, 128, 128, 0)",shapeCStart:"rgba(224, 255, 255, 0)",shapeCMiddle:"rgba(32, 178, 170, 0)",shapeCEnd:"#006064",shapeDStart:"rgba(224, 255, 255, 0)",shapeDMiddle:"rgba(45, 8, 255, 0)",shapeDEnd:"#00838f"},cherryBlossom:{mainBgStart:"rgb(255, 204, 229)",mainBgEnd:"rgb(255, 102, 153)",shadowColor1:"rgba(255, 153, 204, 0)",shadowColor2:"rgba(255, 102, 178, 0.5)",shadowColor3:"rgba(255, 255, 255, 0.9)",shadowColor4:"rgb(255, 183, 197)",shapeAStart:"rgb(255, 228, 240)",shapeAEnd:"rgba(255, 140, 189, 0)",shapeBStart:"rgb(255, 240, 245)",shapeBMiddle:"rgb(255, 105, 180)",shapeBEnd:"rgba(255, 20, 147, 0)",shapeCStart:"rgba(255, 250, 250, 0)",shapeCMiddle:"rgba(255, 182, 193, 0)",shapeCEnd:"#FF69B4",shapeDStart:"rgba(255, 245, 247, 0)",shapeDMiddle:"rgba(255, 92, 143, 0)",shapeDEnd:"#FF1493"},galaxy:{mainBgStart:"rgb(40, 40, 99)",mainBgEnd:"rgb(50, 50, 100)",shadowColor1:"rgba(166, 35, 248, 0)",shadowColor2:"rgba(121, 19, 255, 0.5)",shadowColor3:"rgba(255, 255, 255, 0.9)",shadowColor4:"rgb(253, 164, 250)",shapeAStart:"rgb(133, 210, 255)",shapeAEnd:"rgba(115, 49, 255, 0)",shapeBStart:"rgb(254, 245, 254)",shapeBMiddle:"rgb(253, 109, 255)",shapeBEnd:"rgba(203, 56, 255, 0)",shapeCStart:"rgba(254, 254, 254, 0)",shapeCMiddle:"rgba(254, 111, 255, 0)",shapeCEnd:"#7006fe",shapeDStart:"rgba(254, 254, 254, 0)",shapeDMiddle:"rgba(142, 111, 255, 0)",shapeDEnd:"#00eeff"},oceanDepths:{mainBgStart:"rgb(4, 63, 255)",mainBgEnd:"rgb(17, 19, 82)",shadowColor1:"rgba(0, 149, 182, 0)",shadowColor2:"rgba(0, 96, 128, 0.5)",shadowColor3:"rgba(255, 255, 255, 0.9)",shadowColor4:"rgb(72, 209, 204)",shapeAStart:"rgb(127, 255, 212)",shapeAEnd:"rgba(0, 105, 148, 0)",shapeBStart:"rgb(240, 255, 255)",shapeBMiddle:"rgb(64, 224, 208)",shapeBEnd:"rgba(0, 128, 128, 0)",shapeCStart:"rgba(224, 255, 255, 0)",shapeCMiddle:"rgba(32, 178, 170, 0)",shapeCEnd:"#006064",shapeDStart:"rgba(224, 255, 255, 0)",shapeDMiddle:"rgba(0, 128, 128, 0)",shapeDEnd:"#00838f"},emerald:{mainBgStart:"rgb(46, 204, 113)",mainBgEnd:"rgb(39, 174, 96)",shadowColor1:"rgba(0, 128, 64, 0)",shadowColor2:"rgba(46, 204, 113, 0.5)",shadowColor3:"rgba(255, 255, 255, 0.8)",shadowColor4:"rgb(88, 214, 141)",shapeAStart:"rgb(102, 255, 178)",shapeAEnd:"rgba(39, 174, 96, 0)",shapeBStart:"rgb(153, 255, 204)",shapeBMiddle:"rgb(46, 204, 113)",shapeBEnd:"rgba(0, 128, 64, 0)",shapeCStart:"rgba(230, 255, 240, 0)",shapeCMiddle:"rgba(102, 255, 178, 0.3)",shapeCEnd:"#2ECC71",shapeDStart:"rgba(240, 255, 250, 0)",shapeDMiddle:"rgba(88, 214, 141, 0.4)",shapeDEnd:"#1E8449"},goldenGlow:{mainBgStart:"rgb(255, 204, 0)",mainBgEnd:"rgb(255, 165, 0)",shadowColor1:"rgba(255, 215, 0, 0)",shadowColor2:"rgba(255, 215, 0, 0.5)",shadowColor3:"rgba(255, 255, 255, 0.8)",shadowColor4:"rgb(255, 140, 0)",shapeAStart:"rgb(255, 233, 100)",shapeAEnd:"rgba(255, 215, 0, 0)",shapeBStart:"rgb(255, 210, 80)",shapeBMiddle:"rgb(255, 180, 50)",shapeBEnd:"rgba(255, 140, 0, 0)",shapeCStart:"rgba(255, 255, 255, 0)",shapeCMiddle:"rgba(255, 245, 100, 0.5)",shapeCEnd:"#FFD700",shapeDStart:"rgba(255, 255, 255, 0)",shapeDMiddle:"rgba(255, 215, 0, 0.5)",shapeDEnd:"#FFB800"},volcanic:{mainBgStart:"rgb(50, 10, 0)",mainBgEnd:"rgb(150, 20, 0)",shadowColor1:"rgba(255, 69, 0, 0)",shadowColor2:"rgba(255, 69, 0, 0.4)",shadowColor3:"rgba(255, 140, 0, 0.7)",shadowColor4:"rgb(255, 0, 0)",shapeAStart:"rgb(255, 87, 34)",shapeAEnd:"rgba(255, 69, 0, 0)",shapeBStart:"rgb(255, 99, 71)",shapeBMiddle:"rgb(255, 69, 0)",shapeBEnd:"rgba(200, 0, 0, 0)",shapeCStart:"rgba(255, 87, 34, 0.5)",shapeCMiddle:"rgba(255, 140, 0, 0.7)",shapeCEnd:"rgba(255, 69, 0, 1)",shapeDStart:"rgba(50, 10, 0, 0.5)",shapeDMiddle:"rgba(200, 30, 10, 0.7)",shapeDEnd:"rgba(255, 69, 0, 0.8)"}},u=82,f=72,h=1,p=1,v=1,y=120,S=!1,w=.3,T=.8,x=!1,R=({palette:V=l.cosmicNebula,size:Y=h,animationSpeedBase:ie=p,animationSpeedHue:he=v,hueRotation:be=y,mainOrbHueAnimation:qe=S,blobAOpacity:H=w,blobBOpacity:ne=T,noShadow:ce=x})=>{const Ce=t.useMemo(()=>({"--react-ai-orb-size":`${Y*u}px`,"--shapes-size":`${Y*f}px`,"--main-bg-start":V.mainBgStart,"--main-bg-end":V.mainBgEnd,"--shadow-color-1":V.shadowColor1,"--shadow-color-2":V.shadowColor2,"--shadow-color-3":V.shadowColor3,"--shadow-color-4":V.shadowColor4,"--main-shadow":ce?"none":`var(--shadow-color-1) 0px 4px 6px 0px,
|
|
49
|
+
var(--shadow-color-2) 0px 5px 10px 0px,
|
|
50
|
+
var(--shadow-color-3) 0px 0px 1px 0px inset,
|
|
51
|
+
var(--shadow-color-4) 0px 1px 7px 0px inset`,"--shape-a-start":V.shapeAStart,"--shape-a-end":V.shapeAEnd,"--shape-b-start":V.shapeBStart,"--shape-b-middle":V.shapeBMiddle,"--shape-b-end":V.shapeBEnd,"--shape-c-start":V.shapeCStart,"--shape-c-middle":V.shapeCMiddle,"--shape-c-end":V.shapeCEnd,"--shape-d-start":V.shapeDStart,"--shape-d-middle":V.shapeDMiddle,"--shape-d-end":V.shapeDEnd,"--blob-a-opacity":H,"--blob-b-opacity":ne,"--animation-rotation-speed-base":`${1/(ie*.5)}s`,"--animation-hue-speed-base":`${1/(he*.5)}s`,"--hue-rotation":`${be}deg`,"--main-hue-animation":qe?"hueShift var(--animation-hue-speed-base) linear infinite":"none"}),[V,Y,ie,he,be,qe,H,ne]);return n.default.createElement("div",{style:Object.assign({},Ce)},n.default.createElement("div",{className:"orb-main"},n.default.createElement("div",{className:"glass loc-glass"}),n.default.createElement("div",{className:"shape-a loc-a"}),n.default.createElement("div",{className:"shape-b loc-b"}),n.default.createElement("div",{className:"shape-c loc-c"}),n.default.createElement("div",{className:"shape-d loc-d"}),n.default.createElement(c,{color1:V.mainBgStart,color2:V.mainBgEnd})))},P={palette:l.oceanDepths,blobBOpacity:.3,size:h,animationSpeedBase:p,animationSpeedHue:v,hueRotation:y,mainOrbHueAnimation:S},L={palette:l.galaxy,blobBOpacity:.3,size:h,animationSpeedBase:1.3,animationSpeedHue:v,hueRotation:360,mainOrbHueAnimation:S},E={palette:l.caribean,size:h,animationSpeedBase:p,animationSpeedHue:v,hueRotation:y,mainOrbHueAnimation:S},k={palette:l.cherryBlossom,size:h,animationSpeedBase:p,animationSpeedHue:v,hueRotation:0,mainOrbHueAnimation:S},_={palette:l.emerald,size:h,animationSpeedBase:p,animationSpeedHue:v,hueRotation:0,blobBOpacity:.2,mainOrbHueAnimation:S},N={palette:l.cosmicNebula,size:h,animationSpeedBase:p,animationSpeedHue:.25,hueRotation:y,mainOrbHueAnimation:!0},U={palette:l.goldenGlow,blobBOpacity:.3,hueRotation:0},G={palette:l.volcanic,blobBOpacity:.3,hueRotation:0};return sn.Orb=R,sn.caribeanPreset=E,sn.cherryBlossomPreset=k,sn.colorPalettes=l,sn.emeraldPreset=_,sn.galaxyPreset=L,sn.goldenGlowPreset=U,sn.multiColorPreset=N,sn.oceanDepthsPreset=P,sn.volcanicPreset=G,sn}var ii=BL();const jL=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),VL=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,a)=>a?a.toUpperCase():n.toLowerCase()),cC=t=>{const e=VL(t);return e.charAt(0).toUpperCase()+e.slice(1)},lC=(...t)=>t.filter((e,n,a)=>!!e&&e.trim()!==""&&a.indexOf(e)===n).join(" ").trim(),zL=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var FL={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"};const qL=q.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:r="",children:c,iconNode:l,...u},f)=>q.createElement("svg",{ref:f,...FL,width:e,height:e,stroke:t,strokeWidth:a?Number(n)*24/Number(e):n,className:lC("lucide",r),...!c&&!zL(u)&&{"aria-hidden":"true"},...u},[...l.map(([h,p])=>q.createElement(h,p)),...Array.isArray(c)?c:[c]]));const uC=(t,e)=>{const n=q.forwardRef(({className:a,...r},c)=>q.createElement(qL,{ref:c,iconNode:e,className:lC(`lucide-${jL(cC(t))}`,`lucide-${t}`,a),...r}));return n.displayName=cC(t),n};const HL=uC("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const GL=uC("phone",[["path",{d:"M13.832 16.568a1 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 2A18 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 6.392 6.384",key:"9njp5v"}]]);function KL(t,e){const n=q.useMemo(()=>new Ls,[]),[a,r]=q.useState(null),[c,l]=q.useState(!1),[u,f]=q.useState(!1);return q.useEffect(()=>{if(!e)return;let h=!1;const p=async()=>{try{const S=window.AudioContext||window.webkitAudioContext;if(S){const w=new S;w.state==="suspended"&&await w.resume()}}catch{}},v=S=>{h||r(`${S.name}: ${S.message}`)},y=()=>{h||f(!1)};return n.on(X.MediaDevicesError,v),n.on(X.Disconnected,y),(async()=>{var S,w;try{l(!0),await p();const{serverUrl:T,participantToken:x}=await Iw(t);if(h)return;await Promise.all([n.localParticipant.setMicrophoneEnabled(!0,void 0,{preConnectBuffer:!0}),n.connect(T,x)]),h||f(!0)}catch(T){h||r(`${(S=T==null?void 0:T.name)!=null?S:"Error"}: ${(w=T==null?void 0:T.message)!=null?w:"unknown"}`)}finally{h||l(!1)}})(),()=>{h=!0,n.off(X.MediaDevicesError,v),n.off(X.Disconnected,y);try{n.disconnect()}catch{}f(!1),l(!1)}},[e,n,t.apiBaseUrl,t.projectId]),{room:n,error:a,setError:r,connecting:c,connected:u}}function dC({onSend:t,disabled:e}){const[n,a]=q.useState(""),r=q.useRef(null),c=l=>{l.preventDefault();const u=n.trim();u&&(t(u),a(""))};return q.useEffect(()=>{var l;e||(l=r.current)==null||l.focus()},[e]),oe.jsxs("form",{className:"chat-input-row",onSubmit:c,children:[oe.jsx("input",{ref:r,type:"text",className:"chat-input",value:n,autoComplete:"off",placeholder:e?"Connecting…":"Type a message…",onChange:l=>a(l.target.value),"aria-label":"Message"}),oe.jsx("button",{type:"submit",className:"bello-trigger small",disabled:e||n.trim().length===0,"aria-label":"Send",children:"Send"})]})}const Oh=new Map;function fC(t,e){var n,a,r,c;return(c=(a=(n=t==null?void 0:t.streamInfo)==null?void 0:n.attributes)==null?void 0:a[e])!=null?c:(r=t==null?void 0:t.attributes)==null?void 0:r[e]}function Ph(t){var e,n,a,r,c;return(c=(r=(a=(e=t==null?void 0:t.participantInfo)==null?void 0:e.identity)!=null?a:(n=t==null?void 0:t.participant)==null?void 0:n.identity)!=null?r:t==null?void 0:t.participantIdentity)!=null?c:t==null?void 0:t.participantSid}function hC(t){var n,a,r;const e=(r=(a=(n=t==null?void 0:t.streamInfo)==null?void 0:n.timestamp)!=null?a:t==null?void 0:t.timestamp)!=null?r:t==null?void 0:t.time;return typeof e=="number"?e:Date.now()}function Nh(t){var e,n,a,r,c,l;return(l=(c=(a=t==null?void 0:t.text)!=null?a:(n=(e=t==null?void 0:t.alternatives)==null?void 0:e[0])==null?void 0:n.text)!=null?c:(r=t==null?void 0:t.result)==null?void 0:r.text)!=null?l:""}function mC(t){var n,a,r,c;const e=fC(t,"lk.transcription_final");return typeof e=="string"?e.toLowerCase()==="true":!!(t!=null&&t.isFinal||t!=null&&t.final||(n=t==null?void 0:t.result)!=null&&n.is_final||(a=t==null?void 0:t.result)!=null&&a.final||(c=(r=t==null?void 0:t.alternatives)==null?void 0:r[0])!=null&&c.isFinal)}function Lh(t){var e;return fC(t,"lk.segment_id")||((e=t==null?void 0:t.streamInfo)==null?void 0:e.id)||`${Ph(t)||"p"}:${hC(t)}`}function ll(t,e){return Oh.set(t,e),e}function YL(t){if(t){if(t.startsWith("user-"))return!0;if(t.startsWith("agent-"))return!1}}function XL(t,e,n){var f;if(Oh.has(t))return Oh.get(t);const a=Ph(e),r=YL(a);if(typeof r=="boolean")return ll(t,r);const c=(e==null?void 0:e.participant)||{};if(typeof(c==null?void 0:c.isLocal)=="boolean")return ll(t,c.isLocal);const l=(n==null?void 0:n.localParticipant)||{},u=(f=l.identity)!=null?f:l.sid;return u&&a?ll(t,String(u)===String(a)):ll(t,!1)}function QL(t,e){const n=t,a=Lh(n),r=hC(n),c=Nh(n),l=Ph(n),u=XL(a,n,e);return{id:`tx-${a}`,from:{isLocal:u,name:u?"You":"Agent",identity:l!=null?l:u?"local":"agent"},message:c,timestamp:r}}function pC(){const t=RL(),e=vL(),n=QT(),a=q.useRef(new Map),r=q.useRef([]),[,c]=q.useState(0),l=t[t.length-1],u=t.length===0?"0":`${t.length}:${Lh(l)}:${Nh(l)}:${mC(l)?1:0}`;q.useEffect(()=>{var v;if(!(t!=null&&t.length))return;let p=!1;for(const y of t){const S=y,w=`tx-${Lh(S)}`,T=QL(y,n),x=Nh(S),R=mC(S),P=a.current.get(w);if(!P){a.current.set(w,{msg:T,final:!!R,lastText:x}),r.current.push(w),p=!0;continue}const L=x&&x!==P.lastText,E=!P.final&&R;(L||E)&&(a.current.set(w,{msg:{...P.msg,message:L?x:P.msg.message,timestamp:Math.max(P.msg.timestamp||0,T.timestamp||0),from:{...P.msg.from,isLocal:(v=P.msg.from)==null?void 0:v.isLocal}},final:P.final||!!R,lastText:L?x:P.lastText}),p=!0)}p&&c(y=>y+1)},[u,n]);const f=q.useMemo(()=>{const v=[...r.current.map(y=>{var S;return(S=a.current.get(y))==null?void 0:S.msg}).filter(Boolean),...e.chatMessages];return v.sort((y,S)=>(y.timestamp||0)-(S.timestamp||0)),v},[e.chatMessages,u]),h=q.useMemo(()=>u,[u]);return{messages:f,send:e.send,revision:h}}function JL({entry:t}){var p,v;const e=QT(),n=(e==null?void 0:e.localParticipant)||{},a=(p=n.identity)!=null?p:n.sid,r=t.from||{},c=(v=r==null?void 0:r.identity)!=null?v:r==null?void 0:r.sid,l=(r==null?void 0:r.isLocal)===!0||a&&c&&String(a)===String(c)||typeof c=="string"&&c.startsWith("user-"),u=l?"You":(r==null?void 0:r.name)||"Agent",f=typeof t.timestamp=="number"?new Date(t.timestamp):new Date,h=f.toLocaleTimeString(void 0,{timeStyle:"short"});return oe.jsxs("li",{className:`chat-entry ${l?"me":"them"}`,title:f.toString(),children:[!l&&oe.jsx("div",{className:"chat-name",children:u}),oe.jsxs("div",{className:`chat-bubble ${l?"me":"them"}`,children:[oe.jsx("span",{className:"chat-text",children:t.message}),oe.jsx("span",{className:"chat-time",children:h})]})]})}function gC(t){switch(t){case"ocean-depths":return ii.oceanDepthsPreset;case"caribbean":return ii.caribeanPreset;case"cherry-blossom":return ii.cherryBlossomPreset;case"emerald":return ii.emeraldPreset;case"multi-color":return ii.multiColorPreset;case"golden-glow":return ii.goldenGlowPreset;case"volcanic":return ii.volcanicPreset;default:return ii.galaxyPreset}}function vC({opts:t,theme:e,onClose:n}){const[a,r]=q.useState(!1),c=t.agentEnabled!==!1,l=t.voiceEnabled!==!1,{room:u,error:f,setError:h,connecting:p,connected:v}=KL(t,a&&c);q.useEffect(()=>{const T=x=>{const R=x.detail,P=R==null?void 0:R.type;P==="open"&&r(!0),P==="close"&&(r(!1),n())};return window.addEventListener("bello:event",T),()=>window.removeEventListener("bello:event",T)},[n]);const y=q.useMemo(()=>{var T,x,R,P;return{title:(T=t.widgetTitle)!=null?T:"Need support?",cta:(x=t.widgetButtonTitle)!=null?x:"Chat with AI",pos:(R=t.position)!=null?R:"bottom-right",orb:(P=t.orbStyle)!=null?P:"galaxy"}},[t]),S=e==="dark"?"theme-dark":e==="glass"?"theme-glass":"theme-light",w=()=>{r(!1),n()};return oe.jsxs("div",{className:S,children:[!a&&oe.jsxs("div",{className:"bello-container bello-row",children:[oe.jsx("div",{className:"px-3",children:oe.jsx(ii.Orb,{...gC(y.orb),size:.7,animationSpeedBase:1,animationSpeedHue:1,mainOrbHueAnimation:!0})}),oe.jsxs("div",{className:"bello-title-container",children:[oe.jsx("div",{className:"bello-hero",children:y.title}),oe.jsx("button",{className:"bello-trigger",onClick:()=>r(!0),children:y.cta})]})]}),oe.jsx(fM.div,{className:"bello-pop","data-pos":y.pos,initial:!1,animate:{opacity:a?1:0,scale:a?1:.98,y:a?0:6,pointerEvents:a?"auto":"none"},children:oe.jsxs("div",{className:"bello-card bello-body",children:[oe.jsxs("div",{className:"bello-header",children:[oe.jsxs("div",{className:"bello-row",children:[oe.jsx("div",{className:"pl-2",children:oe.jsx(ii.Orb,{...gC(y.orb),size:.5,animationSpeedBase:1,animationSpeedHue:1,mainOrbHueAnimation:!0})}),oe.jsxs("div",{className:"min-w-0 flex-1",children:[oe.jsx("div",{className:"bello-title",children:y.title}),oe.jsx("div",{className:"bello-subtitle",children:c?"Voice & text assistant":"UI preview (agent off)"})]})]}),oe.jsxs("button",{className:"bello-trigger-danger small",onClick:w,"aria-label":"End session",title:"End",children:[oe.jsx(GL,{size:14}),"End"]})]}),f?oe.jsx("div",{className:"bello-main",children:oe.jsxs("div",{className:"bello-error",children:[oe.jsx("div",{className:"bello-error-title",children:"Error"}),oe.jsx("div",{className:"bello-error-text",children:f}),oe.jsx("button",{className:"bello-trigger small mt",onClick:()=>h(null),children:"Dismiss"})]})}):c?oe.jsxs(Ah.Provider,{value:u,children:[oe.jsxs("div",{className:"bello-main",children:[l&&oe.jsxs(oe.Fragment,{children:[oe.jsx(OL,{}),oe.jsx(xL,{label:"Start Audio"}),oe.jsx(WL,{})]}),oe.jsx(ZL,{connecting:p,connected:v,voiceOn:l}),oe.jsx($L,{})]}),oe.jsx("div",{className:"bello-footer",children:oe.jsx(eI,{connected:v})})]}):oe.jsxs(oe.Fragment,{children:[oe.jsxs("div",{className:"bello-main",children:[oe.jsx("div",{className:"center",children:oe.jsx("p",{className:"status",children:"UI preview · Agent disabled"})}),oe.jsx("div",{className:"chat-wrap",children:oe.jsx("ol",{className:"chat-list","aria-live":"polite",children:oe.jsxs("li",{className:"chat-entry them",children:[oe.jsx("div",{className:"chat-name",children:"Agent"}),oe.jsxs("div",{className:"chat-bubble them",children:[oe.jsx("span",{className:"chat-text",children:"Hi! This is UI-only mode."}),oe.jsx("span",{className:"chat-time",children:"—"})]})]})})})]}),oe.jsx("div",{className:"bello-footer",children:oe.jsx(dC,{disabled:!0,onSend:()=>{}})})]})]})}),a&&oe.jsx("button",{className:"bello-fab",onClick:w,"aria-label":"Collapse widget",title:"Collapse",children:oe.jsx(HL,{size:20})})]})}function ZL({connecting:t,connected:e,voiceOn:n=!0}){const{state:a,audioTrack:r}=iC();return oe.jsxs("div",{className:"center",children:[n&&oe.jsx(UL,{barCount:5,options:{minHeight:6},className:"bars",trackRef:r,state:a,children:oe.jsx("span",{className:"bar"})}),oe.jsxs("p",{className:"status",children:[t&&"Connecting…",!t&&e&&(a==="speaking"?"Agent speaking…":a==="listening"?"Agent listening…":a==="thinking"?"Agent thinking…":"Connected"),!t&&!e&&"Ready"]})]})}function WL(){const{audioTrack:t}=iC();return q.useEffect(()=>{var a;if(!t)return;const e=(a=t==null?void 0:t.attachedElements)==null?void 0:a[0],n=r=>{try{r.muted=!1,r.playsInline=!0;const c=r.play();c&&typeof c.then=="function"&&c.catch(()=>{})}catch{}};if(e){n(e);return}try{const r=new Audio;r.autoplay=!0,r.playsInline=!0,r.muted=!1,typeof t.attach=="function"?t.attach(r):t.mediaStream&&(r.srcObject=t.mediaStream),n(r)}catch{}},[t]),null}function $L(){var c,l;const{messages:t,revision:e}=pC(),n=q.useRef(null),a=q.useRef(null),r=q.useRef(!0);return q.useEffect(()=>{const u=n.current;if(!u)return;const f=u.closest(".chat-wrap, .bello-main, .scroll-container")||u.parentElement||u,h=()=>{const p=f.scrollHeight-f.scrollTop-f.clientHeight<80;r.current=p};return f.addEventListener("scroll",h,{passive:!0}),h(),()=>f.removeEventListener("scroll",h)},[]),q.useLayoutEffect(()=>{r.current&&requestAnimationFrame(()=>{var u;(u=a.current)==null||u.scrollIntoView({block:"end",inline:"nearest",behavior:"auto"})})},[e,t.length,(c=t[t.length-1])==null?void 0:c.id,(l=t[t.length-1])==null?void 0:l.message]),oe.jsx("div",{className:"chat-wrap",children:oe.jsxs("ol",{ref:n,className:"chat-list","aria-live":"polite",children:[t.map(u=>oe.jsx(JL,{entry:u},u.id)),oe.jsx("li",{"aria-hidden":"true",children:oe.jsx("div",{ref:a})})]})})}function eI({connected:t}){const{send:e}=pC();return oe.jsx(dC,{disabled:!t,onSend:n=>{const a=n.trim();a&&e(a)}})}const tI=':host{all:initial;font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Arial,Noto Sans,"Apple Color Emoji","Segoe UI Emoji";--bello-bg: #111;--bello-fg: #fff;--bello-surface: #111;--bello-border: rgba(255, 255, 255, .12);--bello-cta-bg: #fff;--bello-cta-fg: #111;--bello-subtle: rgba(255, 255, 255, .72);--bello-danger: #ff6b6b;--bello-shadow: 0 10px 24px rgba(0, 0, 0, .18);--bello-radius: 12px;--bello-radius-pill: 999px;--bello-gap: 12px;--bello-pop-offset: 50px;--bello-width: 420px;--bello-height: 520px;--bello-fab-size-width: 80px;--bello-fab-size-height: 52px;--bello-fab-gap: 12px}.theme-light :host,.theme-light{--bello-bg: #fff;--bello-fg: #111;--bello-surface: #fff;--bello-border: rgba(0, 0, 0, .08);--bello-cta-bg: #111;--bello-cta-fg: #fff;--bello-subtle: rgba(17, 17, 17, .72)}.theme-glass :host,.theme-glass{--bello-surface: rgba(255, 255, 255, .1);--bello-fg: #111;--bello-border: rgba(255, 255, 255, .2);--bello-cta-bg: #111;--bello-cta-fg: #fff;backdrop-filter:blur(10px)}.bello-container{border-radius:var(--bello-radius);border:1px solid var(--bello-border);box-shadow:var(--bello-shadow);padding:var(--bello-gap);background:var(--bello-surface);color:var(--bello-fg)}.bello-title-container{display:flex;flex-direction:column;gap:8px}.bello-card{border-radius:var(--bello-radius);border:1px solid var(--bello-border);background:var(--bello-surface);color:var(--bello-fg)}.bello-trigger{border-radius:var(--bello-radius-pill);padding:10px 18px;font-weight:600;border:none;cursor:pointer;background:var(--bello-cta-bg);color:var(--bello-cta-fg)}.bello-trigger.small{padding:8px 12px;font-size:12px}.bello-trigger:hover{opacity:.9}.bello-trigger-danger{display:flex;align-items:center;gap:6px;border-radius:var(--bello-radius-pill);padding:10px 18px;font-weight:600;border:none;cursor:pointer;background:var(--bello-danger);color:#fff}.bello-trigger-danger.small{padding:8px 12px;font-size:12px}.bello-trigger-danger:hover{opacity:.9}.bello-header{display:flex;align-items:center;gap:var(--bello-gap);padding:var(--bello-gap);border-bottom:1px solid var(--bello-border);justify-content:space-between}.bello-title{font-size:14px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.bello-subtitle{font-size:12px;opacity:.8}.bello-body{position:relative;display:flex;flex-direction:column;height:var(--bello-height);width:var(--bello-width);max-height:80vh}.bello-main{flex:1;overflow:auto;padding:var(--bello-gap)}.bello-fab{position:absolute;z-index:2;width:var(--bello-fab-size-width);height:var(--bello-fab-size-height);border-radius:999px;border:1px solid var(--bello-border);background:var(--bello-cta-bg);color:var(--bello-cta-fg);box-shadow:var(--bello-shadow);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;inset:auto}.bello-fab:hover{opacity:.9}.bello-pop[data-pos=bottom-right]~.bello-fab{right:calc(-1 * var(--bello-fab-gap));bottom:calc(-1 * var(--bello-fab-gap))}.bello-pop[data-pos=bottom-left]~.bello-fab{left:calc(-1 * var(--bello-fab-gap));bottom:calc(-1 * var(--bello-fab-gap))}.bello-pop[data-pos=top-right]~.bello-fab{right:calc(-1 * var(--bello-fab-gap));top:calc(-1 * var(--bello-fab-gap))}.bello-pop[data-pos=top-left]~.bello-fab{left:calc(-1 * var(--bello-fab-gap));top:calc(-1 * var(--bello-fab-gap))}.bello-footer{height:60px;display:flex;align-items:center;justify-content:flex-end;gap:8px;padding:0 var(--bello-gap)}.bello-footer .chat-input-row{width:100%}.bello-pop{position:absolute;transform-origin:bottom right}.bello-pop[data-pos=bottom-right]{bottom:var(--bello-pop-offset);right:0}.bello-pop[data-pos=bottom-left]{bottom:var(--bello-pop-offset);left:0;transform-origin:bottom left}.bello-pop[data-pos=top-right]{top:var(--bello-pop-offset);right:0;transform-origin:top right}.bello-pop[data-pos=top-left]{top:var(--bello-pop-offset);left:0;transform-origin:top left}.bello-row{display:flex;align-items:center;gap:8px}.bello-hero{font-weight:700}.bello-error{border:1px solid var(--bello-danger);padding:var(--bello-gap);border-radius:8px}.bello-error-title{font-weight:700;margin-bottom:4px}.bello-error-text{font-size:12px;opacity:.9}.center{display:flex;align-items:center;justify-content:center;flex-direction:column;gap:8px}.status{font-size:12px;opacity:.8}.chat-wrap{display:flex;flex-direction:column;gap:8px;height:100%}.chat-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}.chat-entry{display:flex;flex-direction:column}.chat-entry.me{align-items:flex-end}.chat-entry.them{align-items:flex-start}.chat-entry .chat-name{font-size:11px;opacity:.7;margin-bottom:2px}.chat-entry.me .chat-name{align-self:flex-end}.chat-entry.them .chat-name{align-self:flex-start}.chat-bubble{max-width:75%;padding:8px 10px;border-radius:10px;border:1px solid var(--bello-border)}.chat-bubble.me{background:#0003}.chat-bubble.them{background:#ffffff0f}.chat-text{display:inline-block}.chat-time{font-size:10px;opacity:.6;margin-left:8px}.chat-input-row{display:flex;gap:8px;align-items:center}.chat-input{flex:1;padding:10px 12px;border-radius:8px;border:1px solid var(--bello-border);background:transparent;color:var(--bello-fg)}.chat-input::placeholder{color:var(--bello-subtle)}';let rn=null,ul=null,yC=null,Ih=null;function nI(t){const e=new WeakSet,n=r=>{var c;if(r instanceof HTMLElement&&r.tagName==="STYLE"&&!e.has(r)){const l=document.createElement("style");l.textContent=(c=r.textContent)!=null?c:"",t.appendChild(l),e.add(r)}};document.head.querySelectorAll("style").forEach(r=>n(r)),new MutationObserver(r=>{for(const c of r)c.addedNodes.forEach(n)}).observe(document.head,{childList:!0})}function bC(t){if(!(!Ih||!t))for(const[e,n]of Object.entries(t))Ih.style.setProperty(e,n)}async function iI(t){var h,p,v,y,S,w,T,x,R,P,L;const e=await Lw(t);rn={agentEnabled:(h=t.agentEnabled)!=null?h:!0,voiceEnabled:(p=t.voiceEnabled)!=null?p:!0,...t,theme:(v=t.theme)!=null?v:e.theme,orbStyle:(y=t.orbStyle)!=null?y:e.orbStyle,position:(S=t.position)!=null?S:e.position,widgetTitle:(w=t.widgetTitle)!=null?w:e.widgetTitle,widgetButtonTitle:(T=t.widgetButtonTitle)!=null?T:e.widgetButtonTitle,themeVars:{...(x=e.themeVars)!=null?x:{},...(R=t.themeVars)!=null?R:{}}};const n=(P=rn.theme)!=null?P:"dark",a=Pw("bello-widget-root");Ih=a;const r=Nw(a);yC=r;const c=document.createElement("style");c.textContent=tI,r.appendChild(c),nI(r),bC(rn.themeVars);const l=document.createElement("div");l.style.position="fixed",l.style.zIndex="2147483647";const u=(L=rn.position)!=null?L:"bottom-right",f={"bottom-right":{bottom:"16px",right:"16px"},"bottom-left":{bottom:"16px",left:"16px"},"top-right":{top:"16px",right:"16px"},"top-left":{top:"16px",left:"16px"}};Object.assign(l.style,f[u]),r.appendChild(l),ul=Ow.createRoot(l),ul.render(oe.jsx(vC,{opts:rn,theme:n,onClose:()=>{}}))}function aI(){var t;!ul||!yC||!rn||(bC(rn.themeVars),ul.render(oe.jsx(vC,{opts:rn,theme:(t=rn.theme)!=null?t:"dark",onClose:()=>{}})))}async function sI(t){typeof window!="undefined"&&await iI(t)}function rI(t){typeof window!="undefined"&&(rn={...rn!=null?rn:{},...t!=null?t:{}},aI())}function oI(t){typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("bello:event",{detail:{type:t}}))}async function cI(t){const[e,n]=t;if(e==="init"){await sI(n);return}if(e==="update"){rI(n!=null?n:{});return}(e==="open"||e==="close")&&oI(e)}const Vs=typeof window!="undefined"?window:globalThis,Uh=Array.isArray(Vs.Bello)?Vs.Bello:[],lI=(TC=(SC=Uh.push)==null?void 0:SC.bind(Uh))!=null?TC:(()=>0);Vs.Bello=Uh,Vs.Bello.push=((...t)=>(t.forEach(cI),lI(...t)));try{window.Bello=Vs.Bello}catch{}(function(){const e=document.currentScript||document.querySelector('script[data-project-id][src*="bello-embed"]');if(!e)return;const n=e.getAttribute("data-project-id")||void 0,a=e.getAttribute("data-api-base-url")||void 0,r=e.getAttribute("data-position"),c=e.getAttribute("data-theme"),l=e.getAttribute("data-orb-style"),u=e.getAttribute("data-agent-enabled"),f=e.getAttribute("data-voice-enabled");n&&Vs.Bello.push(["init",{projectId:n,apiBaseUrl:a,position:r!=null?r:void 0,theme:c!=null?c:void 0,orbStyle:l!=null?l:void 0,agentEnabled:u!=null?u!=="false":void 0,voiceEnabled:f!=null?f!=="false":void 0}])})()}));
|
|
52
|
+
//# sourceMappingURL=bello-embed.umd.cjs.map
|