@byteplus/rtc 4.55.10 → 4.55.12
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/index.esm.min.js +2 -2
- package/index.min.js +2 -2
- package/package.json +2 -2
package/index.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2020 The BytePlusRTC project authors. All Rights Reserved.
|
|
3
3
|
* @brief BytePlusRTC Advance API
|
|
4
|
-
* version: 4.55.
|
|
4
|
+
* version: 4.55.12
|
|
5
5
|
*/
|
|
6
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).BytePlusRTC=t()}(this,(function(){"use strict";function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r=function(e){return e&&e.Math==Math&&e},n=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof t&&t)||function(){return this}()||Function("return this")(),i=function(e){try{return!!e()}catch(t){return!0}},o=!i((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),a=o,s=Function.prototype,c=s.apply,u=s.call,d="object"==typeof Reflect&&Reflect.apply||(a?u.bind(c):function(){return u.apply(c,arguments)}),l=o,h=Function.prototype,v=h.call,_=l&&h.bind.bind(v,v),p=l?_:function(e){return function(){return v.apply(e,arguments)}},f=p,m=f({}.toString),g=f("".slice),y=function(e){return g(m(e),8,-1)},S=y,b=p,E=function(e){if("Function"===S(e))return b(e)},T="object"==typeof document&&document.all,k={all:T,IS_HTMLDDA:void 0===T&&void 0!==T},I=k.all,R=k.IS_HTMLDDA?function(e){return"function"==typeof e||e===I}:function(e){return"function"==typeof e},A={},w=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),C=o,x=Function.prototype.call,O=C?x.bind(x):function(){return x.apply(x,arguments)},N={},D={}.propertyIsEnumerable,P=Object.getOwnPropertyDescriptor,M=P&&!D.call({1:2},1);N.f=M?function(e){var t=P(this,e);return!!t&&t.enumerable}:D;var L,U,V=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},F=i,B=y,j=Object,G=E("".split),H=F((function(){return!j("z").propertyIsEnumerable(0)}))?function(e){return"String"==B(e)?G(e,""):j(e)}:j,z=function(e){return null==e},K=z,X=TypeError,W=function(e){if(K(e))throw X("Can't call method on "+e);return e},q=H,Y=W,J=function(e){return q(Y(e))},Q=R,Z=k.all,$=k.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:Q(e)||e===Z}:function(e){return"object"==typeof e?null!==e:Q(e)},ee={},te=ee,re=n,ne=R,ie=function(e){return ne(e)?e:void 0},oe=function(e,t){return arguments.length<2?ie(te[e])||ie(re[e]):te[e]&&te[e][t]||re[e]&&re[e][t]},ae=E({}.isPrototypeOf),se=oe("navigator","userAgent")||"",ce=n,ue=se,de=ce.process,le=ce.Deno,he=de&&de.versions||le&&le.version,ve=he&&he.v8;ve&&(U=(L=ve.split("."))[0]>0&&L[0]<4?1:+(L[0]+L[1])),!U&&ue&&(!(L=ue.match(/Edge\/(\d+)/))||L[1]>=74)&&(L=ue.match(/Chrome\/(\d+)/))&&(U=+L[1]);var _e=U,pe=_e,fe=i,me=!!Object.getOwnPropertySymbols&&!fe((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&pe&&pe<41})),ge=me&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ye=oe,Se=R,be=ae,Ee=Object,Te=ge?function(e){return"symbol"==typeof e}:function(e){var t=ye("Symbol");return Se(t)&&be(t.prototype,Ee(e))},ke=String,Ie=function(e){try{return ke(e)}catch(t){return"Object"}},Re=R,Ae=Ie,we=TypeError,Ce=function(e){if(Re(e))return e;throw we(Ae(e)+" is not a function")},xe=Ce,Oe=z,Ne=function(e,t){var r=e[t];return Oe(r)?void 0:xe(r)},De=O,Pe=R,Me=$,Le=TypeError,Ue={exports:{}},Ve=n,Fe=Object.defineProperty,Be=function(e,t){try{Fe(Ve,e,{value:t,configurable:!0,writable:!0})}catch(r){Ve[e]=t}return t},je="__core-js_shared__",Ge=n[je]||Be(je,{}),He=Ge;(Ue.exports=function(e,t){return He[e]||(He[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.0",mode:"pure",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.0/LICENSE",source:"https://github.com/zloirock/core-js"});var ze=W,Ke=Object,Xe=function(e){return Ke(ze(e))},We=Xe,qe=E({}.hasOwnProperty),Ye=Object.hasOwn||function(e,t){return qe(We(e),t)},Je=E,Qe=0,Ze=Math.random(),$e=Je(1..toString),et=function(e){return"Symbol("+(void 0===e?"":e)+")_"+$e(++Qe+Ze,36)},tt=n,rt=Ue.exports,nt=Ye,it=et,ot=me,at=ge,st=rt("wks"),ct=tt.Symbol,ut=ct&&ct.for,dt=at?ct:ct&&ct.withoutSetter||it,lt=function(e){if(!nt(st,e)||!ot&&"string"!=typeof st[e]){var t="Symbol."+e;ot&&nt(ct,e)?st[e]=ct[e]:st[e]=at&&ut?ut(t):dt(t)}return st[e]},ht=O,vt=$,_t=Te,pt=Ne,ft=function(e,t){var r,n;if("string"===t&&Pe(r=e.toString)&&!Me(n=De(r,e)))return n;if(Pe(r=e.valueOf)&&!Me(n=De(r,e)))return n;if("string"!==t&&Pe(r=e.toString)&&!Me(n=De(r,e)))return n;throw Le("Can't convert object to primitive value")},mt=TypeError,gt=lt("toPrimitive"),yt=function(e,t){if(!vt(e)||_t(e))return e;var r,n=pt(e,gt);if(n){if(void 0===t&&(t="default"),r=ht(n,e,t),!vt(r)||_t(r))return r;throw mt("Can't convert object to primitive value")}return void 0===t&&(t="number"),ft(e,t)},St=Te,bt=function(e){var t=yt(e,"string");return St(t)?t:t+""},Et=$,Tt=n.document,kt=Et(Tt)&&Et(Tt.createElement),It=function(e){return kt?Tt.createElement(e):{}},Rt=It,At=!w&&!i((function(){return 7!=Object.defineProperty(Rt("div"),"a",{get:function(){return 7}}).a})),wt=w,Ct=O,xt=N,Ot=V,Nt=J,Dt=bt,Pt=Ye,Mt=At,Lt=Object.getOwnPropertyDescriptor;A.f=wt?Lt:function(e,t){if(e=Nt(e),t=Dt(t),Mt)try{return Lt(e,t)}catch(r){}if(Pt(e,t))return Ot(!Ct(xt.f,e,t),e[t])};var Ut=i,Vt=R,Ft=/#|\.prototype\./,Bt=function(e,t){var r=Gt[jt(e)];return r==zt||r!=Ht&&(Vt(t)?Ut(t):!!t)},jt=Bt.normalize=function(e){return String(e).replace(Ft,".").toLowerCase()},Gt=Bt.data={},Ht=Bt.NATIVE="N",zt=Bt.POLYFILL="P",Kt=Bt,Xt=Ce,Wt=o,qt=E(E.bind),Yt=function(e,t){return Xt(e),void 0===t?e:Wt?qt(e,t):function(){return e.apply(t,arguments)}},Jt={},Qt=w&&i((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Zt=$,$t=String,er=TypeError,tr=function(e){if(Zt(e))return e;throw er($t(e)+" is not an object")},rr=w,nr=At,ir=Qt,or=tr,ar=bt,sr=TypeError,cr=Object.defineProperty,ur=Object.getOwnPropertyDescriptor,dr="enumerable",lr="configurable",hr="writable";Jt.f=rr?ir?function(e,t,r){if(or(e),t=ar(t),or(r),"function"==typeof e&&"prototype"===t&&"value"in r&&hr in r&&!r.writable){var n=ur(e,t);n&&n.writable&&(e[t]=r.value,r={configurable:lr in r?r.configurable:n.configurable,enumerable:dr in r?r.enumerable:n.enumerable,writable:!1})}return cr(e,t,r)}:cr:function(e,t,r){if(or(e),t=ar(t),or(r),nr)try{return cr(e,t,r)}catch(n){}if("get"in r||"set"in r)throw sr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var vr=Jt,_r=V,pr=w?function(e,t,r){return vr.f(e,t,_r(1,r))}:function(e,t,r){return e[t]=r,e},fr=n,mr=d,gr=E,yr=R,Sr=A.f,br=Kt,Er=ee,Tr=Yt,kr=pr,Ir=Ye,Rr=function(e){var t=function(r,n,i){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,i)}return mr(e,this,arguments)};return t.prototype=e.prototype,t},Ar=function(e,t){var r,n,i,o,a,s,c,u,d=e.target,l=e.global,h=e.stat,v=e.proto,_=l?fr:h?fr[d]:(fr[d]||{}).prototype,p=l?Er:Er[d]||kr(Er,d,{})[d],f=p.prototype;for(i in t)r=!br(l?i:d+(h?".":"#")+i,e.forced)&&_&&Ir(_,i),a=p[i],r&&(s=e.dontCallGetSet?(u=Sr(_,i))&&u.value:_[i]),o=r&&s?s:t[i],r&&typeof a==typeof o||(c=e.bind&&r?Tr(o,fr):e.wrap&&r?Rr(o):v&&yr(o)?gr(o):o,(e.sham||o&&o.sham||a&&a.sham)&&kr(c,"sham",!0),kr(p,i,c),v&&(Ir(Er,n=d+"Prototype")||kr(Er,n,{}),kr(Er[n],i,o),e.real&&f&&!f[i]&&kr(f,i,o)))},wr=Math.ceil,Cr=Math.floor,xr=Math.trunc||function(e){var t=+e;return(t>0?Cr:wr)(t)},Or=function(e){var t=+e;return t!=t||0===t?0:xr(t)},Nr=Or,Dr=Math.max,Pr=Math.min,Mr=function(e,t){var r=Nr(e);return r<0?Dr(r+t,0):Pr(r,t)},Lr=Or,Ur=Math.min,Vr=function(e){return e>0?Ur(Lr(e),9007199254740991):0},Fr=Vr,Br=function(e){return Fr(e.length)},jr=J,Gr=Mr,Hr=Br,zr=function(e){return function(t,r,n){var i,o=jr(t),a=Hr(o),s=Gr(n,a);if(e&&r!=r){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},Kr={includes:zr(!0),indexOf:zr(!1)},Xr={},Wr=Ye,qr=J,Yr=Kr.indexOf,Jr=Xr,Qr=E([].push),Zr=function(e,t){var r,n=qr(e),i=0,o=[];for(r in n)!Wr(Jr,r)&&Wr(n,r)&&Qr(o,r);for(;t.length>i;)Wr(n,r=t[i++])&&(~Yr(o,r)||Qr(o,r));return o},$r=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],en=Zr,tn=$r,rn=Object.keys||function(e){return en(e,tn)},nn=Xe,on=rn;Ar({target:"Object",stat:!0,forced:i((function(){on(1)}))},{keys:function(e){return on(nn(e))}});var an=ee.Object.keys,sn={};sn[lt("toStringTag")]="z";var cn="[object z]"===String(sn),un=cn,dn=R,ln=y,hn=lt("toStringTag"),vn=Object,_n="Arguments"==ln(function(){return arguments}()),pn=un?ln:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=vn(e),hn))?r:_n?ln(t):"Object"==(n=ln(t))&&dn(t.callee)?"Arguments":n},fn=pn,mn=String,gn=function(e){if("Symbol"===fn(e))throw TypeError("Cannot convert a Symbol value to a string");return mn(e)},yn={},Sn=w,bn=Qt,En=Jt,Tn=tr,kn=J,In=rn;yn.f=Sn&&!bn?Object.defineProperties:function(e,t){Tn(e);for(var r,n=kn(t),i=In(t),o=i.length,a=0;o>a;)En.f(e,r=i[a++],n[r]);return e};var Rn,An=oe("document","documentElement"),wn=Ue.exports,Cn=et,xn=wn("keys"),On=function(e){return xn[e]||(xn[e]=Cn(e))},Nn=tr,Dn=yn,Pn=$r,Mn=Xr,Ln=An,Un=It,Vn=On("IE_PROTO"),Fn=function(){},Bn=function(e){return"<script>"+e+"</"+"script>"},jn=function(e){e.write(Bn("")),e.close();var t=e.parentWindow.Object;return e=null,t},Gn=function(){try{Rn=new ActiveXObject("htmlfile")}catch(n){}var e,t;Gn="undefined"!=typeof document?document.domain&&Rn?jn(Rn):((t=Un("iframe")).style.display="none",Ln.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(Bn("document.F=Object")),e.close(),e.F):jn(Rn);for(var r=Pn.length;r--;)delete Gn.prototype[Pn[r]];return Gn()};Mn[Vn]=!0;var Hn=Object.create||function(e,t){var r;return null!==e?(Fn.prototype=Nn(e),r=new Fn,Fn.prototype=null,r[Vn]=e):r=Gn(),void 0===t?r:Dn.f(r,t)},zn={},Kn=Zr,Xn=$r.concat("length","prototype");zn.f=Object.getOwnPropertyNames||function(e){return Kn(e,Xn)};var Wn={},qn=bt,Yn=Jt,Jn=V,Qn=function(e,t,r){var n=qn(t);n in e?Yn.f(e,n,Jn(0,r)):e[n]=r},Zn=Mr,$n=Br,ei=Qn,ti=Array,ri=Math.max,ni=function(e,t,r){for(var n=$n(e),i=Zn(t,n),o=Zn(void 0===r?n:r,n),a=ti(ri(o-i,0)),s=0;i<o;i++,s++)ei(a,s,e[i]);return a.length=s,a},ii=y,oi=J,ai=zn.f,si=ni,ci="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Wn.f=function(e){return ci&&"Window"==ii(e)?function(e){try{return ai(e)}catch(t){return si(ci)}}(e):ai(oi(e))};var ui={};ui.f=Object.getOwnPropertySymbols;var di=pr,li=function(e,t,r,n){return n&&n.enumerable?e[t]=r:di(e,t,r),e},hi={},vi=lt;hi.f=vi;var _i,pi,fi,mi=ee,gi=Ye,yi=hi,Si=Jt.f,bi=function(e){var t=mi.Symbol||(mi.Symbol={});gi(t,e)||Si(t,e,{value:yi.f(e)})},Ei=O,Ti=oe,ki=lt,Ii=li,Ri=function(){var e=Ti("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=ki("toPrimitive");t&&!t[n]&&Ii(t,n,(function(e){return Ei(r,this)}),{arity:1})},Ai=pn,wi=cn?{}.toString:function(){return"[object "+Ai(this)+"]"},Ci=cn,xi=Jt.f,Oi=pr,Ni=Ye,Di=wi,Pi=lt("toStringTag"),Mi=function(e,t,r,n){if(e){var i=r?e:e.prototype;Ni(i,Pi)||xi(i,Pi,{configurable:!0,value:t}),n&&!Ci&&Oi(i,"toString",Di)}},Li=R,Ui=n.WeakMap,Vi=Li(Ui)&&/native code/.test(String(Ui)),Fi=Vi,Bi=n,ji=$,Gi=pr,Hi=Ye,zi=Ge,Ki=On,Xi=Xr,Wi="Object already initialized",qi=Bi.TypeError,Yi=Bi.WeakMap;if(Fi||zi.state){var Ji=zi.state||(zi.state=new Yi);Ji.get=Ji.get,Ji.has=Ji.has,Ji.set=Ji.set,_i=function(e,t){if(Ji.has(e))throw qi(Wi);return t.facade=e,Ji.set(e,t),t},pi=function(e){return Ji.get(e)||{}},fi=function(e){return Ji.has(e)}}else{var Qi=Ki("state");Xi[Qi]=!0,_i=function(e,t){if(Hi(e,Qi))throw qi(Wi);return t.facade=e,Gi(e,Qi,t),t},pi=function(e){return Hi(e,Qi)?e[Qi]:{}},fi=function(e){return Hi(e,Qi)}}var Zi={set:_i,get:pi,has:fi,enforce:function(e){return fi(e)?pi(e):_i(e,{})},getterFor:function(e){return function(t){var r;if(!ji(t)||(r=pi(t)).type!==e)throw qi("Incompatible receiver, "+e+" required");return r}}},$i=y,eo=Array.isArray||function(e){return"Array"==$i(e)},to=R,ro=Ge,no=E(Function.toString);to(ro.inspectSource)||(ro.inspectSource=function(e){return no(e)});var io=ro.inspectSource,oo=E,ao=i,so=R,co=pn,uo=io,lo=function(){},ho=[],vo=oe("Reflect","construct"),_o=/^\s*(?:class|function)\b/,po=oo(_o.exec),fo=!_o.exec(lo),mo=function(e){if(!so(e))return!1;try{return vo(lo,ho,e),!0}catch(t){return!1}},go=function(e){if(!so(e))return!1;switch(co(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return fo||!!po(_o,uo(e))}catch(t){return!0}};go.sham=!0;var yo=!vo||ao((function(){var e;return mo(mo.call)||!mo(Object)||!mo((function(){e=!0}))||e}))?go:mo,So=eo,bo=yo,Eo=$,To=lt("species"),ko=Array,Io=function(e){var t;return So(e)&&(t=e.constructor,(bo(t)&&(t===ko||So(t.prototype))||Eo(t)&&null===(t=t[To]))&&(t=void 0)),void 0===t?ko:t},Ro=function(e,t){return new(Io(e))(0===t?0:t)},Ao=Yt,wo=H,Co=Xe,xo=Br,Oo=Ro,No=E([].push),Do=function(e){var t=1==e,r=2==e,n=3==e,i=4==e,o=6==e,a=7==e,s=5==e||o;return function(c,u,d,l){for(var h,v,_=Co(c),p=wo(_),f=Ao(u,d),m=xo(p),g=0,y=l||Oo,S=t?y(c,m):r||a?y(c,0):void 0;m>g;g++)if((s||g in p)&&(v=f(h=p[g],g,_),e))if(t)S[g]=v;else if(v)switch(e){case 3:return!0;case 5:return h;case 6:return g;case 2:No(S,h)}else switch(e){case 4:return!1;case 7:No(S,h)}return o?-1:n||i?i:S}},Po={forEach:Do(0),map:Do(1),filter:Do(2),some:Do(3),every:Do(4),find:Do(5),findIndex:Do(6),filterReject:Do(7)},Mo=Ar,Lo=n,Uo=O,Vo=E,Fo=w,Bo=me,jo=i,Go=Ye,Ho=ae,zo=tr,Ko=J,Xo=bt,Wo=gn,qo=V,Yo=Hn,Jo=rn,Qo=zn,Zo=Wn,$o=ui,ea=A,ta=Jt,ra=yn,na=N,ia=li,oa=Ue.exports,aa=Xr,sa=et,ca=lt,ua=hi,da=bi,la=Ri,ha=Mi,va=Zi,_a=Po.forEach,pa=On("hidden"),fa="Symbol",ma=va.set,ga=va.getterFor(fa),ya=Object.prototype,Sa=Lo.Symbol,ba=Sa&&Sa.prototype,Ea=Lo.TypeError,Ta=Lo.QObject,ka=ea.f,Ia=ta.f,Ra=Zo.f,Aa=na.f,wa=Vo([].push),Ca=oa("symbols"),xa=oa("op-symbols"),Oa=oa("wks"),Na=!Ta||!Ta.prototype||!Ta.prototype.findChild,Da=Fo&&jo((function(){return 7!=Yo(Ia({},"a",{get:function(){return Ia(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=ka(ya,t);n&&delete ya[t],Ia(e,t,r),n&&e!==ya&&Ia(ya,t,n)}:Ia,Pa=function(e,t){var r=Ca[e]=Yo(ba);return ma(r,{type:fa,tag:e,description:t}),Fo||(r.description=t),r},Ma=function(e,t,r){e===ya&&Ma(xa,t,r),zo(e);var n=Xo(t);return zo(r),Go(Ca,n)?(r.enumerable?(Go(e,pa)&&e[pa][n]&&(e[pa][n]=!1),r=Yo(r,{enumerable:qo(0,!1)})):(Go(e,pa)||Ia(e,pa,qo(1,{})),e[pa][n]=!0),Da(e,n,r)):Ia(e,n,r)},La=function(e,t){zo(e);var r=Ko(t),n=Jo(r).concat(Ba(r));return _a(n,(function(t){Fo&&!Uo(Ua,r,t)||Ma(e,t,r[t])})),e},Ua=function(e){var t=Xo(e),r=Uo(Aa,this,t);return!(this===ya&&Go(Ca,t)&&!Go(xa,t))&&(!(r||!Go(this,t)||!Go(Ca,t)||Go(this,pa)&&this[pa][t])||r)},Va=function(e,t){var r=Ko(e),n=Xo(t);if(r!==ya||!Go(Ca,n)||Go(xa,n)){var i=ka(r,n);return!i||!Go(Ca,n)||Go(r,pa)&&r[pa][n]||(i.enumerable=!0),i}},Fa=function(e){var t=Ra(Ko(e)),r=[];return _a(t,(function(e){Go(Ca,e)||Go(aa,e)||wa(r,e)})),r},Ba=function(e){var t=e===ya,r=Ra(t?xa:Ko(e)),n=[];return _a(r,(function(e){!Go(Ca,e)||t&&!Go(ya,e)||wa(n,Ca[e])})),n};Bo||(Sa=function(){if(Ho(ba,this))throw Ea("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Wo(arguments[0]):void 0,t=sa(e),r=function(e){this===ya&&Uo(r,xa,e),Go(this,pa)&&Go(this[pa],t)&&(this[pa][t]=!1),Da(this,t,qo(1,e))};return Fo&&Na&&Da(ya,t,{configurable:!0,set:r}),Pa(t,e)},ia(ba=Sa.prototype,"toString",(function(){return ga(this).tag})),ia(Sa,"withoutSetter",(function(e){return Pa(sa(e),e)})),na.f=Ua,ta.f=Ma,ra.f=La,ea.f=Va,Qo.f=Zo.f=Fa,$o.f=Ba,ua.f=function(e){return Pa(ca(e),e)},Fo&&Ia(ba,"description",{configurable:!0,get:function(){return ga(this).description}})),Mo({global:!0,constructor:!0,wrap:!0,forced:!Bo,sham:!Bo},{Symbol:Sa}),_a(Jo(Oa),(function(e){da(e)})),Mo({target:fa,stat:!0,forced:!Bo},{useSetter:function(){Na=!0},useSimple:function(){Na=!1}}),Mo({target:"Object",stat:!0,forced:!Bo,sham:!Fo},{create:function(e,t){return void 0===t?Yo(e):La(Yo(e),t)},defineProperty:Ma,defineProperties:La,getOwnPropertyDescriptor:Va}),Mo({target:"Object",stat:!0,forced:!Bo},{getOwnPropertyNames:Fa}),la(),ha(Sa,fa),aa[pa]=!0;var ja=me&&!!Symbol.for&&!!Symbol.keyFor,Ga=Ar,Ha=oe,za=Ye,Ka=gn,Xa=Ue.exports,Wa=ja,qa=Xa("string-to-symbol-registry"),Ya=Xa("symbol-to-string-registry");Ga({target:"Symbol",stat:!0,forced:!Wa},{for:function(e){var t=Ka(e);if(za(qa,t))return qa[t];var r=Ha("Symbol")(t);return qa[t]=r,Ya[r]=t,r}});var Ja=Ar,Qa=Ye,Za=Te,$a=Ie,es=ja,ts=(0,Ue.exports)("symbol-to-string-registry");Ja({target:"Symbol",stat:!0,forced:!es},{keyFor:function(e){if(!Za(e))throw TypeError($a(e)+" is not a symbol");if(Qa(ts,e))return ts[e]}});var rs=E([].slice),ns=Ar,is=oe,os=d,as=O,ss=E,cs=i,us=eo,ds=R,ls=$,hs=Te,vs=rs,_s=me,ps=is("JSON","stringify"),fs=ss(/./.exec),ms=ss("".charAt),gs=ss("".charCodeAt),ys=ss("".replace),Ss=ss(1..toString),bs=/[\uD800-\uDFFF]/g,Es=/^[\uD800-\uDBFF]$/,Ts=/^[\uDC00-\uDFFF]$/,ks=!_s||cs((function(){var e=is("Symbol")();return"[null]"!=ps([e])||"{}"!=ps({a:e})||"{}"!=ps(Object(e))})),Is=cs((function(){return'"\\udf06\\ud834"'!==ps("\udf06\ud834")||'"\\udead"'!==ps("\udead")})),Rs=function(e,t){var r=vs(arguments),n=t;if((ls(t)||void 0!==e)&&!hs(e))return us(t)||(t=function(e,t){if(ds(n)&&(t=as(n,this,e,t)),!hs(t))return t}),r[1]=t,os(ps,null,r)},As=function(e,t,r){var n=ms(r,t-1),i=ms(r,t+1);return fs(Es,e)&&!fs(Ts,i)||fs(Ts,e)&&!fs(Es,n)?"\\u"+Ss(gs(e,0),16):e};ps&&ns({target:"JSON",stat:!0,arity:3,forced:ks||Is},{stringify:function(e,t,r){var n=vs(arguments),i=os(ks?Rs:ps,null,n);return Is&&"string"==typeof i?ys(i,bs,As):i}});var ws=ui,Cs=Xe;Ar({target:"Object",stat:!0,forced:!me||i((function(){ws.f(1)}))},{getOwnPropertySymbols:function(e){var t=ws.f;return t?t(Cs(e)):[]}});var xs=ee.Object.getOwnPropertySymbols,Os=i,Ns=_e,Ds=lt("species"),Ps=function(e){return Ns>=51||!Os((function(){var t=[];return(t.constructor={})[Ds]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Ms=Po.filter;Ar({target:"Array",proto:!0,forced:!Ps("filter")},{filter:function(e){return Ms(this,e,arguments.length>1?arguments[1]:void 0)}});var Ls=ee,Us=function(e){return Ls[e+"Prototype"]},Vs=Us("Array").filter,Fs=ae,Bs=Vs,js=Array.prototype,Gs=function(e){var t=e.filter;return e===js||Fs(js,e)&&t===js.filter?Bs:t},Hs={exports:{}},zs=Ar,Ks=i,Xs=J,Ws=A.f,qs=w,Ys=Ks((function(){Ws(1)}));zs({target:"Object",stat:!0,forced:!qs||Ys,sham:!qs},{getOwnPropertyDescriptor:function(e,t){return Ws(Xs(e),t)}});var Js=ee.Object,Qs=Hs.exports=function(e,t){return Js.getOwnPropertyDescriptor(e,t)};Js.getOwnPropertyDescriptor.sham&&(Qs.sham=!0);var Zs,$s,ec,tc=Hs.exports,rc={},nc=w,ic=Ye,oc=Function.prototype,ac=nc&&Object.getOwnPropertyDescriptor,sc=ic(oc,"name"),cc={EXISTS:sc,PROPER:sc&&"something"===function(){}.name,CONFIGURABLE:sc&&(!nc||nc&&ac(oc,"name").configurable)},uc=!i((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),dc=Ye,lc=R,hc=Xe,vc=uc,_c=On("IE_PROTO"),pc=Object,fc=pc.prototype,mc=vc?pc.getPrototypeOf:function(e){var t=hc(e);if(dc(t,_c))return t[_c];var r=t.constructor;return lc(r)&&t instanceof r?r.prototype:t instanceof pc?fc:null},gc=i,yc=R,Sc=$,bc=Hn,Ec=mc,Tc=li,kc=lt("iterator"),Ic=!1;[].keys&&("next"in(ec=[].keys())?($s=Ec(Ec(ec)))!==Object.prototype&&(Zs=$s):Ic=!0);var Rc=!Sc(Zs)||gc((function(){var e={};return Zs[kc].call(e)!==e}));yc((Zs=Rc?{}:bc(Zs))[kc])||Tc(Zs,kc,(function(){return this}));var Ac={IteratorPrototype:Zs,BUGGY_SAFARI_ITERATORS:Ic},wc=Ac.IteratorPrototype,Cc=Hn,xc=V,Oc=Mi,Nc=rc,Dc=function(){return this},Pc=function(e,t,r,n){var i=t+" Iterator";return e.prototype=Cc(wc,{next:xc(+!n,r)}),Oc(e,i,!1,!0),Nc[i]=Dc,e},Mc=R,Lc=String,Uc=TypeError,Vc=E,Fc=tr,Bc=function(e){if("object"==typeof e||Mc(e))return e;throw Uc("Can't set "+Lc(e)+" as a prototype")},jc=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=Vc(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),t=r instanceof Array}catch(n){}return function(r,n){return Fc(r),Bc(n),t?e(r,n):r.__proto__=n,r}}():void 0),Gc=Ar,Hc=O,zc=cc,Kc=Pc,Xc=mc,Wc=Mi,qc=li,Yc=rc,Jc=Ac,Qc=zc.PROPER,Zc=Jc.BUGGY_SAFARI_ITERATORS,$c=lt("iterator"),eu="keys",tu="values",ru="entries",nu=function(){return this},iu=function(e,t,r,n,i,o,a){Kc(r,t,n);var s,c,u,d=function(e){if(e===i&&p)return p;if(!Zc&&e in v)return v[e];switch(e){case eu:case tu:case ru:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,v=e.prototype,_=v[$c]||v["@@iterator"]||i&&v[i],p=!Zc&&_||d(i),f="Array"==t&&v.entries||_;if(f&&(s=Xc(f.call(new e)))!==Object.prototype&&s.next&&(Wc(s,l,!0,!0),Yc[l]=nu),Qc&&i==tu&&_&&_.name!==tu&&(h=!0,p=function(){return Hc(_,this)}),i)if(c={values:d(tu),keys:o?p:d(eu),entries:d(ru)},a)for(u in c)(Zc||h||!(u in v))&&qc(v,u,c[u]);else Gc({target:t,proto:!0,forced:Zc||h},c);return a&&v[$c]!==p&&qc(v,$c,p,{name:i}),Yc[t]=p,c},ou=function(e,t){return{value:e,done:t}},au=J,su=function(){},cu=rc,uu=Zi,du=(Jt.f,iu),lu=ou,hu="Array Iterator",vu=uu.set,_u=uu.getterFor(hu);du(Array,"Array",(function(e,t){vu(this,{type:hu,target:au(e),index:0,kind:t})}),(function(){var e=_u(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,lu(void 0,!0)):lu("keys"==r?n:"values"==r?t[n]:[n,t[n]],!1)}),"values");cu.Arguments=cu.Array;su(),su(),su();var pu={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},fu=n,mu=pn,gu=pr,yu=rc,Su=lt("toStringTag");for(var bu in pu){var Eu=fu[bu],Tu=Eu&&Eu.prototype;Tu&&mu(Tu)!==Su&&gu(Tu,Su,bu),yu[bu]=yu.Array}var ku=i,Iu=function(e,t){var r=[][e];return!!r&&ku((function(){r.call(null,t||function(){return 1},1)}))},Ru=Po.forEach,Au=Iu("forEach")?[].forEach:function(e){return Ru(this,e,arguments.length>1?arguments[1]:void 0)};Ar({target:"Array",proto:!0,forced:[].forEach!=Au},{forEach:Au});var wu=Us("Array").forEach,Cu=pn,xu=Ye,Ou=ae,Nu=wu,Du=Array.prototype,Pu={DOMTokenList:!0,NodeList:!0},Mu=function(e){var t=e.forEach;return e===Du||Ou(Du,e)&&t===Du.forEach||xu(Pu,Cu(e))?Nu:t},Lu=oe,Uu=zn,Vu=ui,Fu=tr,Bu=E([].concat),ju=Lu("Reflect","ownKeys")||function(e){var t=Uu.f(Fu(e)),r=Vu.f;return r?Bu(t,r(e)):t},Gu=ju,Hu=J,zu=A,Ku=Qn;Ar({target:"Object",stat:!0,sham:!w},{getOwnPropertyDescriptors:function(e){for(var t,r,n=Hu(e),i=zu.f,o=Gu(n),a={},s=0;o.length>s;)void 0!==(r=i(n,t=o[s++]))&&Ku(a,t,r);return a}});var Xu=ee.Object.getOwnPropertyDescriptors,Wu={exports:{}},qu=Ar,Yu=w,Ju=yn.f;qu({target:"Object",stat:!0,forced:Object.defineProperties!==Ju,sham:!Yu},{defineProperties:Ju});var Qu=ee.Object,Zu=Wu.exports=function(e,t){return Qu.defineProperties(e,t)};Qu.defineProperties.sham&&(Zu.sham=!0);var $u=Wu.exports,ed={exports:{}},td=Ar,rd=w,nd=Jt.f;td({target:"Object",stat:!0,forced:Object.defineProperty!==nd,sham:!rd},{defineProperty:nd});var id=ee.Object,od=ed.exports=function(e,t,r){return id.defineProperty(e,t,r)};id.defineProperty.sham&&(od.sham=!0);var ad=ed.exports,sd=TypeError,cd=function(e){if(e>9007199254740991)throw sd("Maximum allowed index exceeded");return e},ud=Ar,dd=i,ld=eo,hd=$,vd=Xe,_d=Br,pd=cd,fd=Qn,md=Ro,gd=Ps,yd=_e,Sd=lt("isConcatSpreadable"),bd=yd>=51||!dd((function(){var e=[];return e[Sd]=!1,e.concat()[0]!==e})),Ed=gd("concat"),Td=function(e){if(!hd(e))return!1;var t=e[Sd];return void 0!==t?!!t:ld(e)};ud({target:"Array",proto:!0,arity:1,forced:!bd||!Ed},{concat:function(e){var t,r,n,i,o,a=vd(this),s=md(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(Td(o=-1===t?a:arguments[t]))for(i=_d(o),pd(c+i),r=0;r<i;r++,c++)r in o&&fd(s,c,o[r]);else pd(c+1),fd(s,c++,o);return s.length=c,s}}),bi("asyncIterator"),bi("hasInstance"),bi("isConcatSpreadable"),bi("iterator"),bi("match"),bi("matchAll"),bi("replace"),bi("search"),bi("species"),bi("split");var kd=Ri;bi("toPrimitive"),kd();var Id=oe,Rd=Mi;bi("toStringTag"),Rd(Id("Symbol"),"Symbol"),bi("unscopables"),Mi(n.JSON,"JSON",!0);var Ad=ee.Symbol;bi("asyncDispose"),bi("dispose"),bi("matcher"),bi("metadataKey"),bi("observable"),bi("metadata"),bi("patternMatch"),bi("replaceAll");var wd=Ad,Cd=E,xd=Or,Od=gn,Nd=W,Dd=Cd("".charAt),Pd=Cd("".charCodeAt),Md=Cd("".slice),Ld=function(e){return function(t,r){var n,i,o=Od(Nd(t)),a=xd(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=Pd(o,a))<55296||n>56319||a+1===s||(i=Pd(o,a+1))<56320||i>57343?e?Dd(o,a):n:e?Md(o,a,a+2):i-56320+(n-55296<<10)+65536}},Ud={codeAt:Ld(!1),charAt:Ld(!0)},Vd=Ud.charAt,Fd=gn,Bd=Zi,jd=iu,Gd=ou,Hd="String Iterator",zd=Bd.set,Kd=Bd.getterFor(Hd);jd(String,"String",(function(e){zd(this,{type:Hd,string:Fd(e),index:0})}),(function(){var e,t=Kd(this),r=t.string,n=t.index;return n>=r.length?Gd(void 0,!0):(e=Vd(r,n),t.index+=e.length,Gd(e,!1))}));var Xd=hi.f("iterator");function Wd(e){return(Wd="function"==typeof wd&&"symbol"==typeof Xd?function(e){return typeof e}:function(e){return e&&"function"==typeof wd&&e.constructor===wd&&e!==wd.prototype?"symbol":typeof e})(e)}var qd=hi.f("toPrimitive");function Yd(e){var t=function(e,t){if("object"!==Wd(e)||null===e)return e;var r=e[qd];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==Wd(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Wd(t)?t:String(t)}function Jd(e,t,r){return(t=Yd(t))in e?ad(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Qd(e,t){var r=an(e);if(xs){var n=xs(e);t&&(n=Gs(n).call(n,(function(t){return tc(e,t).enumerable}))),r.push.apply(r,n)}return r}function Zd(e){for(var t=1;t<arguments.length;t++){var r,n,i=null!=arguments[t]?arguments[t]:{};t%2?Mu(r=Qd(Object(i),!0)).call(r,(function(t){Jd(e,t,i[t])})):Xu?$u(e,Xu(i)):Mu(n=Qd(Object(i))).call(n,(function(t){ad(e,t,tc(i,t))}))}return e}var $d=function(e){return e[e.VIDEO_SOURCE_TYPE_EXTERNAL=0]="VIDEO_SOURCE_TYPE_EXTERNAL",e[e.VIDEO_SOURCE_TYPE_INTERNAL=1]="VIDEO_SOURCE_TYPE_INTERNAL",e}($d||{}),el=function(e){return e[e.AUDIO_SOURCE_TYPE_EXTERNAL=0]="AUDIO_SOURCE_TYPE_EXTERNAL",e[e.AUDIO_SOURCE_TYPE_INTERNAL=1]="AUDIO_SOURCE_TYPE_INTERNAL",e}(el||{}),tl=function(e){return e[e.QUIT=0]="QUIT",e[e.DROPPED=1]="DROPPED",e[e.SWITCH_TO_INVISIBLE=2]="SWITCH_TO_INVISIBLE",e[e.KICKED_BY_ADMIN=3]="KICKED_BY_ADMIN",e}(tl||{}),rl=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(rl||{}),nl=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(nl||{}),il=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(il||{}),ol=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(ol||{}),al=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(al||{}),sl=function(e){return e[e.RENDER_MODE_HIDDEN=0]="RENDER_MODE_HIDDEN",e[e.RENDER_MODE_FIT=1]="RENDER_MODE_FIT",e[e.RENDER_MODE_FILL=2]="RENDER_MODE_FILL",e}(sl||{}),cl=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(cl||{}),ul=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(ul||{}),dl=function(e){return e[e.STREAM_REMOVE_REASON_UNPUBLISH=0]="STREAM_REMOVE_REASON_UNPUBLISH",e[e.STREAM_REMOVE_REASON_PUBLISH_FAILED=1]="STREAM_REMOVE_REASON_PUBLISH_FAILED",e[e.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED=2]="STREAM_REMOVE_REASON_KEEP_LIVE_FAILED",e[e.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED=3]="STREAM_REMOVE_REASON_CLIENT_DISCONNECTED",e[e.STREAM_REMOVE_REASON_REPUBLISH=4]="STREAM_REMOVE_REASON_REPUBLISH",e[e.STREAM_REMOVE_REASON_OTHER=5]="STREAM_REMOVE_REASON_OTHER",e}(dl||{}),ll=function(e){return e[e.CONNECTION_START=0]="CONNECTION_START",e[e.CONNECTION_STATE_DISCONNECTED=1]="CONNECTION_STATE_DISCONNECTED",e[e.CONNECTION_STATE_CONNECTING=2]="CONNECTION_STATE_CONNECTING",e[e.CONNECTION_STATE_CONNECTED=3]="CONNECTION_STATE_CONNECTED",e[e.CONNECTION_STATE_RECONNECTING=4]="CONNECTION_STATE_RECONNECTING",e[e.CONNECTION_STATE_RECONNECTED=5]="CONNECTION_STATE_RECONNECTED",e[e.CONNECTION_STATE_LOST=6]="CONNECTION_STATE_LOST",e}(ll||{}),hl=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(hl||{}),vl=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(vl||{}),_l=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(_l||{}),pl=function(e){return e[e.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",e[e.AUDIO_ONLY=1]="AUDIO_ONLY",e[e.VIDEO_ONLY=2]="VIDEO_ONLY",e}(pl||{}),fl=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(fl||{}),ml=function(e){return e[e.DISABLE=0]="DISABLE",e[e.VIDEO_STREAM_LOW=1]="VIDEO_STREAM_LOW",e[e.AUDIO_ONLY=2]="AUDIO_ONLY",e}(ml||{}),gl=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(gl||{}),yl=function(e){return e[e.UNKNOWN=0]="UNKNOWN",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.POOR=3]="POOR",e[e.BAD=4]="BAD",e[e.VBAD=5]="VBAD",e[e.DOWN=6]="DOWN",e}(yl||{}),Sl=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(Sl||{}),bl=function(e){return e[e.communication=0]="communication",e[e.chat=5]="chat",e[e.chatRoom=6]="chatRoom",e[e.coHost=9]="coHost",e[e.meeting=16]="meeting",e[e.classRoom=18]="classRoom",e}(bl||{}),El=function(e){return e[e.default=0]="default",e[e.fluent=1]="fluent",e[e.standard=2]="standard",e[e.hd=3]="hd",e[e.standardStereo=4]="standardStereo",e[e.hdMono=5]="hdMono",e}(El||{}),Tl=function(e){return e[e.AUTO_PLAY=0]="AUTO_PLAY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.PLAY_MANUALLY=2]="PLAY_MANUALLY",e}(Tl||{}),kl=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(kl||{}),Il=function(e){return e.H264="H264",e.H265="H265",e}(Il||{}),Rl=function(e){return e[e.ASR_ONLY=0]="ASR_ONLY",e[e.ASR_AND_TRANSLATION=1]="ASR_AND_TRANSLATION",e}(Rl||{}),Al=function(e){return e[e.STARTED=0]="STARTED",e[e.STOPPED=1]="STOPPED",e[e.ERROR=2]="ERROR",e}(Al||{}),wl=function(e){return e[e.FORWARD_STREAM_STATE_SUCCESS=0]="FORWARD_STREAM_STATE_SUCCESS",e[e.FORWARD_STREAM_STATE_FAILURE=1]="FORWARD_STREAM_STATE_FAILURE",e}(wl||{}),Cl=function(e){return e[e.FORWARD_STREAM_ERROR_OK=0]="FORWARD_STREAM_ERROR_OK",e[e.FORWARD_STREAM_ERROR_INVALID_TOKEN=1202]="FORWARD_STREAM_ERROR_INVALID_TOKEN",e[e.FORWARD_STREAM_ERROR_RESPONSE=1203]="FORWARD_STREAM_ERROR_RESPONSE",e[e.FORWARD_STREAM_ERROR_REMOTE_KICKED=1204]="FORWARD_STREAM_ERROR_REMOTE_KICKED",e[e.FORWARD_STREAM_ERROR_NOT_SUPPORT=1205]="FORWARD_STREAM_ERROR_NOT_SUPPORT",e}(Cl||{}),xl=Object.freeze(Object.defineProperty({__proto__:null,VideoSourceType:$d,AudioSourceType:el,UserOfflineReason:tl,ChannelProfile:rl,SubscribeMode:nl,SubscribeState:il,PublishState:ol,MirrorMode:al,VideoRenderMode:sl,StreamIndex:cl,MediaType:ul,StreamRemoveReason:dl,ConnectionState:ll,MirrorType:hl,LogChannel:vl,USER_ONLINE_STATUS:_l,PublicStreamType:pl,PublicInterpolationMode:fl,SubscribeFallbackOption:ml,RemoteUserPriority:gl,NetworkQuality:yl,FallbackOrRecoverReason:Sl,RoomProfileType:bl,AudioProfileType:El,RTCAutoPlayPolicy:Tl,AAC_PROFILE:kl,TRANSCODING_VIDEO_CODEC:Il,SUBTITLE_MODE:Rl,SubtitleEventType:Al,ForwardStreamState:wl,ForwardStreamError:Cl},Symbol.toStringTag,{value:"Module"})),Ol=function(e){return e[e.AUTO=0]="AUTO",e[e.MODE_L=1]="MODE_L",e[e.MODE_R=2]="MODE_R",e[e.MODE_MIX=3]="MODE_MIX",e}(Ol||{}),Nl=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(Nl||{}),Dl=function(e){return e[e.AUDIO_MIXING_STATE_PRELOADED=0]="AUDIO_MIXING_STATE_PRELOADED",e[e.AUDIO_MIXING_STATE_PLAYING=1]="AUDIO_MIXING_STATE_PLAYING",e[e.AUDIO_MIXING_STATE_PAUSED=2]="AUDIO_MIXING_STATE_PAUSED",e[e.AUDIO_MIXING_STATE_STOPPED=3]="AUDIO_MIXING_STATE_STOPPED",e[e.AUDIO_MIXING_STATE_FAILED=4]="AUDIO_MIXING_STATE_FAILED",e[e.AUDIO_MIXING_STATE_FINISHED=5]="AUDIO_MIXING_STATE_FINISHED",e[e.AUDIO_MIXING_STATE_PCM_ENABLED=6]="AUDIO_MIXING_STATE_PCM_ENABLED",e[e.AUDIO_MIXING_STATE_PCM_DISABLED=7]="AUDIO_MIXING_STATE_PCM_DISABLED",e}(Dl||{}),Pl=Object.freeze(Object.defineProperty({__proto__:null,AudioMixingDualMonoMode:Ol,AudioMixingType:Nl,AudioMixingState:Dl},Symbol.toStringTag,{value:"Module"})),Ml=function(e){return e.onTrackEnded="onTrackEnded",e.onTrackMute="onTrackMute",e.onTrackUnmute="onTrackUnmute",e.onPlayerEvent="onPlayerEvent",e.onAutoplayFailed="onAutoplayFailed",e.onUserJoined="onUserJoined",e.onUserLeave="onUserLeave",e.onConnectionStateChanged="onConnectionStateChanged",e.onUserPublishStream="onUserPublishStream",e.onUserUnpublishStream="onUserUnpublishStream",e.onUserPublishScreen="onUserPublishScreen",e.onUserUnpublishScreen="onUserUnpublishScreen",e.onRoomMessageReceived="onRoomMessageReceived",e.onRoomBinaryMessageReceived="onRoomBinaryMessageReceived",e.onUserMessageReceived="onUserMessageReceived",e.onUserBinaryMessageReceived="onUserBinaryMessageReceived",e.onVideoFirstFrameRendered="onVideoFirstFrameRendered",e.onVideoFirstFrameDecoded="onVideoFirstFrameDecoded",e.onRemoteVideoFirstFrame="onRemoteVideoFirstFrame",e.onAudioFirstFrameDecoded="onAudioFirstFrameDecoded",e.onRemoteAudioFirstFrame="onRemoteAudioFirstFrame",e.onFirstPublicStreamVideoFrameRendered="onFirstPublicStreamVideoFrameRendered",e.onFirstPublicStreamVideoFrameDecoded="onFirstPublicStreamVideoFrameDecoded",e.onFirstPublicStreamAudioFrameDecoded="onFirstPublicStreamAudioFrameDecoded",e.onVideoDeviceStateChanged="onVideoDeviceStateChanged",e.onAudioDeviceStateChanged="onAudioDeviceStateChanged",e.onRemoteStreamStats="onRemoteStreamStats",e.onPublicStreamStats="onPublicStreamStats",e.onLocalStreamStats="onLocalStreamStats",e.onAudioVolumeIndication="onAudioVolumeIndication",e.onLocalAudioPropertiesReport="onLocalAudioPropertiesReport",e.onRemoteAudioPropertiesReport="onRemoteAudioPropertiesReport",e.onActiveSpeaker="onActiveSpeaker",e.onAudioPlaybackDeviceChanged="onAudioPlaybackDeviceChanged",e.onUserStartVideoCapture="onUserStartVideoCapture",e.onUserStopVideoCapture="onUserStopVideoCapture",e.onUserStartAudioCapture="onUserStartAudioCapture",e.onUserStopAudioCapture="onUserStopAudioCapture",e.onAutoPublishResult="onAutoPublishResult",e.onAutoSubscribeResult="onAutoSubscribeResult",e.onLiveTranscodingResult="onLiveTranscodingResult",e.onStreamMixingEvent="onStreamMixingEvent",e.onAudioPlaybackDeviceTestVolume="onAudioPlaybackDeviceTestVolume",e.onSEIMessageReceived="onSEIMessageReceived",e.onError="onError",e.onAudioMixingStateChanged="onAudioMixingStateChanged",e.onUserMessageReceivedOutsideRoom="onUserMessageReceivedOutsideRoom",e.onUserBinaryMessageReceivedOutsideRoom="onUserBinaryMessageReceivedOutsideRoom",e.onTokenWillExpire="onTokenWillExpire",e.onCloudProxyConnected="onCloudProxyConnected",e.onPushPublicStreamResult="onPushPublicStreamResult",e.onPublicStreamSEIMessageReceived="onPublicStreamSEIMessageReceived",e.onNetworkQuality="onNetworkQuality",e.onSimulcastSubscribeFallback="onSimulcastSubscribeFallback",e.onRemoteVideoSizeChanged="onRemoteVideoSizeChanged",e.onVideoStreamBanned="onVideoStreamBanned",e.onAudioStreamBanned="onAudioStreamBanned",e.onLocalVideoSizeChanged="onLocalVideoSizeChanged",e.onSubtitleStateChanged="onSubtitleStateChanged",e.onSubtitleMessageReceived="onSubtitleMessageReceived",e.onServerParamsSetResult="onServerParamsSetResult",e.onLocalStreamTrackChangedByExtension="onLocalStreamTrackChangedByExtension",e.onVendorConnectionStateChanged="onVendorConnectionStateChanged",e.onForwardStreamError="onForwardStreamError",e.onRejoinWithTcp="onRejoinWithTcp",e.onIceConnectWithTcp="onIceConnectWithTcp",e}(Ml||{});function Ll(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),ad(e,Yd(n.key),n)}}function Ul(e,t,r){return t&&Ll(e.prototype,t),r&&Ll(e,r),ad(e,"prototype",{writable:!1}),e}function Vl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Ar({target:"Object",stat:!0,sham:!w},{create:Hn});var Fl=ee.Object,Bl=function(e,t){return Fl.create(e,t)},jl=Xe,Gl=mc,Hl=uc;Ar({target:"Object",stat:!0,forced:i((function(){Gl(1)})),sham:!Hl},{getPrototypeOf:function(e){return Gl(jl(e))}});var zl=ee.Object.getPrototypeOf;Ar({target:"Object",stat:!0},{setPrototypeOf:jc});var Kl=ee.Object.setPrototypeOf,Xl=Ye,Wl=ju,ql=A,Yl=Jt,Jl=Error,Ql=E("".replace),Zl=String(Jl("zxcasd").stack),$l=/\n\s*at [^:]*:[^\n]*/,eh=$l.test(Zl),th=$,rh=pr,nh=rc,ih=lt("iterator"),oh=Array.prototype,ah=function(e){return void 0!==e&&(nh.Array===e||oh[ih]===e)},sh=pn,ch=Ne,uh=z,dh=rc,lh=lt("iterator"),hh=function(e){if(!uh(e))return ch(e,lh)||ch(e,"@@iterator")||dh[sh(e)]},vh=O,_h=Ce,ph=tr,fh=Ie,mh=hh,gh=TypeError,yh=function(e,t){var r=arguments.length<2?mh(e):t;if(_h(r))return ph(vh(r,e));throw gh(fh(e)+" is not iterable")},Sh=O,bh=tr,Eh=Ne,Th=function(e,t,r){var n,i;bh(e);try{if(!(n=Eh(e,"return"))){if("throw"===t)throw r;return r}n=Sh(n,e)}catch(o){i=!0,n=o}if("throw"===t)throw r;if(i)throw n;return bh(n),r},kh=Yt,Ih=O,Rh=tr,Ah=Ie,wh=ah,Ch=Br,xh=ae,Oh=yh,Nh=hh,Dh=Th,Ph=TypeError,Mh=function(e,t){this.stopped=e,this.result=t},Lh=Mh.prototype,Uh=function(e,t,r){var n,i,o,a,s,c,u,d=r&&r.that,l=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),v=!(!r||!r.IS_ITERATOR),_=!(!r||!r.INTERRUPTED),p=kh(t,d),f=function(e){return n&&Dh(n,"normal",e),new Mh(!0,e)},m=function(e){return l?(Rh(e),_?p(e[0],e[1],f):p(e[0],e[1])):_?p(e,f):p(e)};if(h)n=e.iterator;else if(v)n=e;else{if(!(i=Nh(e)))throw Ph(Ah(e)+" is not iterable");if(wh(i)){for(o=0,a=Ch(e);a>o;o++)if((s=m(e[o]))&&xh(Lh,s))return s;return new Mh(!1)}n=Oh(e,i)}for(c=h?e.next:n.next;!(u=Ih(c,n)).done;){try{s=m(u.value)}catch(g){Dh(n,"throw",g)}if("object"==typeof s&&s&&xh(Lh,s))return s}return new Mh(!1)},Vh=gn,Fh=V,Bh=!i((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",Fh(1,7)),7!==e.stack)})),jh=Ar,Gh=ae,Hh=mc,zh=jc,Kh=function(e,t,r){for(var n=Wl(t),i=Yl.f,o=ql.f,a=0;a<n.length;a++){var s=n[a];Xl(e,s)||r&&Xl(r,s)||i(e,s,o(t,s))}},Xh=Hn,Wh=pr,qh=V,Yh=function(e,t){if(eh&&"string"==typeof e&&!Jl.prepareStackTrace)for(;t--;)e=Ql(e,$l,"");return e},Jh=function(e,t){th(t)&&"cause"in t&&rh(e,"cause",t.cause)},Qh=Uh,Zh=function(e,t){return void 0===e?arguments.length<2?"":t:Vh(e)},$h=Bh,ev=lt("toStringTag"),tv=Error,rv=[].push,nv=function(e,t){var r,n=arguments.length>2?arguments[2]:void 0,i=Gh(iv,this);zh?r=zh(tv(),i?Hh(this):iv):(r=i?this:Xh(iv),Wh(r,ev,"Error")),void 0!==t&&Wh(r,"message",Zh(t)),$h&&Wh(r,"stack",Yh(r.stack,1)),Jh(r,n);var o=[];return Qh(e,rv,{that:o}),Wh(r,"errors",o),r};zh?zh(nv,tv):Kh(nv,tv,{name:!0});var iv=nv.prototype=Xh(tv.prototype,{constructor:qh(1,nv),message:qh(1,""),name:qh(1,"AggregateError")});jh({global:!0,constructor:!0,arity:2},{AggregateError:nv});var ov,av,sv,cv,uv="process"==y(n.process),dv=oe,lv=Jt,hv=w,vv=lt("species"),_v=function(e){var t=dv(e),r=lv.f;hv&&t&&!t[vv]&&r(t,vv,{configurable:!0,get:function(){return this}})},pv=ae,fv=TypeError,mv=function(e,t){if(pv(t,e))return e;throw fv("Incorrect invocation")},gv=yo,yv=Ie,Sv=TypeError,bv=function(e){if(gv(e))return e;throw Sv(yv(e)+" is not a constructor")},Ev=tr,Tv=bv,kv=z,Iv=lt("species"),Rv=function(e,t){var r,n=Ev(e).constructor;return void 0===n||kv(r=Ev(n)[Iv])?t:Tv(r)},Av=TypeError,wv=function(e,t){if(e<t)throw Av("Not enough arguments");return e},Cv=/(?:ipad|iphone|ipod).*applewebkit/i.test(se),xv=n,Ov=d,Nv=Yt,Dv=R,Pv=Ye,Mv=i,Lv=An,Uv=rs,Vv=It,Fv=wv,Bv=Cv,jv=uv,Gv=xv.setImmediate,Hv=xv.clearImmediate,zv=xv.process,Kv=xv.Dispatch,Xv=xv.Function,Wv=xv.MessageChannel,qv=xv.String,Yv=0,Jv={},Qv="onreadystatechange";try{ov=xv.location}catch(uW){}var Zv=function(e){if(Pv(Jv,e)){var t=Jv[e];delete Jv[e],t()}},$v=function(e){return function(){Zv(e)}},e_=function(e){Zv(e.data)},t_=function(e){xv.postMessage(qv(e),ov.protocol+"//"+ov.host)};Gv&&Hv||(Gv=function(e){Fv(arguments.length,1);var t=Dv(e)?e:Xv(e),r=Uv(arguments,1);return Jv[++Yv]=function(){Ov(t,void 0,r)},av(Yv),Yv},Hv=function(e){delete Jv[e]},jv?av=function(e){zv.nextTick($v(e))}:Kv&&Kv.now?av=function(e){Kv.now($v(e))}:Wv&&!Bv?(cv=(sv=new Wv).port2,sv.port1.onmessage=e_,av=Nv(cv.postMessage,cv)):xv.addEventListener&&Dv(xv.postMessage)&&!xv.importScripts&&ov&&"file:"!==ov.protocol&&!Mv(t_)?(av=t_,xv.addEventListener("message",e_,!1)):av=Qv in Vv("script")?function(e){Lv.appendChild(Vv("script")).onreadystatechange=function(){Lv.removeChild(this),Zv(e)}}:function(e){setTimeout($v(e),0)});var r_,n_,i_,o_,a_,s_,c_,u_,d_={set:Gv,clear:Hv},l_=n,h_=/ipad|iphone|ipod/i.test(se)&&void 0!==l_.Pebble,v_=/web0s(?!.*chrome)/i.test(se),__=n,p_=Yt,f_=A.f,m_=d_.set,g_=Cv,y_=h_,S_=v_,b_=uv,E_=__.MutationObserver||__.WebKitMutationObserver,T_=__.document,k_=__.process,I_=__.Promise,R_=f_(__,"queueMicrotask"),A_=R_&&R_.value;A_||(r_=function(){var e,t;for(b_&&(e=k_.domain)&&e.exit();n_;){t=n_.fn,n_=n_.next;try{t()}catch(uW){throw n_?o_():i_=void 0,uW}}i_=void 0,e&&e.enter()},g_||b_||S_||!E_||!T_?!y_&&I_&&I_.resolve?((c_=I_.resolve(void 0)).constructor=I_,u_=p_(c_.then,c_),o_=function(){u_(r_)}):b_?o_=function(){k_.nextTick(r_)}:(m_=p_(m_,__),o_=function(){m_(r_)}):(a_=!0,s_=T_.createTextNode(""),new E_(r_).observe(s_,{characterData:!0}),o_=function(){s_.data=a_=!a_}));var w_=A_||function(e){var t={fn:e,next:void 0};i_&&(i_.next=t),n_||(n_=t,o_()),i_=t},C_=n,x_=function(e){try{return{error:!1,value:e()}}catch(uW){return{error:!0,value:uW}}},O_=function(){this.head=null,this.tail=null};O_.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var N_=O_,D_=n.Promise,P_="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,M_=!P_&&!uv&&"object"==typeof window&&"object"==typeof document,L_=n,U_=D_,V_=R,F_=Kt,B_=io,j_=lt,G_=M_,H_=P_,z_=_e,K_=U_&&U_.prototype,X_=j_("species"),W_=!1,q_=V_(L_.PromiseRejectionEvent),Y_={CONSTRUCTOR:F_("Promise",(function(){var e=B_(U_),t=e!==String(U_);if(!t&&66===z_)return!0;if(!K_.catch||!K_.finally)return!0;if(!z_||z_<51||!/native code/.test(e)){var r=new U_((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[X_]=n,!(W_=r.then((function(){}))instanceof n))return!0}return!t&&(G_||H_)&&!q_})),REJECTION_EVENT:q_,SUBCLASSING:W_},J_={},Q_=Ce,Z_=TypeError,$_=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw Z_("Bad Promise constructor");t=e,r=n})),this.resolve=Q_(t),this.reject=Q_(r)};J_.f=function(e){return new $_(e)};var ep,tp,rp=Ar,np=uv,ip=n,op=O,ap=li,sp=Mi,cp=_v,up=Ce,dp=R,lp=$,hp=mv,vp=Rv,_p=d_.set,pp=w_,fp=function(e,t){var r=C_.console;r&&r.error&&(1==arguments.length?r.error(e):r.error(e,t))},mp=x_,gp=N_,yp=Zi,Sp=D_,bp=Y_,Ep=J_,Tp="Promise",kp=bp.CONSTRUCTOR,Ip=bp.REJECTION_EVENT,Rp=yp.getterFor(Tp),Ap=yp.set,wp=Sp&&Sp.prototype,Cp=Sp,xp=wp,Op=ip.TypeError,Np=ip.document,Dp=ip.process,Pp=Ep.f,Mp=Pp,Lp=!!(Np&&Np.createEvent&&ip.dispatchEvent),Up="unhandledrejection",Vp=function(e){var t;return!(!lp(e)||!dp(t=e.then))&&t},Fp=function(e,t){var r,n,i,o=t.value,a=1==t.state,s=a?e.ok:e.fail,c=e.resolve,u=e.reject,d=e.domain;try{s?(a||(2===t.rejection&&zp(t),t.rejection=1),!0===s?r=o:(d&&d.enter(),r=s(o),d&&(d.exit(),i=!0)),r===e.promise?u(Op("Promise-chain cycle")):(n=Vp(r))?op(n,r,c,u):c(r)):u(o)}catch(uW){d&&!i&&d.exit(),u(uW)}},Bp=function(e,t){e.notified||(e.notified=!0,pp((function(){for(var r,n=e.reactions;r=n.get();)Fp(r,e);e.notified=!1,t&&!e.rejection&&Gp(e)})))},jp=function(e,t,r){var n,i;Lp?((n=Np.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),ip.dispatchEvent(n)):n={promise:t,reason:r},!Ip&&(i=ip["on"+e])?i(n):e===Up&&fp("Unhandled promise rejection",r)},Gp=function(e){op(_p,ip,(function(){var t,r=e.facade,n=e.value;if(Hp(e)&&(t=mp((function(){np?Dp.emit("unhandledRejection",n,r):jp(Up,r,n)})),e.rejection=np||Hp(e)?2:1,t.error))throw t.value}))},Hp=function(e){return 1!==e.rejection&&!e.parent},zp=function(e){op(_p,ip,(function(){var t=e.facade;np?Dp.emit("rejectionHandled",t):jp("rejectionhandled",t,e.value)}))},Kp=function(e,t,r){return function(n){e(t,n,r)}},Xp=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,Bp(e,!0))},Wp=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw Op("Promise can't be resolved itself");var n=Vp(t);n?pp((function(){var r={done:!1};try{op(n,t,Kp(Wp,r,e),Kp(Xp,r,e))}catch(uW){Xp(r,uW,e)}})):(e.value=t,e.state=1,Bp(e,!1))}catch(uW){Xp({done:!1},uW,e)}}};kp&&(xp=(Cp=function(e){hp(this,xp),up(e),op(ep,this);var t=Rp(this);try{e(Kp(Wp,t),Kp(Xp,t))}catch(uW){Xp(t,uW)}}).prototype,(ep=function(e){Ap(this,{type:Tp,done:!1,notified:!1,parent:!1,reactions:new gp,rejection:!1,state:0,value:void 0})}).prototype=ap(xp,"then",(function(e,t){var r=Rp(this),n=Pp(vp(this,Cp));return r.parent=!0,n.ok=!dp(e)||e,n.fail=dp(t)&&t,n.domain=np?Dp.domain:void 0,0==r.state?r.reactions.add(n):pp((function(){Fp(n,r)})),n.promise})),tp=function(){var e=new ep,t=Rp(e);this.promise=e,this.resolve=Kp(Wp,t),this.reject=Kp(Xp,t)},Ep.f=Pp=function(e){return e===Cp||undefined===e?new tp(e):Mp(e)}),rp({global:!0,constructor:!0,wrap:!0,forced:kp},{Promise:Cp}),sp(Cp,Tp,!1,!0),cp(Tp);var qp=lt("iterator"),Yp=!1;try{var Jp=0,Qp={next:function(){return{done:!!Jp++}},return:function(){Yp=!0}};Qp[qp]=function(){return this},Array.from(Qp,(function(){throw 2}))}catch(uW){}var Zp=function(e,t){if(!t&&!Yp)return!1;var r=!1;try{var n={};n[qp]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(uW){}return r},$p=D_,ef=Y_.CONSTRUCTOR||!Zp((function(e){$p.all(e).then(void 0,(function(){}))})),tf=O,rf=Ce,nf=J_,of=x_,af=Uh;Ar({target:"Promise",stat:!0,forced:ef},{all:function(e){var t=this,r=nf.f(t),n=r.resolve,i=r.reject,o=of((function(){var r=rf(t.resolve),o=[],a=0,s=1;af(e,(function(e){var c=a++,u=!1;s++,tf(r,t,e).then((function(e){u||(u=!0,o[c]=e,--s||n(o))}),i)})),--s||n(o)}));return o.error&&i(o.value),r.promise}});var sf=Ar,cf=Y_.CONSTRUCTOR;D_&&D_.prototype,sf({target:"Promise",proto:!0,forced:cf,real:!0},{catch:function(e){return this.then(void 0,e)}});var uf=O,df=Ce,lf=J_,hf=x_,vf=Uh;Ar({target:"Promise",stat:!0,forced:ef},{race:function(e){var t=this,r=lf.f(t),n=r.reject,i=hf((function(){var i=df(t.resolve);vf(e,(function(e){uf(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var _f=O,pf=J_;Ar({target:"Promise",stat:!0,forced:Y_.CONSTRUCTOR},{reject:function(e){var t=pf.f(this);return _f(t.reject,void 0,e),t.promise}});var ff=tr,mf=$,gf=J_,yf=function(e,t){if(ff(e),mf(t)&&t.constructor===e)return t;var r=gf.f(e);return(0,r.resolve)(t),r.promise},Sf=Ar,bf=D_,Ef=Y_.CONSTRUCTOR,Tf=yf,kf=oe("Promise"),If=!Ef;Sf({target:"Promise",stat:!0,forced:true},{resolve:function(e){return Tf(If&&this===kf?bf:this,e)}});var Rf=O,Af=Ce,wf=J_,Cf=x_,xf=Uh;Ar({target:"Promise",stat:!0},{allSettled:function(e){var t=this,r=wf.f(t),n=r.resolve,i=r.reject,o=Cf((function(){var r=Af(t.resolve),i=[],o=0,a=1;xf(e,(function(e){var s=o++,c=!1;a++,Rf(r,t,e).then((function(e){c||(c=!0,i[s]={status:"fulfilled",value:e},--a||n(i))}),(function(e){c||(c=!0,i[s]={status:"rejected",reason:e},--a||n(i))}))})),--a||n(i)}));return o.error&&i(o.value),r.promise}});var Of=O,Nf=Ce,Df=oe,Pf=J_,Mf=x_,Lf=Uh,Uf="No one promise resolved";Ar({target:"Promise",stat:!0},{any:function(e){var t=this,r=Df("AggregateError"),n=Pf.f(t),i=n.resolve,o=n.reject,a=Mf((function(){var n=Nf(t.resolve),a=[],s=0,c=1,u=!1;Lf(e,(function(e){var d=s++,l=!1;c++,Of(n,t,e).then((function(e){l||u||(u=!0,i(e))}),(function(e){l||u||(l=!0,a[d]=e,--c||o(new r(a,Uf)))}))})),--c||o(new r(a,Uf))}));return a.error&&o(a.value),n.promise}});var Vf=Ar,Ff=D_,Bf=i,jf=oe,Gf=R,Hf=Rv,zf=yf,Kf=Ff&&Ff.prototype;Vf({target:"Promise",proto:!0,real:!0,forced:!!Ff&&Bf((function(){Kf.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=Hf(this,jf("Promise")),r=Gf(e);return this.then(r?function(r){return zf(t,e()).then((function(){return r}))}:e,r?function(r){return zf(t,e()).then((function(){throw r}))}:e)}});var Xf=ee.Promise,Wf=J_,qf=x_;Ar({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=Wf.f(this),r=qf(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var Yf=Xf,Jf=Ar,Qf=eo,Zf=E([].reverse),$f=[1,2];Jf({target:"Array",proto:!0,forced:String($f)===String($f.reverse())},{reverse:function(){return Qf(this)&&(this.length=this.length),Zf(this)}});var em=Us("Array").reverse,tm=ae,rm=em,nm=Array.prototype,im=function(e){var t=e.reverse;return e===nm||tm(nm,e)&&t===nm.reverse?rm:t},om=Ar,am=eo,sm=yo,cm=$,um=Mr,dm=Br,lm=J,hm=Qn,vm=lt,_m=rs,pm=Ps("slice"),fm=vm("species"),mm=Array,gm=Math.max;om({target:"Array",proto:!0,forced:!pm},{slice:function(e,t){var r,n,i,o=lm(this),a=dm(o),s=um(e,a),c=um(void 0===t?a:t,a);if(am(o)&&(r=o.constructor,(sm(r)&&(r===mm||am(r.prototype))||cm(r)&&null===(r=r[fm]))&&(r=void 0),r===mm||void 0===r))return _m(o,s,c);for(n=new(void 0===r?mm:r)(gm(c-s,0)),i=0;s<c;s++,i++)s in o&&hm(n,i,o[s]);return n.length=i,n}});var ym=Us("Array").slice,Sm=ae,bm=ym,Em=Array.prototype,Tm=function(e){var t=e.slice;return e===Em||Sm(Em,e)&&t===Em.slice?bm:t};function km(){km=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=ad||function(e,t,r){e[t]=r.value},i="function"==typeof wd?wd:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(e,t,r){return ad(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(A){c=function(e,t,r){return e[t]=r}}function u(e,t,r,i){var o=t&&t.prototype instanceof h?t:h,a=Bl(o.prototype),s=new k(i||[]);return n(a,"_invoke",{value:S(e,r,s)}),a}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(A){return{type:"throw",arg:A}}}e.wrap=u;var l={};function h(){}function v(){}function _(){}var p={};c(p,o,(function(){return this}));var f=zl&&zl(zl(I([])));f&&f!==t&&r.call(f,o)&&(p=f);var m=_.prototype=h.prototype=Bl(p);function g(e){var t;Mu(t=["next","throw","return"]).call(t,(function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){function i(n,o,a,s){var c=d(e[n],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==Wd(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return i("throw",e,a,s)}))}s(c.arg)}var o;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}})}function S(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=b(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=d(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function b(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),l;var i=d(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,l;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],Mu(e).call(e,E,this),this.reset(!0)}function I(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:R}}function R(){return{value:void 0,done:!0}}return v.prototype=_,n(m,"constructor",{value:_,configurable:!0}),n(_,"constructor",{value:v,configurable:!0}),v.displayName=c(_,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Kl?Kl(e,_):(e.__proto__=_,c(e,s,"GeneratorFunction")),e.prototype=Bl(m),e},e.awrap=function(e){return{__await:e}},g(y.prototype),c(y.prototype,a,(function(){return this})),e.AsyncIterator=y,e.async=function(t,r,n,i,o){void 0===o&&(o=Yf);var a=new y(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),c(m,s,"Generator"),c(m,o,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return im(r).call(r),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=I,k.prototype={constructor:k,reset:function(e){var t;if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,Mu(t=this.tryEntries).call(t,T),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+Tm(n).call(n,1))&&(this[n]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function Im(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(uW){return void r(uW)}s.done?t(c):Yf.resolve(c).then(n,i)}function Rm(e){return function(){var t=this,r=arguments;return new Yf((function(n,i){var o=e.apply(t,r);function a(e){Im(o,n,i,a,s,"next",e)}function s(e){Im(o,n,i,a,s,"throw",e)}a(void 0)}))}}var Am=Us("Array").concat,wm=ae,Cm=Am,xm=Array.prototype,Om=function(e){var t=e.concat;return e===xm||wm(xm,e)&&t===xm.concat?Cm:t},Nm=ee,Dm=d;Nm.JSON||(Nm.JSON={stringify:JSON.stringify});var Pm=function(e,t,r){return Dm(Nm.JSON.stringify,null,arguments)},Mm=Pm,Lm=Po.map;Ar({target:"Array",proto:!0,forced:!Ps("map")},{map:function(e){return Lm(this,e,arguments.length>1?arguments[1]:void 0)}});var Um=Us("Array").map,Vm=ae,Fm=Um,Bm=Array.prototype,jm=function(e){var t=e.map;return e===Bm||Vm(Bm,e)&&t===Bm.map?Fm:t},Gm="\t\n\v\f\r \u2028\u2029\ufeff",Hm=W,zm=gn,Km=E("".replace),Xm="[\t\n\v\f\r \u2028\u2029\ufeff]",Wm=RegExp("^"+Xm+Xm+"*"),qm=RegExp(Xm+Xm+"*$"),Ym=function(e){return function(t){var r=zm(Hm(t));return 1&e&&(r=Km(r,Wm,"")),2&e&&(r=Km(r,qm,"")),r}},Jm={start:Ym(1),end:Ym(2),trim:Ym(3)},Qm=n,Zm=i,$m=E,eg=gn,tg=Jm.trim,rg=Gm,ng=Qm.parseInt,ig=Qm.Symbol,og=ig&&ig.iterator,ag=/^[+-]?0x/i,sg=$m(ag.exec),cg=8!==ng(rg+"08")||22!==ng(rg+"0x16")||og&&!Zm((function(){ng(Object(og))}))?function(e,t){var r=tg(eg(e));return ng(r,t>>>0||(sg(ag,r)?16:10))}:ng;Ar({global:!0,forced:parseInt!=cg},{parseInt:cg});var ug=ee.parseInt,dg={exports:{}},lg=i((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),hg=i,vg=$,_g=y,pg=lg,fg=Object.isExtensible,mg=hg((function(){fg(1)}))||pg?function(e){return!!vg(e)&&((!pg||"ArrayBuffer"!=_g(e))&&(!fg||fg(e)))}:fg,gg=!i((function(){return Object.isExtensible(Object.preventExtensions({}))})),yg=Ar,Sg=E,bg=Xr,Eg=$,Tg=Ye,kg=Jt.f,Ig=zn,Rg=Wn,Ag=mg,wg=gg,Cg=!1,xg=et("meta"),Og=0,Ng=function(e){kg(e,xg,{value:{objectID:"O"+Og++,weakData:{}}})},Dg=dg.exports={enable:function(){Dg.enable=function(){},Cg=!0;var e=Ig.f,t=Sg([].splice),r={};r[xg]=1,e(r).length&&(Ig.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===xg){t(n,i,1);break}return n},yg({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Rg.f}))},fastKey:function(e,t){if(!Eg(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!Tg(e,xg)){if(!Ag(e))return"F";if(!t)return"E";Ng(e)}return e[xg].objectID},getWeakData:function(e,t){if(!Tg(e,xg)){if(!Ag(e))return!0;if(!t)return!1;Ng(e)}return e[xg].weakData},onFreeze:function(e){return wg&&Cg&&Ag(e)&&!Tg(e,xg)&&Ng(e),e}};bg[xg]=!0;var Pg=Ar,Mg=n,Lg=dg.exports,Ug=i,Vg=pr,Fg=Uh,Bg=mv,jg=R,Gg=$,Hg=Mi,zg=Jt.f,Kg=Po.forEach,Xg=w,Wg=Zi.set,qg=Zi.getterFor,Yg=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=Mg[e],c=s&&s.prototype,u={};if(Xg&&jg(s)&&(o||c.forEach&&!Ug((function(){(new s).entries().next()})))){var d=(n=t((function(t,r){Wg(Bg(t,d),{type:e,collection:new s}),null!=r&&Fg(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,l=qg(e);Kg(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in c)||o&&"clear"==e||Vg(d,e,(function(r,n){var i=l(this).collection;if(!t&&o&&!Gg(r))return"get"==e&&void 0;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||zg(d,"size",{configurable:!0,get:function(){return l(this).collection.size}})}else n=r.getConstructor(t,e,i,a),Lg.enable();return Hg(n,e,!1,!0),u[e]=n,Pg({global:!0,forced:!0},u),o||r.setStrong(n,e,i),n},Jg=li,Qg=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:Jg(e,n,t[n],r);return e},Zg=Jt.f,$g=Hn,ey=Qg,ty=Yt,ry=mv,ny=z,iy=Uh,oy=iu,ay=ou,sy=_v,cy=w,uy=dg.exports.fastKey,dy=Zi.set,ly=Zi.getterFor,hy={getConstructor:function(e,t,r,n){var i=e((function(e,i){ry(e,o),dy(e,{type:t,index:$g(null),first:void 0,last:void 0,size:0}),cy||(e.size=0),ny(i)||iy(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=ly(t),s=function(e,t,r){var n,i,o=a(e),s=c(e,t);return s?s.value=r:(o.last=s={index:i=uy(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),cy?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var r,n=a(e),i=uy(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key==t)return r};return ey(o,{clear:function(){for(var e=a(this),t=e.index,r=e.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=void 0),delete t[r.index],r=r.next;e.first=e.last=void 0,cy?e.size=0:this.size=0},delete:function(e){var t=this,r=a(t),n=c(t,e);if(n){var i=n.next,o=n.previous;delete r.index[n.index],n.removed=!0,o&&(o.next=i),i&&(i.previous=o),r.first==n&&(r.first=i),r.last==n&&(r.last=o),cy?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=ty(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:r.first;)for(n(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!c(this,e)}}),ey(o,r?{get:function(e){var t=c(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),cy&&Zg(o,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=ly(t),o=ly(n);oy(e,t,(function(e,t){dy(this,{type:n,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=o(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;return e.target&&(e.last=r=r?r.next:e.state.first)?ay("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,ay(void 0,!0))}),r?"entries":"values",!r,!0),sy(t)}};Yg("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),hy);var vy=ee.Map,_y=Yt,py=O,fy=Ce,my=bv,gy=z,yy=Uh,Sy=[].push,by=function(e){var t,r,n,i,o=arguments.length,a=o>1?arguments[1]:void 0;return my(this),(t=void 0!==a)&&fy(a),gy(e)?new this:(r=[],t?(n=0,i=_y(a,o>2?arguments[2]:void 0),yy(e,(function(e){py(Sy,r,i(e,n++))}))):yy(e,Sy,{that:r}),new this(r))};Ar({target:"Map",stat:!0,forced:!0},{from:by});var Ey=rs,Ty=function(){return new this(Ey(arguments))};Ar({target:"Map",stat:!0,forced:!0},{of:Ty});var ky=O,Iy=Ce,Ry=tr,Ay=function(){for(var e,t=Ry(this),r=Iy(t.delete),n=!0,i=0,o=arguments.length;i<o;i++)e=ky(r,t,arguments[i]),n=n&&e;return!!n};Ar({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:Ay});var wy=O,Cy=Ce,xy=tr,Oy=function(e,t){var r,n,i=xy(this),o=Cy(i.get),a=Cy(i.has),s=Cy(i.set);return wy(a,i,e)?(r=wy(o,i,e),"update"in t&&(r=t.update(r,e,i),wy(s,i,e,r)),r):(n=t.insert(e,i),wy(s,i,e,n),n)};Ar({target:"Map",proto:!0,real:!0,forced:!0},{emplace:Oy});var Ny=yh,Dy=tr,Py=Yt,My=Ny,Ly=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=Dy(this),r=My(t),n=Py(e,arguments.length>1?arguments[1]:void 0);return!Ly(r,(function(e,r,i){if(!n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var Uy=oe,Vy=Yt,Fy=O,By=Ce,jy=tr,Gy=Rv,Hy=Ny,zy=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=jy(this),r=Hy(t),n=Vy(e,arguments.length>1?arguments[1]:void 0),i=new(Gy(t,Uy("Map"))),o=By(i.set);return zy(r,(function(e,r){n(r,e,t)&&Fy(o,i,e,r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var Ky=tr,Xy=Yt,Wy=Ny,qy=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=Ky(this),r=Wy(t),n=Xy(e,arguments.length>1?arguments[1]:void 0);return qy(r,(function(e,r,i){if(n(r,e,t))return i(r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var Yy=tr,Jy=Yt,Qy=Ny,Zy=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=Yy(this),r=Qy(t),n=Jy(e,arguments.length>1?arguments[1]:void 0);return Zy(r,(function(e,r,i){if(n(r,e,t))return i(e)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var $y=Ar,eS=O,tS=Ce,rS=yh,nS=Uh,iS=E([].push);$y({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){tS(t);var r=rS(e),n=new this,i=tS(n.has),o=tS(n.get),a=tS(n.set);return nS(r,(function(e){var r=t(e);eS(i,n,r)?iS(eS(o,n,r),e):eS(a,n,r,[e])}),{IS_ITERATOR:!0}),n}});var oS=tr,aS=Ny,sS=function(e,t){return e===t||e!=e&&t!=t},cS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return cS(aS(oS(this)),(function(t,r,n){if(sS(r,e))return n()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var uS=O,dS=Uh,lS=Ce;Ar({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new this;lS(t);var n=lS(r.set);return dS(e,(function(e){uS(n,r,t(e),e)})),r}});var hS=tr,vS=Ny,_S=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){return _S(vS(hS(this)),(function(t,r,n){if(r===e)return n(t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var pS=oe,fS=Yt,mS=O,gS=Ce,yS=tr,SS=Rv,bS=Ny,ES=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=yS(this),r=bS(t),n=fS(e,arguments.length>1?arguments[1]:void 0),i=new(SS(t,pS("Map"))),o=gS(i.set);return ES(r,(function(e,r){mS(o,i,n(r,e,t),r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var TS=oe,kS=Yt,IS=O,RS=Ce,AS=tr,wS=Rv,CS=Ny,xS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=AS(this),r=CS(t),n=kS(e,arguments.length>1?arguments[1]:void 0),i=new(wS(t,TS("Map"))),o=RS(i.set);return xS(r,(function(e,r){IS(o,i,e,n(r,e,t))}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var OS=Ce,NS=tr,DS=Uh;Ar({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=NS(this),r=OS(t.set),n=arguments.length,i=0;i<n;)DS(arguments[i++],r,{that:t,AS_ENTRIES:!0});return t}});var PS=tr,MS=Ce,LS=Ny,US=Uh,VS=TypeError;Ar({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=PS(this),r=LS(t),n=arguments.length<2,i=n?void 0:arguments[1];if(MS(e),US(r,(function(r,o){n?(n=!1,i=o):i=e(i,o,r,t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),n)throw VS("Reduce of empty map with no initial value");return i}});var FS=tr,BS=Yt,jS=Ny,GS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=FS(this),r=jS(t),n=BS(e,arguments.length>1?arguments[1]:void 0);return GS(r,(function(e,r,i){if(n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var HS=O,zS=tr,KS=Ce,XS=TypeError;Ar({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=zS(this),n=KS(r.get),i=KS(r.has),o=KS(r.set),a=arguments.length;KS(t);var s=HS(i,r,e);if(!s&&a<3)throw XS("Updating absent value");var c=s?HS(n,r,e):KS(a>2?arguments[2]:void 0)(e,r);return HS(o,r,e,t(c,e,r)),r}});var WS=O,qS=Ce,YS=R,JS=tr,QS=TypeError,ZS=function(e,t){var r,n=JS(this),i=qS(n.get),o=qS(n.has),a=qS(n.set),s=arguments.length>2?arguments[2]:void 0;if(!YS(t)&&!YS(s))throw QS("At least one callback required");return WS(o,n,e)?(r=WS(i,n,e),YS(t)&&(r=t(r),WS(a,n,e,r))):YS(s)&&(r=s(),WS(a,n,e,r)),r};Ar({target:"Map",proto:!0,real:!0,forced:!0},{upsert:ZS}),Ar({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:ZS});var $S=vy,eb=Ce,tb=Xe,rb=H,nb=Br,ib=TypeError,ob=function(e){return function(t,r,n,i){eb(r);var o=tb(t),a=rb(o),s=nb(o),c=e?s-1:0,u=e?-1:1;if(n<2)for(;;){if(c in a){i=a[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw ib("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=u)c in a&&(i=r(i,a[c],c,o));return i}},ab={left:ob(!1),right:ob(!0)}.left,sb=_e,cb=uv;Ar({target:"Array",proto:!0,forced:!Iu("reduce")||!cb&&sb>79&&sb<83},{reduce:function(e){var t=arguments.length;return ab(this,e,t,t>1?arguments[1]:void 0)}});var ub=Us("Array").reduce,db=ae,lb=ub,hb=Array.prototype,vb=function(e){var t=e.reduce;return e===hb||db(hb,e)&&t===hb.reduce?lb:t},_b=w,pb=E,fb=O,mb=i,gb=rn,yb=ui,Sb=N,bb=Xe,Eb=H,Tb=Object.assign,kb=Object.defineProperty,Ib=pb([].concat),Rb=!Tb||mb((function(){if(_b&&1!==Tb({b:1},Tb(kb({},"a",{enumerable:!0,get:function(){kb(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!=Tb({},e)[r]||gb(Tb({},t)).join("")!=n}))?function(e,t){for(var r=bb(e),n=arguments.length,i=1,o=yb.f,a=Sb.f;n>i;)for(var s,c=Eb(arguments[i++]),u=o?Ib(gb(c),o(c)):gb(c),d=u.length,l=0;d>l;)s=u[l++],_b&&!fb(a,c,s)||(r[s]=c[s]);return r}:Tb,Ab=Rb;Ar({target:"Object",stat:!0,arity:2,forced:Object.assign!==Ab},{assign:Ab});var wb=ee.Object.assign,Cb=$,xb=y,Ob=lt("match"),Nb=function(e){var t;return Cb(e)&&(void 0!==(t=e[Ob])?!!t:"RegExp"==xb(e))},Db=TypeError,Pb=function(e){if(Nb(e))throw Db("The method doesn't accept regular expressions");return e},Mb=lt("match"),Lb=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[Mb]=!1,"/./"[e](t)}catch(n){}}return!1},Ub=Ar,Vb=E;A.f;var Fb=Vr,Bb=gn,jb=Pb,Gb=W,Hb=Lb,zb=Vb("".endsWith),Kb=Vb("".slice),Xb=Math.min;Ub({target:"String",proto:!0,forced:!Hb("endsWith")},{endsWith:function(e){var t=Bb(Gb(this));jb(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:Xb(Fb(r),n),o=Bb(e);return zb?zb(t,o,i):Kb(t,i-o.length,i)===o}});var Wb=Us("String").endsWith,qb=ae,Yb=Wb,Jb=String.prototype,Qb=function(e){var t=e.endsWith;return"string"==typeof e||e===Jb||qb(Jb,e)&&t===Jb.endsWith?Yb:t},Zb=!0,$b=!0;function eE(e,t,r){var n=e.match(t);return n&&n.length>=r&&ug(n[r],10)}function tE(e,t,r){if(e.RTCPeerConnection){var n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return i.apply(this,arguments);var o=function(e){var t=r(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new $S),this._eventMap[t].set(n,o),i.apply(this,[e,o])};var o=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(r))return o.apply(this,arguments);var n=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===an(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},ad(n,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}}function rE(e){return"boolean"!=typeof e?new Error("Argument type: "+Wd(e)+". Please use a boolean."):(Zb=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function nE(e){return"boolean"!=typeof e?new Error("Argument type: "+Wd(e)+". Please use a boolean."):($b=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function iE(){if("object"===("undefined"==typeof window?"undefined":Wd(window))){if(Zb)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function oE(e,t){$b&&console.warn(e+" is deprecated, please use "+t+" instead.")}function aE(e){var t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;var r=e.navigator;if(r.mozGetUserMedia)t.browser="firefox",t.version=eE(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=eE(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=eE(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}function sE(e){return"[object Object]"===Object.prototype.toString.call(e)}function cE(e){var t;return sE(e)?vb(t=an(e)).call(t,(function(t,r){var n=sE(e[r]),i=n?cE(e[r]):e[r],o=n&&!an(i).length;return void 0===i||o?t:wb(t,Jd({},r,i))}),{}):e}function uE(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),an(t).forEach((function(n){Qb(n).call(n,"Id")?uE(e,e.get(t[n]),r):Qb(n).call(n,"Ids")&&t[n].forEach((function(t){uE(e,e.get(t),r)}))})))}function dE(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new $S;if(null===t)return i;var o=[];return e.forEach((function(e){"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((function(t){e.forEach((function(r){r.type===n&&r.trackId===t.id&&uE(e,r,i)}))})),i}var lE=Ar,hE=Po.find,vE="find",_E=!0;vE in[]&&Array(1).find((function(){_E=!1})),lE({target:"Array",proto:!0,forced:_E},{find:function(e){return hE(this,e,arguments.length>1?arguments[1]:void 0)}});var pE=Us("Array").find,fE=ae,mE=pE,gE=Array.prototype,yE=function(e){var t=e.find;return e===gE||fE(gE,e)&&t===gE.find?mE:t},SE=Ar,bE=Kr.indexOf,EE=Iu,TE=E([].indexOf),kE=!!TE&&1/TE([1],1,-0)<0,IE=EE("indexOf");SE({target:"Array",proto:!0,forced:kE||!IE},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return kE?TE(this,e,t)||0:bE(this,e,t)}});var RE=Us("Array").indexOf,AE=ae,wE=RE,CE=Array.prototype,xE=function(e){var t=e.indexOf;return e===CE||AE(CE,e)&&t===CE.indexOf?wE:t},OE=w,NE=eo,DE=TypeError,PE=Object.getOwnPropertyDescriptor,ME=OE&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(uW){return uW instanceof TypeError}}(),LE=Ie,UE=TypeError,VE=function(e,t){if(!delete e[t])throw UE("Cannot delete property "+LE(t)+" of "+LE(e))},FE=Ar,BE=Xe,jE=Mr,GE=Or,HE=Br,zE=ME?function(e,t){if(NE(e)&&!PE(e,"length").writable)throw DE("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},KE=cd,XE=Ro,WE=Qn,qE=VE,YE=Ps("splice"),JE=Math.max,QE=Math.min;FE({target:"Array",proto:!0,forced:!YE},{splice:function(e,t){var r,n,i,o,a,s,c=BE(this),u=HE(c),d=jE(e,u),l=arguments.length;for(0===l?r=n=0:1===l?(r=0,n=u-d):(r=l-2,n=QE(JE(GE(t),0),u-d)),KE(u+r-n),i=XE(c,n),o=0;o<n;o++)(a=d+o)in c&&WE(i,o,c[a]);if(i.length=n,r<n){for(o=d;o<u-n;o++)s=o+r,(a=o+n)in c?c[s]=c[a]:qE(c,s);for(o=u;o>u-n+r;o--)qE(c,o-1)}else if(r>n)for(o=u-n;o>d;o--)s=o+r-1,(a=o+n-1)in c?c[s]=c[a]:qE(c,s);for(o=0;o<r;o++)c[o+d]=arguments[o+2];return zE(c,u-n+r),i}});var ZE=Us("Array").splice,$E=ae,eT=ZE,tT=Array.prototype,rT=function(e){var t=e.splice;return e===tT||$E(tT,e)&&t===tT.splice?eT:t},nT=Kr.includes;Ar({target:"Array",proto:!0,forced:i((function(){return!Array(1).includes()}))},{includes:function(e){return nT(this,e,arguments.length>1?arguments[1]:void 0)}});var iT=Us("Array").includes,oT=Ar,aT=Pb,sT=W,cT=gn,uT=Lb,dT=E("".indexOf);oT({target:"String",proto:!0,forced:!uT("includes")},{includes:function(e){return!!~dT(cT(sT(this)),cT(aT(e)),arguments.length>1?arguments[1]:void 0)}});var lT=Us("String").includes,hT=ae,vT=iT,_T=lT,pT=Array.prototype,fT=String.prototype,mT=function(e){var t=e.includes;return e===pT||hT(pT,e)&&t===pT.includes?vT:"string"==typeof e||e===fT||hT(fT,e)&&t===fT.includes?_T:t},gT=iE;function yT(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==Wd(e)||e.mandatory||e.optional)return e;var t,r={};(an(e).forEach((function(t){if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var n="object"===Wd(e[t])?e[t]:{ideal:e[t]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+Tm(t).call(t,1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){r.optional=r.optional||[];var o={};"number"==typeof n.ideal?(o[i("min",t)]=n.ideal,r.optional.push(o),(o={})[i("max",t)]=n.ideal,r.optional.push(o)):(o[i("",t)]=n.ideal,r.optional.push(o))}void 0!==n.exact&&"number"!=typeof n.exact?(r.mandatory=r.mandatory||{},r.mandatory[i("",t)]=n.exact):["min","max"].forEach((function(e){void 0!==n[e]&&(r.mandatory=r.mandatory||{},r.mandatory[i(e,t)]=n[e])}))}})),e.advanced)&&(r.optional=Om(t=r.optional||[]).call(t,e.advanced));return r},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(Mm(e)))&&"object"===Wd(e.audio)){var o=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};o((e=JSON.parse(Mm(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===Wd(e.video)){var a=e.video.facingMode;a=a&&("object"===Wd(a)?a:{ideal:a});var s,c=t.version<66;if(a&&("user"===a.exact||"environment"===a.exact||"user"===a.ideal||"environment"===a.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||c))if(delete e.video.facingMode,"environment"===a.exact||"environment"===a.ideal?s=["back","rear"]:"user"!==a.exact&&"user"!==a.ideal||(s=["front"]),s)return r.mediaDevices.enumerateDevices().then((function(t){t=Gs(t).call(t,(function(e){return"videoinput"===e.kind}));var r=yE(t).call(t,(function(e){return s.some((function(t){var r;return mT(r=e.label.toLowerCase()).call(r,t)}))}));return!r&&t.length&&mT(s).call(s,"back")&&(r=t[t.length-1]),r&&(e.video.deviceId=a.exact?{exact:r.deviceId}:{ideal:r.deviceId}),e.video=n(e.video),gT("chrome: "+Mm(e)),i(e)}));e.video=n(e.video)}return gT("chrome: "+Mm(e)),i(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};if(r.getUserMedia=function(e,t,n){i(e,(function(e){r.webkitGetUserMedia(e,t,(function(e){n&&n(o(e))}))}))}.bind(r),r.mediaDevices.getUserMedia){var a=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(e){return i(e,(function(e){return a(e).then((function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach((function(e){e.stop()})),new DOMException("","NotFoundError");return t}),(function(e){return Yf.reject(o(e))}))}))}}}}function ST(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function bT(e){if("object"===Wd(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){ad(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var r=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",(function(n){var i,o;e.RTCPeerConnection.prototype.getReceivers?i=yE(o=r.getReceivers()).call(o,(function(e){return e.track&&e.track.id===n.track.id})):i={track:n.track};var a=new Event("track");a.track=n.track,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)})),t.stream.getTracks().forEach((function(n){var i,o;e.RTCPeerConnection.prototype.getReceivers?i=yE(o=r.getReceivers()).call(o,(function(e){return e.track&&e.track.id===n.id})):i={track:n};var a=new Event("track");a.track=n,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else tE(e,"track",(function(e){return e.transceiver||ad(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function ET(e){if("object"===Wd(e)&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){var e;return this._senders=this._senders||[],Tm(e=this._senders).call(e)};var r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){var i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t;n.apply(this,arguments);var r,i=xE(t=this._senders).call(t,e);-1!==i&&rT(r=this._senders).call(r,i,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((function(e){r._senders.push(t(r,e))}))};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach((function(e){var r,n,i,o=yE(r=t._senders).call(r,(function(t){return t.track===e}));o&&rT(n=t._senders).call(n,xE(i=t._senders).call(i,o),1)}))}}else if("object"===Wd(e)&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var a=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=a.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t},ad(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function TT(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=Tm(Array.prototype).call(arguments),n=r[0],i=r[1],o=r[2];if(arguments.length>0&&"function"==typeof n)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof n))return t.apply(this,[]);var a=function(e){var t={};return e.result().forEach((function(e){var r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((function(t){r[t]=e.stat(t)})),t[r.id]=r})),t},s=function(e){var t;return new $S(jm(t=an(e)).call(t,(function(t){return[t,e[t]]})))};if(arguments.length>=2){var c=function(e){i(s(a(e)))};return t.apply(this,[c,n])}return new Yf((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function kT(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return dE(t,e.track,!0)}))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var n=e.RTCPeerConnection.prototype.getReceivers;n&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=n.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t}),tE(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return dE(t,e.track,!1)}))}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t,r,n,o=arguments[0];return this.getSenders().forEach((function(e){e.track===o&&(t?n=!0:t=e)})),this.getReceivers().forEach((function(e){return e.track===o&&(r?n=!0:r=e),e.track===o})),n||t&&r?Yf.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Yf.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function IT(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e,t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},jm(e=an(this._shimmedLocalStreams)).call(e,(function(e){return t._shimmedLocalStreams[e][0]}))};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var n;if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var i=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===xE(n=this._shimmedLocalStreams[r.id]).call(n,i)&&this._shimmedLocalStreams[r.id].push(i):this._shimmedLocalStreams[r.id]=[r,i],i};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t,n,i=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((function(e){var t;if(yE(t=i.getSenders()).call(t,(function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")}));var o=this.getSenders();r.apply(this,arguments);var a=Gs(t=this.getSenders()).call(t,(function(e){return-1===xE(o).call(o,e)}));this._shimmedLocalStreams[e.id]=Om(n=[e]).call(n,a)};var n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&an(this._shimmedLocalStreams).forEach((function(r){var n,i,o=xE(n=t._shimmedLocalStreams[r]).call(n,e);-1!==o&&rT(i=t._shimmedLocalStreams[r]).call(i,o,1);1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function RT(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return IT(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},jm(t).call(t,(function(t){return e._reverseStreams[t.id]}))};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((function(e){var t;if(yE(t=r.getSenders()).call(t,(function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,r){var n,i,o,a=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var s=Tm([]).call(arguments,1);if(1!==s.length||!yE(n=s[0].getTracks()).call(n,(function(e){return e===t})))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var c=yE(i=this.getSenders()).call(i,(function(e){return e.track===t}));if(c)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var u=this._streams[r.id];if(u)u.addTrack(t),Yf.resolve().then((function(){a.dispatchEvent(new Event("negotiationneeded"))}));else{var d=new e.MediaStream([t]);this._streams[r.id]=d,this._reverseStreams[d.id]=r,this.addStream(d)}return yE(o=this.getSenders()).call(o,(function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){var e=this,t=arguments,n=arguments.length&&"function"==typeof arguments[0];return n?r.apply(this,[function(r){var n=s(e,r);t[0].apply(null,[n])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):r.apply(this,arguments).then((function(t){return s(e,t)}))}));e.RTCPeerConnection.prototype[t]=n[t]}));var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=c(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};var a=tc(e.RTCPeerConnection.prototype,"localDescription");ad(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=a.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t,r=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{},an(this._streams).forEach((function(n){var i;yE(i=r._streams[n].getTracks()).call(i,(function(t){return e.track===t}))&&(t=r._streams[n])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function s(e,t){var r=t.sdp;return an(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:r})}function c(e,t){var r=t.sdp;return an(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:r})}}function AT(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}))}function wT(e,t){tE(e,"negotiationneeded",(function(e){var r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e}))}var CT=Object.freeze(Object.defineProperty({__proto__:null,shimMediaStream:ST,shimOnTrack:bT,shimGetSendersWithDtmf:ET,shimGetStats:TT,shimSenderReceiverGetStats:kT,shimAddTrackRemoveTrackWithNative:IT,shimAddTrackRemoveTrack:RT,shimPeerConnection:AT,fixNegotiationNeeded:wT,shimGetUserMedia:yT,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then((function(t){var n=r.video&&r.video.width,i=r.video&&r.video.height,o=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}},Symbol.toStringTag,{value:"Module"}));Ar({target:"Array",stat:!0},{isArray:eo});var xT=ee.Array.isArray;function OT(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var NT=hh,DT=tr,PT=Th,MT=Yt,LT=O,UT=Xe,VT=function(e,t,r,n){try{return n?t(DT(r)[0],r[1]):t(r)}catch(uW){PT(e,"throw",uW)}},FT=ah,BT=yo,jT=Br,GT=Qn,HT=yh,zT=hh,KT=Array,XT=function(e){var t=UT(e),r=BT(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=MT(i,n>2?arguments[2]:void 0));var a,s,c,u,d,l,h=zT(t),v=0;if(!h||this===KT&&FT(h))for(a=jT(t),s=r?new this(a):KT(a);a>v;v++)l=o?i(t[v],v):t[v],GT(s,v,l);else for(d=(u=HT(t,h)).next,s=r?new this:[];!(c=LT(d,u)).done;v++)l=o?VT(u,i,[c.value,v],!0):c.value,GT(s,v,l);return s.length=v,s},WT=XT;Ar({target:"Array",stat:!0,forced:!Zp((function(e){Array.from(e)}))},{from:WT});var qT=ee.Array.from;function YT(e,t){var r;if(e){if("string"==typeof e)return OT(e,t);var n=Tm(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?qT(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?OT(e,t):void 0}}function JT(e){return function(e){if(xT(e))return OT(e)}(e)||function(e){if(void 0!==wd&&null!=NT(e)||null!=e["@@iterator"])return qT(e)}(e)||YT(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var QT=n,ZT=i,$T=gn,ek=Jm.trim,tk=E("".charAt),rk=QT.parseFloat,nk=QT.Symbol,ik=nk&&nk.iterator,ok=1/rk("\t\n\v\f\r \u2028\u2029\ufeff-0")!=-1/0||ik&&!ZT((function(){rk(Object(ik))}))?function(e){var t=ek($T(e)),r=rk(t);return 0===r&&"-"==tk(t,0)?-0:r}:rk;Ar({global:!0,forced:parseFloat!=ok},{parseFloat:ok});var ak=ee.parseFloat;function sk(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){oE("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var i=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},o=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(e){return"object"===Wd(e)&&"object"===Wd(e.audio)&&(e=JSON.parse(Mm(e)),i(e.audio,"autoGainControl","mozAutoGainControl"),i(e.audio,"noiseSuppression","mozNoiseSuppression")),o(e)},n&&n.prototype.getSettings){var a=n.prototype.getSettings;n.prototype.getSettings=function(){var e=a.apply(this,arguments);return i(e,"mozAutoGainControl","autoGainControl"),i(e,"mozNoiseSuppression","noiseSuppression"),e}}if(n&&n.prototype.applyConstraints){var s=n.prototype.applyConstraints;n.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===Wd(e)&&(e=JSON.parse(Mm(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function ck(e){"object"===Wd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&ad(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function uk(e,t){if("object"===Wd(e)&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}));var r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=Tm(Array.prototype).call(arguments),i=e[0],o=e[1],a=e[2];return n.apply(this,[i||null]).then((function(e){if(t.version<53&&!o)try{e.forEach((function(e){e.type=r[e.type]||e.type}))}catch(n){if("TypeError"!==n.name)throw n;e.forEach((function(t,n){e.set(n,wb({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function dk(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpSender.prototype))){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Yf.resolve(new $S)}}}function lk(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpReceiver.prototype))){var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r}),tE(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function hk(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;oE("removeStream","removeTrack"),this.getSenders().forEach((function(r){var n;r.track&&mT(n=e.getTracks()).call(n,r.track)&&t.removeTrack(r)}))})}function vk(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function _k(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]);var r=(e=JT(e)).length>0;r&&e.forEach((function(e){if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(ak(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(ak(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));var n=t.apply(this,arguments);if(r){var i=n.sender,o=i.getParameters();(!("encodings"in o)||1===o.encodings.length&&0===an(o.encodings[0]).length)&&(o.encodings=e,i.sendEncodings=e,this.setParametersPromises.push(i.setParameters(o).then((function(){delete i.sendEncodings})).catch((function(){delete i.sendEncodings}))))}return n})}}function pk(e){if("object"===Wd(e)&&e.RTCRtpSender){var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e,r=t.apply(this,arguments);"encodings"in r||(r.encodings=Om(e=[]).call(e,this.sendEncodings||[{}]));return r})}}function fk(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Yf.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function mk(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Yf.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var gk=Object.freeze(Object.defineProperty({__proto__:null,shimOnTrack:ck,shimPeerConnection:uk,shimSenderGetStats:dk,shimReceiverGetStats:lk,shimRemoveStream:hk,shimRTCDataChannel:vk,shimAddTransceiver:_k,shimGetParameters:pk,shimCreateOffer:fk,shimCreateAnswer:mk,shimGetUserMedia:sk,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){var n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Yf.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}},Symbol.toStringTag,{value:"Module"}));function yk(e){if("object"===Wd(e)&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var r,n=this;this._localStreams||(this._localStreams=[]),mT(r=this._localStreams).call(r,e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(r){return t.call(n,r,e)})),e.getVideoTracks().forEach((function(r){return t.call(n,r,e)}))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var r=this,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return i&&i.forEach((function(e){var t;r._localStreams?mT(t=r._localStreams).call(t,e)||r._localStreams.push(e):r._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t,r,n=this;this._localStreams||(this._localStreams=[]);var i=xE(t=this._localStreams).call(t,e);if(-1!==i){rT(r=this._localStreams).call(r,i,1);var o=e.getTracks();this.getSenders().forEach((function(e){mT(o).call(o,e.track)&&n.removeTrack(e)}))}})}}function Sk(e){if("object"===Wd(e)&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){ad(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){var t=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach((function(e){var r;if(t._remoteStreams||(t._remoteStreams=[]),!mT(r=t._remoteStreams).call(r,e)){t._remoteStreams.push(e);var n=new Event("addstream");n.stream=e,t.dispatchEvent(n)}}))})}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((function(t){var r;if(e._remoteStreams||(e._remoteStreams=[]),!(xE(r=e._remoteStreams).call(r,t)>=0)){e._remoteStreams.push(t);var n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}}))}),t.apply(e,arguments)}}}function bk(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Yf.resolve()):i},t.createAnswer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Yf.resolve()):i};var s=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),Yf.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Yf.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),Yf.resolve()):n},t.addIceCandidate=s}}function Ek(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices,n=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(e){return n(Tk(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function Tk(e){return e&&void 0!==e.video?wb({},e,{video:cE(e.video)}):e}function kk(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){for(var n=[],i=0;i<e.iceServers.length;i++){var o=e.iceServers[i];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(oE("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(Mm(o))).urls=o.url,delete o.url,n.push(o)):n.push(e.iceServers[i])}e.iceServers=n}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&ad(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function Ik(e){"object"===Wd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&ad(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function Rk(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){var r,n;void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var i=yE(r=this.getTransceivers()).call(r,(function(e){return"audio"===e.receiver.track.kind}));!1===e.offerToReceiveAudio&&i?"sendrecv"===i.direction?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":"recvonly"===i.direction&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):!0!==e.offerToReceiveAudio||i||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var o=yE(n=this.getTransceivers()).call(n,(function(e){return"video"===e.receiver.track.kind}));!1===e.offerToReceiveVideo&&o?"sendrecv"===o.direction?o.setDirection?o.setDirection("sendonly"):o.direction="sendonly":"recvonly"===o.direction&&(o.setDirection?o.setDirection("inactive"):o.direction="inactive"):!0!==e.offerToReceiveVideo||o||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function Ak(e){"object"!==Wd(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var wk=Object.freeze(Object.defineProperty({__proto__:null,shimLocalStreamsAPI:yk,shimRemoteStreamsAPI:Sk,shimCallbacksAPI:bk,shimGetUserMedia:Ek,shimConstraints:Tk,shimRTCIceServerUrls:kk,shimTrackEventTransceiver:Ik,shimCreateOfferLegacy:Rk,shimAudioContext:Ak},Symbol.toStringTag,{value:"Module"})),Ck=cc.PROPER,xk=i,Ok=Gm,Nk=Jm.trim;Ar({target:"String",proto:!0,forced:function(e){return xk((function(){return!!Ok[e]()||"
"!=="
"[e]()||Ck&&Ok[e].name!==e}))}("trim")},{trim:function(){return Nk(this)}});var Dk,Pk,Mk=Us("String").trim,Lk=ae,Uk=Mk,Vk=String.prototype,Fk=function(e){var t=e.trim;return"string"==typeof e||e===Vk||Lk(Vk,e)&&t===Vk.trim?Uk:t},Bk={exports:{}};Dk=Bk,(Pk={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}}).localCName=Pk.generateIdentifier(),Pk.splitLines=function(e){var t;return jm(t=Fk(e).call(e).split("\n")).call(t,(function(e){return Fk(e).call(e)}))},Pk.splitSections=function(e){var t=e.split("\nm=");return jm(t).call(t,(function(e,t){var r;return Fk(r=t>0?"m="+e:e).call(r)+"\r\n"}))},Pk.getDescription=function(e){var t=Pk.splitSections(e);return t&&t[0]},Pk.getMediaSections=function(e){var t=Pk.splitSections(e);return t.shift(),t},Pk.matchPrefix=function(e,t){var r;return Gs(r=Pk.splitLines(e)).call(r,(function(e){return 0===xE(e).call(e,t)}))},Pk.parseCandidate=function(e){for(var t,r={foundation:(t=0===xE(e).call(e,"a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:ug(t[3],10),ip:t[4],address:t[4],port:ug(t[5],10),type:t[7]},n=8;n<t.length;n+=2)switch(t[n]){case"raddr":r.relatedAddress=t[n+1];break;case"rport":r.relatedPort=ug(t[n+1],10);break;case"tcptype":r.tcpType=t[n+1];break;case"ufrag":r.ufrag=t[n+1],r.usernameFragment=t[n+1];break;default:void 0===r[t[n]]&&(r[t[n]]=t[n+1])}return r},Pk.writeCandidate=function(e){var t=[];t.push(e.foundation);var r=e.component;"rtp"===r?t.push(1):"rtcp"===r?t.push(2):t.push(r),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},Pk.parseIceOptions=function(e){return e.substr(14).split(" ")},Pk.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:ug(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=ug(t[1],10),r.channels=3===t.length?ug(t[2],10):1,r.numChannels=r.channels,r},Pk.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==r?"/"+r:"")+"\r\n"},Pk.parseExtmap=function(e){var t,r=e.substr(9).split(" ");return{id:ug(r[0],10),direction:xE(t=r[0]).call(t,"/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},Pk.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},Pk.parseFmtp=function(e){for(var t,r={},n=e.substr(xE(e).call(e," ")+1).split(";"),i=0;i<n.length;i++){var o,a;t=Fk(o=n[i]).call(o).split("="),r[Fk(a=t[0]).call(a)]=t[1]}return r},Pk.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&an(e.parameters).length){var n=[];an(e.parameters).forEach((function(t){void 0!==e.parameters[t]?n.push(t+"="+e.parameters[t]):n.push(t)})),t+="a=fmtp:"+r+" "+n.join(";")+"\r\n"}return t},Pk.parseRtcpFb=function(e){var t=e.substr(xE(e).call(e," ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},Pk.writeRtcpFb=function(e){var t="",r=e.payloadType;return void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+r+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},Pk.parseSsrcMedia=function(e){var t=xE(e).call(e," "),r={ssrc:ug(e.substr(7,t-7),10)},n=xE(e).call(e,":",t);return n>-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},Pk.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:jm(t).call(t,(function(e){return ug(e,10)}))}},Pk.getMid=function(e){var t=Pk.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},Pk.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},Pk.getDtlsParameters=function(e,t){var r=Pk.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:jm(r).call(r,Pk.parseFingerprint)}},Pk.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),r},Pk.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:ug(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:Tm(t).call(t,3)}},Pk.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===Wd(e.keyParams)?Pk.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},Pk.parseCryptoKeyParams=function(e){if(0!==xE(e).call(e,"inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},Pk.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},Pk.getCryptoParameters=function(e,t){var r=Pk.matchPrefix(e+t,"a=crypto:");return jm(r).call(r,Pk.parseCryptoLine)},Pk.getIceParameters=function(e,t){var r=Pk.matchPrefix(e+t,"a=ice-ufrag:")[0],n=Pk.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},Pk.writeIceParameters=function(e){var t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},Pk.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=Pk.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],o=Pk.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(o){var a,s=Pk.parseRtpMap(o),c=Pk.matchPrefix(e,"a=fmtp:"+i+" ");switch(s.parameters=c.length?Pk.parseFmtp(c[0]):{},s.rtcpFeedback=jm(a=Pk.matchPrefix(e,"a=rtcp-fb:"+i+" ")).call(a,Pk.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return Pk.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(Pk.parseExtmap(e))})),t},Pk.writeRtpDescription=function(e,t){var r,n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=jm(r=t.codecs).call(r,(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach((function(e){n+=Pk.writeRtpMap(e),n+=Pk.writeFmtp(e),n+=Pk.writeRtcpFb(e)}));var i=0;return t.codecs.forEach((function(e){e.maxptime>i&&(i=e.maxptime)})),i>0&&(n+="a=maxptime:"+i+"\r\n"),t.headerExtensions&&t.headerExtensions.forEach((function(e){n+=Pk.writeExtmap(e)})),n},Pk.parseRtpEncodingParameters=function(e){var t,r,n,i,o,a,s=[],c=Pk.parseRtpParameters(e),u=-1!==xE(t=c.fecMechanisms).call(t,"RED"),d=-1!==xE(r=c.fecMechanisms).call(r,"ULPFEC"),l=Gs(n=jm(i=Pk.matchPrefix(e,"a=ssrc:")).call(i,(function(e){return Pk.parseSsrcMedia(e)}))).call(n,(function(e){return"cname"===e.attribute})),h=l.length>0&&l[0].ssrc,v=jm(o=Pk.matchPrefix(e,"a=ssrc-group:FID")).call(o,(function(e){var t=e.substr(17).split(" ");return jm(t).call(t,(function(e){return ug(e,10)}))}));v.length>0&&v[0].length>1&&v[0][0]===h&&(a=v[0][1]),c.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:h,codecPayloadType:ug(e.parameters.apt,10)};h&&a&&(t.rtx={ssrc:a}),s.push(t),u&&((t=JSON.parse(Mm(t))).fec={ssrc:h,mechanism:d?"red+ulpfec":"red"},s.push(t))}})),0===s.length&&h&&s.push({ssrc:h});var _,p,f=Pk.matchPrefix(e,"b=");return f.length&&(f=0===xE(_=f[0]).call(_,"b=TIAS:")?ug(f[0].substr(7),10):0===xE(p=f[0]).call(p,"b=AS:")?1e3*ug(f[0].substr(5),10)*.95-16e3:void 0,s.forEach((function(e){e.maxBitrate=f}))),s},Pk.parseRtcpParameters=function(e){var t,r,n={},i=Gs(t=jm(r=Pk.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return Pk.parseSsrcMedia(e)}))).call(t,(function(e){return"cname"===e.attribute}))[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);var o=Pk.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=o.length>0,n.compound=0===o.length;var a=Pk.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},Pk.writeRtcpParameters=function(e){var t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},Pk.parseMsid=function(e){var t,r,n,i=Pk.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(n=i[0].substr(7).split(" "))[0],track:n[1]};var o=Gs(t=jm(r=Pk.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return Pk.parseSsrcMedia(e)}))).call(t,(function(e){return"msid"===e.attribute}));return o.length>0?{stream:(n=o[0].value.split(" "))[0],track:n[1]}:void 0},Pk.parseSctpDescription=function(e){var t,r=Pk.parseMLine(e),n=Pk.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=ug(n[0].substr(19),10)),isNaN(t)&&(t=65536);var i=Pk.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:ug(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};var o=Pk.matchPrefix(e,"a=sctpmap:");if(o.length>0){var a=o[0].substr(10).split(" ");return{port:ug(a[0],10),protocol:a[1],maxMessageSize:t}}},Pk.writeSctpDescription=function(e,t){var r=[];return r="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},Pk.generateSessionId=function(){return Math.random().toString().substr(2,21)},Pk.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||Pk.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},Pk.getDirection=function(e,t){for(var r=Pk.splitLines(e),n=0;n<r.length;n++)switch(r[n]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[n].substr(2)}return t?Pk.getDirection(t):"sendrecv"},Pk.getKind=function(e){return Pk.splitLines(e)[0].split(" ")[0].substr(2)},Pk.isRejected=function(e){return"0"===e.split(" ",2)[1]},Pk.parseMLine=function(e){var t=Pk.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:ug(t[1],10),protocol:t[2],fmt:Tm(t).call(t,3).join(" ")}},Pk.parseOLine=function(e){var t=Pk.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:ug(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},Pk.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=Pk.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},Dk.exports=Pk;var jk=Bk.exports,Gk=e({__proto__:null,default:jk},[Bk.exports]);function Hk(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){var r;if("object"===Wd(e)&&e.candidate&&0===xE(r=e.candidate).call(r,"a=")&&((e=JSON.parse(Mm(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=jk.parseCandidate(e.candidate),o=wb(n,i);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,tE(e,"icecandidate",(function(t){return t.candidate&&ad(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function zk(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||tE(e,"icecandidate",(function(e){if(e.candidate){var t=jk.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function Kk(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||ad(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var r=function(e){if(!e||!e.sdp)return!1;var t=jk.splitSections(e.sdp);return t.shift(),t.some((function(e){var t,r=jk.parseMLine(e);return r&&"application"===r.kind&&-1!==xE(t=r.protocol).call(t,"SCTP")}))},n=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=ug(t[1],10);return r!=r?-1:r},i=function(e){var r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r},o=function(e,r){var n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);var i=jk.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=ug(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){var e=this.getConfiguration(),s=e.sdpSemantics;"plan-b"===s&&ad(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){var c,u=n(arguments[0]),d=i(u),l=o(arguments[0],u);c=0===d&&0===l?Number.POSITIVE_INFINITY:0===d||0===l?Math.max(d,l):Math.min(d,l);var h={};ad(h,"maxMessageSize",{get:function(){return c}}),this._sctp=h}return a.apply(this,arguments)}}}function Xk(e){if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=t.apply(this,arguments);return r(e),e},tE(e,"datachannel",(function(e){return r(e.channel,e.target),e}))}function r(e,t){var r=e.send;e.send=function(){return r.apply(e,arguments)}}}function Wk(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;ad(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),ad(t,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((function(e){var r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}}))}}function qk(e,t){if(e.RTCPeerConnection&&!("chrome"===t.browser&&t.version>=71||"safari"===t.browser&&t.version>=605)){var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){var n;if(t&&t.sdp&&-1!==xE(n=t.sdp).call(n,"\na=extmap-allow-mixed")){var i,o=Gs(i=t.sdp.split("\n")).call(i,(function(e){return"a=extmap-allow-mixed"!==Fk(e).call(e)})).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:o}):t.sdp=o}return r.apply(this,arguments)}}}function Yk(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.addIceCandidate;r&&0!==r.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Yf.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Yf.resolve())})}}function Jk(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.setLocalDescription;r&&0!==r.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this,t=arguments[0]||{};if("object"!==Wd(t)||t.type&&t.sdp)return r.apply(this,arguments);if(!(t={type:t.type,sdp:t.sdp}).type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":t.type="offer";break;default:t.type="answer"}if(t.sdp||"offer"!==t.type&&"answer"!==t.type)return r.apply(this,[t]);var n="offer"===t.type?this.createOffer:this.createAnswer;return n.apply(this).then((function(t){return r.apply(e,[t])}))})}}var Qk=Object.freeze(Object.defineProperty({__proto__:null,shimRTCIceCandidate:Hk,shimRTCIceCandidateRelayProtocol:zk,shimMaxMessageSize:Kk,shimSendThrowTypeError:Xk,shimConnectionState:Wk,removeExtmapAllowMixed:qk,shimAddIceCandidateNullOrEmpty:Yk,shimParameterlessSetLocalDescription:Jk},Symbol.toStringTag,{value:"Module"}));if(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.window,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},n=iE,i=aE(t),o={browserDetails:i,commonShim:Qk,extractVersion:eE,disableLog:rE,disableWarnings:nE,sdp:Gk};switch(i.browser){case"chrome":if(!CT||!AT||!r.shimChrome)return n("Chrome shim is not included in this adapter release."),o;if(null===i.version)return n("Chrome shim can not determine version, not shimming."),o;n("adapter.js shimming chrome."),o.browserShim=CT,Yk(t,i),Jk(t),yT(t,i),ST(t),AT(t,i),bT(t),RT(t,i),ET(t),TT(t),kT(t),wT(t,i),Hk(t),zk(t),Wk(t),Kk(t,i),Xk(t),qk(t,i);break;case"firefox":if(!gk||!uk||!r.shimFirefox)return n("Firefox shim is not included in this adapter release."),o;n("adapter.js shimming firefox."),o.browserShim=gk,Yk(t,i),Jk(t),sk(t,i),uk(t,i),ck(t),hk(t),dk(t),lk(t),vk(t),_k(t),pk(t),fk(t),mk(t),Hk(t),Wk(t),Kk(t,i),Xk(t);break;case"safari":if(!wk||!r.shimSafari)return n("Safari shim is not included in this adapter release."),o;n("adapter.js shimming safari."),o.browserShim=wk,Yk(t,i),Jk(t),kk(t),Rk(t),bk(t),yk(t),Sk(t),Ik(t),Ek(t),Ak(t),Hk(t),zk(t),Kk(t,i),Xk(t),qk(t,i);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window}),"undefined"!=typeof MediaStreamTrack){var Zk=MediaStreamTrack.prototype.getSettings;MediaStreamTrack.prototype.getSettings=function(){var e=Zk.call(this);return e.width&&(e.width=Math.floor(e.width)),e.height&&(e.height=Math.floor(e.height)),e.frameRate&&(e.frameRate=Math.floor(e.frameRate)),e}}function $k(e,t){var r=void 0!==wd&&NT(e)||e["@@iterator"];if(!r){if(xT(e)||(r=YT(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function eI(e,t){return function(e){if(xT(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==wd&&NT(e)||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],c=!0,u=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(d){u=!0,i=d}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||YT(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tI(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var rI=Ye,nI=function(e){return void 0!==e&&(rI(e,"value")||rI(e,"writable"))},iI=O,oI=$,aI=tr,sI=nI,cI=A,uI=mc;Ar({target:"Reflect",stat:!0},{get:function e(t,r){var n,i,o=arguments.length<3?t:arguments[2];return aI(t)===o?t[r]:(n=cI.f(t,r))?sI(n)?n.value:void 0===n.get?void 0:iI(n.get,o):oI(i=uI(t))?e(i,r,o):void 0}});var dI=ee.Reflect.get,lI=E,hI=Ce,vI=$,_I=Ye,pI=rs,fI=o,mI=Function,gI=lI([].concat),yI=lI([].join),SI={},bI=function(e,t,r){if(!_I(SI,t)){for(var n=[],i=0;i<t;i++)n[i]="a["+i+"]";SI[t]=mI("C,a","return new C("+yI(n,",")+")")}return SI[t](e,r)},EI=fI?mI.bind:function(e){var t=hI(this),r=t.prototype,n=pI(arguments,1),i=function(){var r=gI(n,pI(arguments));return this instanceof i?bI(t,r.length,r):t.apply(e,r)};return vI(r)&&(i.prototype=r),i},TI=EI;Ar({target:"Function",proto:!0,forced:Function.bind!==TI},{bind:TI});var kI=Us("Function").bind,II=ae,RI=kI,AI=Function.prototype,wI=function(e){var t=e.bind;return e===AI||II(AI,e)&&t===AI.bind?RI:t};function CI(e){var t;return(CI=Kl?wI(t=zl).call(t):function(e){return e.__proto__||zl(e)})(e)}function xI(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=CI(e)););return e}function OI(){var e;"undefined"!=typeof Reflect&&dI?OI=wI(e=dI).call(e):OI=function(e,t,r){var n=xI(e,t);if(n){var i=tc(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}};return OI.apply(this,arguments)}function NI(e,t){var r;return(NI=Kl?wI(r=Kl).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function DI(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Bl(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),ad(e,"prototype",{writable:!1}),t&&NI(e,t)}var PI=Ar,MI=d,LI=EI,UI=bv,VI=tr,FI=$,BI=Hn,jI=i,GI=oe("Reflect","construct"),HI=Object.prototype,zI=[].push,KI=jI((function(){function e(){}return!(GI((function(){}),[],e)instanceof e)})),XI=!jI((function(){GI((function(){}))})),WI=KI||XI;PI({target:"Reflect",stat:!0,forced:WI,sham:WI},{construct:function(e,t){UI(e),VI(t);var r=arguments.length<3?e:UI(arguments[2]);if(XI&&!KI)return GI(e,t,r);if(e==r){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var n=[null];return MI(zI,n,t),new(MI(LI,e,n))}var i=r.prototype,o=BI(FI(i)?i:HI),a=MI(e,o,t);return FI(a)?a:o}});var qI=ee.Reflect.construct;function YI(){if("undefined"==typeof Reflect||!qI)return!1;if(qI.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(qI(Boolean,[],(function(){}))),!0}catch(e){return!1}}function JI(e,t){if(t&&("object"===Wd(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return tI(e)}function QI(e){var t=YI();return function(){var r,n=CI(e);if(t){var i=CI(this).constructor;r=qI(n,arguments,i)}else r=n.apply(this,arguments);return JI(this,r)}}var ZI=Us("Array").values,$I=pn,eR=Ye,tR=ae,rR=ZI,nR=Array.prototype,iR={DOMTokenList:!0,NodeList:!0},oR=function(e){var t=e.values;return e===nR||tR(nR,e)&&t===nR.values||eR(iR,$I(e))?rR:t},aR=ni,sR=Math.floor,cR=function(e,t){var r=e.length,n=sR(r/2);return r<8?uR(e,t):dR(e,cR(aR(e,0,n),t),cR(aR(e,n),t),t)},uR=function(e,t){for(var r,n,i=e.length,o=1;o<i;){for(n=o,r=e[o];n&&t(e[n-1],r)>0;)e[n]=e[--n];n!==o++&&(e[n]=r)}return e},dR=function(e,t,r,n){for(var i=t.length,o=r.length,a=0,s=0;a<i||s<o;)e[a+s]=a<i&&s<o?n(t[a],r[s])<=0?t[a++]:r[s++]:a<i?t[a++]:r[s++];return e},lR=cR,hR=se.match(/firefox\/(\d+)/i),vR=!!hR&&+hR[1],_R=/MSIE|Trident/.test(se),pR=se.match(/AppleWebKit\/(\d+)\./),fR=!!pR&&+pR[1],mR=Ar,gR=E,yR=Ce,SR=Xe,bR=Br,ER=VE,TR=gn,kR=i,IR=lR,RR=Iu,AR=vR,wR=_R,CR=_e,xR=fR,OR=[],NR=gR(OR.sort),DR=gR(OR.push),PR=kR((function(){OR.sort(void 0)})),MR=kR((function(){OR.sort(null)})),LR=RR("sort"),UR=!kR((function(){if(CR)return CR<70;if(!(AR&&AR>3)){if(wR)return!0;if(xR)return xR<603;var e,t,r,n,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(n=0;n<47;n++)OR.push({k:t+n,v:r})}for(OR.sort((function(e,t){return t.v-e.v})),n=0;n<OR.length;n++)t=OR[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));mR({target:"Array",proto:!0,forced:PR||!MR||!LR||!UR},{sort:function(e){void 0!==e&&yR(e);var t=SR(this);if(UR)return void 0===e?NR(t):NR(t,e);var r,n,i=[],o=bR(t);for(n=0;n<o;n++)n in t&&DR(i,t[n]);for(IR(i,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:TR(t)>TR(r)?1:-1}}(e)),r=bR(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)ER(t,n++);return t}});var VR=Us("Array").sort,FR=ae,BR=VR,jR=Array.prototype,GR=function(e){var t=e.sort;return e===jR||FR(jR,e)&&t===jR.sort?BR:t},HR=Ar,zR=Po.findIndex,KR="findIndex",XR=!0;KR in[]&&Array(1).findIndex((function(){XR=!1})),HR({target:"Array",proto:!0,forced:XR},{findIndex:function(e){return zR(this,e,arguments.length>1?arguments[1]:void 0)}});var WR=Us("Array").findIndex,qR=ae,YR=WR,JR=Array.prototype,QR=function(e){var t=e.findIndex;return e===JR||qR(JR,e)&&t===JR.findIndex?YR:t},ZR=Ar,$R=E;A.f;var eA=Vr,tA=gn,rA=Pb,nA=W,iA=Lb,oA=$R("".startsWith),aA=$R("".slice),sA=Math.min;ZR({target:"String",proto:!0,forced:!iA("startsWith")},{startsWith:function(e){var t=tA(nA(this));rA(e);var r=eA(sA(arguments.length>1?arguments[1]:void 0,t.length)),n=tA(e);return oA?oA(t,n,r):aA(t,r,r+n.length)===n}});var cA=Us("String").startsWith,uA=ae,dA=cA,lA=String.prototype,hA=function(e){var t=e.startsWith;return"string"==typeof e||e===lA||uA(lA,e)&&t===lA.startsWith?dA:t},vA=function(e){return e.INVALID_ENGINE="INVALID_ENGINE",e.INVALID_PARAMS="INVALID_PARAMS",e.INVOKED_BEFORE_JOIN_ROOM="INVOKED_BEFORE_JOIN_ROOM",e.INVALID_TOKEN="INVALID_TOKEN",e.EXPIRED_TOKEN="EXPIRED_TOKEN",e.JOIN_ROOM_FAILED="JOIN_ROOM_FAILED",e.UPDATE_TOKEN_WITH_INVALID_TOKEN="UPDATE_TOKEN_WITH_INVALID_TOKEN",e.UPDATE_TOKEN_BEFORE_JOIN="UPDATE_TOKEN_BEFORE_JOIN",e.REPEAT_JOIN="REPEAT_JOIN",e.REPEAT_PUBLISH="REPEAT_PUBLISH",e.REPEAT_PUSH="REPEAT_PUSH",e.REPEAT_PLAY="REPEAT_PLAY",e.PUBLISH_BEFORE_JOIN="PUBLISH_BEFORE_JOIN",e.UNPUBLISH_BEFORE_JOIN="UNPUBLISH_BEFORE_JOIN",e.SUBSCRIBE_BEFORE_JOIN="SUBSCRIBE_BEFORE_JOIN",e.UNSUBSCRIBE_BEFORE_JOIN="UNSUBSCRIBE_BEFORE_JOIN",e.NO_PUBLISH_PERMISSION="NO_PUBLISH_PERMISSION",e.STREAM_NOT_EXIST="STREAM_NOT_EXIST",e.EMPTY_STREAM="EMPTY_STREAM",e.NOT_CONNECTED_YET="NOT_CONNECTED_YET",e.IM_BEFORE_JOIN="IM_BEFORE_JOIN",e.USER_NOT_EXIST="USER_NOT_EXIST",e.ALREADY_IN_ROOM="ALREADY_IN_ROOM",e.KICKED_OUT="KICKED_OUT",e.ROOM_DISMISS="ROOM_DISMISS",e.TOKEN_EXPIRED="TOKEN_EXPIRED",e.DUPLICATE_LOGIN="DUPLICATE_LOGIN",e.INVOKED_BEFORE_CAPTURE="INVOKED_BEFORE_CAPTURE",e.REPEAT_CAPTURE="REPEAT_CAPTURE",e.GET_VIDEO_TRACK_FAILED="GET_VIDEO_TRACK_FAILED",e.GET_AUDIO_TRACK_FAILED="GET_AUDIO_TRACK_FAILED",e.GET_SCREEN_TRACK_FAILED="GET_SCREEN_TRACK_FAILED",e.STREAM_TYPE_NOT_MATCH="STREAM_TYPE_NOT_MATCH",e.CANT_FIND_DOM="CANT_FIND_DOM",e.INVALID_DEVICE_ID="INVALID_DEVICE_ID",e.NO_PERMISSION="NO_PERMISSION",e.NOT_SUPPORTED="NOT_SUPPORTED",e.INTERRUPT="INTERRUPT",e.ICE_SERVER_WRONG="ICE_SERVER_WRONG",e.ESTABLISH_DATACHANNEL_FAILED="ESTABLISH_DATACHANNEL_FAILED",e.LOAD_RESOURCES_FAILED="LOAD_RESOURCES_FAILED",e.SIGNALING_CHANNEL_NOT_OPEN="SIGNALING_CHANNEL_NOT_OPEN",e.TIME_OUT="TIME_OUT",e.REFUSE_OPERATION_IN_DISCONNECT="REFUSE_OPERATION_IN_DISCONNECT",e.ADD_TRANSCEIVER_FAILED="ADD_TRANSCEIVER_FAILED",e.UPDATE_TRACK_FAILED="UPDATE_TRACK_FAILED",e.PUBLISH_FAILED="PUBLISH_FAILED",e.UNPUBLISH_FAILED="UNPUBLISH_FAILED",e.SUBSCRIBE_FAILED="SUBSCRIBE_FAILED",e.UNSUBSCRIBE_FAILED="UNSUBSCRIBE_FAILED",e.OPERATION_CANCEL="OPERATION_CANCEL",e.START_CLOUD_PROXY_AFTER_JOIN="START_CLOUD_PROXY_AFTER_JOIN",e.STOP_CLOUD_PROXY_BEFORE_LEAVE="STOP_CLOUD_PROXY_BEFORE_LEAVE",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.REPEAT_DEVICE_TEST="REPEAT_DEVICE_TEST",e.AUDIO_DEVICE_TEST_FAILED="AUDIO_DEVICE_RECORD_FAILED",e.ALREADY_LOGIN="ALREADY_LOGIN",e.LOGIN_FAILED="LOGIN_FAILED",e.NOT_LOGIN="NOT_LOGIN",e.RTM_DUPLICATE_LOGIN="RTM_DUPLICATE_LOGIN",e.RTM_TOKEN_ERROR="RTM_TOKEN_ERROR",e.USER_MESSAGE_TIMEOUT="USER_MESSAGE_TIMEOUT",e.USER_MESSAGE_BROKEN="USER_MESSAGE_BROKEN",e.USER_MESSAGE_NO_RECEIVER="USER_MESSAGE_NO_RECEIVER",e.USER_MESSAGE_NO_RELAYPATH="USER_MESSAGE_NO_RELAYPATH",e.USER_MESSAGE_EXCEED_QPS="USER_MESSAGE_EXCEED_QPS",e.USER_MESSAGE_SEND_TO_SERVER_ERROR="USER_MESSAGE_SEND_TO_SERVER_ERROR",e.USER_MESSAGE_SERVER_RESPONSE_ERROR="USER_MESSAGE_SERVER_RESPONSE_ERROR",e.USER_MESSAGE_NOT_JOIN="USER_MESSAGE_NOT_JOIN",e.USER_MESSAGE_INIT="USER_MESSAGE_INIT",e.USER_MESSAGE_NO_CONNECTION="USER_MESSAGE_NO_CONNECTION",e.USER_MESSAGE_NOT_LOGIN="USER_MESSAGE_NOT_LOGIN",e.USER_MESSAGE_SERVER_PARAMS_NOTSET="USER_MESSAGE_SERVER_PARAMS_NOTSET",e.USER_MESSAGE_UNKNOWN="USER_MESSAGE_UNKNOWN",e.START_PUBLIC_STREAM_BEFORE_JOIN="START_PUBLIC_STREAM_BEFORE_JOIN",e.RECONNECT_FAILED="RECONNECT_FAILED",e.SUBTITLE_ALREADY_ON="SUBTITLE_ALREADY_ON",e.SUBTITLE_NOT_TURNED_ON="SUBTITLE_NOT_TURNED_ON",e.SUBTITLE_ERR_POSTPROCESS="SUBTITLE_ERR_POSTPROCESS",e.SUBTITLE_ERR_CONNECTION_ERROR="SUBTITLE_ERR_CONNECTION_ERROR",e.SUBTITLE_ERR_PROCESS_ERROR="SUBTITLE_ERR_PROCESS_ERROR",e.SUBTITLE_ERR_UNKNOWN="SUBTITLE_ERR_UNKNOWN",e.UNEXPECTED_INVOKE_FORWARD_STREAM="UNEXPECTED_INVOKE_FORWARD_STREAM",e}(vA||{}),_A=function(e){return e[e.AUDIO_MIXING_ERROR_OK=0]="AUDIO_MIXING_ERROR_OK",e[e.AUDIO_MIXING_ERROR_PRELOAD_FAILED=1]="AUDIO_MIXING_ERROR_PRELOAD_FAILED",e[e.AUDIO_MIXING_ERROR_START_FAILED=2]="AUDIO_MIXING_ERROR_START_FAILED",e[e.AUDIO_MIXING_ERROR_ID_NOT_FOUND=3]="AUDIO_MIXING_ERROR_ID_NOT_FOUND",e[e.AUDIO_MIXING_ERROR_SET_POSITION_FAILED=4]="AUDIO_MIXING_ERROR_SET_POSITION_FAILED",e[e.AUDIO_MIXING_ERROR_INVALID_VOLUME=5]="AUDIO_MIXING_ERROR_INVALID_VOLUME",e[e.AUDIO_MIXING_ERROR_LOAD_CONFLICT=6]="AUDIO_MIXING_ERROR_LOAD_CONFLICT",e[e.AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH=7]="AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH",e[e.AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH=8]="AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH",e[e.AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK=9]="AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK",e}(_A||{});function pA(e,t,r){var n;YI()?pA=wI(n=qI).call(n):pA=function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(wI(Function).apply(e,n));return r&&NI(i,r.prototype),i};return pA.apply(null,arguments)}function fA(e){var t="function"==typeof $S?new $S:void 0;return fA=function(e){if(null===e||(r=e,-1===xE(n=Function.toString.call(r)).call(n,"[native code]")))return e;var r,n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return pA(e,arguments,CI(this).constructor)}return i.prototype=Bl(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),NI(i,e)},fA(e)}var mA=function(e){DI(r,e);var t=QI(r);function r(e,n,i){var o;return Vl(this,r),Jd(tI(o=t.call(this,n)),"code",void 0),Jd(tI(o),"message",void 0),Jd(tI(o),"error",void 0),o.code=e,o.message=n,o.error=i,Kl(tI(o),r.prototype),o}return Ul(r,[{key:"toString",value:function(){var e;return Om(e="SDKError: ".concat(this.code," ")).call(e,this.message)}}]),r}(fA(Error)),gA=w,yA=E,SA=rn,bA=J,EA=yA(N.f),TA=yA([].push),kA=function(e){return function(t){for(var r,n=bA(t),i=SA(n),o=i.length,a=0,s=[];o>a;)r=i[a++],gA&&!EA(n,r)||TA(s,e?[r,n[r]]:n[r]);return s}},IA={entries:kA(!0),values:kA(!1)}.entries;Ar({target:"Object",stat:!0},{entries:function(e){return IA(e)}});var RA=ee.Object.entries,AA=Or,wA=gn,CA=W,xA=RangeError,OA=E,NA=Vr,DA=gn,PA=function(e){var t=wA(CA(this)),r="",n=AA(e);if(n<0||n==1/0)throw xA("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},MA=W,LA=OA(PA),UA=OA("".slice),VA=Math.ceil,FA=function(e){return function(t,r,n){var i,o,a=DA(MA(t)),s=NA(r),c=a.length,u=void 0===n?" ":DA(n);return s<=c||""==u?a:((o=LA(u,VA((i=s-c)/u.length))).length>i&&(o=UA(o,0,i)),e?a+o:o+a)}},BA={start:FA(!1),end:FA(!0)},jA=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(se),GA=BA.end;Ar({target:"String",proto:!0,forced:jA},{padEnd:function(e){return GA(this,e,arguments.length>1?arguments[1]:void 0)}});var HA=Us("String").padEnd,zA=ae,KA=HA,XA=String.prototype,WA=function(e){var t=e.padEnd;return"string"==typeof e||e===XA||zA(XA,e)&&t===XA.padEnd?KA:t},qA=cg;Ar({target:"Number",stat:!0,forced:Number.parseInt!=qA},{parseInt:qA});var YA=ee.Number.parseInt,JA=Math.log,QA=Math.LOG10E;Ar({target:"Math",stat:!0},{log10:Math.log10||function(e){return JA(e)*QA}});var ZA,$A=ee.Math.log10,ew=Us("Array").keys,tw=pn,rw=Ye,nw=ae,iw=ew,ow=Array.prototype,aw={DOMTokenList:!0,NodeList:!0},sw=function(e){var t=e.keys;return e===ow||nw(ow,e)&&t===ow.keys||rw(aw,tw(e))?iw:t},cw=new Uint8Array(16);function uw(){if(!ZA&&!(ZA="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ZA(cw)}var dw=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function lw(e){return"string"==typeof e&&dw.test(e)}for(var hw=[],vw=0;vw<256;++vw)hw.push((vw+256).toString(16).substr(1));function _w(e,t,r){var n=(e=e||{}).random||(e.rng||uw)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=n[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(hw[e[t+0]]+hw[e[t+1]]+hw[e[t+2]]+hw[e[t+3]]+"-"+hw[e[t+4]]+hw[e[t+5]]+"-"+hw[e[t+6]]+hw[e[t+7]]+"-"+hw[e[t+8]]+hw[e[t+9]]+"-"+hw[e[t+10]]+hw[e[t+11]]+hw[e[t+12]]+hw[e[t+13]]+hw[e[t+14]]+hw[e[t+15]]).toLowerCase();if(!lw(r))throw TypeError("Stringified UUID is invalid");return r}(n)}var pw=function(){return"undefined"==typeof window},fw=function(){return _w()},mw=function(e){return"number"==typeof e},gw=function(e){var t;return mT(t=Function.prototype.toString.call(e)).call(t,"[native code]")},yw="@byted/ve-rtc",Sw="@byted/ve-rtc-cache-size",bw=function(){function e(){Vl(this,e),Jd(this,"storeKey",void 0),Jd(this,"logLevel",void 0),Jd(this,"LogfileSize",void 0),Jd(this,"db",void 0),Jd(this,"logId",void 0),Jd(this,"cacheLog",void 0),Jd(this,"cachedSize",void 0),Jd(this,"preCacheTime",void 0),Jd(this,"timer",void 0),Jd(this,"_getSize",(function(e){return new Blob(e).size/1048576})),this.storeKey="",this.logId=1,this.cacheLog="",this.logLevel="none",this.LogfileSize=100,this._createStore()}return Ul(e,[{key:"_createStore",value:function(){var e=this;if(!pw()&&window.indexedDB){var t=indexedDB.open("@byted/ve-rtc");t.onupgradeneeded=function(){t.result.createObjectStore(yw);try{localStorage.removeItem(Sw)}catch(uW){}},t.onerror=function(e){},t.onsuccess=function(){e.db=t.result,e._getCachedSize()}}}},{key:"_getCachedSize",value:function(){var e=this;try{var t=localStorage.getItem(Sw);if(t)this.cachedSize=Number(t);else oR(this).call(this).then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(uW){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(Sw,"".concat(this.cachedSize))}catch(uW){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(yw,e).objectStore(yw)}},{key:"set",value:function(e){var t=this;return new Yf((function(r,n){if("none"===t.logLevel)return r();var i;if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+=Om(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,t.timer||(t.timer=setTimeout((function(){t.set("")}),1e3-(t.preCacheTime-Date.now()))),r();clearTimeout(t.timer),t.timer=null;var o=t._getStore("readwrite");if(!o)return n("get store fail");t.cachedSize&&t.cachedSize>t.LogfileSize&&t.keyEarliest().then((function(e){t.get(e).then((function(r){t.del(e).then((function(){t.cachedSize=t.cachedSize-t._getSize(["".concat(r)]),t._setCachedSize()}))}))}));var a=o.get(t.storeKey);a.onsuccess=function(){try{var i,s,c,u,d,l=Om(i="".concat(a.result||"")).call(i,t.cacheLog),h=e?Om(s=Om(c="".concat(l?"\n\n":"")).call(c,t.logId,": ")).call(s,e):"";o.put(Om(u="".concat(l)).call(u,h),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize([Om(d="".concat(t.cacheLog)).call(d,h)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(_){var v;if(!e)return n(_);t.cacheLog+=Om(v="\n\n".concat(t.logId,": ")).call(v,e),t.logId++,n(_)}},a.onerror=function(r){var i;if(!e)return n(r);t.cacheLog+=Om(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new Yf((function(r,n){var i=t._getStore("readonly");if(!i)return n();var o=i.get(e);o.onsuccess=function(){r(o.result)},o.onerror=function(e){n(e)}}))}},{key:"del",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.storeKey;return new Yf((function(r,n){var i=e._getStore("readwrite");if(!i)return n();var o=i.delete(t);o.onsuccess=function(){return r(o.result)},o.onerror=function(e){return n(e)}}))}},{key:"keyEarliest",value:function(){return sw(this).call(this).then((function(e){var t,r=Date.now();return e.forEach((function(e){if(e&&e.length){var n=e.split("-")[0];Number(n)<r&&(r=Number(n),t=e)}})),t}))}},{key:"keys",value:function(){var e=this;return new Yf((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAllKeys){var i=n.getAllKeys();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.key),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"values",value:function(){var e=this;return new Yf((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAll){var i=n.getAll();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.value),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"download",value:function(e){e=e||this.storeKey,this.get(e).then((function(t){var r=document.createElement("a");r.download="".concat(e,".txt"),r.href="data:text/paint;utf-8,".concat(t||""),r.click()}))}}]),e}(),Ew=new bw,Tw=BA.start;Ar({target:"String",proto:!0,forced:jA},{padStart:function(e){return Tw(this,e,arguments.length>1?arguments[1]:void 0)}});var kw,Iw,Rw=Us("String").padStart,Aw=ae,ww=Rw,Cw=String.prototype,xw=function(e){var t=e.padStart;return"string"==typeof e||e===Cw||Aw(Cw,e)&&t===Cw.padStart?ww:t},Ow="[VERTC]",Nw="#0050b3",Dw=(Jd(kw={},"DEBUG","rgba(0, 0, 0, 0)"),Jd(kw," INFO","rgba(93, 173, 226, 0)"),Jd(kw," WARN","rgba(255, 119, 0, 0.3)"),Jd(kw,"ERROR","rgba(255, 0, 0, 0.3)"),Jd(kw," SUCC","rgba(0, 119, 0, 0.3)"),kw),Pw="undefined"!=typeof window&&mT(Iw=window.location.search).call(Iw,"_rtc_debug_"),Mw=function(){function e(t,r){Vl(this,e),Jd(this,"indent",void 0),Jd(this,"module",void 0),this.module=t,this.indent=r}return Ul(e,[{key:"log",value:function(e,t){for(var r,n,i,o,a,s,c,u,d=arguments.length,l=new Array(d>2?d-2:0),h=2;h<d;h++)l[h-2]=arguments[h];var v=l.shift();try{var _,p,f,m,g=Om(_=[]).call(_,l),y="".concat(v).replace(/%o/gi,(function(){var e=g.shift();return Mm(e)}));Ew.set(Om(p=Om(f=Om(m="".concat(Ow,"[").concat(this.module,".")).call(m,t,"] ")).call(f,y," ")).call(p,jm(g).call(g,(function(e){return Mm(e)})).join(", ")))}catch(uW){}if(Pw){for(var S="",b=0;b<this.indent;b++)S+=" ";(r=console).log.apply(r,Om(n=[Om(i=Om(o=Om(a=Om(s=Om(c=Om(u="%c".concat(Lw(),"-")).call(u,Ow,"%c[")).call(c,e,"]%c")).call(s,S,"[")).call(a,this.module,".")).call(o,t,"] ")).call(i,v),"color:".concat(Nw,";"),"background-color:".concat(Dw[e],";"),"color:".concat(Nw,";")]).call(n,l))}}},{key:"print",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=[" INFO",e]).call(t,n))}},{key:"debug",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=["DEBUG",e]).call(t,n))}},{key:"info",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=[" INFO",e]).call(t,n))}},{key:"warn",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=[" WARN",e]).call(t,n))}},{key:"error",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=["ERROR",e]).call(t,n))}},{key:"success",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=[" SUCC",e]).call(t,n))}}]),e}(),Lw=function(){var e,t,r=new Date;return Om(e="".concat(r.toTimeString().split(" ")[0],":")).call(e,xw(t=r.getMilliseconds().toString()).call(t,3,"0"))},Uw={};!function(e){var t="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.assign=function(e){for(var t=Tm(Array.prototype).call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==Wd(n))throw new TypeError(n+"must be non-object");for(var i in n)r(n,i)&&(e[i]=n[i])}}return e},e.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){var t,r,n,i,o,a;for(n=0,t=0,r=e.length;t<r;t++)n+=e[t].length;for(a=new Uint8Array(n),i=0,t=0,r=e.length;t<r;t++)o=e[t],a.set(o,i),i+=o.length;return a}},i={arraySet:function(e,t,r,n,i){for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){return Om([]).apply([],e)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,n)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,i))},e.setTyped(t)}(Uw);var Vw={},Fw={},Bw={},jw=Uw;function Gw(e){for(var t=e.length;--t>=0;)e[t]=0}var Hw=256,zw=286,Kw=30,Xw=15,Ww=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],qw=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Yw=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Jw=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Qw=new Array(576);Gw(Qw);var Zw=new Array(60);Gw(Zw);var $w=new Array(512);Gw($w);var eC=new Array(256);Gw(eC);var tC=new Array(29);Gw(tC);var rC,nC,iC,oC=new Array(Kw);function aC(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function sC(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function cC(e){return e<256?$w[e]:$w[256+(e>>>7)]}function uC(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function dC(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,uC(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function lC(e,t,r){dC(e,r[2*t],r[2*t+1])}function hC(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function vC(e,t,r){var n,i,o=new Array(16),a=0;for(n=1;n<=Xw;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=hC(o[s]++,s))}}function _C(e){var t;for(t=0;t<zw;t++)e.dyn_ltree[2*t]=0;for(t=0;t<Kw;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function pC(e){e.bi_valid>8?uC(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function fC(e,t,r,n){var i=2*t,o=2*r;return e[i]<e[o]||e[i]===e[o]&&n[t]<=n[r]}function mC(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&fC(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!fC(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function gC(e,t,r){var n,i,o,a,s=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],i=e.pending_buf[e.l_buf+s],s++,0===n?lC(e,i,t):(lC(e,(o=eC[i])+Hw+1,t),0!==(a=Ww[o])&&dC(e,i-=tC[o],a),lC(e,o=cC(--n),r),0!==(a=qw[o])&&dC(e,n-=oC[o],a))}while(s<e.last_lit);lC(e,256,t)}function yC(e,t){var r,n,i,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,c=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=573,r=0;r<c;r++)0!==o[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=a[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;r>=1;r--)mC(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],mC(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,o[2*i]=o[2*r]+o[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,o[2*r+1]=o[2*n+1]=i,e.heap[1]=i++,mC(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,o,a,s,c=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,l=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,v=t.stat_desc.extra_base,_=t.stat_desc.max_length,p=0;for(o=0;o<=Xw;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>_&&(o=_,p++),c[2*n+1]=o,n>u||(e.bl_count[o]++,a=0,n>=v&&(a=h[n-v]),s=c[2*n],e.opt_len+=s*(o+a),l&&(e.static_len+=s*(d[2*n+1]+a)));if(0!==p){do{for(o=_-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[_]--,p-=2}while(p>0);for(o=_;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),n--)}}(e,t),vC(o,u,e.bl_count)}function SC(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++s<c&&i===a||(s<u?e.bl_tree[2*i]+=s:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))}function bC(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++s<c&&i===a)){if(s<u)do{lC(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(lC(e,i,e.bl_tree),s--),lC(e,16,e.bl_tree),dC(e,s-3,2)):s<=10?(lC(e,17,e.bl_tree),dC(e,s-3,3)):(lC(e,18,e.bl_tree),dC(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}}Gw(oC);var EC=!1;function TC(e,t,r,n){dC(e,0+(n?1:0),3),function(e,t,r,n){pC(e),n&&(uC(e,r),uC(e,~r)),jw.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}Bw._tr_init=function(e){EC||(!function(){var e,t,r,n,i,o=new Array(16);for(r=0,n=0;n<28;n++)for(tC[n]=r,e=0;e<1<<Ww[n];e++)eC[r++]=n;for(eC[r-1]=n,i=0,n=0;n<16;n++)for(oC[n]=i,e=0;e<1<<qw[n];e++)$w[i++]=n;for(i>>=7;n<Kw;n++)for(oC[n]=i<<7,e=0;e<1<<qw[n]-7;e++)$w[256+i++]=n;for(t=0;t<=Xw;t++)o[t]=0;for(e=0;e<=143;)Qw[2*e+1]=8,e++,o[8]++;for(;e<=255;)Qw[2*e+1]=9,e++,o[9]++;for(;e<=279;)Qw[2*e+1]=7,e++,o[7]++;for(;e<=287;)Qw[2*e+1]=8,e++,o[8]++;for(vC(Qw,287,o),e=0;e<Kw;e++)Zw[2*e+1]=5,Zw[2*e]=hC(e,5);rC=new aC(Qw,Ww,257,zw,Xw),nC=new aC(Zw,qw,0,Kw,Xw),iC=new aC(new Array(0),Yw,0,19,7)}(),EC=!0),e.l_desc=new sC(e.dyn_ltree,rC),e.d_desc=new sC(e.dyn_dtree,nC),e.bl_desc=new sC(e.bl_tree,iC),e.bi_buf=0,e.bi_valid=0,_C(e)},Bw._tr_stored_block=TC,Bw._tr_flush_block=function(e,t,r,n){var i,o,a=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<Hw;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),yC(e,e.l_desc),yC(e,e.d_desc),a=function(e){var t;for(SC(e,e.dyn_ltree,e.l_desc.max_code),SC(e,e.dyn_dtree,e.d_desc.max_code),yC(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Jw[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==t?TC(e,t,r,n):4===e.strategy||o===i?(dC(e,2+(n?1:0),3),gC(e,Qw,Zw)):(dC(e,4+(n?1:0),3),function(e,t,r,n){var i;for(dC(e,t-257,5),dC(e,r-1,5),dC(e,n-4,4),i=0;i<n;i++)dC(e,e.bl_tree[2*Jw[i]+1],3);bC(e,e.dyn_ltree,t-1),bC(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),gC(e,e.dyn_ltree,e.dyn_dtree)),_C(e),n&&pC(e)},Bw._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(eC[r]+Hw+1)]++,e.dyn_dtree[2*cC(t)]++),e.last_lit===e.lit_bufsize-1},Bw._tr_align=function(e){dC(e,2,3),lC(e,256,Qw),function(e){16===e.bi_valid?(uC(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)};var kC=function(e,t,r,n){for(var i=65535&e|0,o=e>>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+t[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16|0};var IC=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();var RC,AC=function(e,t,r,n){var i=IC,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},wC={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},CC=Uw,xC=Bw,OC=kC,NC=AC,DC=wC,PC=-2,MC=258,LC=262,UC=103,VC=113,FC=666;function BC(e,t){return e.msg=DC[t],t}function jC(e){return(e<<1)-(e>4?9:0)}function GC(e){for(var t=e.length;--t>=0;)e[t]=0}function HC(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(CC.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function zC(e,t){xC._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,HC(e.strm)}function KC(e,t){e.pending_buf[e.pending++]=t}function XC(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function WC(e,t){var r,n,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-LC?e.strstart-(e.w_size-LC):0,u=e.window,d=e.w_mask,l=e.prev,h=e.strstart+MC,v=u[o+a-1],_=u[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(r=t)+a]===_&&u[r+a-1]===v&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&o<h);if(n=MC-(h-o),o=h-MC,n>a){if(e.match_start=t,a=n,n>=s)break;v=u[o+a-1],_=u[o+a]}}}while((t=l[t&d])>c&&0!=--i);return a<=e.lookahead?a:e.lookahead}function qC(e){var t,r,n,i,o,a,s,c,u,d,l=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=l+(l-LC)){CC.arraySet(e.window,e.window,l,l,0),e.match_start-=l,e.strstart-=l,e.block_start-=l,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=l?n-l:0}while(--r);t=r=l;do{n=e.prev[--t],e.prev[t]=n>=l?n-l:0}while(--r);i+=l}if(0===e.strm.avail_in)break;if(a=e.strm,s=e.window,c=e.strstart+e.lookahead,u=i,d=void 0,(d=a.avail_in)>u&&(d=u),r=0===d?0:(a.avail_in-=d,CC.arraySet(s,a.input,a.next_in,d,c),1===a.state.wrap?a.adler=OC(a.adler,s,d,c):2===a.state.wrap&&(a.adler=NC(a.adler,s,d,c)),a.next_in+=d,a.total_in+=d,d),e.lookahead+=r,e.lookahead+e.insert>=3)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+3-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<LC&&0!==e.strm.avail_in)}function YC(e,t){for(var r,n;;){if(e.lookahead<LC){if(qC(e),e.lookahead<LC&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-LC&&(e.match_length=WC(e,r)),e.match_length>=3)if(n=xC._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=xC._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(zC(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(zC(e,!1),0===e.strm.avail_out)?1:2}function JC(e,t){for(var r,n,i;;){if(e.lookahead<LC){if(qC(e),e.lookahead<LC&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-LC&&(e.match_length=WC(e,r),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=xC._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(zC(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=xC._tr_tally(e,0,e.window[e.strstart-1]))&&zC(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=xC._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(zC(e,!1),0===e.strm.avail_out)?1:2}function QC(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function ZC(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new CC.Buf16(1146),this.dyn_dtree=new CC.Buf16(122),this.bl_tree=new CC.Buf16(78),GC(this.dyn_ltree),GC(this.dyn_dtree),GC(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new CC.Buf16(16),this.heap=new CC.Buf16(573),GC(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new CC.Buf16(573),GC(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function $C(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:VC,e.adler=2===t.wrap?0:1,t.last_flush=0,xC._tr_init(t),0):BC(e,PC)}function ex(e){var t,r=$C(e);return 0===r&&((t=e.state).window_size=2*t.w_size,GC(t.head),t.max_lazy_match=RC[t.level].max_lazy,t.good_match=RC[t.level].good_length,t.nice_match=RC[t.level].nice_length,t.max_chain_length=RC[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),r}function tx(e,t,r,n,i,o){if(!e)return PC;var a=1;if(-1===t&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>9||8!==r||n<8||n>15||t<0||t>9||o<0||o>4)return BC(e,PC);8===n&&(n=9);var s=new ZC;return e.state=s,s.strm=e,s.wrap=a,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+3-1)/3),s.window=new CC.Buf8(2*s.w_size),s.head=new CC.Buf16(s.hash_size),s.prev=new CC.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new CC.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=o,s.method=r,ex(e)}RC=[new QC(0,0,0,0,(function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(qC(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,zC(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-LC&&(zC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(zC(e,!1),e.strm.avail_out),1)})),new QC(4,4,8,4,YC),new QC(4,5,16,8,YC),new QC(4,6,32,32,YC),new QC(4,4,16,16,JC),new QC(8,16,32,32,JC),new QC(8,16,128,128,JC),new QC(8,32,128,256,JC),new QC(32,128,258,1024,JC),new QC(32,258,258,4096,JC)],Fw.deflateInit=function(e,t){return tx(e,t,8,15,8,0)},Fw.deflateInit2=tx,Fw.deflateReset=ex,Fw.deflateResetKeep=$C,Fw.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?PC:(e.state.gzhead=t,0):PC},Fw.deflate=function(e,t){var r,n,i,o;if(!e||!e.state||t>5||t<0)return e?BC(e,PC):PC;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===FC&&4!==t)return BC(e,0===e.avail_out?-5:PC);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,KC(n,31),KC(n,139),KC(n,8),n.gzhead?(KC(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),KC(n,255&n.gzhead.time),KC(n,n.gzhead.time>>8&255),KC(n,n.gzhead.time>>16&255),KC(n,n.gzhead.time>>24&255),KC(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),KC(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(KC(n,255&n.gzhead.extra.length),KC(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=NC(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(KC(n,0),KC(n,0),KC(n,0),KC(n,0),KC(n,0),KC(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),KC(n,3),n.status=VC);else{var a=8+(n.w_bits-8<<4)<<8;a|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=32),a+=31-a%31,n.status=VC,XC(n,a),0!==n.strstart&&(XC(n,e.adler>>>16),XC(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=NC(e.adler,n.pending_buf,n.pending-i,i)),HC(e),i=n.pending,n.pending!==n.pending_buf_size));)KC(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=NC(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=NC(e.adler,n.pending_buf,n.pending-i,i)),HC(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,KC(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=NC(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=NC(e.adler,n.pending_buf,n.pending-i,i)),HC(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,KC(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=NC(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=UC)}else n.status=UC;if(n.status===UC&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&HC(e),n.pending+2<=n.pending_buf_size&&(KC(n,255&e.adler),KC(n,e.adler>>8&255),e.adler=0,n.status=VC)):n.status=VC),0!==n.pending){if(HC(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&jC(t)<=jC(r)&&4!==t)return BC(e,-5);if(n.status===FC&&0!==e.avail_in)return BC(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&n.status!==FC){var s=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(qC(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=xC._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(zC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(zC(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=MC){if(qC(e),e.lookahead<=MC&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){o=e.strstart+MC;do{}while(n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&i<o);e.match_length=MC-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=xC._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=xC._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(zC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(zC(e,!1),0===e.strm.avail_out)?1:2}(n,t):RC[n.level].func(n,t);if(3!==s&&4!==s||(n.status=FC),1===s||3===s)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===s&&(1===t?xC._tr_align(n):5!==t&&(xC._tr_stored_block(n,0,0,!1),3===t&&(GC(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),HC(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(KC(n,255&e.adler),KC(n,e.adler>>8&255),KC(n,e.adler>>16&255),KC(n,e.adler>>24&255),KC(n,255&e.total_in),KC(n,e.total_in>>8&255),KC(n,e.total_in>>16&255),KC(n,e.total_in>>24&255)):(XC(n,e.adler>>>16),XC(n,65535&e.adler)),HC(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)},Fw.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==UC&&t!==VC&&t!==FC?BC(e,PC):(e.state=null,t===VC?BC(e,-3):0):PC},Fw.deflateSetDictionary=function(e,t){var r,n,i,o,a,s,c,u,d=t.length;if(!e||!e.state)return PC;if(2===(o=(r=e.state).wrap)||1===o&&42!==r.status||r.lookahead)return PC;for(1===o&&(e.adler=OC(e.adler,t,d,0)),r.wrap=0,d>=r.w_size&&(0===o&&(GC(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new CC.Buf8(r.w_size),CC.arraySet(u,t,d-r.w_size,r.w_size,0),t=u,d=r.w_size),a=e.avail_in,s=e.next_in,c=e.input,e.avail_in=d,e.next_in=0,e.input=t,qC(r);r.lookahead>=3;){n=r.strstart,i=r.lookahead-2;do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+3-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--i);r.strstart=n,r.lookahead=2,qC(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=s,e.input=c,e.avail_in=a,r.wrap=o,0},Fw.deflateInfo="pako deflate (from Nodeca project)";var rx={},nx=Uw,ix=!0,ox=!0;try{String.fromCharCode.apply(null,[0])}catch(dW){ix=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(dW){ox=!1}for(var ax=new nx.Buf8(256),sx=0;sx<256;sx++)ax[sx]=sx>=252?6:sx>=248?5:sx>=240?4:sx>=224?3:sx>=192?2:1;function cx(e,t){if(t<65534&&(e.subarray&&ox||!e.subarray&&ix))return String.fromCharCode.apply(null,nx.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}ax[254]=ax[254]=1,rx.string2buf=function(e){var t,r,n,i,o,a=e.length,s=0;for(i=0;i<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),s+=r<128?1:r<2048?2:r<65536?3:4;for(t=new nx.Buf8(s),o=0,i=0;o<s;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[o++]=r:r<2048?(t[o++]=192|r>>>6,t[o++]=128|63&r):r<65536?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|63&r):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|63&r);return t},rx.buf2binstring=function(e){return cx(e,e.length)},rx.binstring2buf=function(e){for(var t=new nx.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},rx.buf2string=function(e,t){var r,n,i,o,a=t||e.length,s=new Array(2*a);for(n=0,r=0;r<a;)if((i=e[r++])<128)s[n++]=i;else if((o=ax[i])>4)s[n++]=65533,r+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&r<a;)i=i<<6|63&e[r++],o--;o>1?s[n++]=65533:i<65536?s[n++]=i:(i-=65536,s[n++]=55296|i>>10&1023,s[n++]=56320|1023&i)}return cx(s,n)},rx.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+ax[e[r]]>t?r:t};var ux=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},dx=Fw,lx=Uw,hx=rx,vx=wC,_x=ux,px=Object.prototype.toString;function fx(e){if(!(this instanceof fx))return new fx(e);this.options=lx.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new _x,this.strm.avail_out=0;var r=dx.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==r)throw new Error(vx[r]);if(t.header&&dx.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?hx.string2buf(t.dictionary):"[object ArrayBuffer]"===px.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(r=dx.deflateSetDictionary(this.strm,n)))throw new Error(vx[r]);this._dict_set=!0}}function mx(e,t){var r=new fx(t);if(r.push(e,!0),r.err)throw r.msg||vx[r.err];return r.result}fx.prototype.push=function(e,t){var r,n,i=this.strm,o=this.options.chunkSize;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?i.input=hx.string2buf(e):"[object ArrayBuffer]"===px.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new lx.Buf8(o),i.next_out=0,i.avail_out=o),1!==(r=dx.deflate(i,n))&&0!==r)return this.onEnd(r),this.ended=!0,!1;0!==i.avail_out&&(0!==i.avail_in||4!==n&&2!==n)||("string"===this.options.to?this.onData(hx.buf2binstring(lx.shrinkBuf(i.output,i.next_out))):this.onData(lx.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=dx.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==n||(this.onEnd(0),i.avail_out=0,!0)},fx.prototype.onData=function(e){this.chunks.push(e)},fx.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=lx.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},Vw.Deflate=fx,Vw.deflate=mx,Vw.deflateRaw=function(e,t){return(t=t||{}).raw=!0,mx(e,t)},Vw.gzip=function(e,t){return(t=t||{}).gzip=!0,mx(e,t)};var gx={},yx=tr,Sx=O,bx=Ye,Ex=ae,Tx=function(){var e=yx(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},kx=RegExp.prototype,Ix=ae,Rx=function(e){var t=e.flags;return void 0!==t||"flags"in kx||bx(e,"flags")||!Ex(kx,e)?t:Sx(Tx,e)},Ax=RegExp.prototype,wx=function(e){return e===Ax||Ix(Ax,e)?Rx(e):e.flags},Cx={},xx=Uw,Ox=15,Nx=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Dx=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],Px=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],Mx=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],Lx=Uw,Ux=kC,Vx=AC,Fx=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k,I,R;r=e.state,n=e.next_in,I=e.input,i=n+(e.avail_in-5),o=e.next_out,R=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),c=r.dmax,u=r.wsize,d=r.whave,l=r.wnext,h=r.window,v=r.hold,_=r.bits,p=r.lencode,f=r.distcode,m=(1<<r.lenbits)-1,g=(1<<r.distbits)-1;e:do{_<15&&(v+=I[n++]<<_,_+=8,v+=I[n++]<<_,_+=8),y=p[v&m];t:for(;;){if(v>>>=S=y>>>24,_-=S,0===(S=y>>>16&255))R[o++]=65535&y;else{if(!(16&S)){if(0==(64&S)){y=p[(65535&y)+(v&(1<<S)-1)];continue t}if(32&S){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}b=65535&y,(S&=15)&&(_<S&&(v+=I[n++]<<_,_+=8),b+=v&(1<<S)-1,v>>>=S,_-=S),_<15&&(v+=I[n++]<<_,_+=8,v+=I[n++]<<_,_+=8),y=f[v&g];r:for(;;){if(v>>>=S=y>>>24,_-=S,!(16&(S=y>>>16&255))){if(0==(64&S)){y=f[(65535&y)+(v&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(E=65535&y,_<(S&=15)&&(v+=I[n++]<<_,(_+=8)<S&&(v+=I[n++]<<_,_+=8)),(E+=v&(1<<S)-1)>c){e.msg="invalid distance too far back",r.mode=30;break e}if(v>>>=S,_-=S,E>(S=o-a)){if((S=E-S)>d&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(T=0,k=h,0===l){if(T+=u-S,S<b){b-=S;do{R[o++]=h[T++]}while(--S);T=o-E,k=R}}else if(l<S){if(T+=u+l-S,(S-=l)<b){b-=S;do{R[o++]=h[T++]}while(--S);if(T=0,l<b){b-=S=l;do{R[o++]=h[T++]}while(--S);T=o-E,k=R}}}else if(T+=l-S,S<b){b-=S;do{R[o++]=h[T++]}while(--S);T=o-E,k=R}for(;b>2;)R[o++]=k[T++],R[o++]=k[T++],R[o++]=k[T++],b-=3;b&&(R[o++]=k[T++],b>1&&(R[o++]=k[T++]))}else{T=o-E;do{R[o++]=R[T++],R[o++]=R[T++],R[o++]=R[T++],b-=3}while(b>2);b&&(R[o++]=R[T++],b>1&&(R[o++]=R[T++]))}break}}break}}while(n<i&&o<s);n-=b=_>>3,v&=(1<<(_-=b<<3))-1,e.next_in=n,e.next_out=o,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=o<s?s-o+257:257-(o-s),r.hold=v,r.bits=_},Bx=function(e,t,r,n,i,o,a,s){var c,u,d,l,h,v,_,p,f,m=s.bits,g=0,y=0,S=0,b=0,E=0,T=0,k=0,I=0,R=0,A=0,w=null,C=0,x=new xx.Buf16(16),O=new xx.Buf16(16),N=null,D=0;for(g=0;g<=Ox;g++)x[g]=0;for(y=0;y<n;y++)x[t[r+y]]++;for(E=m,b=Ox;b>=1&&0===x[b];b--);if(E>b&&(E=b),0===b)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(S=1;S<b&&0===x[S];S++);for(E<S&&(E=S),I=1,g=1;g<=Ox;g++)if(I<<=1,(I-=x[g])<0)return-1;if(I>0&&(0===e||1!==b))return-1;for(O[1]=0,g=1;g<Ox;g++)O[g+1]=O[g]+x[g];for(y=0;y<n;y++)0!==t[r+y]&&(a[O[t[r+y]]++]=y);if(0===e?(w=N=a,v=19):1===e?(w=Nx,C-=257,N=Dx,D-=257,v=256):(w=Px,N=Mx,v=-1),A=0,y=0,g=S,h=o,T=E,k=0,d=-1,l=(R=1<<E)-1,1===e&&R>852||2===e&&R>592)return 1;for(;;){_=g-k,a[y]<v?(p=0,f=a[y]):a[y]>v?(p=N[D+a[y]],f=w[C+a[y]]):(p=96,f=0),c=1<<g-k,S=u=1<<T;do{i[h+(A>>k)+(u-=c)]=_<<24|p<<16|f|0}while(0!==u);for(c=1<<g-1;A&c;)c>>=1;if(0!==c?(A&=c-1,A+=c):A=0,y++,0==--x[g]){if(g===b)break;g=t[r+a[y]]}if(g>E&&(A&l)!==d){for(0===k&&(k=E),h+=S,I=1<<(T=g-k);T+k<b&&!((I-=x[T+k])<=0);)T++,I<<=1;if(R+=1<<T,1===e&&R>852||2===e&&R>592)return 1;i[d=A&l]=E<<24|T<<16|h-o|0}}return 0!==A&&(i[h+A]=g-k<<24|64<<16|0),s.bits=E,0},jx=-2,Gx=12,Hx=30;function zx(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function Kx(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Lx.Buf16(320),this.work=new Lx.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Xx(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Lx.Buf32(852),t.distcode=t.distdyn=new Lx.Buf32(592),t.sane=1,t.back=-1,0):jx}function Wx(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,Xx(e)):jx}function qx(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?jx:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,Wx(e))):jx}function Yx(e,t){var r,n;return e?(n=new Kx,e.state=n,n.window=null,0!==(r=qx(e,t))&&(e.state=null),r):jx}var Jx,Qx,Zx=!0;function $x(e){if(Zx){var t;for(Jx=new Lx.Buf32(512),Qx=new Lx.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Bx(1,e.lens,0,288,Jx,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Bx(2,e.lens,0,32,Qx,0,e.work,{bits:5}),Zx=!1}e.lencode=Jx,e.lenbits=9,e.distcode=Qx,e.distbits=5}function eO(e,t,r,n){var i,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Lx.Buf8(o.wsize)),n>=o.wsize?(Lx.arraySet(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((i=o.wsize-o.wnext)>n&&(i=n),Lx.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?(Lx.arraySet(o.window,t,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0}Cx.inflateReset=Wx,Cx.inflateReset2=qx,Cx.inflateResetKeep=Xx,Cx.inflateInit=function(e){return Yx(e,15)},Cx.inflateInit2=Yx,Cx.inflate=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k,I,R=0,A=new Lx.Buf8(4),w=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return jx;(r=e.state).mode===Gx&&(r.mode=13),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,l=s,h=c,T=0;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(2&r.wrap&&35615===u){r.check=0,A[0]=255&u,A[1]=u>>>8&255,r.check=Vx(r.check,A,2,0),u=0,d=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=Hx;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=Hx;break}if(d-=4,E=8+(15&(u>>>=4)),0===r.wbits)r.wbits=E;else if(E>r.wbits){e.msg="invalid window size",r.mode=Hx;break}r.dmax=1<<E,e.adler=r.check=1,r.mode=512&u?10:Gx,u=0,d=0;break;case 2:for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(r.flags=u,8!=(255&wx(r))){e.msg="unknown compression method",r.mode=Hx;break}if(57344&wx(r)){e.msg="unknown header flags set",r.mode=Hx;break}r.head&&(r.head.text=u>>8&1),512&wx(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=Vx(r.check,A,2,0)),u=0,d=0,r.mode=3;case 3:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.head&&(r.head.time=u),512&wx(r)&&(A[0]=255&u,A[1]=u>>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,r.check=Vx(r.check,A,4,0)),u=0,d=0,r.mode=4;case 4:for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&wx(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=Vx(r.check,A,2,0)),u=0,d=0,r.mode=5;case 5:if(1024&wx(r)){for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length=u,r.head&&(r.head.extra_len=u),512&wx(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=Vx(r.check,A,2,0)),u=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&wx(r)&&((v=r.length)>s&&(v=s),v&&(r.head&&(E=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),Lx.arraySet(r.head.extra,n,o,v,E)),512&wx(r)&&(r.check=Vx(r.check,n,v,o)),s-=v,o+=v,r.length-=v),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&wx(r)){if(0===s)break e;v=0;do{E=n[o+v++],r.head&&E&&r.length<65536&&(r.head.name+=String.fromCharCode(E))}while(E&&v<s);if(512&wx(r)&&(r.check=Vx(r.check,n,v,o)),s-=v,o+=v,E)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&wx(r)){if(0===s)break e;v=0;do{E=n[o+v++],r.head&&E&&r.length<65536&&(r.head.comment+=String.fromCharCode(E))}while(E&&v<s);if(512&wx(r)&&(r.check=Vx(r.check,n,v,o)),s-=v,o+=v,E)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&wx(r)){for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=Hx;break}u=0,d=0}r.head&&(r.head.hcrc=wx(r)>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=Gx;break;case 10:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}e.adler=r.check=zx(u),u=0,d=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,2;e.adler=r.check=1,r.mode=Gx;case Gx:if(5===t||6===t)break e;case 13:if(r.last){u>>>=7&d,d-=7&d,r.mode=27;break}for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}switch(r.last=1&u,d-=1,3&(u>>>=1)){case 0:r.mode=14;break;case 1:if($x(r),r.mode=20,6===t){u>>>=2,d-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=Hx}u>>>=2,d-=2;break;case 14:for(u>>>=7&d,d-=7&d;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=Hx;break}if(r.length=65535&u,u=0,d=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(v=r.length){if(v>s&&(v=s),v>c&&(v=c),0===v)break e;Lx.arraySet(i,n,o,v,a),s-=v,o+=v,c-=v,a+=v,r.length-=v;break}r.mode=Gx;break;case 17:for(;d<14;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(r.nlen=257+(31&u),u>>>=5,d-=5,r.ndist=1+(31&u),u>>>=5,d-=5,r.ncode=4+(15&u),u>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Hx;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.lens[w[r.have++]]=7&u,u>>>=3,d-=3}for(;r.have<19;)r.lens[w[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,k={bits:r.lenbits},T=Bx(0,r.lens,0,19,r.lencode,0,r.work,k),r.lenbits=k.bits,T){e.msg="invalid code lengths set",r.mode=Hx;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,g=65535&R,!((f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(g<16)u>>>=f,d-=f,r.lens[r.have++]=g;else{if(16===g){for(I=f+2;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u>>>=f,d-=f,0===r.have){e.msg="invalid bit length repeat",r.mode=Hx;break}E=r.lens[r.have-1],v=3+(3&u),u>>>=2,d-=2}else if(17===g){for(I=f+3;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=f,E=0,v=3+(7&(u>>>=f)),u>>>=3,d-=3}else{for(I=f+7;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=f,E=0,v=11+(127&(u>>>=f)),u>>>=7,d-=7}if(r.have+v>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Hx;break}for(;v--;)r.lens[r.have++]=E}}if(r.mode===Hx)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=Hx;break}if(r.lenbits=9,k={bits:r.lenbits},T=Bx(1,r.lens,0,r.nlen,r.lencode,0,r.work,k),r.lenbits=k.bits,T){e.msg="invalid literal/lengths set",r.mode=Hx;break}if(r.distbits=6,r.distcode=r.distdyn,k={bits:r.distbits},T=Bx(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,k),r.distbits=k.bits,T){e.msg="invalid distances set",r.mode=Hx;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,Fx(e,h),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,r.mode===Gx&&(r.back=-1);break}for(r.back=0;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,g=65535&R,!((f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(m&&0==(240&m)){for(y=f,S=m,b=g;m=(R=r.lencode[b+((u&(1<<y+S)-1)>>y)])>>>16&255,g=65535&R,!(y+(f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=y,d-=y,r.back+=y}if(u>>>=f,d-=f,r.back+=f,r.length=g,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=Gx;break}if(64&m){e.msg="invalid literal/length code",r.mode=Hx;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=(R=r.distcode[u&(1<<r.distbits)-1])>>>16&255,g=65535&R,!((f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(0==(240&m)){for(y=f,S=m,b=g;m=(R=r.distcode[b+((u&(1<<y+S)-1)>>y)])>>>16&255,g=65535&R,!(y+(f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=y,d-=y,r.back+=y}if(u>>>=f,d-=f,r.back+=f,64&m){e.msg="invalid distance code",r.mode=Hx;break}r.offset=g,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Hx;break}r.mode=25;case 25:if(0===c)break e;if(v=h-c,r.offset>v){if((v=r.offset-v)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Hx;break}v>r.wnext?(v-=r.wnext,_=r.wsize-v):_=r.wnext-v,v>r.length&&(v=r.length),p=r.window}else p=i,_=a-r.offset,v=r.length;v>c&&(v=c),c-=v,r.length-=v;do{i[a++]=p[_++]}while(--v);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[a++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;d<32;){if(0===s)break e;s--,u|=n[o++]<<d,d+=8}if(h-=c,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=wx(r)?Vx(r.check,i,h,a-h):Ux(r.check,i,h,a-h)),h=c,(wx(r)?u:zx(u))!==r.check){e.msg="incorrect data check",r.mode=Hx;break}u=0,d=0}r.mode=28;case 28:if(r.wrap&&wx(r)){for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=Hx;break}u=0,d=0}r.mode=29;case 29:T=1;break e;case Hx:T=-3;break e;case 31:return-4;default:return jx}return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,(r.wsize||h!==e.avail_out&&r.mode<Hx&&(r.mode<27||4!==t))&&eO(e,e.output,e.next_out,h-e.avail_out),l-=e.avail_in,h-=e.avail_out,e.total_in+=l,e.total_out+=h,r.total+=h,r.wrap&&h&&(e.adler=r.check=wx(r)?Vx(r.check,i,h,e.next_out-h):Ux(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===Gx?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===h||4===t)&&0===T&&(T=-5),T},Cx.inflateEnd=function(e){if(!e||!e.state)return jx;var t=e.state;return t.window&&(t.window=null),e.state=null,0},Cx.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?jx:(r.head=t,t.done=!1,0):jx},Cx.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?jx:11===r.mode&&Ux(1,t,n,0)!==r.check?-3:eO(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,0):jx},Cx.inflateInfo="pako inflate (from Nodeca project)";var tO={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};var rO=Cx,nO=Uw,iO=rx,oO=tO,aO=wC,sO=ux,cO=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},uO=Object.prototype.toString;function dO(e){if(!(this instanceof dO))return new dO(e);this.options=nO.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new sO,this.strm.avail_out=0;var r=rO.inflateInit2(this.strm,t.windowBits);if(r!==oO.Z_OK)throw new Error(aO[r]);if(this.header=new cO,rO.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=iO.string2buf(t.dictionary):"[object ArrayBuffer]"===uO.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=rO.inflateSetDictionary(this.strm,t.dictionary))!==oO.Z_OK))throw new Error(aO[r])}function lO(e,t){var r=new dO(t);if(r.push(e,!0),r.err)throw r.msg||aO[r.err];return r.result}dO.prototype.push=function(e,t){var r,n,i,o,a,s=this.strm,c=this.options.chunkSize,u=this.options.dictionary,d=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?oO.Z_FINISH:oO.Z_NO_FLUSH,"string"==typeof e?s.input=iO.binstring2buf(e):"[object ArrayBuffer]"===uO.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new nO.Buf8(c),s.next_out=0,s.avail_out=c),(r=rO.inflate(s,oO.Z_NO_FLUSH))===oO.Z_NEED_DICT&&u&&(r=rO.inflateSetDictionary(this.strm,u)),r===oO.Z_BUF_ERROR&&!0===d&&(r=oO.Z_OK,d=!1),r!==oO.Z_STREAM_END&&r!==oO.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==oO.Z_STREAM_END&&(0!==s.avail_in||n!==oO.Z_FINISH&&n!==oO.Z_SYNC_FLUSH)||("string"===this.options.to?(i=iO.utf8border(s.output,s.next_out),o=s.next_out-i,a=iO.buf2string(s.output,i),s.next_out=o,s.avail_out=c-o,o&&nO.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(nO.shrinkBuf(s.output,s.next_out)))),0===s.avail_in&&0===s.avail_out&&(d=!0)}while((s.avail_in>0||0===s.avail_out)&&r!==oO.Z_STREAM_END);return r===oO.Z_STREAM_END&&(n=oO.Z_FINISH),n===oO.Z_FINISH?(r=rO.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===oO.Z_OK):n!==oO.Z_SYNC_FLUSH||(this.onEnd(oO.Z_OK),s.avail_out=0,!0)},dO.prototype.onData=function(e){this.chunks.push(e)},dO.prototype.onEnd=function(e){e===oO.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=nO.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},gx.Inflate=dO,gx.inflate=lO,gx.inflateRaw=function(e,t){return(t=t||{}).raw=!0,lO(e,t)},gx.ungzip=lO;var hO={};(0,Uw.assign)(hO,Vw,gx,tO);var vO,_O=hO,pO="BytePlusRTC",fO=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},mO=function(){function e(t){Vl(this,e),Jd(this,"storeName",void 0),Jd(this,"pendingList",[]),this.storeName=t,!pw()&&fO()&&this._checkAndCreateStore(t)}var t,r;return Ul(e,[{key:"_checkAndCreateStore",value:function(t,r){var n=this;e.db&&e.db.close();var i=r?fO().open(pO,r):fO().open(pO);i.onupgradeneeded=function(){i.result.createObjectStore(t)},i.onerror=function(e){console.error("IndexedDBInterface error",i.error)},i.onsuccess=function(){var r=i.result;e.db=r;try{e.db.transaction(n.storeName,"readonly"),n.pendingList.forEach(function(){var e=Rm(km().mark((function e(t){var r,i,o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.txMode,i=t.resolve,o=t.reject,e.prev=1,e.next=4,n._getStore(r);case 4:a=e.sent,i(a),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o();case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}())}catch(o){n._checkAndCreateStore(t,r.version+1)}}}},{key:"_getStore",value:function(t){var r=this;return new Yf((function(n,i){e.db?n(e.db.transaction(r.storeName,t).objectStore(r.storeName)):r.pendingList.push({txMode:t,resolve:n,reject:i})}))}},{key:"put",value:(r=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readwrite");case 2:return n=e.sent,e.abrupt("return",new Yf((function(e,i){var o=n.put(t,r);o.onsuccess=function(){e()},o.onerror=function(e){i(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"get",value:(t=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readonly");case 2:return r=e.sent,e.abrupt("return",new Yf((function(e,n){var i=r.get(t);i.onsuccess=function(){e(i.result)},i.onerror=function(e){n(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();Jd(mO,"db",void 0),Jd(mO,"state","init");var gO={product_line:"rtc",report_version:"5",os:"web",user_agent:pw()?"":null===(vO=navigator)||void 0===vO?void 0:vO.userAgent,platform:"web",product:"webrtc",app_state:"active"},yO="ReportErrorBuffer",SO=function(){function e(){Vl(this,e),Jd(this,"_buffer",new mO(yO))}var t,r;return Ul(e,[{key:"set",value:(r=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._buffer.put(t,yO);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"get",value:(t=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.prev=1,e.next=4,this._buffer.get(yO);case 4:t=e.sent,e.next=9;break;case 7:e.prev=7,e.t0=e.catch(1);case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(){return t.apply(this,arguments)})}]),e}(),bO=function(){function e(){var t=this;Vl(this,e),Jd(this,"reportCommon",gO),Jd(this,"dataBuffer",[]),Jd(this,"logBuffer",[]),Jd(this,"posting",!1),Jd(this,"sucSendTimer",void 0),Jd(this,"preSucTime",0),Jd(this,"errSendTimer",void 0),Jd(this,"errSendDelay",100),Jd(this,"errSendBuffer",void 0),Jd(this,"_logServerUrl",void 0),Jd(this,"_retryCount",0),pw()||(window.addEventListener("beforeunload",(function(){clearTimeout(t.errSendTimer),clearTimeout(t.sucSendTimer),t.send(void 0,!0)})),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState?t.setCommonStats({app_state:"active"}):"hidden"===document.visibilityState&&t.setCommonStats({app_state:"background"})})))}var t;return Ul(e,[{key:"setUrl",value:function(e){this._logServerUrl=e}},{key:"setCommonStats",value:function(e){this.reportCommon=wb(this.reportCommon,e)}},{key:"enableErrorBuffer",value:function(){this.errSendBuffer=new SO,this.loadErrorBuffer()}},{key:"push",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?this.send(e):(this.dataBuffer.push(e),!this.posting&&!this.errSendTimer&&Date.now()-this.preSucTime>2e3&&(clearTimeout(this.sucSendTimer),this.send()))}},{key:"unshift",value:function(e){this.dataBuffer=Om(e).call(e,this.dataBuffer)}},{key:"send",value:function(e,t){var r,n,i=this;if((e||this.dataBuffer.length)&&this._logServerUrl){var o={data:e||rT(r=this.dataBuffer).call(r,0,EO(this.dataBuffer,5e5)),header:Zd(Zd({},this.reportCommon),{},{http_retry_count:this._retryCount}),from:"web",os:"web",version:"1"},a=new XMLHttpRequest;if(a.timeout=1e4,a.onreadystatechange=function(){if(4===a.readyState){var r,n,s,c;if(e||(i.posting=!1),200===a.status||304===a.status)try{r=JSON.parse(a.responseText)}catch(uW){n=uW}if(r&&0===r.StatusCode){if(!e&&!t)null===(s=i.errSendBuffer)||void 0===s||s.set([]),i.sucSend()}else if(setTimeout((function(){var e,t;MO(Om(e="reportor error, res:".concat(null===(t=r)||void 0===t?void 0:t.toString()," err:")).call(e,n),a.status,n)}),0),e)i.send(e);else i.unshift(o.data),null===(c=i.errSendBuffer)||void 0===c||c.set(JT(i.dataBuffer)),t?i.send():i.errSend()}},a.open("POST",this._logServerUrl,!0),e||(this.posting=!0),!pw()&&mT(n=location.search).call(n,"_rtc_debug_"))a.send(Mm(o));else{var s=_O.gzip(Mm(o));a.setRequestHeader("Content-Encoding","gzip"),a.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),a.send(s)}}}},{key:"sucSend",value:function(){this.errSendDelay=100,this._retryCount=0,this.preSucTime=Date.now(),this.sucSendTimer=window.setTimeout(this.send.bind(this),2e3)}},{key:"errSend",value:function(){var e=this;this.errSendTimer=window.setTimeout((function(){e.send(),delete e.errSendTimer}),this.errSendDelay),this.errSendDelay*=2,this._retryCount++}},{key:"loadErrorBuffer",value:(t=Rm(km().mark((function e(){var t,r,n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this.errSendBuffer)||void 0===r?void 0:r.get();case 2:if(e.t1=t=e.sent,e.t0=null!==e.t1,!e.t0){e.next=6;break}e.t0=void 0!==t;case 6:if(!e.t0){e.next=10;break}e.t2=t,e.next=11;break;case 10:e.t2=[];case 11:e.t2.forEach((function(e){n.push(e)}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}();function EO(e,t){for(var r=0,n=0;n<e.length;n++)if((r+=Mm(e[n]).length)>t)return n-1;return e.length}var TO=new bO,kO=function(){function e(t){Vl(this,e),Jd(this,"report_id",0),Jd(this,"modify_ids",{}),this.id=t}return Ul(e,[{key:"report",value:function(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=Zd(Zd(Zd({event_key:e,report_id:this.report_id++,rtc_timestamp:Date.now()},this.modify_ids),t),{},{common_extra_info:Mm(i)});(TO.push(o),pw())||(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,this.id,o))}},{key:"set",value:function(e){this.modify_ids=wb(this.modify_ids,e)}},{key:"destroy",value:function(){}}]),e}(),IO=new Mw("MessageReportor",1),RO=function(){function e(t){Vl(this,e),Jd(this,"_preTime",Date.now()),Jd(this,"_one2oneNum",0),Jd(this,"_one2manyNum",0),Jd(this,"_one2oneMsgCache",new $S),Jd(this,"_one2manyMsgCache",new $S),Jd(this,"roomId",""),Jd(this,"userId",""),Jd(this,"rtsSessionId",""),this.id=t}return Ul(e,[{key:"needReport",value:function(t){return!!e.config&&(Date.now()-this._preTime>=36e5&&(this._preTime=Date.now(),this._one2oneNum=0,this._one2manyNum=0),"one2one"===t&&this._one2oneNum<e.config.max_one2one_fpt_per_hour&&Math.random()<=e.config.one2one_fpt_ratio/100||"one2many"===t&&this._one2manyNum<e.config.max_one2many_fpt_per_hour&&Math.random()<=e.config.one2many_fpt_ratio/100)}},{key:"cacheP2PMsg",value:function(t){var r;this._one2oneMsgCache.set(t.msg_id,Zd({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateP2PMsg",value:function(e,t){var r=this._one2oneMsgCache.get(e);r&&this._one2oneMsgCache.set(e,Zd(Zd({},r),t))}},{key:"cacheCustomMsg",value:function(t){var r;this._one2manyMsgCache.set(t.msg_id,Zd({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateOne2ManyMsg",value:function(e,t){var r=this._one2manyMsgCache.get(e);r&&this._one2manyMsgCache.set(e,Zd(Zd({},r),t))}},{key:"reportP2PMsg",value:function(e){var t,r=this._one2oneMsgCache.get(e);r&&(IO.info("reportP2PMsg",r.type,Mm(r)),null===(t=VO(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportOne2ManyMsg",value:function(e){var t,r=this._one2manyMsgCache.get(e);r&&(IO.info("reportOne2ManyMsg",r.type,Mm(r)),null===(t=VO(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportMsgRecv",value:function(t){var r,n;t.config_version=(null===(r=e.config)||void 0===r?void 0:r.version)||"",IO.info("reportMsgRecv",t.type,Mm(t)),null===(n=VO(this.id))||void 0===n||n.report("rts_message",t)}},{key:"destroy",value:function(){this._one2manyNum=0,this._one2oneNum=0,this._one2manyMsgCache.clear(),this._one2oneMsgCache.clear(),this._preTime=Date.now(),this.roomId="",this.userId="",this.rtsSessionId=""}}]),e}();Jd(RO,"config",void 0);var AO=new $S,wO={_cache:AO,setConfig:function(e){IO.info("setConfig","get config: ".concat(Mm(e))),RO.config=e},setRtsSessionId:function(e,t){var r=AO.get(e);r&&(r.rtsSessionId=t)},createRTSMsgReportor:function(e){var t=AO.get(e)||new RO(e);return AO.set(e,t),t},destroyRTSMsgReportor:function(e){var t=AO.get(e);t&&(t.destroy(),AO.delete(e))},setRoomId:function(e,t){var r=AO.get(e);r&&(r.roomId=t||"")},setUserId:function(e,t){var r=AO.get(e);r&&(r.userId=t||"")},samplingP2PMsg:function(e,t){var r=AO.get(e);if(null!=r&&r.needReport("one2one")){var n,i=Om(n="".concat(t.from)).call(n,t.id),o=t.to?"one2one":"one2server";t.enable_report=!0,t.report_msg_id=t.id,r.cacheP2PMsg({rts_session_id:r.rtsSessionId,msg_id:i,node_role:"src_sdk",from:t.from,to:t.to||"server",type:o,rts_room_id:t.room,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""})}return t},updateP2PMsgReq:function(e,t,r){var n,i;t.enable_report&&mw(t.report_msg_id)&&(null===(n=AO.get(e))||void 0===n||n.updateP2PMsg(Om(i="".concat(t.from)).call(i,t.report_msg_id),{send_ts:Date.now(),msg_size:r}))},updateP2PMsgAck:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i,o=AO.get(e);null==o||o.updateP2PMsg(Om(n="".concat(t.from)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportP2PMsg(Om(i="".concat(t.from)).call(i,t.report_msg_id))}},samplingOne2ManyMsg:function(e,t,r){var n,i=AO.get(e);null!=i&&i.needReport("one2many")&&(r.enable_report=!0,r.report_msg_id=t,i.cacheCustomMsg({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(r.clientId)).call(n,t),node_role:"src_sdk",from:r.clientId,to:i.roomId,type:"one2many",rts_room_id:i.roomId,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""}));return r},reportP2PMsgRecv:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i=AO.get(e),o=t.to?"one2one":"one2many";null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(t.from)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:o,rts_room_id:t.room,from:t.from,to:t.to||t.room,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:t.to?"":i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}},updateOne2ManyMsgAck:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i,o=AO.get(e);if(o)null==o||o.updateOne2ManyMsg(Om(n="".concat(t.clientId)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportOne2ManyMsg(Om(i="".concat(t.clientId)).call(i,t.report_msg_id))}},updateOne2ManyMsgReq:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i=AO.get(e);if(i)i.updateOne2ManyMsg(Om(n="".concat(t.clientId)).call(n,t.report_msg_id),{send_ts:Date.now(),msg_size:r})}},reportOne2ManyMsgRecv:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i=AO.get(e);null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(t.clientId)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:"one2many",rts_room_id:t.roomId,from:t.clientId,to:t.roomId,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}}},CO=function(){function e(t){Vl(this,e),Jd(this,"_timer",void 0),Jd(this,"userMessage",{}),Jd(this,"roomMessage",{}),this.id=t,this._setTimer()}return Ul(e,[{key:"_setTimer",value:function(){var e=this;!function t(){e._reportAndgReset(),clearTimeout(e._timer),e._timer=setTimeout(t,1e4)}()}},{key:"_reportAndgReset",value:function(){(an(this.userMessage).length||an(this.roomMessage).length)&&(this._report(),this._reset())}},{key:"_report",value:function(){var e,t,r,n=this;null===(e=VO(this.id))||void 0===e||e.report("rtc_message_statistics",{dc_user_message:jm(t=an(this.userMessage)).call(t,(function(e){return n.userMessage[e]})),dc_room_message:jm(r=an(this.roomMessage)).call(r,(function(e){return n.roomMessage[e]})),media_server_ip:""})}},{key:"_reset",value:function(){this.userMessage={},this.roomMessage={}}},{key:"_checkInitUserMessage",value:function(e,t){var r,n;this.userMessage[Om(r="".concat(t,"-")).call(r,e)]||(this.userMessage[Om(n="".concat(t,"-")).call(n,e)]={dc_peer_user_id:e,dc_send_total:0,dc_recv_total:0,dc_send_ack:0,dc_send_fail:0,dc_fail_timeout:0,dc_fail_no_receiver:0,dc_fail_no_relay_path:0,dc_cost_time:0,dc_cost_e2s:0,dc_cost_s2s:0,dc_least_time:Number(1/0),dc_most_time:0,dc_cost_peer_s2e:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_message_type:t,dc_send_binary:0})}},{key:"_sendUserMessage",value:function(e,t,r){var n,i;(this._checkInitUserMessage(e,t),this.userMessage[Om(n="".concat(t,"-")).call(n,e)].dc_send_total++,r)&&this.userMessage[Om(i="".concat(t,"-")).call(i,e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){var r;this._checkInitUserMessage(e,t),this.userMessage[Om(r="".concat(t,"-")).call(r,e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n,i=this.userMessage[Om(n="".concat(t,"-")).call(n,e)];i&&(i.dc_send_fail++,this._handleUserFail(i,r))}},{key:"_handleUserFail",value:function(e,t){var r;t&&(t.code||t.err)&&(mT(r=["TIME_OUT","USER_MESSAGE_TIMEOUT"]).call(r,t.code)?e.dc_fail_timeout++:3===t.err?e.dc_fail_no_receiver++:4===t.err?e.dc_fail_no_relay_path++:1===t.err&&e.dc_fail_timeout++)}},{key:"_sendUserAck",value:function(e,t,r,n,i){var o,a=this.userMessage[Om(o="".concat(t,"-")).call(o,e)];a&&(a.dc_send_ack++,a.dc_cost_time+=r,a.dc_cost_s2s+=n||0,a.dc_cost_peer_s2e+=i,a.dc_cost_e2s+=r-(n||0)-i,r<=100?(a.dc_send_ack_100++,a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=200?(a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=400?(a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=1e3&&a.dc_send_ack_1s++,r<a.dc_least_time&&(a.dc_least_time=r),r>a.dc_most_time&&(a.dc_most_time=r))}},{key:"sendRoomMessage",value:function(e,t){this.roomMessage[e]||(this.roomMessage[e]={dc_room_id:e,dc_send_total:0,dc_send_ack:0,dc_cost_time:0,dc_least_time:Number(1/0),dc_most_time:0,dc_send_fail:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_send_binary:0}),this.roomMessage[e].dc_send_total++,t&&this.roomMessage[e].dc_send_binary++}},{key:"sendRoomFail",value:function(e){var t=this.roomMessage[e];t&&t.dc_send_fail++}},{key:"sendRoomAck",value:function(e,t){var r=this.roomMessage[e];r&&(r.dc_send_ack++,r.dc_cost_time+=t,t<r.dc_least_time&&(r.dc_least_time=t),t>r.dc_most_time&&(r.dc_most_time=t),t<=100?(r.dc_send_ack_100++,r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=200?(r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=400?(r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=1e3&&r.dc_send_ack_1s++)}},{key:"sendP2PMessage",value:function(e,t){this._sendUserMessage(e,"p2p",t)}},{key:"recvP2PMessage",value:function(e){this._recvUserMessage(e,"p2p")}},{key:"sendP2PFail",value:function(e,t){this._sendUserFail(e,"p2p",t)}},{key:"sendP2PAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p",t,r,n)}},{key:"sendP2POutRoomMessage",value:function(e,t){this._sendUserMessage(e,"p2p_outside_room",t)}},{key:"recvP2POutRoomMessage",value:function(e){this._recvUserMessage(e,"p2p_outside_room")}},{key:"sendP2POutRoomFail",value:function(e,t){this._sendUserFail(e,"p2p_outside_room",t)}},{key:"sendP2POutRoomAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p_outside_room",t,r,n)}},{key:"sendP2serverMessage",value:function(e){this._sendUserMessage("","p2server",e)}},{key:"sendP2serverFail",value:function(e){this._sendUserFail("","p2server",e)}},{key:"sendP2serveAck",value:function(e,t,r){this._sendUserAck("","p2server",e,t,r)}},{key:"countP2PMessage",value:function(e,t,r,n,i){this.sendP2PMessage(t,r),e?this.sendP2PAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2PFail(t,i)}},{key:"countRoomMessage",value:function(e,t,r,n){this.sendRoomMessage(t,r),e?this.sendRoomAck(t,Date.now()-n):this.sendRoomFail(t)}},{key:"countUserMessageOutsideRoom",value:function(e,t,r,n,i){this.sendP2POutRoomMessage(t,r),e?this.sendP2POutRoomAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2POutRoomFail(t,i)}},{key:"countServerMessage",value:function(e,t,r,n){this.sendP2serverMessage(t),e?(n=n||{},this.sendP2serveAck(Date.now()-r,n.s2s_time||0,n.s2e_time||0)):this.sendP2serverFail(n)}},{key:"destroy",value:function(){this._reset(),clearTimeout(this._timer)}}]),e}(),xO=function(e){TO.setCommonStats(e)},OO=function(e){TO.setUrl(e)},NO=new kO("global"),DO=function(e,t,r){NO.report("rtc_sdk_api_call",{sdk_api_name:e,error_code:t,message:r})},PO=function(e,t,r){NO.report("rtc_sdk_callback",{sdk_callback_name:e,error_code:t,message:r})},MO=function(e,t,r){NO.report("rtc_error",{message:e,error_code:t},r)},LO=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;NO.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)},UO=new $S,VO=function(e){return UO.get(e)};function FO(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e,r,n){if("function"==typeof n.value){var i=n.value;n.value=function(){for(var e,n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];var s,c,u=this.engineId||this.id,d={};(t.forEach((function(e,t){d[e]=o[t]})),"joinRoom"===r)&&(null===(s=VO(u))||void 0===s||s.set({room_id:o[1],user_id:null===(c=o[2])||void 0===c?void 0:c.userId}));null===(e=VO(u))||void 0===e||e.report("rtc_sdk_api_call",{sdk_api_name:r,message:Mm(GO(o)),error_code:0},d);var l=i.apply(this,o);return"function"==typeof(null==l?void 0:l.then)?l.then((function(e){return BO(u,r,[e||{}]),e})).catch((function(e){throw BO(u,r,e.message,e.code),e})):(BO(u,r,[l||{}]),l)}}}}var BO=function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4?arguments[4]:void 0,a={sdk_callback_name:t,error_code:i,message:Mm(Array.isArray(r)?GO(r):r)};o&&(a.room_id=o),null===(n=VO(e))||void 0===n||n.report("rtc_sdk_callback",a)},jO=function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",a=arguments.length>5?arguments[5]:void 0;null===(n=VO(e))||void 0===n||n.report("rtc_invoke_status",{sdk_api_name:t,message:r,error_code:i,stream_id:o,elapse:0},a)};function GO(e){return jm(e).call(e,(function e(t){var r;if(null!=t&&t._reportName)return t._reportName;if(t instanceof HTMLElement)return t.toString();if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)){var n,i,o=ArrayBuffer.isView(t)?t.buffer:t,a=o.byteLength,s=[];if(a>10){var c,u,d,l,h=new DataView(o),v=jm(c=qT({length:5})).call(c,(function(e,t){return h.getUint8(t)})),_=jm(u=jm(d=qT({length:5})).call(d,(function(e,t){return a-1-t})).reverse()).call(u,(function(e){return h.getUint8(e)}));s=Om(l=[]).call(l,JT(v),["..."],JT(_))}else s=qT(new Uint8Array(o));return Om(n=Om(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return jm(t).call(t,e);if(mT(r=["[object Object]","[object MediaStreamTrack]"]).call(r,Object.prototype.toString.call(t))){var p={};for(var f in t)p[f]=e(t[f]);return p}return t}))}var HO=function(e){var t,r=VO(e.engineId),n={keys:sw(e),labelSelector:"",sdkVersion:e.sdkVersion,deviceType:"web",appId:e.appId},i=jm(t=e.requestDomains).call(t,(function(e){return"https://".concat(e,"/decision/v1/multi")}));null==r||r.report("rtc_get_config",{error_code:0,message:Mm(n),elapse:0,host:i.join(","),type:"request",config_id:"",enable_cloud_proxy:!1});var o=jm(i).call(i,function(){var e=Rm(km().mark((function e(t,r){var i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"POST",body:Mm(n)}).then((function(e){return e.json()}));case 2:return i=e.sent,e.abrupt("return",{result:i,index:r});case 4:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}());return new Yf((function(e){(function(e){return new Yf((function(t,r){var n=(e=Array.isArray(e)?e:[]).length,i=[];0===n?r([]):e.forEach((function(e){e.then((function(e){t(e)}),(function(e){n--,i.push(e),0===n&&r(i)}))}))}))})(o).then((function(t){var n=t.result,o=t.index;null==r||r.report("rtc_get_config",{error_code:200,message:Mm(n),elapse:0,host:i[o],type:"response",config_id:"",enable_cloud_proxy:!1}),e(n)})).catch((function(e){var t;null==r||r.report("rtc_get_config",{error_code:500,message:null===(t=e[0])||void 0===t?void 0:t.message,elapse:0,host:"",type:"response",config_id:"",enable_cloud_proxy:!1})}))}))},zO=new TextDecoder,KO=new TextEncoder,XO=function(){return _w()},WO=function(){return Date.now()};function qO(e){for(var t=0,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];for(var o=0,a=n;o<a.length;o++){var s=a[o];t+=s.length}for(var c=new e(t),u=0,d=0,l=n;d<l.length;d++){var h=l[d];c.set(h,u),u+=h.length}return c}var YO=function(){function e(){Vl(this,e)}var t,r;return Ul(e,null,[{key:"token2auth",value:function(t,r,n,i){return i?"Bearer ".concat(i):"Basic ".concat(e.createUnsafeToken(t,r,n))}},{key:"createUnsafeToken",value:function(e,t,r){var n;return window.btoa(Gs(n=[e,t,r]).call(n,(function(e){return null!==e})).join(":"))}},{key:"merge",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,i=RA(t);n<i.length;n++){var o=eI(i[n],2),a=o[0],s=o[1];null!==s&&"object"===Wd(s)?e.merge(t[a],r[a]):void 0!==r[a]&&(t[a]=r[a])}}},{key:"ab2str",value:function(e){return zO.decode(e)}},{key:"ab2obj",value:function(t){try{var r=e.ab2str(t);return JSON.parse(r)}catch(n){return{}}}},{key:"str2ab",value:function(e){return KO.encode(e).buffer}},{key:"ab2b64str",value:(r=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Yf((function(e){var r=new FileReader;r.onload=function(){return e(r.result)},r.readAsDataURL(new Blob([t]))}));case 2:return r=e.sent,e.abrupt("return",r.split(",",2)[1]);case 4:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"b64str2ab",value:(t=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch("data:application/octet;base64,".concat(t)).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();function JO(){for(var e,t,r=Number(WA(e=Tm(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=WA(r).call(r,28,"1").split(""),i=[];n.length;)i.push(rT(n).call(n,0,7));return jm(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return YA(r+e.join(""),2)}))}var QO=function(){return Math.floor(65535*Math.random())};function ZO(e){return"string"==typeof e&&xE(e).call(e,"__web__rtc__rtt__")>-1}var $O,eN,tN,rN,nN,iN,oN,aN,sN=function(){var e=Rm(km().mark((function e(){var t,r,n,i=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]&&i[0],(r=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"})).createDataChannel("default"),r.addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),t&&(r.addTransceiver("audio",{direction:"sendonly"}),r.addTransceiver("video",{direction:"sendonly"})),e.next=8,r.createOffer();case 8:return n=e.sent,r.close(),e.abrupt("return",n.sdp);case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),cN=function(e){return new Yf((function(t,r){var n=(e=Array.isArray(e)?e:[]).length,i=[];0===n?r([]):e.forEach((function(e){e.then((function(e){t(e)}),(function(e){n--,i.push(e),0===n&&r(i)}))}))}))};function uN(e){return Number(Math.max(-127,10*$A(Math.pow(e/255,2))).toFixed(2))}function dN(e){return(e&ul.AUDIO)===ul.AUDIO}function lN(e){return(e&ul.VIDEO)===ul.VIDEO}function hN(e){var t={};return an(e).forEach((function(r){"object"===Wd(e[r])?t[r]=hN(e[r]):hA(r).call(r,"_")||(t[r]=e[r])})),t}function vN(e){var t=new DataView(e.buffer);if(t.byteLength<=4||65535!==t.getUint16(0))return{seiCount:1,seis:[e]};for(var r={seiCount:0,seis:[]},n=!1,i=2;i<t.byteLength;){var o=t.getUint16(i);if(i+=2,t.byteLength-i<o){n=!0;break}var a=new Uint8Array(e.buffer,i,o);if(i+=o,t.byteLength-i>0&&t.byteLength-i<=2){n=!0;break}r.seiCount++,r.seis.push(a)}return n&&(r.seiCount=1,r.seis=[e]),r}function _N(e){return null==e?"undefined | null":"string"==typeof e?e:Mm({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function pN(e){return void 0===e}function fN(e){return function(t,r,n){var i=n.value;n.value=function(){var t;console.warn(Om(t="[RTC WebSDK]: Api: ".concat(r," has been abandoned from version ")).call(t,e));for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return i.apply(this,o)}}}function mN(e){console.warn("[RTC WebSDK]: ".concat(e))}function gN(e){return"number"==typeof e?e:"number"==typeof(null==e?void 0:e.exact)?e.exact:"number"==typeof(null==e?void 0:e.ideal)?e.ideal:"number"==typeof(null==e?void 0:e.max)?e.max:"number"==typeof(null==e?void 0:e.min)?e.min:1}var yN=function(){return"undefined"==typeof window},SN=yN()?"":window.navigator.userAgent;function bN(){var e="none";return yN()||(null!==SN.match("Firefox")?e="mozilla":null!==SN.match("Chrome")?(e="chrome-stable",null!==SN.match("Electron")&&(e="electron")):(null!==SN.match("Safari")||null!==SN.match("AppleWebKit"))&&(e="safari")),e}var EN="mozilla"===bN(),TN="safari"===bN(),kN="chrome-stable"===bN(),IN=!yN()&&/CriOS/i.test(SN),RN=!yN()&&/Edg\//i.test(SN),AN=!yN()&&/EdgA/i.test(SN),wN=!yN()&&/EdgiOS/i.test(SN),CN=RN||AN||wN;!yN()&&/(iPhone|iPod)/i.exec(SN);var xN=!yN()&&(!!/(iPad)/i.exec(SN)||/Macintosh/i.test(SN)&&"ontouchend"in document),ON=!yN()&&/Macintosh/i.test(SN),NN=!yN()&&/MicroMessenger/i.test(SN),DN=!yN()&&mT($O=SN.toLowerCase()).call($O,"mobile");!yN()&&/SM-\w+/i.test(SN);var PN=!yN()&&!!/(iPhone|iPad|iPod)/i.exec(SN),MN=!yN()&&/Android/i.test(SN),LN=!yN()&&/Windows/i.test(SN),UN=0,VN=!yN()&&(null===(eN=SN.match(/version\/(\d+)/i))||void 0===eN?void 0:eN[1]);TN&&VN&&(UN=Number(VN));var FN=!yN()&&(null===(tN=SN.match(/Firefox\/(\d+)/i))||void 0===tN?void 0:tN[1]);EN&&FN&&(UN=Number(FN));var BN=UN,jN=UN,GN=null!==(rN=!yN()&&(null===(nN=SN.match(/ ([\d_]+) like Mac OS X/i))||void 0===nN||null===(iN=nN[1])||void 0===iN?void 0:jm(oN=iN.split("_")).call(oN,(function(e){return ug(e)}))))&&void 0!==rN?rN:[],HN=0,zN=!yN()&&(null===(aN=SN.match(/Chrome\/(\d+)/i))||void 0===aN?void 0:aN[1]);zN&&(HN=Number(zN));var KN=HN,XN="BytePlus",WN="RTC_DEVICE_ID",qN="RTC_ACCESS_NODE",YN="RTC_ACCESS_URLS",JN="ENGINE_WEB_CONFIG",QN=function(){function e(){Vl(this,e)}return Ul(e,[{key:"get",value:function(e){var t=localStorage.getItem(e);if(!t)return null;try{var r=JSON.parse(t);return r.ttl>0&&Date.now()-r.saveTime>r.ttl?(this.delete(e),null):r.message}catch(n){return null}}},{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n={ttl:r,saveTime:Date.now(),message:t};try{return localStorage.setItem(e,Mm(n)),!0}catch(i){return!1}}},{key:"getTtl",value:function(e){var t=localStorage.getItem(e);if(!t)return null;try{return JSON.parse(t).ttl}catch(r){return null}}},{key:"delete",value:function(e){try{return localStorage.removeItem(e),!0}catch(t){return!1}}}]),e}(),ZN=function(e){DI(r,e);var t=QI(r);function r(){return Vl(this,r),t.apply(this,arguments)}return Ul(r,[{key:"getDeviceId",value:function(){if(yN())return"";var e=this.get(WN);return e&&!/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(e)||(e=function(e){for(var t="",r=0;r<e;r++)t+=Math.floor(10*Math.random());return t}(30)),this.setDeviceId(e),e}},{key:"setDeviceId",value:function(e){return xO({device_id:e}),this.set(WN,e),e}},{key:"getAccessNode",value:function(e){var t;return this.get(Om(t="".concat(qN,"_").concat(e,"-")).call(t,XN))}},{key:"setAccessNode",value:function(e,t,r){var n;return this.set(Om(n="".concat(qN,"_").concat(e,"-")).call(n,XN),t,1e3*r)}},{key:"deleteAccessNode",value:function(e,t){var r,n=this.getAccessNode(e),i=this.getTtl(Om(r="".concat(qN,"_").concat(e,"-")).call(r,XN));Array.isArray(n)&&n.length>0&&((n=Gs(n).call(n,(function(e){return e.mediaID!==t.mediaID&&e.msgKey!==t.msgKey}))).length>0?this.setAccessNode(e,n,i||0):this.clearAccessNode(e))}},{key:"clearAccessNode",value:function(e){var t;this.delete(Om(t="".concat(qN,"_").concat(e,"-")).call(t,XN))}},{key:"getAccessUrls",value:function(){return this.get("".concat(YN,"-").concat(XN))}},{key:"setAccessUrls",value:function(e){var t=jm(e).call(e,(function(e){var t,r=e.host,n=e.path;return Om(t="https://".concat(r)).call(t,n)}));return this.set("".concat(YN,"-").concat(XN),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(YN,"-").concat(XN))}},{key:"getEngineWebConfig",value:function(e,t){var r,n,i,o=Om(r=Om(n="".concat(e,"_")).call(n,t,"_")).call(r,this.getDeviceId()),a=this.get(JN);return(null==a||null===(i=yE(a).call(a,(function(e){return e.key===o})))||void 0===i?void 0:i.config)||{}}},{key:"setEngineWebConfig",value:function(e,t,r){var n,i;if(r){var o=Om(n=Om(i="".concat(e,"_")).call(i,t,"_")).call(n,this.getDeviceId()),a=this.get(JN)||[];return(a=Gs(a).call(a,(function(e){return e.key!==o}))).push({key:o,config:r}),this.set(JN,Tm(a).call(a,-5))}}}]),r}(QN),$N=new ZN,eD=new Mw("JoinRoomConfig",0),tD=function(){function e(t){var r;Vl(this,e),Jd(this,"_useTcpAfterJoinTimeout",e.DEFAULT_CONF.useTcpAfterJoinTimeout),Jd(this,"_joinWithTcpOnly",e.DEFAULT_CONF.joinWithTcpOnly),Jd(this,"_joinWithTcpOnlyDelay",e.DEFAULT_CONF.joinWithTcpOnlyDelay),Jd(this,"_blackBrowserRegexList",[]),this._engineId=t,xE(r=location.search).call(r,"__rtc_tcp_only__")>-1&&(this._joinWithTcpOnly=!0,this._joinWithTcpOnlyDelay=0),this._report()}return Ul(e,[{key:"useTcpAfterJoinTimeout",get:function(){return this._useTcpAfterJoinTimeout}},{key:"useTcpJoin",get:function(){return this._joinWithTcpOnly}},{key:"useTcpJoinDelay",get:function(){return this._joinWithTcpOnlyDelay}},{key:"isBlackBrower",value:function(){var e;return yE(e=this._blackBrowserRegexList).call(e,(function(e){return new RegExp(e).test(navigator.userAgent)}))}},{key:"setServerConfig",value:function(e){var t,r,n,i,o,a,s=!1;"boolean"==typeof(null==e||null===(t=e.use_tcp_after_join_timeout)||void 0===t?void 0:t.enable)&&(this._useTcpAfterJoinTimeout=null===(i=e.use_tcp_after_join_timeout)||void 0===i?void 0:i.enable,s=!0);"boolean"==typeof(null==e||null===(r=e.join_with_tcp_only)||void 0===r?void 0:r.enable)&&(this._joinWithTcpOnly=null===(o=e.join_with_tcp_only)||void 0===o?void 0:o.enable,s=!0);"number"==typeof(null==e||null===(n=e.join_with_tcp_only)||void 0===n?void 0:n.delay_ms)&&(this._joinWithTcpOnlyDelay=null===(a=e.join_with_tcp_only)||void 0===a?void 0:a.delay_ms,s=!0);e&&Array.isArray(e.black_browser_regex_list)&&(this._blackBrowserRegexList=e.black_browser_regex_list,s=!0),s&&this._report()}},{key:"toString",value:function(){return Mm({use_tcp_after_join_timeout:this._useTcpAfterJoinTimeout,join_with_tcp_only:this._joinWithTcpOnly,join_with_tcp_only_delay:this._joinWithTcpOnlyDelay,black_browser_regex_list:this._blackBrowserRegexList})}},{key:"_report",value:function(){eD.print("_report",this.toString()),jO(this._engineId,"web_join_room_config",this.toString())}}],[{key:"setDefaulConf",value:function(t){var r=t.useTcpAfterJoinTimeout,n=t.joinWithTcpOnly,i=t.joinWithTcpOnlyDelay;return"boolean"==typeof r&&(e.DEFAULT_CONF.useTcpAfterJoinTimeout=r),"boolean"==typeof n&&(e.DEFAULT_CONF.joinWithTcpOnly=n),"number"==typeof i&&(e.DEFAULT_CONF.joinWithTcpOnlyDelay=Math.max(0,i)),e.DEFAULT_CONF}}]),e}();Jd(tD,"DEFAULT_CONF",{useTcpAfterJoinTimeout:!0,joinWithTcpOnly:!1,joinWithTcpOnlyDelay:5e3});var rD="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function nD(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://".concat(e)),"".concat(e,"/dispatch/v1/AccessInfo?Action=GetAccessInfo")}var iD="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",oD="rtc.rtcplus.com".split(","),aD={VERSION:"4.55.10",ICE_CONFIG_REQUEST_URLS_INTERNAL:jm(rD).call(rD,nD),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:iD,CONFIG_REQUEST_DOMAINS:oD,DEVICE_ID:"",OVERSEA:!1,PLATFORM:"",PRODUCT:"",FORCE_ENABLED_REPORT_CALLBACKS:[],SKIP_WEB_AUDIO_IN_TRACK:!1,AUDIO_STALL:!0,VIDEO_STALL:!0,STATS_SCALLBACK_SUPPORT:!0,JOIN_ROOM_CONFIG:tD.DEFAULT_CONF,IOS_SAFARI_ORIENTATION:!1,ENABLE_REPORT_ERROR_BUFFER:!1,PUB_SUB_MODE:"recv_and_send"};function sD(e,t){var r;if(DO("setParameter",0,Om(r="key: ".concat(e,", value: ")).call(r,t)),"VERSION"!==e){if("JOIN_ROOM_CONFIG"===e)return tD.setDefaulConf(t);if("ICE_CONFIG_REQUEST_URLS"===e)return"string"==typeof t&&(t=[t]),void(aD.ICE_CONFIG_REQUEST_URLS=jm(t).call(t,nD));if("PLATFORM"!==e||"string"!=typeof t)if("PRODUCT"!==e||"string"!=typeof t){if("FORCE_ENABLED_REPORT_CALLBACKS"===e)return"string"==typeof t&&(t=[t]),void(aD.FORCE_ENABLED_REPORT_CALLBACKS=t);if("LOG_SERVER_URL"===e){var n=t===vl.overseas?"https://web-log-report.rtcplus.com/video/v1/webrtc_log/":t===vl.domestic?iD:"string"==typeof t?t:void 0;n&&(aD.LOG_SERVER_URL=n,OO(n))}else if("OVERSEA"===e)return xO({extra_is_oversea:t?"1":"0"}),void(aD.OVERSEA=t);"DEVICE_ID"===e&&$N.setDeviceId(t),"ENABLE_REPORT_ERROR_BUFFER"===e&&t&&TO.enableErrorBuffer(),aD[e]=t}else xO({product:t});else xO({platform:t})}}function cD(e){return"DEVICE_ID"===e?$N.getDeviceId():aD[e]}function uD(e,t,r){var n,i,o,a,s,c,u,d,l;return{type:"publicstream",action:t,publicStreamID:e,publicStreamMeta:{audio:{},video:{fps:(null===(n=r.video)||void 0===n?void 0:n.fps)||15,bitrate:1e3*((null===(i=r.video)||void 0===i?void 0:i.kBitRate)||40),width:(null===(o=r.video)||void 0===o?void 0:o.width)||640,height:(null===(a=r.video)||void 0===a?void 0:a.height)||360},layout:{layoutMode:2,interpolationMode:(null===(s=r.layout)||void 0===s?void 0:s.interpolationMode)||fl.PREV_FRAME,canvas:{bgColor:(null===(c=r.layout)||void 0===c?void 0:c.backgroundColor)||"#000000",bgImage:(null===(u=r.layout)||void 0===u?void 0:u.backgroundImage)||""},regions:(null===(d=r.layout)||void 0===d||null===(l=d.regions)||void 0===l?void 0:jm(l).call(l,(function(e){return{roomId:e.roomId,userId:e.userId,alterImage:e.alertImage||"",alpha:!e.alpha||Number(e.alpha)>1||Number(e.alpha)<=0?1:Number(e.alpha),x:!e.x||Number(e.x)>=1||Number(e.x)<0?0:Number(e.x),y:!e.y||Number(e.y)>=1||Number(e.y)<0?0:Number(e.y),w:!e.w||Number(e.w)>1||Number(e.w)<=0?1:Number(e.w),h:!e.h||Number(e.h)>1||Number(e.h)<=0?1:Number(e.h),zorder:!e.zorder||Number(e.zorder)<0||Number(e.zorder)>100?0:Number(e.zorder),renderMode:void 0===e.renderMode?1:e.renderMode,streamType:e.isScreenStream?1:0,mediaType:e.mediaType||0,sourceCrop:e.sourceCrop}})))||[]}}}}var dD={width:640,height:480,frameRate:15,maxKbps:600},lD={width:1920,height:1080,frameRate:15,maxKbps:3e3};function hD(e,t){if("boolean"!=typeof e)throw new mA(vA.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}function vD(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(e<r||e>n||"number"!=typeof e){var i,o,a=new mA(vA.INVALID_PARAMS,Om(i=Om(o="Invalid ".concat(t,": the value range is [")).call(o,r,", ")).call(i,n,"]. integer only"));throw a}}function _D(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(null==e)throw new mA(vA.INVALID_PARAMS,"".concat(t," cannot be empty"));if(!SD(e,i,o))throw new mA(vA.INVALID_PARAMS,Om(r=Om(n="Invalid ".concat(t,": The value should be string type. Length of the string: [")).call(n,i,",")).call(r,o,"]"))}function pD(e,t,r){var n;if(!mT(r).call(r,e))throw new mA(vA.INVALID_PARAMS,Om(n="Invalid ".concat(t,": The value can only be set as ")).call(n,Mm(r)))}function fD(e){if(!(e instanceof MediaStreamTrack))throw new mA(vA.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}function mD(e,t){if(bD(e))throw new mA(vA.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function gD(e,t){if(!(e instanceof ArrayBuffer))throw new mA(vA.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function yD(e){try{for(var t=navigator.mediaDevices.getSupportedConstraints(),r=0,n=an(e);r<n.length;r++){var i=n[r];t[i]||delete e[i]}}catch(o){}}function SD(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.POSITIVE_INFINITY;return"string"==typeof e&&e.length<=r&&e.length>=t}function bD(e){return null==e}function ED(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new mA(vA.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function TD(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new mA(vA.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function kD(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new mA(vA.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function ID(e){mD(e,"userInfo"),TD(e.userId),bD(e.extraInfo)||_D(e.extraInfo,"userInfo.extraInfo",1,200)}function RD(e){mD(e,"roomConfig"),hD(e.isAutoPublish,"roomConfig.isAutoPublish"),hD(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),hD(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo"),bD(e.roomProfileType)||pD(e.roomProfileType,"roomConfig",[bl.communication,bl.chat,bl.chatRoom,bl.coHost,bl.meeting,bl.classRoom])}function AD(e){mD(e,"videoPlayerOption")}function wD(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64;if(!e||0===(null==e?void 0:e.byteLength))throw new mA(vA.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:YO.str2ab(Mm(e)))||void 0===t?void 0:t.byteLength)>1e3*r)throw new mA(vA.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function CD(e){var t,r=cD("FORCE_ENABLED_REPORT_CALLBACKS");return!(null==r||!mT(r).call(r,e))||!mT(t=[Ml.onRemoteStreamStats,Ml.onLocalStreamStats,Ml.onAudioVolumeIndication,Ml.onLocalAudioPropertiesReport,Ml.onRemoteAudioPropertiesReport]).call(t,e)}function xD(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new mA(vA.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}function OD(e,t){if("number"!=typeof e||Number.isNaN(e)||!(e>=1)){var r=e;if(!(null!=r&&r.min||null!=r&&r.max||null!=r&&r.exact||null!=r&&r.ideal))throw new mA(vA.INVALID_PARAMS,"".concat(t," is not a valid ConstrainULong"))}}function ND(e){var t,r=$k(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;vD(null==n?void 0:n.maxKbps,"maxKbps"),OD(null==n?void 0:n.width,"width"),OD(null==n?void 0:n.height,"height"),OD(null==n?void 0:n.frameRate,"frameRate")}}catch(i){r.e(i)}finally{r.f()}}function DD(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.NEGATIVE_INFINITY,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;return vD(e,t,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),e=(e=e>r?e:r)<n?e:n}var PD={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?Tm(n).call(n,1):n);return xs?Om(i).call(i,xs(e)):i},s.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,a=new Array(o);i<o;i++)a[i]=n[i].fn;return a},s.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var c,u,d=this._events[s],l=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),l){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,n),!0;case 4:return d.fn.call(d.context,t,n,i),!0;case 5:return d.fn.call(d.context,t,n,i,o),!0;case 6:return d.fn.call(d.context,t,n,i,o,a),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];d.fn.apply(d.context,c)}else{var h,v=d.length;for(u=0;u<v;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),l){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,n);break;case 4:d[u].fn.call(d[u].context,t,n,i);break;default:if(!c)for(h=1,c=new Array(l-1);h<l;h++)c[h-1]=arguments[h];d[u].fn.apply(d[u].context,c)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var c=0,u=[],d=s.length;c<d;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(PD);var MD=PD.exports,LD=new Mw("VERTC",0),UD=function(e){DI(r,e);var t=QI(r);function r(){return Vl(this,r),t.apply(this,arguments)}return Ul(r,[{key:"safeEmit",value:function(e){var t=this.listenerCount(e);try{for(var n,i,o=arguments.length,a=new Array(o>1?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return(n=OI(CI(r.prototype),"emit",this)).call.apply(n,Om(i=[this,e]).call(i,a))}catch(uW){return LD.error("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,uW),console.error(uW),Boolean(t)}}}]),r}(PD.exports.EventEmitter),VD=O,FD=tr,BD=$,jD=nI,GD=Jt,HD=A,zD=mc,KD=V;Ar({target:"Reflect",stat:!0,forced:i((function(){var e=function(){},t=GD.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}))},{set:function e(t,r,n){var i,o,a,s=arguments.length<4?t:arguments[3],c=HD.f(FD(t),r);if(!c){if(BD(o=zD(t)))return e(o,r,n,s);c=KD(0)}if(jD(c)){if(!1===c.writable||!BD(s))return!1;if(i=HD.f(s,r)){if(i.get||i.set||!1===i.writable)return!1;i.value=n,GD.f(s,r,i)}else GD.f(s,r,KD(0,n))}else{if(void 0===(a=c.set))return!1;VD(a,s,n)}return!0}});var XD=ee.Reflect.set,WD=hi.f("asyncIterator");function qD(e){var t,r,n,i=2;for(void 0!==wd&&(r=WD,n=Xd);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new YD(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function YD(e){function t(e){if(Object(e)!==e)return Yf.reject(new TypeError(e+" is not an object."));var t=e.done;return Yf.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(YD=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Yf.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Yf.reject(e):t(r.apply(this.s,arguments))}},new YD(e)}var JD=[{maxLayers:3,totalPixels:2073600},{maxLayers:3,totalPixels:921600},{maxLayers:3,totalPixels:518400},{maxLayers:2,totalPixels:230400},{maxLayers:2,totalPixels:129600},{maxLayers:1,totalPixels:57600},{maxLayers:1,totalPixels:0}];Yg("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),hy);var QD=ee.Set;Ar({target:"Set",stat:!0,forced:!0},{from:by}),Ar({target:"Set",stat:!0,forced:!0},{of:Ty});var ZD=O,$D=Ce,eP=tr,tP=function(){for(var e=eP(this),t=$D(e.add),r=0,n=arguments.length;r<n;r++)ZD(t,e,arguments[r]);return e};Ar({target:"Set",proto:!0,real:!0,forced:!0},{addAll:tP}),Ar({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:Ay});var rP=yh,nP=tr,iP=Yt,oP=rP,aP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=nP(this),r=oP(t),n=iP(e,arguments.length>1?arguments[1]:void 0);return!aP(r,(function(e,r){if(!n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var sP=oe,cP=O,uP=Ce,dP=tr,lP=Rv,hP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){var t=dP(this),r=new(lP(t,sP("Set")))(t),n=uP(r.delete);return hP(e,(function(e){cP(n,r,e)})),r}});var vP=oe,_P=O,pP=Ce,fP=tr,mP=Yt,gP=Rv,yP=rP,SP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=fP(this),r=yP(t),n=mP(e,arguments.length>1?arguments[1]:void 0),i=new(gP(t,vP("Set"))),o=pP(i.add);return SP(r,(function(e){n(e,e,t)&&_P(o,i,e)}),{IS_ITERATOR:!0}),i}});var bP=tr,EP=Yt,TP=rP,kP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=bP(this),r=TP(t),n=EP(e,arguments.length>1?arguments[1]:void 0);return kP(r,(function(e,r){if(n(e,e,t))return r(e)}),{IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var IP=oe,RP=O,AP=Ce,wP=tr,CP=Rv,xP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){var t=wP(this),r=new(CP(t,IP("Set"))),n=AP(t.has),i=AP(r.add);return xP(e,(function(e){RP(n,t,e)&&RP(i,r,e)})),r}});var OP=O,NP=Ce,DP=tr,PP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){var t=DP(this),r=NP(t.has);return!PP(e,(function(e,n){if(!0===OP(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var MP=oe,LP=O,UP=Ce,VP=R,FP=tr,BP=yh,jP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){var t=BP(this),r=FP(e),n=r.has;return VP(n)||(r=new(MP("Set"))(e),n=UP(r.has)),!jP(t,(function(e,t){if(!1===LP(n,r,e))return t()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var GP=O,HP=Ce,zP=tr,KP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){var t=zP(this),r=HP(t.has);return!KP(e,(function(e,n){if(!1===GP(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var XP=Ar,WP=tr,qP=gn,YP=rP,JP=Uh,QP=E([].join),ZP=[].push;XP({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=WP(this),r=YP(t),n=void 0===e?",":qP(e),i=[];return JP(r,ZP,{that:i,IS_ITERATOR:!0}),QP(i,n)}});var $P=oe,eM=Yt,tM=O,rM=Ce,nM=tr,iM=Rv,oM=rP,aM=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=nM(this),r=oM(t),n=eM(e,arguments.length>1?arguments[1]:void 0),i=new(iM(t,$P("Set"))),o=rM(i.add);return aM(r,(function(e){tM(o,i,n(e,e,t))}),{IS_ITERATOR:!0}),i}});var sM=Ce,cM=tr,uM=rP,dM=Uh,lM=TypeError;Ar({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=cM(this),r=uM(t),n=arguments.length<2,i=n?void 0:arguments[1];if(sM(e),dM(r,(function(r){n?(n=!1,i=r):i=e(i,r,r,t)}),{IS_ITERATOR:!0}),n)throw lM("Reduce of empty set with no initial value");return i}});var hM=tr,vM=Yt,_M=rP,pM=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=hM(this),r=_M(t),n=vM(e,arguments.length>1?arguments[1]:void 0);return pM(r,(function(e,r){if(n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var fM=oe,mM=O,gM=Ce,yM=tr,SM=Rv,bM=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){var t=yM(this),r=new(SM(t,fM("Set")))(t),n=gM(r.delete),i=gM(r.add);return bM(e,(function(e){mM(n,r,e)||mM(i,r,e)})),r}});var EM=oe,TM=Ce,kM=tr,IM=Rv,RM=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){var t=kM(this),r=new(IM(t,EM("Set")))(t);return RM(e,TM(r.add),{that:r}),r}});var AM=QD,wM=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!yN()&&window.RTCPeerConnection&&window.RTCPeerConnection.prototype.addTransceiver&&window.RTCPeerConnection.prototype.createDataChannel){e.next=3;break}return e.abrupt("return",!1);case 3:return e.next=5,FM();case 5:if(e.t0=e.sent,!e.t0){e.next=10;break}return e.next=9,VM();case 9:e.t0=e.sent;case 10:return e.abrupt("return",e.t0);case 13:return e.prev=13,e.t1=e.catch(0),e.abrupt("return",!1);case 16:case"end":return e.stop()}}),e,null,[[0,13]])})));return function(){return e.apply(this,arguments)}}(),CM=function(){var e=Rm(km().mark((function e(t){var r,n,i,o,a,s;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t||"recv_and_send",n=[],e.next=4,FM();case 4:return i=e.sent,e.next=7,VM();case 7:return o=e.sent,e.next=10,jM();case 10:return a=e.sent,e.next=13,BM();case 13:return s=e.sent,"send_only"===r&&(o&&n.push("H264"),s&&n.push("vp8")),"recv_only"===r&&(i&&n.push("H264"),a&&n.push("vp8")),"recv_and_send"===r&&(o&&i&&n.push("H264"),s&&a&&n.push("vp8")),e.abrupt("return",n);case 18:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),xM=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Mm(DM));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),OM=function(){var e=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,CM();case 2:return t=e.sent,e.abrupt("return",jm(t).call(t,(function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),NM={},DM={};function PM(e){var t,r=!1,n=$k(e.split("\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value;if(mT(i).call(i,"level-asymmetry-allowed=1")&&mT(i).call(i,"packetization-mode=1")&&mT(i).call(i,"profile-level-id=42e0")){r=!0;break}}}catch(d){n.e(d)}finally{n.f()}if(r){for(var o=navigator.userAgent.toLowerCase(),a=!1,s=0,c=["miuibrowser"];s<c.length;s++){var u=c[s];mT(o).call(o,u)&&(a=!0)}return!a}return!1}var MM=function(){var e=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection({sdpSemantics:"unified-plan"})).addTransceiver("video",{direction:t}),e.next=4,r.createOffer();case 4:return n=e.sent,r.close(),e.abrupt("return",n.sdp.toLowerCase());case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),LM=function(){var e=Rm(km().mark((function e(){var t,r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,MM("sendonly");case 2:if(r=e.sent,!mT(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,MM("sendonly");case 6:r=e.sent;case 7:return NM.h264encode=PM(r),DM.h264encode=r,NM.vp8encode=xE(r).call(r,"vp8")>-1,DM.vp8encode="same as h264encode",e.abrupt("return",NM);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),UM=function(){var e=Rm(km().mark((function e(){var t,r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,MM("recvonly");case 2:if(r=e.sent,!mT(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,MM("recvonly");case 6:r=e.sent;case 7:return NM.h264decode=PM(r),DM.h264decode=r,NM.vp8decode=xE(r).call(r,"vp8")>-1,DM.vp8decode="same as h264decode",e.abrupt("return",NM);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),VM=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==NM.h264encode){e.next=10;break}return e.prev=1,e.next=4,LM();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),DM.h264encode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",NM.h264encode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),FM=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==NM.h264decode){e.next=10;break}return e.prev=1,e.next=4,UM();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),DM.h264decode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",NM.h264decode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),BM=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==NM.vp8encode){e.next=10;break}return e.prev=1,e.next=4,LM();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),DM.vp8encode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",NM.vp8encode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),jM=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==NM.vp8decode){e.next=10;break}return e.prev=1,e.next=4,UM();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),DM.vp8decode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",NM.vp8decode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),GM=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},HM=function(){return ON?kN&&KN>=70||EN&&jN>=80||TN&&BN>=14:LN?kN&&KN>=70||EN&&jN>=80:PN?GN[0]>=14:!!MN&&(kN&&KN>=86)},zM=kN&&KN<=114,KM=new $S,XM=function(){var e=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Yf((function(e,r){var n=cD("STATS_SCALLBACK_SUPPORT");if(kN&&void 0===window.InstallTrigger&&zM&&n)try{t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!mT(JM).call(JM,e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(Zd(Zd({},t),{},{id:e.id,type:e.type,timestamp:e.timestamp}))}})),e({all:r,getTrackStats:function(e){return Gs(r).call(r,(function(t){return"ssrc"!==t.type||t.googTrackId===e}))}})}))}catch(uW){r(uW)}else e({all:[],getTrackStats:function(){return[]}})})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),WM=function(){var e=Rm(km().mark((function e(t){var r,n,i,o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getStats();case 2:return n=e.sent,i={all:[]},o=new $S,n.forEach((function(e){var t=o.get(e.type)||new $S;t.set(e.id,e),o.set(e.type,t),i.all.push(e)})),a=function(e,t){e.forEach((function(e){var r,n,i,a,s,c,u=e.codecId,d=e.transportId,l=e.trackId,h=e.playoutId;if(null===(r=o.get(YM.codec))||void 0===r||r.forEach((function(e){e.id===u&&t.add(e)})),null===(n=o.get(YM.transport))||void 0===n||n.forEach((function(e){e.id===d&&(s=e,t.add(e))})),null===(i=o.get(YM.track))||void 0===i||i.forEach((function(e){e.id===l&&t.add(e)})),null===(a=o.get(YM.mediaPlayout))||void 0===a||a.forEach((function(e){e.id===h&&t.add(e)})),s){var v,_,p=s,f=p.localCertificateId,m=p.remoteCertificateId,g=p.selectedCandidatePairId;null===(v=o.get(YM.certificate))||void 0===v||v.forEach((function(e){(e.id===f||e.id===m)&&t.add(e)})),null===(_=o.get(YM.candidatePair))||void 0===_||_.forEach((function(e){e.id===g&&(c=e,t.add(e))}))}if(c){var y,S,b=c,E=b.localCandidateId,T=b.remoteCandidateId;null===(y=o.get(YM.localCandidate))||void 0===y||y.forEach((function(e){e.id===E&&t.add(e)})),null===(S=o.get(YM.remoteCandidate))||void 0===S||S.forEach((function(e){e.id===T&&t.add(e)}))}}))},o.get(YM.mediaSource)?null===(s=o.get(YM.mediaSource))||void 0===s||s.forEach((function(e){var t,r=new AM;r.add(e);var n=[];null===(t=o.get(YM.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=o.get(YM.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=qT(r)})):o.get(YM.track)&&(null===(c=o.get(YM.track))||void 0===c||c.forEach((function(e){var t,r=new AM;r.add(e);var n=[];null===(t=o.get(YM.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.trackId===e.id&&(r.add(t),n.push(t),null===(i=o.get(YM.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=qT(r)}))),null===(r=o.get(YM.inboundRtp))||void 0===r||r.forEach((function(e){var t,r=new AM;r.add(e),null===(t=o.get(YM.remoteOutboundRtp))||void 0===t||t.forEach((function(t){t.localId===e.id&&r.add(t)})),a([e],r);var n,s=e.trackIdentifier;s||(null===(n=o.get(YM.track))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(s=t.trackIdentifier)})));i[s]=qT(r)})),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),qM=function(){var e=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null==r?void 0:r.id,t instanceof RTCPeerConnection){e.next=3;break}return e.abrupt("return",[]);case 3:if(!EN&&!TN){e.next=10;break}return o=[],e.next=7,t.getStats(r);case 7:return e.sent.forEach((function(e){o.push(e)})),e.abrupt("return",o);case 10:return(!(a=KM.get(t))||Date.now()-a.timestamp>150)&&(a={timestamp:Date.now(),statsPromise:WM(t),extraStatsPromise:XM(t)},KM.set(t,a)),e.next=14,a.statsPromise;case 14:if(s=e.sent,c=(i?s[i]:s.all)||[],n){e.next=21;break}return e.next=19,a.extraStatsPromise;case 19:u=e.sent,c=Om(c).call(c,(i?u.getTrackStats(i):u.all)||[]);case 21:return e.abrupt("return",c);case 22:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),YM=function(e){return e.codec="codec",e.inboundRtp="inbound-rtp",e.outboundRtp="outbound-rtp",e.remoteInboundRtp="remote-inbound-rtp",e.remoteOutboundRtp="remote-outbound-rtp",e.mediaSource="media-source",e.csrc="csrc",e.peerConnection="peer-connection",e.dataChannel="data-channel",e.stream="stream",e.track="track",e.transceiver="transceiver",e.sender="sender",e.receiver="receiver",e.transport="transport",e.sctpTransport="sctp-transport",e.candidatePair="candidate-pair",e.localCandidate="local-candidate",e.remoteCandidate="remote-candidate",e.certificate="certificate",e.iceServer="ice-server",e.mediaPlayout="media-playout",e}(YM||{}),JM=["codec","inbound-rtp","outbound-rtp","remote-inbound-rtp","remote-outbound-rtp","media-source","csrc","peer-connection","data-channel","stream","track","transceiver","sender","receiver","transport","sctp-transport","candidate-pair","local-candidate","remote-candidate","certificate","ice-server"],QM={},ZM={},$M={exports:{}},eL=$M.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 null!=e.address?"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 null!=e.subtype?"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 null!=e.sessionConfig?"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 t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{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 t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{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 null!=e.maxMessageSize?"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"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{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"]}]};an(eL).forEach((function(e){eL[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))})),function(e){var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,n){var i=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:i&&!r[e.name]&&(r[e.name]={});var o=e.push?{}:i?r[e.name]:r;!function(e,r,n,i){if(i&&!n)r[i]=t(e[1]);else for(var o=0;o<n.length;o+=1)null!=e[o+1]&&(r[n[o]]=t(e[o+1]))}(n.match(e.reg),o,e.names,e.name),e.push&&r[e.push].push(o)},n=$M.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t,o={},a=[],s=o;return Gs(t=e.split(/(\r\n|\r|\n)/)).call(t,i).forEach((function(e){var t=e[0],i=Tm(e).call(e,2);"m"===t&&(a.push({rtp:[],fmtp:[]}),s=a[a.length-1]);for(var o=0;o<(n[t]||[]).length;o+=1){var c=n[t][o];if(c.reg.test(i))return r(c,s,i)}})),o.media=a,o};var o=function(e,r){var n=r.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&r.length>1&&(e[n[0]]=void 0),e};e.parseParams=function(e){var t;return vb(t=e.split(/;\s?/)).call(t,o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){var t;return jm(t=e.toString().split(" ")).call(t,Number)},e.parseRemoteCandidates=function(e){for(var r,n=[],i=jm(r=e.split(" ")).call(r,t),o=0;o<i.length;o+=3)n.push({component:i[o],ip:i[o+1],port:i[o+2]});return n},e.parseImageAttributes=function(e){var t;return jm(t=e.split(" ")).call(t,(function(e){var t;return vb(t=e.substring(1,e.length-1).split(",")).call(t,o,{})}))},e.parseSimulcastStreamList=function(e){var r;return jm(r=e.split(";")).call(r,(function(e){var r;return jm(r=e.split(",")).call(r,(function(e){var r,n=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),n=!0),{scid:r,paused:n}}))}))}}(ZM);var tL=$M.exports,rL=/%[sdv%]/g,nL=function(e){var t=1,r=arguments,n=r.length;return e.replace(rL,(function(e){if(t>=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}}))},iL=function(e,t,r){var n=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var o=t.names[i];t.name?n.push(r[t.name][o]):n.push(r[t.names[i]])}else n.push(r[t.name]);return nL.apply(null,n)},oL=["v","o","s","i","u","e","p","c","b","t","r","z","a"],aL=["i","c","b","a"],sL=ZM,cL=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||oL,n=t.innerOrder||aL,i=[];return r.forEach((function(t){tL[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(iL(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(iL(t,r,e))}))}))})),e.media.forEach((function(e){i.push(iL("m",tL.m[0],e)),n.forEach((function(t){tL[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(iL(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(iL(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"};QM.write=cL,QM.parse=sL.parse,QM.parseParams=sL.parseParams,QM.parseFmtpConfig=sL.parseFmtpConfig,QM.parsePayloads=sL.parsePayloads,QM.parseRemoteCandidates=sL.parseRemoteCandidates,QM.parseImageAttributes=sL.parseImageAttributes,QM.parseSimulcastStreamList=sL.parseSimulcastStreamList;var uL=new Mw("FirefoxHandler",3),dL=Math.pow(2,32),lL="kp34Za0H+aVf862l",hL="o/i14u9pJrxRKAsu";function vL(e){return e>dL-18?(uL.warn("generateAllSsrc","reset start id",e),vL(e=e-dL+1e4+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var _L=function(e,t,r){var n,i,o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:hL;return[{id:r,attribute:"cname",value:a},{id:r,attribute:"msid",value:Om(n=Om(i="".concat(e," ")).call(i,e,"-")).call(n,t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:Om(o="".concat(e,"-")).call(o,t)}]},pL=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.video,o=t.videoRtx,a=t.videoFec,s=[i,o],c=n.cname,u=n.flexfec;u&&s.push(a);var d,l=vb(s).call(s,(function(t,r){return Om(t).call(t,_L(e,"video",r,c))}),[]),h=[{semantics:"FID",ssrcs:Om(r="".concat(i," ")).call(r,o)}];u&&h.push({semantics:"FEC-FR",ssrcs:Om(d="".concat(i," ")).call(d,a)});return{ssrcs:l,ssrcGroups:h}};function fL(e){return e.direction="inactive",e.port=0,delete e.ext,delete e.ssrcs,delete e.ssrcGroups,delete e.simulcast,delete e.simulcast_03,delete e.rids,delete e.extmapAllowMixed,delete e.msid,delete e.bundleOnly,e}var mL=function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=Zd(Zd({},e),{},{media:[]});return n&&(i.invalid=[{value:"realx-exts:rscp"}]),t&&i.media.push(t),r&&i.media.push(r),delete i.groups,delete i.msidSemantic,QM.write(i)};function gL(e){return yL.apply(this,arguments)}function yL(){return(yL=Rm(km().mark((function e(t){var r,n,i,o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={},n=t.publicIPs,i=t.certFingerprint,o=t.iceParams,a=t.iceConfig,r.fingerprint={type:"sha-256",hash:i},r.icePwd=o.serverIcePwd,e.next=6,bL(o.serverIceUfrag);case 6:return r.iceUfrag=e.sent,r.candidates=SL(n,a),r.setup="active",r.iceOptions="renomination",e.abrupt("return",r);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function SL(e,t){if(!Array.isArray(e))return[];var r=0,n=2130706431,i=[];return e.forEach((function(e){var o={component:1,ip:e.ip,type:"host",generation:e.generation};e.udpPorts&&!t.tcpOnly&&e.udpPorts.forEach((function(e){i.push(Zd(Zd({},o),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){i.push(Zd(Zd({},o),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),i}var bL=function(){var e=Rm(km().mark((function e(t){var r,n,i,o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new TextEncoder,n=r.encode("PREC"),e.t0=Uint8Array,e.next=5,YO.b64str2ab(t);case 5:return e.t1=e.sent,i=new e.t0(e.t1),o=new Uint8Array(4),crypto.getRandomValues(o),(a=new Uint8Array(2))[0]=0,a[1]=1,s=qO(Uint8Array,n,i,o,a),e.next=15,YO.ab2b64str(s.buffer);case 15:return c=e.sent,e.abrupt("return",c);case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),EL=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=$k(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o,a,s,c=n.value;if(mT(o=c.config).call(o,"level-asymmetry-allowed=1")&&mT(a=c.config).call(a,"packetization-mode=1")&&mT(s=c.config).call(s,"profile-level-id=42e0")){r=c.payload;break}}}catch(_){i.e(_)}finally{i.f()}for(var u=0;u<e.rtp.length;u++){var d=e.rtp[u];if("H264"===t){if(d.payload===r){var l;e.rtp.unshift(rT(l=e.rtp).call(l,u,1)[0]);break}}else if(d.codec===t){var h;e.rtp.unshift(rT(h=e.rtp).call(h,u,1)[0]);break}}var v=[];e.rtp.forEach((function(e){return v.push(e.payload)})),e.payloads=v.join(" ")}},TL=new Mw("BasicHandler",3),kL=function(e){DI(n,e);var t,r=QI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this)),"_peerConnection",void 0),Jd(tI(i),"_dataChannel",void 0),Jd(tI(i),"_context",void 0),Jd(tI(i),"peerConnectionMode",0),Jd(tI(i),"peerConnectionId",""),Jd(tI(i),"id",void 0),Jd(tI(i),"_monitor",void 0),Jd(tI(i),"_nextSsrc",Math.floor(Math.random()*dL+1e4)),Jd(tI(i),"_aSendonlyAnswerTpl",void 0),Jd(tI(i),"_vSendonlyAnswerTpl",void 0),Jd(tI(i),"_enableSubFlexfec",!1),Jd(tI(i),"audioTrack4ff",void 0),Jd(tI(i),"setLocalDescription",void 0),Jd(tI(i),"setRemoteDescription",void 0),i.peer=t,i.id=e.id,i._monitor=VO(i.id),i._peerConnection=t.getOriginRTCPeerConnection(),i._dataChannel=t.getOriginRTCDataChannel(),i.setLocalDescription=t.setLocalDescription.bind(t),i.setRemoteDescription=t.setRemoteDescription.bind(t),i._context=e,i.peer.on("ontrack",(function(e){i.emit("ontrack",e)})),i}return Ul(n,[{key:"destroy",value:function(){TL.info("destroy",this.peerConnectionId||""),OI(CI(n.prototype),"removeAllListeners",this).call(this)}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"getConnectionState",value:function(){return this._peerConnection.connectionState}},{key:"_simulcast",value:function(e,t,r,n,i){var o,a,s,c=[];1===e.videoEncodeConfig.length?(c=function(e,t){var r=[];if(t<=1)return r;var n=Math.min(e.width,e.height)/90;return r.push({scaleResolutionDownBy:n,width:Math.floor(e.width/n),height:Math.floor(e.height/n),maxkbps:100,frameRate:10}),t<=2||r.unshift({scaleResolutionDownBy:2,width:Math.floor(e.width/2),height:Math.floor(e.height/2),maxkbps:Math.floor(e.maxKbps/2),frameRate:e.frameRate>=30?Math.floor(e.frameRate/2):e.frameRate}),r}(t,i),TL.info("simulcast() ","simulcastLayers: %o",c)):(c=jm(o=Tm(a=Tm(s=e.videoEncodeConfig).call(s,1)).call(a,1-i)).call(o,(function(e){var r=gN(e.width),n=t.width/r;return{width:r,height:Math.floor(t.height/n),scaleResolutionDownBy:n,frameRate:gN(e.frameRate)||15,maxkbps:e.maxKbps||600}})),TL.info("simulcast() ","simulcastLayers2: %o",c));var u=[!0];c.forEach((function(e,t){var i,o={maxBitrate:1e3*e.maxkbps,scaleResolutionDownBy:e.scaleResolutionDownBy,rid:"".concat(t+1),maxFramerate:e.frameRate};null===(i=r.sendEncodings)||void 0===i||i.unshift(o),n.push({width:e.width,height:e.height,framerate:e.frameRate,maxkbps:e.maxkbps,rid:"".concat(t+1)}),u.push(!0)})),this._context&&(this._context.activeSimStreams=u)}},{key:"internalPublish",value:function(e){var t=e.stream,r=e.videoTrack,n=e.audioTrack,i=e.enableSimulcast,o=e.pubAudio,a=e.pubVideo,s={direction:"sendonly",streams:[t]},c={direction:"sendonly",streams:[t]},u=[],d=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var l=null==r?void 0:r.getTrack(),h=Zd({},dD);if(l){var v=null==l?void 0:l.getSettings();h={width:Math.floor(v.width),height:Math.floor(v.height),frameRate:Math.floor(v.frameRate)}}"number"!=typeof h.frameRate&&(h.frameRate=30);var _=null==e?void 0:e.videoEncodeConfig[0],p={maxBitrate:1e3*_.maxKbps,rid:"0"};if(e.prevBitrate=_.maxKbps,c.sendEncodings=[p],u.push({width:h.width,height:h.height,framerate:h.frameRate,maxkbps:_.maxKbps,rid:"0"}),!EN&&i){var f,m,g=function(e){for(var t=0,r=e.width*e.height,n=0;n<JD.length;n++)if(r>=JD[n].totalPixels){t=n;break}if(0===t)return JD[t].maxLayers;var i=JD[t-1].totalPixels;return(i-r)/(i-JD[t].totalPixels)<.1?JD[t-1].maxLayers:JD[t].maxLayers}(h);if(TL.info("simulcast() ","maxLayers: %o",g),g>1)this._simulcast(e,Zd(Zd({},h),{},{maxKbps:_.maxKbps}),c,u,g),null!==(f=this._context)&&void 0!==f&&null!==(m=f.serverConfig)&&void 0!==m&&m.simulcastOnDemand&&(d=jm(u).call(u,(function(e,t){return Zd(Zd({},e),{},{video_index:t,sub_index:t})})))}}TL.info("publish videoTransceiverInit videoDescriptions","",c,u);var y=null==n?void 0:n.getTrack("preprocessing");(null==n?void 0:n.mixType)!==Nl.PLAYOUT&&null!=n&&n.mixedAudioTrack&&(y=null==n?void 0:n.mixedAudioTrack),y=o&&y?y:"audio";var S=null==r?void 0:r.getTrack("preprocessing");S=a&&S?S:"video";try{this._reportRtcInvokeStatus("Handler.internalPublish",Mm({aTrack:_N(y),vTrack:_N(S),audioTransceiverInit:s,videoTransceiverInit:c}))}catch(uW){}return{semantics:"unified-plan",videoDescriptions:u,subVideoDescriptions:d,audioTransceiverInit:{track:y,init:s},videoTransceiverInit:{track:S,init:c}}}},{key:"updateMaxBitrate",value:function(e){var t,r,n,i;TL.info("updateMaxBitrate()");var o=null===(t=e.videoTrack)||void 0===t?void 0:t.getTrack(),a=e.videoTransceiver;if(o&&e.pubVideo&&a){var s=null===(r=e.videoEncodeConfig)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.maxKbps;if(s){if(s===e.prevBitrate)return void TL.warn("updateMaxBitrate()","no change");e.prevBitrate=s}var c=null===(i=a.sender)||void 0===i?void 0:i.getParameters();if(c){var u;c.encodings=null==c||null===(u=c.encodings)||void 0===u?void 0:jm(u).call(u,(function(t){var r,n=Number(t.rid)||0,i=null===(r=e.videoEncodeConfig[n])||void 0===r?void 0:r.maxKbps;return"number"==typeof i&&(t.maxBitrate=1e3*i),t})),null==a||a.sender.setParameters(c);try{this._reportRtcInvokeStatus("Handler.updateScaleResolutionDownBy",Mm(c.encodings))}catch(uW){}}}else TL.warn("updateMaxBitrate()","no pub")}},{key:"getStats",value:function(e,t){return qM(this._peerConnection,e,t)}},{key:"setCurrentDescription",value:(t=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineAnswerTpl",value:function(e){var t=this;QM.parse(e).media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r,n=null==e?void 0:yE(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&null!=e&&e.fmtp){var i,o=null==e?void 0:yE(i=e.fmtp).call(i,(function(e){return e.payload===n.payload}));o&&t._context&&(o.config+=";stereo=1;sprop-stereo=1")}t._aSendonlyAnswerTpl=e}}else"video"===e.type&&("sendonly"===e.direction&&(t._vSendonlyAnswerTpl=e),Array.isArray(e.rtp)&&e.rtp.forEach((function(e){var r;null!==(r=e.codec)&&void 0!==r&&mT(r).call(r,"flexfec")&&(t._enableSubFlexfec=!0)})))}))}},{key:"pc",get:function(){return this._peerConnection}},{key:"addBitrateLimit",value:function(e,t){null==e||e.rtp.forEach((function(r){var n,i=r.codec,o=r.payload;if(mT(n=["vp8","h264"]).call(n,i.toLocaleLowerCase())){var a,s,c=yE(a=e.fmtp).call(a,(function(e){return e.payload===o}));if(c)c.config=Om(s=[]).call(s,JT(c.config.split(";")),["x-google-min-bitrate=100","x-google-start-bitrate=".concat(t)]).join(";");else e.fmtp.push({payload:o,config:"x-google-min-bitrate=100;x-google-start-bitrate=".concat(t)})}}))}},{key:"_report",value:function(e,t,r){var n;null===(n=this._monitor)||void 0===n||n.report(e,Zd(Zd({},t),{},{connection_id:this.peer.getConnectionId(),group_connection_id:this.peer.getGroupConnectionId()}),r)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)}}]),n}(PD.exports.EventEmitter),IL=E,RL=Qg,AL=dg.exports.getWeakData,wL=mv,CL=tr,xL=z,OL=$,NL=Uh,DL=Ye,PL=Zi.set,ML=Zi.getterFor,LL=Po.find,UL=Po.findIndex,VL=IL([].splice),FL=0,BL=function(e){return e.frozen||(e.frozen=new jL)},jL=function(){this.entries=[]},GL=function(e,t){return LL(e.entries,(function(e){return e[0]===t}))};jL.prototype={get:function(e){var t=GL(this,e);if(t)return t[1]},has:function(e){return!!GL(this,e)},set:function(e,t){var r=GL(this,e);r?r[1]=t:this.entries.push([e,t])},delete:function(e){var t=UL(this.entries,(function(t){return t[0]===e}));return~t&&VL(this.entries,t,1),!!~t}};var HL,zL={getConstructor:function(e,t,r,n){var i=e((function(e,i){wL(e,o),PL(e,{type:t,id:FL++,frozen:void 0}),xL(i)||NL(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=ML(t),s=function(e,t,r){var n=a(e),i=AL(CL(t),!0);return!0===i?BL(n).set(t,r):i[n.id]=r,e};return RL(o,{delete:function(e){var t=a(this);if(!OL(e))return!1;var r=AL(e);return!0===r?BL(t).delete(e):r&&DL(r,t.id)&&delete r[t.id]},has:function(e){var t=a(this);if(!OL(e))return!1;var r=AL(e);return!0===r?BL(t).has(e):r&&DL(r,t.id)}}),RL(o,r?{get:function(e){var t=a(this);if(OL(e)){var r=AL(e);return!0===r?BL(t).get(e):r?r[t.id]:void 0}},set:function(e,t){return s(this,e,t)}}:{add:function(e){return s(this,e,!0)}}),i}},KL=n,XL=E,WL=Qg,qL=dg.exports,YL=Yg,JL=zL,QL=$,ZL=mg,$L=Zi.enforce,eU=Vi,tU=!KL.ActiveXObject&&"ActiveXObject"in KL,rU=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},nU=YL("WeakMap",rU,JL);if(eU&&tU){HL=JL.getConstructor(rU,"WeakMap",!0),qL.enable();var iU=nU.prototype,oU=XL(iU.delete),aU=XL(iU.has),sU=XL(iU.get),cU=XL(iU.set);WL(iU,{delete:function(e){if(QL(e)&&!ZL(e)){var t=$L(this);return t.frozen||(t.frozen=new HL),oU(this,e)||t.frozen.delete(e)}return oU(this,e)},has:function(e){if(QL(e)&&!ZL(e)){var t=$L(this);return t.frozen||(t.frozen=new HL),aU(this,e)||t.frozen.has(e)}return aU(this,e)},get:function(e){if(QL(e)&&!ZL(e)){var t=$L(this);return t.frozen||(t.frozen=new HL),aU(this,e)?sU(this,e):t.frozen.get(e)}return sU(this,e)},set:function(e,t){if(QL(e)&&!ZL(e)){var r=$L(this);r.frozen||(r.frozen=new HL),aU(this,e)?cU(this,e,t):r.frozen.set(e,t)}else cU(this,e,t);return this}})}var uU=ee.WeakMap;Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{emplace:Oy}),Ar({target:"WeakMap",stat:!0,forced:!0},{from:by}),Ar({target:"WeakMap",stat:!0,forced:!0},{of:Ty}),Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{deleteAll:Ay}),Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{upsert:ZS});var dU=uU,lU=function(e){DI(v,e);var t,r,n,i,o,a,s,c,u,d,l,h=QI(v);function v(){var e,t,r;return Vl(this,v),Jd(tI(r=h.call(this)),"inited",!1),Jd(tI(r),"deviceMap",{audioinput:new $S,audiooutput:new $S,videoinput:new $S}),Jd(tI(r),"checkDeviceChangeTimer",null),Jd(tI(r),"isSupportedPermissionsQuery",!1),Jd(tI(r),"isGrantedMicrophonePermission",!1),Jd(tI(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!yN()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(tI(r)),!yN()&&r.refreshDevices(),r}return Ul(v,[{key:"refreshDevices",value:(l=Rm(km().mark((function e(){var t,r,n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(navigator.mediaDevices){e.next=2;break}return e.abrupt("return");case 2:if(t=void 0,!EN){e.next=12;break}return e.prev=4,e.next=7,navigator.mediaDevices.getUserMedia({audio:!0});case 7:t=e.sent,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:return e.next=14,navigator.mediaDevices.enumerateDevices();case 14:r=e.sent,t&&t.getTracks().forEach((function(e){return e.stop()})),r.forEach((function(e){var t;e.deviceId&&(null===(t=n.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e))})),this.inited||this.initListener(),this.inited=!0;case 19:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return l.apply(this,arguments)})},{key:"initListener",value:(d=Rm(km().mark((function e(){var t,r,n,i,o=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(null===(t=navigator.mediaDevices)||void 0===t?void 0:t.ondevicechange)&&"function"==typeof(null===(r=navigator.mediaDevices)||void 0===r?void 0:r.addEventListener)?navigator.mediaDevices.addEventListener("devicechange",(function(){o._handleDeviceChange(),setTimeout((function(){o._handleDeviceChange()}),300)})):this.checkDeviceChangeTimer=window.setInterval((function(){o._handleDeviceChange()}),3e3),!this.isSupportedPermissionsQuery){e.next=22;break}return e.prev=2,e.next=5,navigator.permissions.query({name:"microphone"});case 5:n=e.sent,this.isGrantedMicrophonePermission="granted"===n.state,n.addEventListener("change",(function(){o.isGrantedMicrophonePermission="granted"===n.state})),e.next=12;break;case 10:e.prev=10,e.t0=e.catch(2);case 12:return e.prev=12,e.next=15,navigator.permissions.query({name:"camera"});case 15:i=e.sent,this.isGrantedCameraPermission="granted"===i.state,i.addEventListener("change",(function(){o.isGrantedCameraPermission="granted"===i.state})),e.next=22;break;case 20:e.prev=20,e.t1=e.catch(12);case 22:case"end":return e.stop()}}),e,this,[[2,10],[12,20]])}))),function(){return d.apply(this,arguments)})},{key:"_handleDeviceChange",value:(u=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=void 0,!EN){e.next=5;break}return e.next=4,navigator.mediaDevices.getUserMedia({audio:!0});case 4:o=e.sent;case 5:return e.next=7,navigator.mediaDevices.enumerateDevices();case 7:a=e.sent,a=Gs(a).call(a,(function(e){return!!e.deviceId})),o&&o.getTracks().forEach((function(e){return e.stop()})),s=qT(Om(t=[]).call(t,JT(oR(r=this.deviceMap.audioinput).call(r)),JT(oR(n=this.deviceMap.videoinput).call(n)),JT(oR(i=this.deviceMap.audiooutput).call(i)))),(DN||xN)&&!s.length&&a.length&&a.forEach((function(e){var t;null===(t=c.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e)})),a.forEach((function(e){var t,r,n=c.deviceMap[e.kind].get(e.deviceId);c.deviceMap[e.kind].set(e.deviceId,e),n||(mT(t=e.kind).call(t,"video")?c.emit(Ml.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):mT(r=e.kind).call(r,"audio")&&c.emit(Ml.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),s.forEach((function(e){var t,r;yE(a).call(a,(function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(c.deviceMap[e.kind].delete(e.deviceId),mT(t=e.kind).call(t,"video")?c.emit(Ml.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):mT(r=e.kind).call(r,"audio")&&c.emit(Ml.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 14:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"getUserMedia",value:(c=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.getUserMedia(t);case 2:return r=e.sent,null!=t&&t.audio&&(this.isGrantedMicrophonePermission=!0),null!=t&&t.video&&(this.isGrantedCameraPermission=!0),this.refreshDevices(),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"checkPermissionsByDevices",value:(s=Rm(km().mark((function e(){var t,r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t={audio:!1,video:!1},navigator.mediaDevices){e.next=3;break}return e.abrupt("return",t);case 3:return e.next=5,navigator.mediaDevices.enumerateDevices();case 5:return r=e.sent,t.audio=Gs(r).call(r,(function(e){return"audioinput"===e.kind&&e.label&&e.deviceId})).length>0,t.video=Gs(r).call(r,(function(e){return"videoinput"===e.kind&&e.label&&e.deviceId})).length>0,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e)}))),function(){return s.apply(this,arguments)})},{key:"getPermissions",value:(a=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=l.length>0&&void 0!==l[0]?l[0]:{},n=r.audio,i=r.video,o=r.force,n||i||(n=!0,i=!0),a={audio:!1,video:!1,reason:void 0},o){e.next=30;break}if(!this.isSupportedPermissionsQuery){e.next=20;break}if(!n||!i){e.next=14;break}if(!this.isGrantedMicrophonePermission||!this.isGrantedCameraPermission){e.next=12;break}return a.audio=!0,a.video=!0,e.abrupt("return",a);case 12:e.next=18;break;case 14:if(!(n&&this.isGrantedMicrophonePermission||i&&this.isGrantedCameraPermission)){e.next=18;break}return a.audio=this.isGrantedMicrophonePermission,a.video=this.isGrantedCameraPermission,e.abrupt("return",a);case 18:e.next=30;break;case 20:return e.next=22,this.checkPermissionsByDevices();case 22:if(s=e.sent,!n||!i){e.next=28;break}if(!s.audio||!s.video){e.next=26;break}return e.abrupt("return",s);case 26:e.next=30;break;case 28:if(!(n&&s.audio||i&&s.video)){e.next=30;break}return e.abrupt("return",s);case 30:if(null===(t=navigator.mediaDevices)||void 0===t||!t.getUserMedia){e.next=70;break}return e.prev=31,e.next=34,navigator.mediaDevices.getUserMedia({audio:n,video:i});case 34:(c=e.sent)&&(c.getTracks().forEach((function(e){return e.stop()})),n&&(a.audio=!0,this.isGrantedMicrophonePermission=!0),i&&(a.video=!0,this.isGrantedCameraPermission=!0)),e.next=70;break;case 38:if(e.prev=38,e.t0=e.catch(31),a.reason=e.t0,!this.isSupportedPermissionsQuery){e.next=70;break}if(!n){e.next=56;break}return e.next=45,navigator.permissions.query({name:"microphone"}).catch((function(){}));case 45:if(e.t2=u=e.sent,e.t1=null===e.t2,e.t1){e.next=49;break}e.t1=void 0===u;case 49:if(!e.t1){e.next=53;break}e.t3=void 0,e.next=54;break;case 53:e.t3=u.state;case 54:e.t4=e.t3,a.audio="granted"===e.t4;case 56:if(!i){e.next=70;break}return e.next=59,navigator.permissions.query({name:"camera"}).catch((function(){}));case 59:if(e.t6=d=e.sent,e.t5=null===e.t6,e.t5){e.next=63;break}e.t5=void 0===d;case 63:if(!e.t5){e.next=67;break}e.t7=void 0,e.next=68;break;case 67:e.t7=d.state;case 68:e.t8=e.t7,a.video="granted"===e.t8;case 70:return e.next=72,this.refreshDevices();case 72:return e.abrupt("return",a);case 73:case"end":return e.stop()}}),e,this,[[31,38]])}))),function(){return a.apply(this,arguments)})},{key:"enumerateDevices",value:(o=Rm(km().mark((function e(){var t,r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions();case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qT(Om(t=[]).call(t,JT(oR(r=this.deviceMap.audioinput).call(r)),JT(oR(n=this.deviceMap.videoinput).call(n)),JT(oR(i=this.deviceMap.audiooutput).call(i)))));case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"enumerateAudioCaptureDevices",value:(i=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qT(oR(t=this.deviceMap.audioinput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"enumerateVideoCaptureDevices",value:(n=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({video:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qT(oR(t=this.deviceMap.videoinput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"enumerateAudioPlaybackDevices",value:(r=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qT(oR(t=this.deviceMap.audiooutput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getDeviceById",value:(t=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.enumerateDevices();case 2:return r=e.sent,e.abrupt("return",yE(r).call(r,(function(e){return e.deviceId===t})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),v}(UD),hU=new lU;!yN()&&(window.__rtc_dd__=hU);var vU=new Mw("InternalEventBus",1),_U=function(e){return e.ON_IOS_INTERRUPTION_START="ON_IOS_INTERRUPTION_START",e.ON_IOS_INTERRUPTION_END="ON_IOS_INTERRUPTION_END",e.ON_IOS_LOCAL_TRACK_MUTE="ON_IOS_LOCAL_TRACK_MUTE",e.ON_IOS_LOCAL_TRACK_UNMUTE="ON_IOS_LOCAL_TRACK_UNMUTE",e}(_U||{}),pU=function(e){DI(r,e);var t=QI(r);function r(){return Vl(this,r),t.apply(this,arguments)}return Ul(r,[{key:"emit",value:function(e){var t,n;vU.info(e);for(var i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return(t=OI(CI(r.prototype),"emit",this)).call.apply(t,Om(n=[this,e]).call(n,o))}}]),r}(PD.exports.EventEmitter),fU=new pU,mU=new Mw("AudioContext",1),gU=function(){function e(){var t=this;Vl(this,e),Jd(this,"_audioContextInstance",void 0),Jd(this,"_previousState",""),Jd(this,"_currentState",""),Jd(this,"_contextStuckAt",0);var r=0;yN()||setInterval((function(){if(t._audioContextInstance){var e=t._audioContextInstance.currentTime;t._contextStuckAt?t._contextStuckAt!==e&&(t._contextStuckAt=0,mU.info("currentTime resume"),LO("currentTime resume","")):e&&r===e&&(t._contextStuckAt=e,mU.warn("currentTime stuck",t._contextStuckAt),t._audioContextInstance.suspend(),t._audioContextInstance.resume(),LO("AudioContext currentTime stuck",t._contextStuckAt)),r=e}}),3e3)}return Ul(e,[{key:"getAudioContextInstance",value:function(){var e=this;if(!this._audioContextInstance){var t=window.AudioContext||window.webkitAudioContext;this._audioContextInstance=new t,this._audioContextInstance.onstatechange=function(){var t,r,n;mU.warn("state change",null===(t=e._audioContextInstance)||void 0===t?void 0:t.state),e._previousState=e._currentState,e._currentState=(null===(r=e._audioContextInstance)||void 0===r?void 0:r.state)||"","interrupted"===(null===(n=e._audioContextInstance)||void 0===n?void 0:n.state)&&e._audioContextInstance.resume(),(PN||xN)&&("running"===e._previousState&&"interrupted"===e._currentState&&fU.emit(_U.ON_IOS_INTERRUPTION_START),"interrupted"===e._previousState&&"running"===e._currentState&&fU.emit(_U.ON_IOS_INTERRUPTION_END))}}return this._audioContextInstance}}]),e}(),yU=function(){function e(t){Vl(this,e),Jd(this,"_ctx",void 0),Jd(this,"_analyserNode",void 0),Jd(this,"_audioSource",void 0);var r=SU.getAudioContextInstance();if(t instanceof MediaStreamTrack){var n=new MediaStream;n.addTrack(t),this._audioSource=r.createMediaStreamSource(n)}else this._audioSource=r.createMediaElementSource(t),this._audioSource.connect(r.destination);var i=r.createAnalyser();this._audioSource.connect(i),this._analyserNode=i,this._ctx=r}var t;return Ul(e,[{key:"getAudioLevel",value:function(){var e;"suspended"===(null===(e=this._ctx)||void 0===e?void 0:e.state)&&this._ctx.resume();var t=new Uint8Array(2048);this._analyserNode.getByteTimeDomainData(t);var r=0;t.forEach((function(e){return r=Math.max(r,Math.abs(e-128))}));var n=r/128*255;return n>2?n:0}},{key:"resume",value:(t=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=this._ctx)||void 0===t?void 0:t.resume();case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._audioSource.disconnect(),this._analyserNode.disconnect()}}]),e}(),SU=new gU,bU=function(e){return e[e.CAPTURE=0]="CAPTURE",e[e.PRE_PROCESSING=1]="PRE_PROCESSING",e[e.ENCODE=2]="ENCODE",e[e.TRANSFER=3]="TRANSFER",e[e.POST_PROCESSING=4]="POST_PROCESSING",e[e.DECODE=5]="DECODE",e[e.RENDERING=6]="RENDERING",e}(bU||{}),EU=function(){function e(t){Vl(this,e),Jd(this,"_plugins",new $S),this.id=t}var t;return Ul(e,[{key:"register",value:function(e){var t=this._plugins.get(e.type)||[];if(QR(t).call(t,(function(t){return t.name===e.name}))>-1)throw new Error("Failed to register ".concat(e.name,": name is repeated."));t.push(e),this._plugins.set(e.type,t)}},{key:"getPluginsByType",value:function(e){return this._plugins.get(e)||[]}},{key:"getPluginByName",value:function(e,t){var r;return yE(r=this._plugins.get(e)||[]).call(r,(function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=Rm(km().mark((function e(t){var r,n,i,o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this._plugins.get(1)||[],n=t.getTrack(),i=$k(r),e.prev=3,i.s();case 5:if((o=i.n()).done){e.next=12;break}return a=o.value,e.next=9,a.effect(t,n);case 9:n=e.sent;case 10:e.next=5;break;case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(3),i.e(e.t0);case 17:return e.prev=17,i.f(),e.finish(17);case 20:return e.abrupt("return",n);case 21:case"end":return e.stop()}}),e,this,[[3,14,17,20]])}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._plugins.forEach((function(e){e.forEach((function(e){return e.destroy()}))})),this._plugins.clear()}}]),e}(),TU=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(TU||{}),kU=new Mw("VERTC",0),IU=new dU,RU=function(e){DI(r,e);var t=QI(r);function r(e,n){var i;return Vl(this,r),Jd(tI(i=t.call(this)),"sourceType",1),Jd(tI(i),"mediaType",void 0),Jd(tI(i),"_trackId",void 0),Jd(tI(i),"_ac",void 0),Jd(tI(i),"_sourceNode",void 0),Jd(tI(i),"_gainNode",void 0),Jd(tI(i),"_destNode",void 0),Jd(tI(i),"_channelCount",void 0),i._trackId=e,i.mediaType=n,"audio"===n&&HM()&&!cD("SKIP_WEB_AUDIO_IN_TRACK")&&(i._ac=SU.getAudioContextInstance(),i._gainNode=i._ac.createGain(),i._destNode=i._ac.createMediaStreamDestination(),i._gainNode.connect(i._destNode)),i}return Ul(r,[{key:"getId",value:function(){return this._trackId}},{key:"setVolume",value:function(e){this._gainNode&&(this._gainNode.gain.value=e/100)}},{key:"getVolume",value:function(){return this._gainNode?Math.round(100*this._gainNode.gain.value):-1}},{key:"channelCount",get:function(){var e;return null!==(e=this._channelCount)&&void 0!==e?e:0}},{key:"connectAudioTrack",value:function(e){var t;if(this._channelCount=e.getSettings().channelCount,!HM()||cD("SKIP_WEB_AUDIO_IN_TRACK"))return e;this._sourceNode&&(this._sourceNode.mediaStream.getTracks().forEach((function(e){e.stop()})),delete this._sourceNode);var r,n=new MediaStream;(n.addTrack(e),this._sourceNode=null===(t=this._ac)||void 0===t?void 0:t.createMediaStreamSource(n),this._gainNode)&&(null===(r=this._sourceNode)||void 0===r||r.connect(this._gainNode));return this._destNode.stream.getTracks()[0]}},{key:"destroy",value:function(){var e,t,r,n;(null===(e=this._sourceNode)||void 0===e||e.mediaStream.getTracks().forEach((function(e){e.stop()})),13!==BN)&&(null===(n=this._destNode)||void 0===n||n.stream.getTracks().forEach((function(e){e.stop()})));null===(t=this._sourceNode)||void 0===t||t.disconnect(),null===(r=this._gainNode)||void 0===r||r.disconnect(),delete this._sourceNode,delete this._gainNode,delete this._destNode}}]),r}(UD),AU=function(e){DI(n,e);var t,r=QI(n);function n(e,t,i){var o;return Vl(this,n),Jd(tI(o=r.call(this,t,i)),"_mediaTrack",void 0),Jd(tI(o),"_preProcessingTrack",void 0),Jd(tI(o),"_originTrack",void 0),Jd(tI(o),"captureSessionId",""),Jd(tI(o),"handleTrackEnded",(function(){o.emit("track-ended",tI(o)),o.close()})),Jd(tI(o),"handleMute",(function(){o.emit("track-mute",tI(o))})),Jd(tI(o),"handleUnmute",(function(){o.emit("track-unmute",tI(o))})),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o._initListeners(),o}return Ul(n,[{key:"getTrack",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"origin";return"origin"===e?this._mediaTrack:this._preProcessingTrack||this._mediaTrack}},{key:"setTrack",value:function(e,t){this._mediaTrack="audio"===this.mediaType?this.connectAudioTrack(e):e,this._originTrack=e,t&&this.generatePreProcessingTrack(t)}},{key:"generatePreProcessingTrack",value:(t=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._preProcessingTrack=void 0,e.prev=1,e.next=4,t.getPreProcessingTrack(this);case 4:(r=e.sent)instanceof MediaStreamTrack&&(this._preProcessingTrack=r),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),console.error(e.t0);case 11:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e){return t.apply(this,arguments)})},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){var e,t,r,n,i;return this._mediaTrack.onended=null,this._mediaTrack.onmute=null,this._mediaTrack.onunmute=null,null===(e=this._originTrack)||void 0===e||e.removeEventListener("ended",this.handleTrackEnded),null===(t=this._originTrack)||void 0===t||t.removeEventListener("mute",this.handleMute),null===(r=this._originTrack)||void 0===r||r.removeEventListener("unmute",this.handleUnmute),null===(n=this._preProcessingTrack)||void 0===n||n.stop(),"audio"===this.mediaType?this.destroy():null===(i=this._mediaTrack)||void 0===i?void 0:i.stop()}},{key:"_initListeners",value:function(){this._originTrack instanceof MediaStreamTrack&&(this._originTrack.addEventListener("ended",this.handleTrackEnded),this._originTrack.addEventListener("mute",this.handleMute),this._originTrack.addEventListener("unmute",this.handleUnmute))}}]),n}(RU),wU=function(e){DI(r,e);var t=QI(r);function r(e,n,i){var o;return Vl(this,r),Jd(tI(o=t.call(this,n,i)),"_mediaTrack",void 0),Jd(tI(o),"_originTrack",void 0),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o}return Ul(r,[{key:"getTrack",value:function(){return this._mediaTrack}},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){return this.destroy()}}]),r}(RU),CU=function(e){DI(n,e);var t,r=QI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this,e,t,"video")),"resolution",void 0),Jd(tI(i),"dummy",!1),i.resolution={width:0,height:0},i}return Ul(n,[{key:"updateVideoCaptureConfig",value:(t=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getTrack()){e.next=2;break}return e.abrupt("return");case 2:return kU.info("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=Zd({},t)).contentHint,EN&&this.streamIndex===cl.STREAM_INDEX_MAIN&&(r.frameRate={ideal:30,max:30}),e.next=8,this.getTrack().applyConstraints(r);case 8:((n=this.getTrack().getSettings()).width&&n.width!==this.resolution.width||n.height&&n.height!==this.resolution.height)&&(this.resolution={width:n.width,height:n.height},this.emit("resolution-change",this.resolution));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"replaceTrack",value:function(e){this.setTrack(e)}},{key:"setContentHint",value:function(e){var t;this._mediaTrack&&"contentHint"in this._mediaTrack&&mT(t=["text","motion","detail"]).call(t,e)&&(this._mediaTrack.contentHint=e)}}]),n}(AU),xU=function(e){DI(n,e);var t,r=QI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this,e,t,"audio")),"audioCaptureConfig",void 0),Jd(tI(i),"_audioLevelFetcher",void 0),Jd(tI(i),"mixedAudioTrack",void 0),Jd(tI(i),"mixType",Nl.PLAYOUT_AND_PUBLISH),i}return Ul(n,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new yU(this.getTrack("preprocessing"))),this._audioLevelFetcher.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.audioCaptureConfig){e.next=2;break}return e.abrupt("return");case 2:return kU.info("updateAudioCaptureConfig","update localAudioTrack: ",this.audioCaptureConfig),e.next=5,null===(t=this.getOrgTrack())||void 0===t?void 0:t.applyConstraints(this.audioCaptureConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),n}(AU),OU=function(e){DI(r,e);var t=QI(r);function r(e,n){return Vl(this,r),t.call(this,e,n,"video")}return Ul(r)}(wU),NU=function(e){DI(r,e);var t=QI(r);function r(e,n){var i;return Vl(this,r),Jd(tI(i=t.call(this,e,n,"audio")),"_audioLevelFetcher",void 0),i}return Ul(r,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new yU(this.getOrgTrack())),this._audioLevelFetcher.getAudioLevel()}}]),r}(wU),DU=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),n}return Ul(r)}(xU),PU=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),n}return Ul(r)}(CU),MU=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(CU),LU=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(xU),UU=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),n}return Ul(r)}(CU),VU=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),n}return Ul(r)}(xU),FU=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(CU),BU=function(e){DI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(xU);function jU(e,t){return GU.apply(this,arguments)}function GU(){return(GU=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new PU(t,XO())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function HU(e,t){return zU.apply(this,arguments)}function zU(){return(zU=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new UU(t,XO())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function KU(e,t){return XU.apply(this,arguments)}function XU(){return(XU=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=VO(r.id),s=XO(),e.prev=3,kU.info("createCameraVideoTrack","constraints:",t),null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o,capture_session_id:s}),c=WO(),EN&&(t.frameRate={ideal:30,max:30}),e.next=10,hU.getUserMedia({video:t});case 10:i=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:o,reason:"success",elapse:WO()-c,capture_session_id:s}),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(3),null==a||a.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:o,error_code:e.t0.code,reason:e.t0.name+e.t0.message,capture_session_id:s}),new mA(vA.GET_VIDEO_TRACK_FAILED,Om(u="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(u,e.t0.message||"unknown message","."),e.t0);case 18:return d=i.getVideoTracks()[0],IU.set(d,i),(l=new PU(d,XO())).captureSessionId=s,e.next=24,l.generatePreProcessingTrack(r);case 24:return e.abrupt("return",l);case 25:case"end":return e.stop()}}),e,null,[[3,14]])})))).apply(this,arguments)}function WU(e,t){return qU.apply(this,arguments)}function qU(){return(qU=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return kU.info("createMicrophoneAudioTrack","constraints:",t),o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=VO(r.id),s=XO(),e.prev=4,null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_begin",media_device_id:o,event_session_id:s}),u=WO(),(d=r.getPluginByName(bU.PRE_PROCESSING,"RTCAIAnsExtension"))&&(d.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=11,hU.getUserMedia({audio:t});case 11:i=e.sent,null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_result",media_device_id:o,media_device_name:(null===(c=i.getAudioTracks()[0])||void 0===c?void 0:c.label)||"",reason:"success",elapse:WO()-u,event_session_id:s}),e.next=19;break;case 15:throw e.prev=15,e.t0=e.catch(4),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_end",media_device_id:o,error_code:e.t0.code,reason:e.t0.name+e.t0.message,event_session_id:s}),new mA(vA.GET_AUDIO_TRACK_FAILED,Om(l="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(l,e.t0.message||"unknown message","."),e.t0);case 19:return h=i.getAudioTracks()[0],IU.set(h,i),(v=new DU(h,XO())).captureSessionId=s,e.next=25,v.generatePreProcessingTrack(r);case 25:return e.abrupt("return",v);case 26:case"end":return e.stop()}}),e,null,[[4,15]])})))).apply(this,arguments)}function YU(){return JU.apply(this,arguments)}function JU(){return JU=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=h.length>0&&void 0!==h[0]&&h[0],r=h.length>1?h[1]:void 0,n=h.length>2?h[2]:void 0,kU.info("createScreenTracks","withAudio: %o, constraints: %o",t,n),o=VO(r.id),a=XO(),e.prev=6,null==o||o.report("rtc_video_capture_event",{event_type:"start",media_device_id:"screen",capture_session_id:a}),s=WO(),e.next=11,navigator.mediaDevices.getDisplayMedia({video:!(n&&(!TN||16!==BN))||n,audio:!!t&&{channelCount:2,noiseSuppression:!1,echoCancellation:!0,autoGainControl:!1}});case 11:i=e.sent,null==o||o.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:"screen",reason:"success",elapse:WO()-s,capture_session_id:a}),e.next=19;break;case 15:throw e.prev=15,e.t0=e.catch(6),null==o||o.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:"screen",error_code:e.t0.code,reason:e.t0.name+e.t0.message,capture_session_id:a}),new mA(vA.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 19:return c=i.getVideoTracks()[0],u=new UU(c,XO()),e.next=23,u.generatePreProcessingTrack(r);case 23:if(!(d=i.getAudioTracks()[0])){e.next=29;break}return l=new VU(d,XO()),e.next=28,l.generatePreProcessingTrack(r);case 28:return e.abrupt("return",[u,l]);case 29:return e.abrupt("return",[u,void 0]);case 30:case"end":return e.stop()}}),e,null,[[6,15]])}))),JU.apply(this,arguments)}function QU(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:XO();return new NU(e,t)}function ZU(e,t){return $U.apply(this,arguments)}function $U(){return($U=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new MU(t,XO()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function eV(e,t){return tV.apply(this,arguments)}function tV(){return(tV=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new LU(t,XO()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function rV(e,t){return nV.apply(this,arguments)}function nV(){return(nV=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new FU(t,XO()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function iV(e,t){return oV.apply(this,arguments)}function oV(){return(oV=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new BU(t,XO()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var aV=xU,sV=NU,cV=function(e){return e[e.NONE=0]="NONE",e}(cV||{}),uV={getNalunits:function(e){if(e.length-e.position<4)return[];var t=e.position;return 1===e.getInt32(t)||0===e.getInt16(t)&&1===e.getInt8(t+2)?uV.getAnnexbNals(e):uV.getAvccNals(e)},getAnnexbNals:function(e){for(var t=[],r=uV.getHeaderPositionAnnexB(e),n=r.pos,i=n;n<e.length-4;){var o,a,s=new Uint8Array(Tm(o=e.buffer).call(o,n,n+r.headerLength));r.pos===e.position&&e.skip(r.headerLength),i=(r=uV.getHeaderPositionAnnexB(e)).pos;var c={header:s,body:new Uint8Array(Tm(a=e.buffer).call(a,n+s.byteLength,i)),type:-1};uV.analyseNal(c),c.type<=9&&0!==c.type&&t.push(c),e.skip(i-e.position),n=i}return t},getAvccNals:function(e){for(var t=[];e.position<e.length-4;){var r=e.getInt32(e.position);if(!(e.length-e.position>=r))break;var n,i,o=new Uint8Array(Tm(n=e.buffer).call(n,e.position,e.position+4));e.skip(4);var a=new Uint8Array(Tm(i=e.buffer).call(i,e.position,e.position+r));e.skip(r);var s={header:o,body:a,type:-1};uV.analyseNal(s),s.type<=9&&0!==s.type&&t.push(s)}return t},analyseNal:function(e){var t=31&e.body[0];switch(e.type=t,t){case 1:e.ndr=!0;break;case 5:e.idr=!0;break;case 6:e.sei=!0;break;case 7:e.sps=!0;break;case 8:e.pps=!0}},getHeaderPositionAnnexB:function(e){for(var t=e.position,r=0,n=e.length;3!==r&&4!==r&&t<n-4;)0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:1===e.getInt8(t+2)?r=3:t++:t++;return t===n-4&&(0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:t=n:(t++,0===e.getInt16(t)&&1===e.getInt8(t)?r=3:t=n)),{pos:t,headerLength:r}}},dV=function(){function e(t){Vl(this,e),Jd(this,"_position",0),Jd(this,"_dataview",void 0),this._dataview=new DataView(t)}return Ul(e,[{key:"length",get:function(){return this.buffer.byteLength}},{key:"buffer",get:function(){return this._dataview.buffer}},{key:"position",get:function(){return this._position},set:function(e){this._position=e}},{key:"back",value:function(e){this.position-=e}},{key:"getUint8",value:function(e){return this._dataview.getUint8(e)}},{key:"getInt8",value:function(e){return this._dataview.getInt8(e)}},{key:"getInt16",value:function(e){return this._dataview.getInt16(e)}},{key:"getUint16",value:function(e){return this._dataview.getUint16(e)}},{key:"getUint32",value:function(e){return this._dataview.getUint32(e)}},{key:"getInt32",value:function(e){return this._dataview.getInt32(e)}},{key:"skip",value:function(t){for(var r=Math.floor(t/4),n=t%4,i=0;i<r;i++)e.readByte(this,4);n>0&&e.readByte(this,n)}},{key:"readUint8",value:function(){return e.readByte(this,1)}},{key:"readUint16",value:function(){return e.readByte(this,2)}},{key:"readUint24",value:function(){return e.readByte(this,3)}},{key:"readUint32",value:function(){return e.readByte(this,4)}},{key:"readUint64",value:function(){return e.readByte(this,8)}},{key:"readInt8",value:function(){return e.readByte(this,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this,4,!0)}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}}],[{key:"readByte",value:function(e,t,r){var n;switch(t){case 1:n=r?e.getInt8(e.position):e.getUint8(e.position);break;case 2:n=r?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(r)throw new Error("not supported for readByte 3");n=e.getUint8(e.position)<<16,n|=e.getUint8(e.position+1)<<8,n|=e.getUint8(e.position+2);break;case 4:n=r?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(r)throw new Error("not supported for readBody 8");n=e.getUint32(e.position)<<32,n|=e.getUint32(e.position+4);break;default:n=""}return e.position+=t,n}}]),e}(),lV=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(lV||{}),hV=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),vV=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]),_V=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]&&t.push(3),t.push(e[r]);return new Uint8Array(t)};function pV(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function fV(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=0;255===e[t]&&t<e.byteLength;)t++,r+=255;return t<e.byteLength&&(r+=e[t++]),[r,t]}var mV=function(){function e(){Vl(this,e)}return Ul(e,null,[{key:"generateSEI",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=new Uint8Array([0,0,0,1]),i=new Uint8Array([6]),o=new Uint8Array([5]),a=r?hV:vV,s=pV(e.byteLength+a.byteLength),c=_V(e);return new Uint8Array(Om(t=[]).call(t,JT(n),JT(i),JT(o),JT(s),JT(a),JT(c),[128]))}},{key:"decodeSeiBody",value:function(e){var t=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]||t.push(e[r]);return new Uint8Array(t)}(e=Tm(e).call(e,0,e.length-1));if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=eI(fV(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=vV.byteLength&&i>=vV.byteLength&&Tm(t).call(t,r,r+vV.byteLength).toString()===vV.toString()?(r+=vV.byteLength,o=1):t.byteLength>=vV.byteLength&&i>=vV.byteLength&&Tm(t).call(t,r,r+hV.byteLength).toString()===hV.toString()&&(r+=hV.byteLength,o=0),{type:o,payload:Tm(t).call(t,r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new $S,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=eI(fV(e.payload,r),2),i=n[0];r=n[1];var o,a=eI(fV(e.payload,r),2),s=a[0];if(r=a[1],t.get(i)||!(s<=e.payload.byteLength-r))break;t.set(i,Tm(o=e.payload).call(o,r,r+s)),r+=s}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=$k(e);try{for(n.s();!(t=n.n()).done;){var i=eI(t.value,2),o=i[0],a=i[1],s=pV(o),c=pV(a.byteLength);r.push(s,c,a)}}catch(l){n.e(l)}finally{n.f()}var u=vb(r).call(r,(function(e,t){return e+t.byteLength}),0),d=new Uint8Array(u);return vb(r).call(r,(function(e,t){return d.set(t,e),e+t.byteLength}),0),d}}]),e}(),gV=new Mw("Stats",3),yV=function(){function e(t){Vl(this,e),Jd(this,"player",void 0),Jd(this,"_timer",void 0),Jd(this,"handler",void 0),Jd(this,"_monitor",void 0),Jd(this,"_destroyed",!1),this._context=t,this._monitor=VO(t.id)}return Ul(e,[{key:"setVar",value:function(e){this.handler=e}},{key:"stopReport",value:function(e){var t;this._timer&&(gV.info("stopReport","invoke"),clearTimeout(this._timer),delete this._timer,jO(this._context.id,"del_media_statistics_timer",Om(t="reason: ".concat(e,", stack: ")).call(t,(new Error).stack),0,this._stream.streamId||""))}},{key:"filterIllegal",value:function(e){var t={};return an(e).forEach((function(r){null===e[r]||void 0===e[r]||Number.isNaN(e[r])||(t[r]=e[r])})),t}},{key:"destroy",value:function(){gV.info("destroy","invoke"),jO(this._context.id,"media_statistics_destroy","".concat((new Error).stack),0,"".concat(this._stream.streamId)),this.stopReport("destroy"),this._destroyed=!0}}]),e}(),SV=function(e){DI(i,e);var t,r,n=QI(i);function i(e,t){var r;return Vl(this,i),(r=n.call(this,e))._stream=t,r}return Ul(i,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t){var r,n,i,o=this;if(!this._timer){gV.info("setLocalStreamStatsEvtInterval","invoke"),this.setVar(t),this._destroyed=!1;var a={audio:{},video:{}},s=this._stream,c=null===(r=s.audioTrack)||void 0===r?void 0:r.getTrack("preprocessing"),u=null===(n=s.videoTrack)||void 0===n?void 0:n.getTrack("preprocessing");this.getAudioStats(c,a,null===(i=s.audioTrack)||void 0===i?void 0:i.getAudioLevel()),this.getVideoStats(u,a);var d=function(){var e=Rm(km().mark((function e(){var t,r,n,i,c,u,d;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=s.audioTrack)||void 0===t?void 0:t.getTrack("preprocessing"),c=null===(r=s.videoTrack)||void 0===r?void 0:r.getTrack("preprocessing"),e.next=4,o.getAudioStats(i,a,null===(n=s.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return u=e.sent,e.next=7,o.getVideoStats(c,a);case 7:return d=e.sent,e.abrupt("return",{audioStats:u,videoStats:d,isScreen:s.isScreen});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),l=function(){var t=Rm(km().mark((function t(){var r;return km().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,d();case 2:r=t.sent,e(r),o._destroyed||(o._timer=setTimeout(l,2e3));case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();this._timer=setTimeout(l,2e3)}}},{key:"getAudioStats",value:(r=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,v,_,p,f,m,g;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s={},c={timestamp:Date.now()},u=this._stream,d=u.streamId,l=u.audioMid,h=u.isScreen,v=u.pubAttributes,_=u.pubAudio,p=u.audioTrack,f={media_type:"audio",is_screen:!!h,direction:"up",stream_id:d,vid:l,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:v.localaudio?"capture_state_on":"capture_state_off",mute_state:_?"mute_state_off":"mute_state_on"},p&&(f.playback_volume=p.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",s);case 7:return e.next=9,this.handler.getStats(t);case 9:if((m=e.sent).length){e.next=12;break}return e.abrupt("return",s);case 12:if(m.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,i=e.bytesSent,o=e.clockRate,a=e.roundTripTime,u=e.channels,d=e.audioLevel;e.googRtt;var l=e.mimeType,h=e.availableIncomingBitrate,v=e.availableOutgoingBitrate,_=e.bytesReceived,p=e.nominated,m=e.id,g=e.currentRoundTripTime,y=e.state,S=e.writable,b=e.requestsReceived,E=e.responsesReceived,T=e.requestsSent,k=e.consentRequestsSent,I=e.responsesSent,R=e.jitter,A=e.candidateType,w=e.ip,C=e.address,x=e.networkType,O=e.port,N=e.protocol,D=e.nackCount,P=e.retransmittedBytesSent,M=e.retransmittedPacketsSent,L=e.audioInputLevel,U=e.ssrc,V=e.totalAudioEnergy,F=e.totalSamplesDuration,B=e.mediaType,j=e.fractionLost;"outbound-rtp"===t?(c.packetsSent=r,c.bytesSent=i,f.bytes=i,f.packetsSent=r,f.nackCount=D,f.ssrc=U,f.retransmitted_bytes_sent=P,f.retransmitted_packets_sent=M,c.retransmittedBytesSent=P,c.retransmittedPacketsSent=M):"remote-inbound-rtp"===t?(c.packetsLost=n,f.packetsLost=n,f.net_jitter=1e3*R,s.rtt=1e3*a,f.rtt=s.rtt,s._fractionLost=j||0):"codec"===t?(s.recordSampleRate=o,s.numChannels=u,f.codecName=l):"media-source"===t&&void 0!==d?(f.audio_level=d?-10*$A(Math.pow(d,2)):d,f.volume=255*d,f.total_audio_energy=V,f.totalInputDuration=F):"ssrc"===t&&"audio"===B?f.send_level=L:"candidate-pair"===t?(f.ice_available_incoming_bitrate=h,f.ice_available_outgoing_bitrate=v,f.ice_bytes_received=_,f.ice_bytes_sent=i,f.ice_nominated=Number(p),f.ice_pair_id=m,f.ice_pair_rtt=g,f.ice_pair_state=y,f.ice_pair_writable=S,f.recv_ping_requests=b,f.recv_ping_responses=E,f.sent_ping_requests_before_first_response=T,f.sent_ping_requests_total=T+(k||0),f.sent_ping_responses=I):"local-candidate"===t?(f.local_candidate_type=A,f.local_ip=w||C,f.local_network_type=x,f.local_port=O,f.protocol=N):"remote-candidate"===t&&(f.remote_candidate_type=A,f.remote_ip=w||C,f.remote_port=O);var G=cD("STATS_SCALLBACK_SUPPORT");zM&&G||"media-source"===t&&(f.send_level=d)})),void 0===f.volume&&void 0!==n&&(f.volume=n,f.audio_level=n?-10*$A(Math.pow(n/255,2)):n),(g=r.audio).timestamp){e.next=18;break}return r.audio=c,e.abrupt("return",this.filterIllegal(s));case 18:return void 0!==c.packetsLost&&(s.audioLossRate=(c.packetsLost-g.packetsLost)/(c.packetsSent-g.packetsSent),s.audioLossRate=Number.isNaN(s.audioLossRate)?0:s.audioLossRate,f.fraction_lost=s.audioLossRate),s.statsInterval=c.timestamp-g.timestamp,f.stats_interval=s.statsInterval,s.sendKBitrate=(c.bytesSent-g.bytesSent||0)/s.statsInterval*8,f.mediaBitratebps=Math.round(1e3*s.sendKBitrate),f.bandwidth=Math.round(f.mediaBitratebps/1024),void 0!==c.retransmittedBytesSent&&(f.retransmitBitratebps=(c.retransmittedBytesSent-g.retransmittedBytesSent||0)/s.statsInterval),r.audio=c,f.vendor_mode=(null===(i=this._stream)||void 0===i?void 0:i.vendorCode)||0,f.pc_session_id=null===(o=this.handler)||void 0===o?void 0:o.peerConnectionId,null===(a=this._monitor)||void 0===a||a.report("rtc_media_statistics",f),s._retransmittedRate=(c.retransmittedPacketsSent-g.retransmittedPacketsSent)/(c.packetsSent-g.packetsSent),void 0===s.audioLossRate&&(s.audioLossRate=s._retransmittedRate,f.fraction_lost=s.audioLossRate),s._fractionLost=Math.max(s._fractionLost,s.audioLossRate),e.abrupt("return",this.filterIllegal(s));case 33:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},i={timestamp:Date.now(),simulcast:{}},o=this._stream,a=o.streamId,s=o.videoMid,c=o.isScreen,u=o.pubAttributes,d=o.enableSimulcast,l=o.pubVideo,e.t0=Zd,e.t1={media_type:"video",is_screen:!!c,direction:"up",stream_id:a,vid:s,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:u.localvideo?"capture_state_on":"capture_state_off",mute_state:l?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,h=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",n);case 11:return h.cap_frame_width=t.getSettings().width,h.cap_frame_height=t.getSettings().height,h.frameRateSent=t.getSettings().frameRate,n.isScreen=c,e.next=17,this.handler.getStats(t);case 17:if((v=e.sent).length){e.next=20;break}return e.abrupt("return",n);case 20:if(_=0,v.forEach((function(e){var t=e.type,o=e.framesEncoded,a=e.packetsLost,s=e.bytesSent,c=e.framesSent,u=e.retransmittedBytesSent,l=e.totalPacketSendDelay,v=e.totalEncodeTime,p=e.firCount,f=e.targetBitrate,m=e.roundTripTime,g=e.mimeType,y=e.frameWidth,S=e.frameHeight,b=e.packetsSent,E=e.googActualEncBitrate,T=e.googAvailableReceiveBandwidth,k=e.googAvailableSendBandwidth,I=e.googAvgEncodeMs,R=e.googBucketDelay,A=e.googEncodeUsagePercent,w=e.googFrameRateInput,C=e.availableIncomingBitrate,x=e.availableOutgoingBitrate,O=e.bytesReceived,N=e.nominated,D=e.id,P=e.currentRoundTripTime,M=e.state,L=e.writable,U=e.candidateType,V=e.ip,F=e.address,B=e.networkType,j=e.port,G=e.nackCount,H=e.pliCount,z=e.protocol,K=e.qpSum,X=e.requestsReceived,W=e.responsesReceived,q=e.googRetransmitBitrate,Y=e.requestsSent,J=e.consentRequestsSent,Q=e.responsesSent,Z=e.ssrc,$=e.googTargetEncBitrate,ee=e.googTransmitBitrate,te=e.retransmittedPacketsSent,re=e.encoderImplementation,ne=e.jitter,ie=e.rid,oe=e.fractionLost,ae=e.googAdaptationChanges,se=e.qualityLimitationReason,ce=e.qualityLimitationDurations,ue=e.googFirsReceived,de=e.googFrameRateSent,le=e.keyFramesEncoded,he=e.scalabilityMode,ve=e.framesPerSecond,_e=e.frames;"outbound-rtp"===t?(d&&(ie?i.simulcast[ie]=e:i.simulcast[_]=e,_++),i.framesEncoded=o||i.framesEncoded||0,h.key_frames_encoded=le||0,i.bytesSent=s||i.bytesSent||0,i.framesSent=c||i.framesSent,h.bytes=s||h.bytes||0,i.packetsSent=b||i.packetsSent||0,h.packetsSent=b||h.packetsSent||0,h.nackCount=G||h.nackCount||0,h.pli_count=H||h.pli_count||0,h.qp_sum=K||h.qp_sum||0,h.ssrc=Z||h.ssrc||0,h.retransmitted_packets_sent=te,i.retransmittedPacketsSent=te,i.retransmittedBytesSent=u,h.encoder_implementation=re,h.qualityLimitationReason=se,h.qualityLimitationDurations=ce,h.scalabilityMode=he,void 0!==y&&((!n.encodedFrameWidth||y>n.encodedFrameWidth)&&(n.encodedFrameWidth=y),(!n.encodedFrameHeight||S>n.encodedFrameHeight)&&(n.encodedFrameHeight=S),h.frame_size_height=S,h.frame_size_width=y)):"track"===t?(n.encodedFrameWidth=y,n.encodedFrameHeight=S,h.frame_size_height=S,h.frame_size_width=y):"remote-inbound-rtp"===t?(i.packetsLost=a,n.rtt=1e3*m,h.rtt=n.rtt,h.jitter=1e3*ne,h.packetsLost=a,n._fractionLost=oe||0):"codec"===t?(n.codecType=g,h.codecName=g):"candidate-pair"===t?(h.ice_available_incoming_bitrate=C,h.ice_available_outgoing_bitrate=x,h.ice_bytes_received=O,h.ice_bytes_sent=s,h.ice_nominated=Number(N),h.ice_pair_id=D,h.ice_pair_rtt=P,h.ice_pair_state=M,h.ice_pair_writable=L,h.recv_ping_requests=X,h.recv_ping_responses=W,h.sent_ping_requests_before_first_response=Y,h.sent_ping_requests_total=Y+J,h.sent_ping_responses=Q):"local-candidate"===t?(h.local_candidate_type=U,h.local_ip=V||F,h.local_network_type=B,h.local_port=j,h.protocol=z):"remote-candidate"===t?(h.remote_candidate_type=U,h.remote_ip=V||F,h.remote_port=j):"VideoBwe"===t?(h.encBitratebps=E,h.available_receive_bandwidth=T,h.available_send_bandwidth=k,h.bucket_delay=R,h.retransmitBitratebps=q,h.targetEncBitratebps=$,h.transmit_bitrate=ee,n._sendBandWidth=Number(k)):"ssrc"===t&&(h.avg_encode_ms=I,h.encodeUsage=A,h.frame_rate_input=w,h.orignal_input_Framerate=Number(w),h.ddaptationChanges=ae,h.firsReceived=ue,h.frameRateSent=de);var pe=cD("STATS_SCALLBACK_SUPPORT");if(!zM||!pe){var fe=r.video,me=i.timestamp-fe.timestamp;if("outbound-rtp"===t){var ge=s-fe.bytesSent,ye=u-fe.retransmittedBytesSent;h.encBitratebps=Math.round(8e3*(ge-ye)/me),h.bucket_delay=l/b,h.retransmitBitratebps=Math.round(8e3*ye/me),h.targetEncBitratebps=f,h.transmit_bitrate=Math.round(1e3*(s-fe.bytesSent)*8/me),h.avg_encode_ms=1e3*v/o,h.firsReceived=p+H}else"candidate-pair"===t?(h.available_send_bandwidth=x,n._sendBandWidth=x):"media-source"===t&&(h.frame_rate_input=ve,h.orignal_input_Framerate=Number(ve),h.frame_input=_e)}})),(p=r.video).timestamp){e.next=26;break}return r.video=i,e.abrupt("return",this.filterIllegal(n));case 26:return n.statsInterval=i.timestamp-p.timestamp,h.stats_interval=n.statsInterval,f=an(i.simulcast),d?(h.sim_enc_width=[],h.sim_enc_height=[],h.sim_enc_bps=[],h.sim_enc_framerate=[],h.sim_enc_key_frames=[],h.sim_rids=[],h.sim_enc_bandwidth=[],h.sim_sent_framerate=[],h.sim_fraction_lost=[],h.sim_keyencoded=[],h.active_sim_streams=(null===(m=this._context)||void 0===m?void 0:m.activeSimStreams)||[],h.sim_retransmittedRate=[],b=!1,GR(f).call(f,(function(e,t){return Number(e)-Number(t)})).forEach((function(e){var t=i.simulcast[e],r=t.frameWidth,o=t.frameHeight,a=t.bytesSent,s=t.framesEncoded,c=t.framesSent,u=t.packetsLost,d=t.packetsSent,l=t.qualityLimitationReason,v=t.qualityLimitationDurations,_=t.qualityLimitationResolutionChanges,f=t.retransmittedPacketsSent,m=t.pliCount,g=t.keyFramesEncoded;void 0!==l&&(h.sim_qualityLimitationReason||(h.sim_qualityLimitationReason=[],h.sim_qualityLimitationDurations=[],h.sim_qualityLimitationResolutionChanges=[]),h.sim_qualityLimitationReason.push(l),h.sim_qualityLimitationDurations.push(v),h.sim_qualityLimitationResolutionChanges.push(_));var y=p.simulcast[e];if(h.sim_enc_width.push(r||0),h.sim_enc_height.push(o||0),h.sim_enc_key_frames.push(g||0),y){var S=(a-y.bytesSent||0)/n.statsInterval;h.sim_enc_bps.push(Math.round(8e3*S)),h.sim_enc_bandwidth.push(Math.round(8e3*S/1024));var E=1e3*(s-y.framesEncoded)/n.statsInterval;h.sim_enc_framerate.push(Math.round(E)),h.sim_rids.push(e);var T=void 0!==c?c-y.framesSent:s-y.framesEncoded,k=1e3*T/n.statsInterval;h.sim_sent_framerate.push(Math.round(k));var I=(u-y.packetsLost)/(d-y.packetsSent);n._retransmittedRate=(f-y.retransmittedPacketsSent)/(d-y.packetsSent),I=Number.isNaN(I)?0:I,h.sim_fraction_lost.push(I),h.sim_keyencoded.push(m-y.pliCount>0),h.sim_retransmittedRate.push(n._retransmittedRate),r>0&&!b&&(n.sentKBitrate=8*S,n.encoderOutputFrameRate=E,n.encodedFrameCount=T,n.sentFrameRate=k,n.videoLossRate=I,b=!0)}})),h.vendor_mode=(null===(g=this._stream)||void 0===g?void 0:g.vendorCode)||0,h.pc_session_id=null===(y=this.handler)||void 0===y?void 0:y.peerConnectionId,null===(S=this._monitor)||void 0===S||S.report("rtc_media_statistics",h)):(n.encodedFrameCount=void 0!==i.framesSent?i.framesSent-p.framesSent:i.framesEncoded-p.framesEncoded,n.sentKBitrate=(i.bytesSent-p.bytesSent||0)/n.statsInterval*8,h.bitrate=Math.round(1e3*n.sentKBitrate),h.bandwidth=Math.round(h.bitrate/1024),n.encoderOutputFrameRate=1e3*(i.framesEncoded-p.framesEncoded)/n.statsInterval,h.frame_rate_encoded=Math.round(n.encoderOutputFrameRate),n.sentFrameRate=1e3*n.encodedFrameCount/n.statsInterval,h.frame_rate_sent=Math.round(n.sentFrameRate),n.videoLossRate=(i.packetsLost-p.packetsLost)/(i.packetsSent-p.packetsSent),n.videoLossRate=Number.isNaN(n.videoLossRate)?0:n.videoLossRate,h.fraction_lost=n.videoLossRate,n._retransmittedRate=(i.retransmittedPacketsSent-p.retransmittedPacketsSent)/(i.packetsSent-p.packetsSent),h.vendor_mode=(null===(E=this._stream)||void 0===E?void 0:E.vendorCode)||0,h.pc_session_id=null===(T=this.handler)||void 0===T?void 0:T.peerConnectionId,null===(k=this._monitor)||void 0===k||k.report("rtc_media_statistics",h)),r.video=i,n._fractionLost=Math.max(n._fractionLost,n.videoLossRate),e.abrupt("return",this.filterIllegal(n));case 33:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}(yV),bV=function(e){DI(o,e);var t,r,n,i=QI(o);function o(e,t){var r;return Vl(this,o),Jd(tI(r=i.call(this,e)),"isPaused",void 0),Jd(tI(r),"pauseStart",void 0),Jd(tI(r),"pauseDuration",void 0),Jd(tI(r),"_audioStallCount",void 0),Jd(tI(r),"_setAudioStallCount",void 0),Jd(tI(r),"_audioStallTimer",void 0),Jd(tI(r),"_audioStallInterval",void 0),Jd(tI(r),"_audioStallRatio",void 0),Jd(tI(r),"_videoInWaiting",void 0),r._stream=t,r._videoInWaiting=!1,r.pauseDuration=0,r}return Ul(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=Rm(km().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,v,_,p,f,m,g,y=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._timer){e.next=2;break}return e.abrupt("return");case 2:return gV.info("setRemoteStreamStatsEvtInterval","invoke"),this.setVar(r),this._audioStallInterval=o.audioStallInterval||100,this._audioStallRatio=o.audioStallRatio||.6,s={audio:{},video:{}},this._destroyed=!1,c=this._stream,u=null===(n=c.audioTrack)||void 0===n?void 0:n.getOrgTrack(),d=null===(i=c.videoTrack)||void 0===i?void 0:i.getTrack(),this.getRemoteVideoStats(d,s),e.next=14,this.getRemoteAudioStats(u,s,null===(a=this._stream.audioTrack)||void 0===a?void 0:a.getAudioLevel());case 14:this._stopAudioStallTimer(),l=0,h=0,_=[],p=0,f=WO(),this._setAudioStallCount=function(){if(aD.AUDIO_STALL&&y._audioStallInterval>0&&void 0!==s.audio.concealedSamples){var e=s.audio.concealedSamples,t=s.audio.totalSamplesReceived;f=WO();var r={isStall:!1,counted:!1,diff:0},n=.5*y._audioStallInterval;y._audioStallCount=Rm(km().mark((function i(){var o,a,s,u,d,v,m,g,S,b,E,T,k,I,R,A,w,C,x,O;return km().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=c.hasAudio,s=c.subAudio,u=c.virtual,d=c.virtualOccupy,!c.removeTrack){i.next=4;break}return clearTimeout(y._audioStallTimer),i.abrupt("return");case 4:if(a&&s){i.next=10;break}return r.isStall=!1,r.counted=!1,_.push({reason:Om(v="hasAudio: ".concat(a,", subAudio: ")).call(v,s)}),f=WO(),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:_,stats_count:p});case 10:if(!u||d){i.next=16;break}return r.isStall=!1,r.counted=!1,_.push({reason:Om(m="virtual: ".concat(u,", virtualOccupy: ")).call(m,d)}),f=WO(),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:_,stats_count:p});case 16:return g=null===(o=c.audioTrack)||void 0===o?void 0:o.getOrgTrack(),S=Date.now(),i.next=20,y.handler.getStats(g,!0);case 20:if(b=i.sent,E=Date.now(),T=WO(),!((k=T-f)<n)){i.next=27;break}return _.push({diff:k,start:f,end:T,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,reason:Om(I="diff(".concat(k,") < minInterval(")).call(I,n,")")}),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:_,stats_count:p});case 27:if(R=b.length,A=yE(b).call(b,(function(e){return"inbound-rtp"===e.type}))){i.next=32;break}return _.push({diff:k,start:f,end:T,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,reason:R?"no inbound-rtp":"no report"}),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:_,stats_count:p});case 32:return w=A.concealedSamples,C=A.totalSamplesReceived,O=C-t,(x=w-e)>=0&&O>=0&&x>=y._audioStallRatio*O?(_.push({concealed:x,received:O,diff:k,start:f,end:T,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,is_stall:!0}),r.isStall?(r.counted?h+=k:(h=h+r.diff+k,l++),r.counted=!0):k>=200?(h+=k,l++,r.counted=!0):(r.counted=!1,r.diff=k),r.isStall=!0):(_.push({concealed:x,received:O,diff:k,start:f,end:T,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E}),r.isStall=!1,r.counted=!1),e=w,t=C,f=T,p++,i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:_,stats_count:p});case 41:case"end":return i.stop()}}),i)}))),v=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!y._audioStallCount&&y._setAudioStallCount&&y._setAudioStallCount(),!y._audioStallCount){e.next=6;break}return e.next=4,y._audioStallCount();case 4:y._audioStallTimer&&clearTimeout(y._audioStallTimer),y._audioStallTimer=setTimeout(v,y._audioStallInterval);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),y._audioStallTimer&&clearTimeout(y._audioStallTimer),y._audioStallTimer=setTimeout(v,y._audioStallInterval)}},this._setAudioStallCount(),m=function(){var e=Rm(km().mark((function e(){var t,r,n,i,o,a,u;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=c.audioTrack)||void 0===t?void 0:t.getOrgTrack(),o=null===(r=c.videoTrack)||void 0===r?void 0:r.getTrack(),e.next=4,y.getRemoteAudioStats(i,s,null===(n=y._stream.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return a=e.sent,l=0,h=0,_=[],p=0,e.next=11,y.getRemoteVideoStats(o,s);case 11:return u=e.sent,e.abrupt("return",{audioStats:a,videoStats:u,isScreen:c.isScreen,userId:c.userId,streamId:c.streamId});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),g=function(){var e=Rm(km().mark((function e(){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,m();case 2:r=e.sent,t(r),v&&(f=WO(),y._audioStallTimer&&clearTimeout(y._audioStallTimer),y._audioStallTimer=setTimeout(v,y._audioStallInterval)),y._timer&&clearTimeout(y._timer),y._destroyed||(y._timer=setTimeout(g,2e3));case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),this._timer&&clearTimeout(this._timer),this._timer=setTimeout(g,2e3);case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_stopAudioStallTimer",value:function(){clearTimeout(this._audioStallTimer),this._audioStallCount=void 0,this._setAudioStallCount=void 0,this.pauseDuration=0}},{key:"unsubscribe",value:function(){gV.info("unsubscribe","invoke"),OI(CI(o.prototype),"stopReport",this).call(this,"unsubscribe"),this._stopAudioStallTimer(),this._videoInWaiting=!1}},{key:"getRemoteAudioStats",value:(r=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k,I,R,A,w,C,x=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(d={},l={},h=this._stream,v=h.streamId,_=h.userId,p=h.isScreen,f=h.audioMid,m=h.subMediaType,g=h._attributes,y=h.virtual,S=h.audioTrack,b={media_type:"audio",is_screen:!!p,direction:"down",stream_id:v,stream_user_id:_,vid:f,audio_mux:y,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:dN(m)?"mute_state_off":"mute_state_on",remote_user_capture_state:g.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:g.localaudio&&g.audiostream?"mute_state_off":"mute_state_on"},S&&(b.playback_volume=S.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",d);case 7:return e.next=9,this.handler.getStats(t);case 9:if((E=e.sent).length){e.next=12;break}return e.abrupt("return",d);case 12:if(E.forEach((function(e){var t=e.type,r=e.packetsLost,i=e.packetsReceived,o=e.bytesReceived,a=e.jitterBufferDelay,s=e.jitterBufferEmittedCount,c=e.clockRate,u=e.channels,h=e.totalSamplesReceived,_=e.concealedSamples,p=e.silentConcealedSamples,f=e.concealmentEvents,m=e.totalRoundTripTime,g=e.packetsDiscarded,y=e.state,S=e.currentRoundTripTime,E=e.audioLevel,T=e.totalAudioEnergy,k=e.totalSamplesDuration,I=e.mimeType,R=e.googDecodingNormal,A=e.googDecodingMuted,w=e.availableIncomingBitrate,C=e.availableOutgoingBitrate,O=e.bytesSent,N=e.nominated,D=e.id,P=e.writable,M=e.jitter,L=e.candidateType,U=e.ip,V=e.address,F=e.networkType,B=e.port,j=e.protocol,G=e.audioOutputLevel,H=e.requestsReceived,z=e.responsesReceived,K=e.requestsSent,X=e.consentRequestsSent,W=e.responsesSent,q=e.ssrc;e.kind;var Y=e.nackCount,J=e.lastPacketReceivedTimestamp,Q=e.concealmentevents,Z=e.fecPacketsReceived;if("inbound-rtp"===t)l.packetsLost=r,l.packetsReceived=i,b.packetsLost=r,b.packetsReceived=i,b.packetsDiscarded=g,b.nackCount=Y,b.lastPacketReceivedTimestamp=J,b.concealmentevents=Q,l.bytesReceived=o,void 0!==a&&(d.jitterBufferDelay=a/s*1e3,b.average_jitter_buffer_delay_ms=d.jitterBufferDelay),void 0!==h&&(l.totalSamplesReceived=h,d.concealedSamples=_,l.concealedSamples=_,l.silentConcealedSamples=p,b.concealedSamples=_,d.concealmentEvents=f,b.totalSamplesReceived=h),void 0!==Z&&(b.fec_packets_received=Z,l.fecPacketsReceived=Z),b.jitter=1e3*M,b.ssrc=q,void 0!==E&&0!==E?(b.audio_level=E?-10*$A(Math.pow(E,2)):E,b.volume=255*E):(b.volume=null!=n?n:255*E,b.audio_level=n?-10*$A(Math.pow(n/255,2)):n),void 0!==T&&(b.total_audio_energy=T),void 0!==k&&(b.totalAudioDuration=k);else if("codec"===t)d.recordSampleRate=c,u&&(d.numChannels=u),b.codecName=I;else if("candidate-pair"===t){var $,ee,te;b.ice_available_incoming_bitrate=w,b.ice_available_outgoing_bitrate=C,b.ice_bytes_received=o,b.ice_bytes_sent=O,b.ice_nominated=Number(N),b.ice_pair_id=D,b.ice_pair_rtt=S,b.rtt=1e3*S,b.rtt&&null!==($=x._context)&&void 0!==$&&null!==(ee=$.streamRTT)&&void 0!==ee&&null!==(te=ee[v])&&void 0!==te&&te.audio&&(b.total_rtt_ms=Math.round(b.rtt+x._context.streamRTT[v].audio)),b.ice_pair_state=y,b.ice_pair_writable=P,b.recv_ping_requests=H,b.recv_ping_responses=z,b.sent_ping_requests_before_first_response=K,b.sent_ping_requests_total=K+(X||0),b.sent_ping_responses=W,"succeeded"===y&&(d.rtt=1e3*S,d.total_rtt=1e3*m)}else"track"===t&&void 0!==E?(0===E&&0!==n?(b.volume=n,b.audio_level=n?-10*$A(Math.pow(n/255,2)):n):(b.audio_level=E?-10*$A(Math.pow(E,2)):E,b.volume=255*E),b.total_audio_energy=T,b.totalAudioDuration=k):"ssrc"===t?(b.decodingNormal=R,b.recvAudioLevel=G,b.decodingMuted=A):"local-candidate"===t?(b.local_candidate_type=L,b.local_ip=U||V,b.local_network_type=F,b.local_port=B,b.protocol=j):"remote-candidate"===t&&(b.remote_candidate_type=L,b.remote_ip=U||V,b.remote_port=B)})),(T=r.audio).timestamp){e.next=18;break}return l.timestamp=Date.now(),r.audio=l,e.abrupt("return",this.filterIllegal(d));case 18:if(k={},void 0!==l.concealedSamples&&(b.interval_concealed_samples=l.concealedSamples-T.concealedSamples,b.interval_samples_received=l.totalSamplesReceived-T.totalSamplesReceived,b.interval_silent_concealed_samples=l.silentConcealedSamples-T.silentConcealedSamples),!(this._audioStallInterval>0&&void 0!==T.concealedSamples)){e.next=36;break}if(!this._audioStallCount&&this._setAudioStallCount&&this._setAudioStallCount(),clearTimeout(this._audioStallTimer),!this._audioStallCount){e.next=36;break}return e.next=26,this._audioStallCount();case 26:I=e.sent,R=I.stall_count,A=I.stall_duration,w=I.stall_list,C=I.stats_count,k.stall_list=w,k.stats_count=C,b.concealedSamples===b.interval_concealed_samples&&b.totalSamplesReceived===b.interval_samples_received?(b.stall_count=0,b.stall_duration=0):(b.stall_count=R,b.stall_duration=A),d.stallCount=b.stall_count,d.stallDuration=b.stall_duration;case 36:return l.timestamp=Date.now(),d.audioLossRate=(l.packetsLost-T.packetsLost)/(l.packetsReceived-T.packetsReceived+(l.packetsLost-T.packetsLost)),d.audioLossRate=Number.isNaN(d.audioLossRate)?0:d.audioLossRate,b.fraction_lost=d.audioLossRate,d.statsInterval=l.timestamp-T.timestamp,b.stats_interval=d.statsInterval,d.receivedKBitrate=(l.bytesReceived-T.bytesReceived||0)/d.statsInterval*8,b.bandwidth=Math.round(1e3*d.receivedKBitrate/1024),void 0!==l.concealedSamples&&(d.receivedSampleRate=1e3*b.interval_samples_received/d.statsInterval),void 0!==l.fecPacketsReceived&&(b.fecBitratebps=(l.fecPacketsReceived-T.fecPacketsReceived||0)/d.statsInterval),b.average_jitter_buffer_delay_ms&&b.total_rtt_ms&&(d.e2eDelay=b.average_jitter_buffer_delay_ms+b.total_rtt_ms),null!==(i=this._context)&&void 0!==i&&null!==(o=i.streamRTT)&&void 0!==o&&null!==(a=o[v])&&void 0!==a&&a.audio&&(d.totalRtt=(b.rtt?b.rtt:0)+this._context.streamRTT[v].audio),r.audio=l,b.vendor_mode=(null===(s=this._stream)||void 0===s?void 0:s.vendorCode)||0,b.pc_session_id=null===(c=this.handler)||void 0===c?void 0:c.peerConnectionId,null===(u=this._monitor)||void 0===u||u.report("rtc_media_statistics",b,k),e.abrupt("return",this.filterIllegal(d));case 53:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u={},d={timestamp:Date.now()},l=this._stream,h=l.streamId,v=l.userId,_=l.isScreen,p=l.subMediaType,f=l._attributes,e.t0=Zd,e.t1={media_type:"video",is_screen:!!_,direction:"down",stream_id:h,stream_user_id:v,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:lN(p)?"mute_state_off":"mute_state_on",remote_user_capture_state:f.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:f.localvideo&&f.videostream?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,m=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",u);case 11:return u.isScreen=_,e.next=14,this.handler.getStats(t);case 14:if((g=e.sent).length){e.next=17;break}return e.abrupt("return",u);case 17:if(g.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,i=e.packetsLost,o=e.packetsReceived,a=e.bytesReceived,s=e.framesDecoded,c=e.jitterBufferDelay,l=e.jitterBufferEmittedCount,v=e.mimeType,_=e.firCount,p=e.availableIncomingBitrate,f=e.availableOutgoingBitrate,g=e.bytesSent,y=e.nominated,S=e.id,E=e.currentRoundTripTime,T=e.state,k=e.writable,I=e.candidateType,R=e.ip,A=e.address,w=e.networkType,C=e.port,x=e.nackCount,O=e.pliCount,N=e.protocol,D=e.requestsReceived,P=e.responsesReceived,M=e.requestsSent,L=e.consentRequestsSent,U=e.responsesSent,V=e.ssrc,F=e.jitter,B=e.framesReceived,j=e.keyFramesDecoded,G=e.totalDecodeTime,H=e.decoderImplementation,z=e.lastPacketReceivedTimestamp,K=e.framesDropped;if("inbound-rtp"===t)d.packetsLost=i,m.packetsLost=i,d.packetsReceived=o,m.packetsReceived=o,d.bytesReceived=a,m.bytes=a,d.framesDecoded=s,d.totalDecodeTime=G,void 0!==c&&(d.jitterBufferDelay=c/l*1e3,m.average_jitter_buffer_delay_ms=d.jitterBufferDelay),m.fir_count=_,m.nackCount=x,d.nackCount=x,m.pli_count=O,m.ssrc=V,m.framesDropped=K,m.jitter=1e3*F,m.framesReceived=B,d.framesReceived=B,m.framesDecoded=s,m.key_frames_decoded=j,m.decoder_name=H,m.last_packet_received_timestamp=z,void 0!==n&&(u.width=n,m.frame_size_width=n,u.height=r,m.frame_size_height=r);else if("track"===t&&void 0!==n)u.width=n,m.frame_size_width=n,u.height=r,m.frame_size_height=r,void 0!==B&&(m.framesReceived=B,d.framesReceived=B);else if("codec"===t)m.codecName=v;else if("candidate-pair"===t){var X,W,q;m.ice_available_incoming_bitrate=p,m.ice_available_outgoing_bitrate=f,m.ice_bytes_received=a,m.ice_bytes_sent=g,m.ice_nominated=Number(y),m.ice_pair_id=S,m.ice_pair_rtt=E,m.rtt=1e3*E,m.rtt&&null!==(X=b._context)&&void 0!==X&&null!==(W=X.streamRTT)&&void 0!==W&&null!==(q=W[h])&&void 0!==q&&q.video&&(m.total_rtt_ms=Math.round(m.rtt+b._context.streamRTT[h].video)),u.rtt=m.rtt,m.ice_pair_state=T,m.ice_pair_writable=k,m.recv_ping_requests=D,m.recv_ping_responses=P,m.sent_ping_requests_before_first_response=M,m.sent_ping_requests_total=M+(L||0),m.sent_ping_responses=U}else"local-candidate"===t?(m.local_candidate_type=I,m.local_ip=R||A,m.local_network_type=w,m.local_port=C,m.protocol=N):"remote-candidate"===t&&(m.remote_candidate_type=I,m.remote_ip=R||A,m.remote_port=C)})),(y=r.video).timestamp){e.next=22;break}return r.video=d,e.abrupt("return",this.filterIllegal(u));case 22:return u.videoLossRate=(d.packetsLost-y.packetsLost)/(d.packetsReceived-y.packetsReceived+(d.packetsLost-y.packetsLost)),y.totalDecodeTime&&y.framesDecoded&&d.framesDecoded!==y.framesDecoded&&(m.decode_elapse_per_frame=Number(((d.totalDecodeTime-y.totalDecodeTime)/(d.framesDecoded-y.framesDecoded)*1e3).toFixed(2))),u._retransmittedRate=(d.nackCount-y.nackCount)/(d.packetsReceived-y.packetsReceived+(d.packetsLost-y.packetsLost)),u.videoLossRate=Number.isNaN(u.videoLossRate)?0:u.videoLossRate,m.fraction_lost=u.videoLossRate,u.statsInterval=d.timestamp-y.timestamp,m.stats_interval=u.statsInterval,u.receivedKBitrate=(d.bytesReceived-y.bytesReceived||0)/u.statsInterval*8,m.bitrate=Math.round(1e3*u.receivedKBitrate),m.bandwidth=Math.round(m.bitrate/1024),u.decoderOutputFrameRate=1e3*(d.framesDecoded-y.framesDecoded)/u.statsInterval,u.receivedFrameRate=1e3*(d.framesReceived-y.framesReceived)/u.statsInterval,m.frame_rate_decoded=Math.round(u.decoderOutputFrameRate),m.frame_rate_received=Math.round(u.receivedFrameRate),m.average_jitter_buffer_delay_ms&&m.total_rtt_ms&&(u.e2eDelay=m.average_jitter_buffer_delay_ms+m.total_rtt_ms),null!==(n=this._context)&&void 0!==n&&null!==(i=n.streamRTT)&&void 0!==i&&null!==(o=i[h])&&void 0!==o&&o.video&&(u.totalRtt=(m.rtt?m.rtt:0)+this._context.streamRTT[h].video),r.video=d,this.processStall(this._stream,m,u,_),this.isPaused?(S=d.timestamp-(this.pauseStart||0),m.pause_duration=this.pauseDuration+(S>500?S:0),this.pauseStart=d.timestamp):m.pause_duration=this.pauseDuration,m.pause_duration=Math.min(m.stall_duration||m.stuck_length||0,m.pause_duration),this.pauseDuration=0,m.vendor_mode=(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,m.pc_session_id=null===(s=this.handler)||void 0===s?void 0:s.peerConnectionId,null===(c=this._monitor)||void 0===c||c.report("rtc_media_statistics",m),e.abrupt("return",this.filterIllegal(u));case 47:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"processStall",value:function(e,t,r,n){var i=0,o=0,a=0;if(e.recordedVideoFrames&&this.player&&this.player.played){e.recordedVideoFrames.forEach((function(e){e.isStall&&(i+=e.stallCount,o+=e.stallDuration),a=e.playTime})),e.recordedVideoFrames.length||(o=2e3,i=this._videoInWaiting?0:1,this._videoInWaiting=!0);var s=e.recordedVideoFrames.pop();s&&(s.isStall?this._videoInWaiting=!0:this._videoInWaiting=!1),e.recordedVideoFrames=[]}t.stall_count=i,n?(t.stuck_length=Math.min(o,t.stats_interval),t.stall_duration=void 0):(t.stall_duration=Math.min(o,t.stats_interval),t.stuck_length=void 0),t.play_time=a,r.stallCount=i,r.stallDuration=o}},{key:"destroy",value:function(){OI(CI(o.prototype),"destroy",this).call(this),OI(CI(o.prototype),"stopReport",this).call(this,"destroy"),this._stopAudioStallTimer(),this._videoInWaiting=!1}}],[{key:"audioStallConfig",set:function(e){o.audioStallInterval=((null==e?void 0:e.audio_stall_interval)||200)/2,o.audioStallRatio=null==e?void 0:e.audio_stall_ratio}}]),o}(yV);Jd(bV,"audioStallInterval",void 0),Jd(bV,"audioStallRatio",void 0);var EV,TV,kV=new Mw("Stream",0),IV=function(e){DI(r,e);var t=QI(r);function r(e){var n;return Vl(this,r),Jd(tI(n=t.call(this)),"videoDom",void 0),Jd(tI(n),"audioMid",void 0),Jd(tI(n),"videoMid",void 0),Jd(tI(n),"videoTransceiver",void 0),Jd(tI(n),"audioTransceiver",void 0),Jd(tI(n),"vendorHandler",void 0),Jd(tI(n),"vendorCode",0),Jd(tI(n),"engineId",void 0),n.engineId=e.id,n}return Ul(r,[{key:"requestVideoFrameCallback",value:function(){var e=this;return new Yf((function(t){var r,n=null===(r=e.videoDom)||void 0===r?void 0:r.requestVideoFrameCallback;if("function"==typeof n){var i=function(e,r){var n={};an(r).forEach((function(e){var t=e.replace(/[a-z]{1}[A-Z]{1}/g,(function(e){var t;return Om(t="".concat(e[0],"_")).call(t,e[1].toLowerCase())}));n["video_".concat(t)]=r[e]})),clearInterval(o),t(n)};n.call(e.videoDom,i);var o=setTimeout((function(){var r;null===(r=e.videoDom)||void 0===r||r.cancelVideoFrameCallback(i),t({})}),500)}else t({})}))}},{key:"stopReport",value:function(e){this.statsReport.stopReport(e)}},{key:"destroy",value:function(){var e,t;delete this.audioMid,delete this.videoMid,this.statsReport.destroy(),null===(e=this.observer)||void 0===e||e.reset(),delete this.videoTransceiver,delete this.audioTransceiver,null===(t=this.vendorHandler)||void 0===t||t.destroy(),this.vendorCode=0,delete this.vendorHandler}}]),r}(UD),RV=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}(RV||{}),AV=function(e){DI(r,e);var t=QI(r);function r(e){var n;return Vl(this,r),Jd(tI(n=t.call(this,e)),"isScreen",!1),Jd(tI(n),"stream",void 0),Jd(tI(n),"streamId",void 0),Jd(tI(n),"seiList",[]),Jd(tI(n),"videoTrack",void 0),Jd(tI(n),"audioTrack",void 0),Jd(tI(n),"videoEncodeConfig",[dD]),Jd(tI(n),"subVideoDescriptions",[]),Jd(tI(n),"enableSimulcast",!1),Jd(tI(n),"observer",void 0),Jd(tI(n),"statsReport",void 0),Jd(tI(n),"prevBitrate",0),Jd(tI(n),"pubAudio",!1),Jd(tI(n),"pubVideo",!1),Jd(tI(n),"pubAttributes",void 0),Jd(tI(n),"pcSessionId",void 0),n.stream=new MediaStream,n.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1},n.statsReport=new SV(e,tI(n)),n}return Ul(r,[{key:"audioHasCapture",get:function(){return this.pubAttributes.localaudio}},{key:"audioHasPublish",get:function(){return this.pubAttributes.audiostream}},{key:"videoHasCapture",get:function(){return this.pubAttributes.localvideo}},{key:"videoHasPublish",get:function(){return this.pubAttributes.videostream}},{key:"hasPublished",get:function(){return!!this.audioMid&&!!this.videoMid}},{key:"isEmptyStream",get:function(){return!this.audioTrack&&!this.videoTrack}},{key:"initStreamId",get:function(){return this.stream.id}},{key:"startReport",value:function(e,t){this.statsReport.setLocalStreamStatsEvtInterval(e,t)}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.sender){var t=this.videoTransceiver.sender;if(GM()){var r=t.createEncodedStreams(),n=r.readable,i=r.writable,o=new TransformStream({transform:function(t,r){var n=e.seiList[0];if(n){var i,o=mV.generateSEI(n.content),a=new Uint8Array(o.byteLength+t.data.byteLength);if(0===n.repeatCount)rT(i=e.seiList).call(i,0,1);n.repeatCount--,a.set(new Uint8Array(t.data)),a.set(o,t.data.byteLength),t.data=a.buffer,r.enqueue(t)}else r.enqueue(t)}});n.pipeThrough(o).pipeTo(i)}}else kV.warn("no sender found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.sender){var e=this.audioTransceiver.sender.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else kV.warn("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){jO(this.engineId,"localstream_clean","".concat((new Error).stack),0,this.streamId||""),OI(CI(r.prototype),"destroy",this).call(this),this.prevBitrate=0,this.subVideoDescriptions=[]}},{key:"switchTrackEnableState",value:function(e,t){var r,n;"audio"===e?n=this.audioTrack:"video"===e&&(n=this.videoTrack);var i=null===(r=n)||void 0===r?void 0:r.getTrack();return!(!i||(null==i?void 0:i.enabled)===t)&&(i.enabled=t,!0)}}]),r}(IV),wV=function(e){DI(r,e);var t=QI(r);function r(e,n,i,o,a,s){var c;return Vl(this,r),Jd(tI(c=t.call(this,e)),"streamId",void 0),Jd(tI(c),"userId",void 0),Jd(tI(c),"isScreen",void 0),Jd(tI(c),"isPublic",void 0),Jd(tI(c),"hasVideo",void 0),Jd(tI(c),"hasAudio",void 0),Jd(tI(c),"_attributes",void 0),Jd(tI(c),"streamState",void 0),Jd(tI(c),"removeTrack",!1),Jd(tI(c),"observer",void 0),Jd(tI(c),"statsReport",void 0),Jd(tI(c),"subVideo",void 0),Jd(tI(c),"subAudio",void 0),Jd(tI(c),"subMediaType",void 0),Jd(tI(c),"subLayer",void 0),Jd(tI(c),"_sequenceId",void 0),Jd(tI(c),"stream",void 0),Jd(tI(c),"videoTrack",void 0),Jd(tI(c),"audioTrack",void 0),Jd(tI(c),"recordedVideoFrames",void 0),Jd(tI(c),"stillExist",void 0),Jd(tI(c),"originalMediaType",void 0),Jd(tI(c),"priority",void 0),Jd(tI(c),"originalStreamIndex",0),Jd(tI(c),"virtual",void 0),Jd(tI(c),"pcSessionId",void 0),Jd(tI(c),"_virtualOccupy",void 0),c.virtual=!1,c._virtualOccupy=!1,c.userId=n,c.isScreen=o,c.isPublic=a,c.streamId=i,c.hasAudio=s.audiostream&&s.localaudio,c.hasVideo=s.videostream&&s.localvideo,c._attributes=s,c.vendorCode=(null==s?void 0:s.vendorCode)||0,c.subVideo=!1,c.subAudio=!1,c._sequenceId=0,c.subMediaType=cV.NONE,c.subLayer={spatialLayer:0,spatialSubLayer:-1},c.streamState=0,c.statsReport=new bV(e,tI(c)),c.enableVendorMode&&(c.pcSessionId=fw()),c}return Ul(r,[{key:"vendor",get:function(){return this._attributes.vendorCode}},{key:"audioHasCapture",get:function(){return this._attributes.localaudio}},{key:"audioHasPublish",get:function(){return this._attributes.audiostream}},{key:"videoHasCapture",get:function(){return this._attributes.localvideo}},{key:"videoHasPublish",get:function(){return this._attributes.videostream}},{key:"sequenceId",get:function(){return this._sequenceId||-1},set:function(e){"number"==typeof e&&(this._sequenceId=e)}},{key:"enableVendorMode",get:function(){return"number"==typeof this.attributes.vendorCode&&0!==this.attributes.vendorCode}},{key:"hasSubscribed",get:function(){return 2===this.streamState}},{key:"attributes",get:function(){return this._attributes},set:function(e){this.hasVideo=e.localvideo&&e.videostream,this.hasAudio=e.localaudio&&e.audiostream,this._attributes=e,this.vendorCode=e.vendorCode||0}},{key:"virtualOccupy",get:function(){return this._virtualOccupy},set:function(e){var t;if(this._virtualOccupy&&!e)null===(t=this.observer)||void 0===t||t.setPushTrack(!1);else if(!this._virtualOccupy&&e){var r;null===(r=this.observer)||void 0===r||r.setPushTrack(!0)}this._virtualOccupy=e}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.receiver){var t=this.videoTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){uV.getNalunits(new dV(t.data)).forEach((function(t){if(t.sei){var r=mV.decodeSeiBody(t.body);r&&r.type!==lV.internal&&e.safeEmit("onSEIMessage",r.payload)}})),r.enqueue(t)}})).pipeTo(n)}else kV.warn("no receiver found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.receiver){var e=this.audioTransceiver.receiver.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){e.data.byteLength<=1e3?t.enqueue(e):kV.print("too large audio frame",e.data.byteLength)}})).pipeTo(r)}else kV.warn("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r,n,i,o,a;try{var s;jO(this.engineId,"Stream.ontrack",Mm({uid:this.userId,streamId:this.streamId,streams:vb(s=e.streams).call(s,(function(e,t){return e+(null==(r=t)?"undefined | null":"string"==typeof r?r:Mm({id:r.id,active:r.active}));var r}),""),transceiver:(i=e.transceiver,null==i?"undefined | null":"string"==typeof i?i:Mm({currentDirection:i.currentDirection,direction:i.direction,mid:i.mid,stopped:i.stopped,receiver:(a=i.receiver,null==a?"undefined | null":"string"==typeof a?a:Mm({track:_N(a.track)})),sender:(o=i.sender,null==o?"undefined | null":"string"==typeof o?o:Mm({track:_N(o.track)}))})),track:_N(e.track)}),0,this.streamId||"")}catch(uW){}if(this.enableVendorMode||null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&mT(n).call(n,this.streamId)){var c,u=e.track;"video"===(null==u?void 0:u.kind)?this._setVideoTrack(u):"audio"===(null===(c=e.track)||void 0===c?void 0:c.kind)&&this._setAudioTrack(u),this._setStream(e.streams[0])}this.safeEmit("ontrack",e)}},{key:"clean",value:function(){var e,t;kV.info("clean",Om(e="exec stream.clean ".concat(this.streamId," ")).call(e,this.userId)),jO(this.engineId,"remotestream_clean","".concat((new Error).stack),0,this.streamId),OI(CI(r.prototype),"destroy",this).call(this),this.subAudio=!1,this.subVideo=!1,this.sequenceId=0,this.videoTrack=void 0,null===(t=this.audioTrack)||void 0===t||t.close(),this.audioTrack=void 0,this.stream=void 0,this.recordedVideoFrames=void 0,delete this.priority}},{key:"destroy",value:function(){this.clean(),this.attributes={audiostream:!1,localaudio:!1,localvideo:!1,videostream:!1,extvideo:!1,extaudio:!1,videoDescriptions:[]}}},{key:"resetHasSubscribed",value:function(){this.streamState=0}},{key:"_setStream",value:function(e){var t=this;this.stream=e,e.onaddtrack=function(e){"video"===e.track.kind?t._setVideoTrack(e.track):"audio"===e.track.kind&&t._setAudioTrack(e.track)}}},{key:"_setAudioTrack",value:function(e){var t,r;(null===(t=this.audioTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.audioTrack=QU(e),this.emit("ontrack",this.audioTrack))}},{key:"_setVideoTrack",value:function(e){var t,r;(null===(t=this.videoTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.videoTrack=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:XO();return new OU(e,t)}(e),this.emit("ontrack",this.videoTrack))}}]),r}(IV),CV=new Mw("queue",4),xV=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(xV||{}),OV=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}(OV||{}),NV=(Jd(EV={},"publish","unpublish"),Jd(EV,"subscribe","unsubscribe"),Jd(EV,"pushtrack","removetrack"),EV),DV=(Jd(TV={},"publish",0),Jd(TV,"subscribe",0),Jd(TV,"pushtrack",0),Jd(TV,"unpublish",1),Jd(TV,"unsubscribe",1),Jd(TV,"removetrack",1),TV),PV=function(e){DI(r,e);var t=QI(r);function r(){var e;return Vl(this,r),Jd(tI(e=t.call(this)),"_queue",void 0),e._queue=[],e}return Ul(r,[{key:"queue",get:function(){return this._queue}},{key:"enqueue",value:function(e){var t,r=this._queue.length,n="";return this._queue=Gs(t=this._queue).call(t,(function(t){return t.streamId!==e.streamId||e.action!==NV[t.action]||(n=t.streamId,CV.info("offsetStreamId",n),!1)})),this._queue.length===r&&this._queue.push(e),this.emit("start"),n}},{key:"dequeue",value:function(){var e;if(!this._queue.length)return null;var t=this._queue.length;kN&&KN>=86&&KN<=92&&(t=Math.min(this._queue.length,5));for(var r=DV[this._queue[0].action],n=1;n<t;n++){var i;if(DV[this._queue[n].action]!==r)return{sdpStrategy:r,items:rT(i=this._queue).call(i,0,n)}}return{sdpStrategy:r,items:rT(e=this._queue).call(e,0,t)}}}]),r}(MD),MV="object"==typeof global&&global&&global.Object===Object&&global,LV="object"==typeof self&&self&&self.Object===Object&&self,UV=MV||LV||Function("return this")(),VV=UV.Symbol,FV=Object.prototype,BV=FV.hasOwnProperty,jV=FV.toString,GV=VV?VV.toStringTag:void 0;var HV=Object.prototype.toString;var zV=VV?VV.toStringTag:void 0;function KV(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":zV&&zV in Object(e)?function(e){var t=BV.call(e,GV),r=e[GV];try{e[GV]=void 0;var n=!0}catch(o){}var i=jV.call(e);return n&&(t?e[GV]=r:delete e[GV]),i}(e):function(e){return HV.call(e)}(e)}function XV(e){return null!=e&&"object"==typeof e}var WV=Array.isArray;function qV(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function YV(e){return e}function JV(e){if(!qV(e))return!1;var t=KV(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var QV,ZV=UV["__core-js_shared__"],$V=(QV=/[^.]+$/.exec(ZV&&ZV.keys&&ZV.keys.IE_PROTO||""))?"Symbol(src)_1."+QV:"";var eF=Function.prototype.toString;function tF(e){if(null!=e){try{return eF.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var rF=/^\[object .+?Constructor\]$/,nF=Function.prototype,iF=Object.prototype,oF=nF.toString,aF=iF.hasOwnProperty,sF=RegExp("^"+oF.call(aF).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function cF(e){return!(!qV(e)||(t=e,$V&&$V in t))&&(JV(e)?sF:rF).test(tF(e));var t}function uF(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return cF(r)?r:void 0}var dF=uF(UV,"WeakMap"),lF=Object.create,hF=function(){function e(){}return function(t){if(!qV(t))return{};if(lF)return lF(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();function vF(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var _F=Date.now;var pF,fF,mF,gF=function(){try{var e=uF(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),yF=gF,SF=yF?function(e,t){return yF(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:YV,bF=(pF=SF,fF=0,mF=0,function(){var e=_F(),t=16-(e-mF);if(mF=e,t>0){if(++fF>=800)return arguments[0]}else fF=0;return pF.apply(void 0,arguments)}),EF=bF;var TF=/^(?:0|[1-9]\d*)$/;function kF(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&TF.test(e))&&e>-1&&e%1==0&&e<t}function IF(e,t,r){"__proto__"==t&&yF?yF(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function RF(e,t){return e===t||e!=e&&t!=t}var AF=Object.prototype.hasOwnProperty;function wF(e,t,r){var n=e[t];AF.call(e,t)&&RF(n,r)&&(void 0!==r||t in e)||IF(e,t,r)}function CF(e,t,r,n){var i=!r;r||(r={});for(var o=-1,a=t.length;++o<a;){var s=t[o],c=n?n(r[s],e[s],s,r,e):void 0;void 0===c&&(c=e[s]),i?IF(r,s,c):wF(r,s,c)}return r}var xF=Math.max;function OF(e,t){return EF(function(e,t,r){return t=xF(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=xF(n.length-t,0),a=Array(o);++i<o;)a[i]=n[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=n[i];return s[t]=r(a),vF(e,this,s)}}(e,t,YV),e+"")}function NF(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function DF(e){return null!=e&&NF(e.length)&&!JV(e)}var PF=Object.prototype;function MF(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||PF)}function LF(e){return XV(e)&&"[object Arguments]"==KV(e)}var UF=Object.prototype,VF=UF.hasOwnProperty,FF=UF.propertyIsEnumerable,BF=LF(function(){return arguments}())?LF:function(e){return XV(e)&&VF.call(e,"callee")&&!FF.call(e,"callee")},jF=BF;var GF="object"==typeof exports&&exports&&!exports.nodeType&&exports,HF=GF&&"object"==typeof module&&module&&!module.nodeType&&module,zF=HF&&HF.exports===GF?UV.Buffer:void 0,KF=(zF?zF.isBuffer:void 0)||function(){return!1},XF={};function WF(e){return function(t){return e(t)}}XF["[object Float32Array]"]=XF["[object Float64Array]"]=XF["[object Int8Array]"]=XF["[object Int16Array]"]=XF["[object Int32Array]"]=XF["[object Uint8Array]"]=XF["[object Uint8ClampedArray]"]=XF["[object Uint16Array]"]=XF["[object Uint32Array]"]=!0,XF["[object Arguments]"]=XF["[object Array]"]=XF["[object ArrayBuffer]"]=XF["[object Boolean]"]=XF["[object DataView]"]=XF["[object Date]"]=XF["[object Error]"]=XF["[object Function]"]=XF["[object Map]"]=XF["[object Number]"]=XF["[object Object]"]=XF["[object RegExp]"]=XF["[object Set]"]=XF["[object String]"]=XF["[object WeakMap]"]=!1;var qF="object"==typeof exports&&exports&&!exports.nodeType&&exports,YF=qF&&"object"==typeof module&&module&&!module.nodeType&&module,JF=YF&&YF.exports===qF&&MV.process,QF=function(){try{var e=YF&&YF.require&&YF.require("util").types;return e||JF&&JF.binding&&JF.binding("util")}catch(t){}}(),ZF=QF&&QF.isTypedArray,$F=ZF?WF(ZF):function(e){return XV(e)&&NF(e.length)&&!!XF[KV(e)]},eB=Object.prototype.hasOwnProperty;function tB(e,t){var r=WV(e),n=!r&&jF(e),i=!r&&!n&&KF(e),o=!r&&!n&&!i&&$F(e),a=r||n||i||o,s=a?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],c=s.length;for(var u in e)!t&&!eB.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||kF(u,c))||s.push(u);return s}function rB(e,t){return function(r){return e(t(r))}}var nB=rB(Object.keys,Object),iB=Object.prototype.hasOwnProperty;function oB(e){return DF(e)?tB(e):function(e){if(!MF(e))return nB(e);var t=[];for(var r in Object(e))iB.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}var aB=Object.prototype.hasOwnProperty;function sB(e){if(!qV(e))return function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}(e);var t=MF(e),r=[];for(var n in e)("constructor"!=n||!t&&aB.call(e,n))&&r.push(n);return r}function cB(e){return DF(e)?tB(e,!0):sB(e)}var uB,dB=(uB=function(e,t){CF(t,cB(t),e)},OF((function(e,t){var r=-1,n=t.length,i=n>1?t[n-1]:void 0,o=n>2?t[2]:void 0;for(i=uB.length>3&&"function"==typeof i?(n--,i):void 0,o&&function(e,t,r){if(!qV(r))return!1;var n=typeof t;return!!("number"==n?DF(r)&&kF(t,r.length):"string"==n&&t in r)&&RF(r[t],e)}(t[0],t[1],o)&&(i=n<3?void 0:i,n=1),e=Object(e);++r<n;){var a=t[r];a&&uB(e,a,r,i)}return e}))),lB=uF(Object,"create");var hB=Object.prototype.hasOwnProperty;var vB=Object.prototype.hasOwnProperty;function _B(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function pB(e,t){for(var r=e.length;r--;)if(RF(e[r][0],t))return r;return-1}_B.prototype.clear=function(){this.__data__=lB?lB(null):{},this.size=0},_B.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},_B.prototype.get=function(e){var t=this.__data__;if(lB){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return hB.call(t,e)?t[e]:void 0},_B.prototype.has=function(e){var t=this.__data__;return lB?void 0!==t[e]:vB.call(t,e)},_B.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=lB&&void 0===t?"__lodash_hash_undefined__":t,this};var fB=Array.prototype.splice;function mB(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}mB.prototype.clear=function(){this.__data__=[],this.size=0},mB.prototype.delete=function(e){var t=this.__data__,r=pB(t,e);return!(r<0)&&(r==t.length-1?t.pop():fB.call(t,r,1),--this.size,!0)},mB.prototype.get=function(e){var t=this.__data__,r=pB(t,e);return r<0?void 0:t[r][1]},mB.prototype.has=function(e){return pB(this.__data__,e)>-1},mB.prototype.set=function(e,t){var r=this.__data__,n=pB(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};var gB=uF(UV,"Map");function yB(e,t){var r,n,i=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof t?"string":"hash"]:i.map}function SB(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function bB(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}SB.prototype.clear=function(){this.size=0,this.__data__={hash:new _B,map:new(gB||mB),string:new _B}},SB.prototype.delete=function(e){var t=yB(this,e).delete(e);return this.size-=t?1:0,t},SB.prototype.get=function(e){return yB(this,e).get(e)},SB.prototype.has=function(e){return yB(this,e).has(e)},SB.prototype.set=function(e,t){var r=yB(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};var EB=rB(Object.getPrototypeOf,Object);function TB(e){var t=this.__data__=new mB(e);this.size=t.size}TB.prototype.clear=function(){this.__data__=new mB,this.size=0},TB.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},TB.prototype.get=function(e){return this.__data__.get(e)},TB.prototype.has=function(e){return this.__data__.has(e)},TB.prototype.set=function(e,t){var r=this.__data__;if(r instanceof mB){var n=r.__data__;if(!gB||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new SB(n)}return r.set(e,t),this.size=r.size,this};var kB="object"==typeof exports&&exports&&!exports.nodeType&&exports,IB=kB&&"object"==typeof module&&module&&!module.nodeType&&module,RB=IB&&IB.exports===kB?UV.Buffer:void 0,AB=RB?RB.allocUnsafe:void 0;function wB(){return[]}var CB=Object.prototype.propertyIsEnumerable,xB=Object.getOwnPropertySymbols,OB=xB?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var r=-1,n=null==e?0:e.length,i=0,o=[];++r<n;){var a=e[r];t(a,r,e)&&(o[i++]=a)}return o}(xB(e),(function(t){return CB.call(e,t)})))}:wB;var NB=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)bB(t,OB(e)),e=EB(e);return t}:wB;function DB(e,t,r){var n=t(e);return WV(e)?n:bB(n,r(e))}function PB(e){return DB(e,oB,OB)}function MB(e){return DB(e,cB,NB)}var LB=uF(UV,"DataView"),UB=uF(UV,"Promise"),VB=uF(UV,"Set"),FB="[object Map]",BB="[object Promise]",jB="[object Set]",GB="[object WeakMap]",HB="[object DataView]",zB=tF(LB),KB=tF(gB),XB=tF(UB),WB=tF(VB),qB=tF(dF),YB=KV;(LB&&YB(new LB(new ArrayBuffer(1)))!=HB||gB&&YB(new gB)!=FB||UB&&YB(UB.resolve())!=BB||VB&&YB(new VB)!=jB||dF&&YB(new dF)!=GB)&&(YB=function(e){var t=KV(e),r="[object Object]"==t?e.constructor:void 0,n=r?tF(r):"";if(n)switch(n){case zB:return HB;case KB:return FB;case XB:return BB;case WB:return jB;case qB:return GB}return t});var JB=YB,QB=Object.prototype.hasOwnProperty;var ZB=UV.Uint8Array;function $B(e){var t=new e.constructor(e.byteLength);return new ZB(t).set(new ZB(e)),t}var ej=/\w*$/;var tj=VV?VV.prototype:void 0,rj=tj?tj.valueOf:void 0;function nj(e,t,r){var n,i,o,a=e.constructor;switch(t){case"[object ArrayBuffer]":return $B(e);case"[object Boolean]":case"[object Date]":return new a(+e);case"[object DataView]":return function(e,t){var r=t?$B(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(e,t){var r=t?$B(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}(e,r);case"[object Map]":case"[object Set]":return new a;case"[object Number]":case"[object String]":return new a(e);case"[object RegExp]":return(o=new(i=e).constructor(i.source,ej.exec(i))).lastIndex=i.lastIndex,o;case"[object Symbol]":return n=e,rj?Object(rj.call(n)):{}}}var ij=QF&&QF.isMap,oj=ij?WF(ij):function(e){return XV(e)&&"[object Map]"==JB(e)};var aj=QF&&QF.isSet,sj=aj?WF(aj):function(e){return XV(e)&&"[object Set]"==JB(e)},cj="[object Arguments]",uj="[object Function]",dj="[object Object]",lj={};function hj(e,t,r,n,i,o){var a,s=1&t,c=2&t,u=4&t;if(r&&(a=i?r(e,n,i,o):r(e)),void 0!==a)return a;if(!qV(e))return e;var d=WV(e);if(d){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&QB.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(e),!s)return function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}(e,a)}else{var l=JB(e),h=l==uj||"[object GeneratorFunction]"==l;if(KF(e))return function(e,t){if(t)return e.slice();var r=e.length,n=AB?AB(r):new e.constructor(r);return e.copy(n),n}(e,s);if(l==dj||l==cj||h&&!i){if(a=c||h?{}:function(e){return"function"!=typeof e.constructor||MF(e)?{}:hF(EB(e))}(e),!s)return c?function(e,t){return CF(e,NB(e),t)}(e,function(e,t){return e&&CF(t,cB(t),e)}(a,e)):function(e,t){return CF(e,OB(e),t)}(e,function(e,t){return e&&CF(t,oB(t),e)}(a,e))}else{if(!lj[l])return i?e:{};a=nj(e,l,s)}}o||(o=new TB);var v=o.get(e);if(v)return v;o.set(e,a),sj(e)?e.forEach((function(n){a.add(hj(n,t,r,n,e,o))})):oj(e)&&e.forEach((function(n,i){a.set(i,hj(n,t,r,i,e,o))}));var _=d?void 0:(u?c?MB:PB:c?cB:oB)(e);return function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););}(_||e,(function(n,i){_&&(n=e[i=n]),wF(a,i,hj(n,t,r,i,e,o))})),a}lj[cj]=lj["[object Array]"]=lj["[object ArrayBuffer]"]=lj["[object DataView]"]=lj["[object Boolean]"]=lj["[object Date]"]=lj["[object Float32Array]"]=lj["[object Float64Array]"]=lj["[object Int8Array]"]=lj["[object Int16Array]"]=lj["[object Int32Array]"]=lj["[object Map]"]=lj["[object Number]"]=lj[dj]=lj["[object RegExp]"]=lj["[object Set]"]=lj["[object String]"]=lj["[object Symbol]"]=lj["[object Uint8Array]"]=lj["[object Uint8ClampedArray]"]=lj["[object Uint16Array]"]=lj["[object Uint32Array]"]=!0,lj["[object Error]"]=lj[uj]=lj["[object WeakMap]"]=!1;function vj(e){return hj(e,5)}function _j(e,t){return function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}(t,(function(t){return e[t]}))}function pj(e){return null==e?[]:_j(e,oB(e))}var fj,mj,gj=new Mw("ChromeHandler",3),yj=GM(),Sj=function(e){DI(u,e);var t,r,n,i,o,a,s,c=QI(u);function u(e,t){var r;return Vl(this,u),Jd(tI(r=c.call(this,e,t)),"name","chrome"),Jd(tI(r),"_queueBusy",!1),Jd(tI(r),"_sdpQueue",void 0),Jd(tI(r),"_aSendonlyOfferTpl",void 0),Jd(tI(r),"_vSendonlyOfferTpl",void 0),Jd(tI(r),"_aRecvonlyOfferTpl",void 0),Jd(tI(r),"_vRecvonlyOfferTpl",void 0),Jd(tI(r),"_mid",10),Jd(tI(r),"_inactiveMlineIndex",[]),Jd(tI(r),"_mlinesCache",{}),Jd(tI(r),"setDescription",void 0),r.setDescription=t.setDescription.bind(t),r._sdpQueue=new PV,r._sdpQueue.on("start",(function(){r._queueBusy||"stable"!==r._peerConnection.signalingState||(gj.info("dequeue start"),r.dequeue())})),r}return Ul(u,[{key:"destroy",value:function(){OI(CI(u.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(s=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k,I,R,A,w,C,x,O,N,D,P,M,L,U,V,F;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d=t.stream,l=t.enableSimulcast,h=OI(CI(u.prototype),"internalPublish",this).call(this,t),v=h.videoDescriptions,_=h.subVideoDescriptions,p=h.audioTransceiverInit,f=h.videoTransceiverInit,m=vL(this._nextSsrc),this._nextSsrc=m.next,g="".concat(this._mid++),y="".concat(this._mid++),S=Zd(Zd(Zd({},this._aSendonlyOfferTpl),this.peer._offerIce),{},{mid:g,msid:Om(r="".concat(d.id," ")).call(r,d.id,"-audio"),ssrcs:_L(d.id,"audio",m.audio,lL)}),b=Zd(Zd(Zd({},this._vSendonlyOfferTpl),this.peer._offerIce),{},{mid:y,msid:Om(n="".concat(d.id," ")).call(n,d.id,"-video")}),l?(gj.info("subVideoDesc","desc: %o ",_),delete b.ssrcGroups,delete b.ssrcs,E=[],b.rids=jm(v).call(v,(function(e){var t=e.rid;return E.unshift(t),{id:t,direction:"send"}})),b.simulcast={dir1:"send",list1:E.join(";")}):(T=pL(d.id,m,{cname:lL}),k=T.ssrcs,I=T.ssrcGroups,b.ssrcs=k,b.ssrcGroups=I),null!==(i=this._context)&&void 0!==i&&null!==(o=i.serverConfig)&&void 0!==o&&o.audioRed&&Array.isArray(S.rtp)&&(-1!==(A=QR(R=S.rtp).call(R,(function(e){return"red"===e.codec})))&&(C=rT(w=S.rtp).call(w,A,1),x=eI(C,1),O=x[0],S.rtp.unshift(O)),N=[],S.rtp.forEach((function(e){return N.push(e.payload)})),S.payloads=N.join(" ")),null!==(a=this._context)&&void 0!==a&&null!==(s=a.serverConfig)&&void 0!==s&&s.videoCodec&&EL(b,null===(D=this._context)||void 0===D||null===(P=D.serverConfig)||void 0===P?void 0:P.videoCodec),!cD("IOS_SAFARI_ORIENTATION")&&(TN||PN)&&Array.isArray(b.ext)&&(b.ext=Gs(M=b.ext).call(M,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&mT(t).call(t,"video-orientation"))}))),(L=null==S?void 0:yE(c=S.rtp).call(c,(function(e){return"opus"===e.codec})))&&S.fmtp&&(F=yE(U=S.fmtp).call(U,(function(e){return e.payload===L.payload})))&&null!==(V=this._context)&&void 0!==V&&V.audioProfileManager&&(F.config=this._context.audioProfileManager.getOpusConfigStr(F.config)),l||TN||this.addBitrateLimit(b,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[S,b],e.abrupt("return",{partialSdp:mL(this.peer._offerSession,S,b),audioMid:g,videoMid:y,type:"incroffer",semantics:"unified-plan",videoDescriptions:v,subVideoDescriptions:_,audioTransceiverInit:p,videoTransceiverInit:f,peerConnectionMode:this.peerConnectionMode});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"subscribe",value:(a=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k,I,R,A,w,C,x,O,N,D,P,M,L,U,V=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(gj.info("subscribe"),a="incroffer",s="unified-plan",this._aRecvonlyOfferTpl&&this._vRecvonlyOfferTpl){e.next=9;break}return e.next=6,this._genOfferSdp();case 6:return c=e.sent,e.next=9,this.createAVMlineOfferTpl(c);case 9:if(u="",d="",l=!1,h=!1,v=void 0,_=void 0,this._mlinesCache[t.streamId]=[v,_],t.virtual?(u="".concat(this._mid++),l=!0):r.multiChatMode?(u="".concat(this._mid++),d="".concat(this._mid++),h=!0):(l=!0,h=!0,u="".concat(this._mid++),d="".concat(this._mid++)),u&&(v=Zd(Zd({},vj(this._aRecvonlyOfferTpl)),{},{mid:u})),l&&(this._mlinesCache[t.streamId][0]=v,p={track:"audio",init:{direction:"recvonly"}}),d&&(_=Zd(Zd({},vj(this._vRecvonlyOfferTpl)),{},{mid:d})),h&&(this._mlinesCache[t.streamId][1]=_,f={track:"video",init:{direction:"recvonly"}}),m=mL(this.peer._offerSession,v,_),g=void 0,t.enableVendorMode||r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._vSendonlyAnswerTpl){e.next=32;break}return g=vL(this._nextSsrc),this._nextSsrc=g.next,R=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Om(y=Om(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:_L(t.streamId,"audio",g.audio)}),A=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:d,msid:Om(E=Om(T="".concat(t.streamId)).call(T,null!==(k=this._context)&&void 0!==k&&k.avSync?"":"-video"," ")).call(E,t.streamId,"-video")},pL(t.streamId,g,{flexfec:this._enableSubFlexfec})),w=new Yf((function(e){V._sdpQueue.enqueue({action:OV.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:p,videoTransceiverInit:f,signalingAck:{sdp:QM.write(Zd(Zd({},V.peer._answerSession),{},{media:[R,A]})),sequenceId:t.sequenceId?++t.sequenceId:0},stream:t,sdp:m,onSuccess:function(){gj.info("subscribe()","sub success"),e(0)}})})),e.next=31,w;case 31:null===(I=g)||void 0===I||delete I.next;case 32:return(C=null===(n=v)||void 0===n?void 0:yE(i=n.rtp).call(i,(function(e){return"opus"===e.codec})))&&null!==(o=v)&&void 0!==o&&o.fmtp&&(N=null===(x=v)||void 0===x?void 0:yE(O=x.fmtp).call(O,(function(e){return e.payload===C.payload})))&&this._context&&(N.config+=";stereo=1;sprop-stereo=1"),t.isPublic&&KN>=86&&null!=(L=null===(D=_)||void 0===D?void 0:Gs(P=D.rtp).call(P,(function(e){return"H264"===e.codec})))&&L.length&&null!==(M=_)&&void 0!==M&&M.fmtp&&(null===(U=_)||void 0===U||U.fmtp.forEach((function(e){yE(L).call(L,(function(t){return t.payload===e.payload}))&&(e.config+=";sps-pps-idr-in-keyframe=1")}))),e.abrupt("return",{partialSdp:m,audioMid:u,videoMid:d,type:a,semantics:s,audioTransceiverInit:p,videoTransceiverInit:f,allSsrc:g,peerConnectionMode:this.peerConnectionMode});case 36:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"handleAck",value:(o=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(gj.info("handleAck()","item: %o",t),!t.generatorSsrc){e.next=4;break}return gj.warn("already set remote"),e.abrupt("return","");case 4:return e.abrupt("return",this._sdpQueue.enqueue(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"dequeue",value:(i=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,v,_,p,f=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._queueBusy=!0,t=this._sdpQueue.dequeue(),gj.info("dequeue()","ret: %o",t),t){e.next=6;break}return this._queueBusy=!1,e.abrupt("return");case 6:if(e.prev=6,r=t.items,n=t.sdpStrategy,i=[],o=[],a=[],n!==xV.ADD){e.next=15;break}return e.delegateYield(km().mark((function e(){var t,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(t=Zd({},f.peer._answerIce)).candidates,s=!1,c=!1,e.prev=4,d=qD(r);case 6:return e.next=8,d.next();case 8:if(!(s=!(l=e.sent).done)){e.next=16;break}if(n=l.value,"break"!==function(){var e=n.audioMid,r=n.videoMid,s=n.action,c=n.audioTransceiverInit,u=n.videoTransceiverInit,d=n.signalingAck,l=n.stream,h=l instanceof wV;if(n.onSuccess&&a.push(n.onSuccess),h&&(null==d?void 0:d.sequenceId)<l.sequenceId)return"break";var v,_={},p={},m=QM.parse(d.sdp);Array.isArray(m.media)&&GR(v=m.media).call(v,(function(e,t){var r;return null==e||null===(r=e.type)||void 0===r?void 0:r.localeCompare(null==t?void 0:t.type)})).forEach((function(n){"audio"===(n=Zd(Zd({},n),t)).type?(_=n).mid=e:(p=n).mid=r}));var g,y=l.streamId;if(s===OV.publish&&(y=null===(g=l.stream)||void 0===g?void 0:g.id),!f._mlinesCache[y])return"break";var S=eI(f._mlinesCache[y],2),b=S[0],E=S[1];if(c&&b){l.audioTransceiver=f._peerConnection.addTransceiver(c.track,c.init),f._reportRtcInvokeStatus("chromeHandler.addTrack",Mm({audioStreamTrack:_N(c.track)}));var T=f._inactiveMlineIndex.shift();T||(T=f.peer._offerMlines.length),f.peer._offerMlines[T]=Zd({},b),f.peer._answerMlines[T]=_,yj&&l.initAudioEncodedTransform()}if(u&&E){var k,I;l.videoTransceiver=f._peerConnection.addTransceiver(u.track,u.init),f._reportRtcInvokeStatus("chromeHandler.addTrack",Mm({videoStreamTrack:_N(u.track)}));var R,A,w=f._inactiveMlineIndex.shift();w||(w=f.peer._offerMlines.length),f.peer._offerMlines[w]=Zd({},E),s===OV.publish&&null!==(k=f._context)&&void 0!==k&&null!==(I=k.serverConfig)&&void 0!==I&&I.videoCodec&&EL(p,null===(R=f._context)||void 0===R||null===(A=R.serverConfig)||void 0===A?void 0:A.videoCodec),f.peer._answerMlines[w]=p,yj&&l.initVideoEncodedTransform()}i.push(l.streamId||""),o.push(h?l.userId:"local"),h&&(l.sequenceId=null==d?void 0:d.sequenceId),delete f._mlinesCache[y]}()){e.next=13;break}return e.abrupt("break",16);case 13:s=!1,e.next=6;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(4),c=!0,u=e.t0;case 22:if(e.prev=22,e.prev=23,!s||null==d.return){e.next=27;break}return e.next=27,d.return();case 27:if(e.prev=27,!c){e.next=30;break}throw u;case 30:return e.finish(27);case 31:return e.finish(22);case 32:case"end":return e.stop()}}),e,null,[[4,18,22,32],[23,,27,31]])}))(),"t0",13);case 13:e.next=20;break;case 15:p={},r.forEach((function(e){var t=e.audioMid,r=e.videoMid,n=e.action;p[t]=t,n!==OV.removetrack&&(p[r]=r),p[t]=t})),this.peer._offerMlines=jm(h=this.peer._offerMlines).call(h,(function(e,t){return p[e.mid]&&(e=fL(e),f._inactiveMlineIndex.push(t)),e})),GR(v=this._inactiveMlineIndex).call(v,(function(e,t){return e-t})),this.peer._answerMlines=jm(_=this.peer._answerMlines).call(_,(function(e){return p[e.mid]&&(e=fL(e)),e}));case 20:return e.next=22,this.setDescription(i.length?{streamId:i.join(","),streamUserId:o.join(",")}:void 0);case 22:try{a.forEach((function(e){return e()}))}catch(uW){}gj.info("dequeue","loop"),e.next=29;break;case 26:e.prev=26,e.t1=e.catch(6),gj.error("dequeue","unknown error: %o",e.t1);case 29:return e.prev=29,this.dequeue(),e.finish(29);case 32:case"end":return e.stop()}}),e,this,[[6,26,29,32]])}))),function(){return i.apply(this,arguments)})},{key:"getDefaultSdp",value:(n=Rm(km().mark((function e(){var t,r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._genOfferSdp();case 2:return r=e.sent,this.createAVMlineOfferTpl(r),n=QM.parse(r),i=[],n.media=Gs(t=n.media).call(t,(function(e){var t;return"recvonly"===e.direction&&(Array.isArray(e.ext)&&(e.ext=Gs(t=e.ext).call(t,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))),i.push("".concat(e.mid)),!0)})),n.groups=[{mids:i.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:QM.write(n),semantics:"unified-plan",type:"incroffer"});case 9:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"rollback",value:(r=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete this._mlinesCache[t];case 1:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;QM.parse(e).media.forEach((function(e){if("audio"===e.type)if("sendonly"===e.direction)t._aSendonlyOfferTpl=e;else{var r;if(Array.isArray(e.ext))e.ext=Gs(r=e.ext).call(r,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._aRecvonlyOfferTpl=e}else if("video"===e.type)if("sendonly"===e.direction)t._vSendonlyOfferTpl=e;else{var n;if(Array.isArray(e.ext))e.ext=Gs(n=e.ext).call(n,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._vRecvonlyOfferTpl=e}}))}},{key:"_genOfferSdp",value:(t=Rm(km().mark((function e(){var t,r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,sN(!0);case 3:if(t=e.sent){e.next=6;break}throw"pc.createOffer() return empty.";case 6:e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),r="Get offer Error. ".concat(e.t0.message|e.t0),new mA(vA.NOT_SUPPORTED,r);case 12:return e.abrupt("return",t);case 13:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(){return t.apply(this,arguments)})}]),u}(kL),bj=new Mw("FirefoxHandler",3),Ej=function(e){DI(d,e);var t,r,n,i,o,a,s,c,u=QI(d);function d(){var e,t;Vl(this,d);for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return Jd(tI(t=u.call.apply(u,Om(e=[this]).call(e,n))),"name","firefox"),Jd(tI(t),"_aRecvonlyOfferTpl",void 0),t}return Ul(d,[{key:"publish",value:(c=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,v,_,p,f,m=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=OI(CI(d.prototype),"internalPublish",this).call(this,t),o=i.videoDescriptions,a=i.subVideoDescriptions,s=i.audioTransceiverInit,c=i.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(s.track,s.init),t.videoTransceiver=this._peerConnection.addTransceiver(c.track,c.init),u=WO(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=7,this._peerConnection.createOffer();case 7:return l=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:WO()-u}),(h=QM.parse(l.sdp)).media=null===(r=h.media)||void 0===r?void 0:jm(r).call(r,(function(e){return Zd(Zd({},e),m.peer._offerIce)})),e.next=13,this.setLocalDescription(QM.write(h));case 13:return v=t.audioTransceiver.mid,_=t.videoTransceiver.mid,p=null,f=null,h.media=null===(n=h.media)||void 0===n?void 0:jm(n).call(n,(function(e){if("".concat(e.mid)===v){var t,r,n=null===(t=p=e)||void 0===t?void 0:yE(r=t.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&p.fmtp){var i,o,a=yE(i=p.fmtp).call(i,(function(e){return e.payload===n.payload}));a&&null!==(o=m._context)&&void 0!==o&&o.audioProfileManager&&(a.config=m._context.audioProfileManager.getOpusConfigStr(a.config))}}else if("".concat(e.mid)===_){var s,c,u,d;null!==(s=m._context)&&void 0!==s&&null!==(c=s.serverConfig)&&void 0!==c&&c.videoCodec&&EL(e,null===(u=m._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.videoCodec),f=e}return e})),this.addBitrateLimit(f,t.videoEncodeConfig[0].maxKbps),e.next=21,this.setLocalDescription(QM.write(h));case 21:return e.abrupt("return",{partialSdp:mL(h,p,f,!1),audioMid:v,videoMid:_,type:"incroffer",semantics:"unified-plan",videoDescriptions:o,subVideoDescriptions:a,audioTransceiverInit:s,videoTransceiverInit:c,peerConnectionMode:this.peerConnectionMode});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k,I,R,A=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return bj.info("subscribe()"),c="",u="",d=!1,l=!1,h=void 0,v=void 0,t.virtual?d=!0:(r.multiChatMode||(d=!0),l=!0),d&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),l&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),_=WO(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=14,this._peerConnection.createOffer();case 14:return p=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:WO()-_}),(f=QM.parse(p.sdp)).media=null===(n=f.media)||void 0===n?void 0:jm(n).call(n,(function(e){return Zd(Zd({},e),A.peer._offerIce)})),jm(i=f.media).call(i,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Gs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Gs(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=21,this.setLocalDescription(QM.write(f),{streamId:t.streamId||"",streamUserId:t.userId});case 21:if(c=null===(o=t.audioTransceiver)||void 0===o?void 0:o.mid,u=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid,null===(s=f.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===c?h=e:"".concat(e.mid)===u&&(v=e)})),c&&h||(c="audio_".concat(u),h=Zd(Zd({},this._aRecvonlyOfferTpl),{},{mid:c})),t.audioMid=c,t.videoMid=u,m=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=36;break}return m=vL(this._nextSsrc),this._nextSsrc=m.next,I=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:c,msid:Om(g=Om(y="".concat(t.streamId)).call(y,null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-audio"," ")).call(g,t.streamId,"-audio"),ssrcs:_L(t.streamId,"audio",m.audio)}),R=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Om(b=Om(E="".concat(t.streamId)).call(E,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-video"," ")).call(b,t.streamId,"-video")},pL(t.streamId,m,{flexfec:this._enableSubFlexfec})),e.next=35,this._internalSetRemoteDescription([I,R],t);case 35:null===(k=m)||void 0===k||delete k.next;case 36:return e.abrupt("return",{partialSdp:mL(f,h,v,!1),audioMid:c,videoMid:u,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:m,peerConnectionMode:this.peerConnectionMode});case 37:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Rm(km().mark((function e(t){var r,n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==OV.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==OV.unpublish&&i!==OV.unsubscribe){e.next=7;break}return e.next=6,this.close(n);case 6:return e.abrupt("return",n.streamId||"");case 7:if(!t.generatorSsrc){e.next=10;break}return bj.warn("already set remote"),e.abrupt("return","");case 10:return o=QM.parse(null==r?void 0:r.sdp),e.next=13,this._internalSetRemoteDescription(o.media,n);case 13:return e.abrupt("return","");case 14:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=QM.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){if("audio"===(e=Zd(Zd({},e),l.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type){if(r instanceof AV&&jN<=87){var t,n,i,o,a={};Array.isArray(e.rtp)&&(e.rtp=Gs(t=e.rtp).call(t,(function(e){return"rtx"!==e.codec||(a[e.payload]=e.payload,!1)}))),"string"==typeof e.payloads&&(e.payloads=Gs(n=e.payloads.split(" ")).call(n,(function(e){return!a[e]})).join(" ")),Array.isArray(e.fmtp)&&(e.fmtp=Gs(i=e.fmtp).call(i,(function(e){return!a[e.payload]}))),Array.isArray(e.rtcpFb)&&(e.fmtp=Gs(o=e.fmtp).call(o,(function(e){return!a[e.payload]})))}r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e}})),u=QM.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=jm(o=u.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=d,jm(a=c.media).call(a,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Gs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Gs(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=11,this.setRemoteDescription(QM.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Rm(km().mark((function e(){var t,r,n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=QM.parse(null===(t=this._peerConnection.localDescription)||void 0===t?void 0:t.sdp),this.createAVMlineOfferTpl(null===(r=this._peerConnection.localDescription)||void 0===r?void 0:r.sdp),o=[],i.media=Gs(n=i.media).call(n,(function(e){return"recvonly"===e.direction&&(e.mid=e.mid+1,o.push("".concat(e.mid)),!0)})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:QM.write(i),semantics:"unified-plan",type:"incroffer"});case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=Rm(km().mark((function e(t,r,n){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return bj.warn("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return bj.info("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(u=QM.parse(null==c?void 0:c.sdp)).media=jm(n=u.media).call(n,(function(e){return a[e.mid]&&(e=fL(e)),"inactive"!==e.direction&&s.push(e.mid),Zd(Zd({},e),h.peer._offerIce)})),d=QM.parse(null===(i=this._peerConnection.remoteDescription)||void 0===i?void 0:i.sdp),l={},d.media.forEach((function(e){void 0!==e.mid&&(l[e.mid]=e)})),d.media=jm(o=u.media).call(o,(function(e){return"inactive"===e.direction?e:l[e.mid]})),u.groups&&d.groups&&(u.groups[0].mids=s.join(" "),d.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(QM.write(u));case 17:return e.next=19,this.setRemoteDescription(QM.write(d));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer();case 2:if(!this._peerConnection.localDescription||!this._peerConnection.remoteDescription){e.next=7;break}return e.next=5,this._peerConnection.setLocalDescription(this._peerConnection.localDescription);case 5:return e.next=7,this._peerConnection.setRemoteDescription(this._peerConnection.remoteDescription);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;QM.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(kL),Tj=function(e,t){return EN?new Ej(e,t):new Sj(e,t)},kj=function(e){return e.streamRemovedBySchedule308="stream removed",e.clientRePublish="client republish",e.publishStreamFaied="publish failed",e.clientUnPublish="client unpublished",e.clientDisconnected="client disconnected",e.videoMuted="video muted",e}(kj||{}),Ij=function(e){return e.PushLimitWarn="PushLimitWarn",e}(Ij||{}),Rj=function(e){return e.ON_ADD_STREAM="onAddStream",e.ON_ADD_STREAM_LIST="onAddStreamList",e.ON_REMOVE_STREAM="onRemoveStream",e.ON_REMOVE_STREAM_LIST="onRemoveStreamList",e.USER_DISCONNECTION="userDisconnection",e.USER_DISCONNECTION_LIST="userDisconnectionList",e.USER_CONNECTION="userConnection",e.USER_CONNECTION_LIST="userConnectionList",e.ON_UPDATE_STREAM_ATTRIBUTES="onUpdateStreamAttributes",e.ON_UPDATE_ROOM_ATTRIBUTES="onUpdateRoomAttributes",e.ON_UPDATE_USER_ATTRIBUTES="onUpdateUserAttributes",e.ON_PUSH_TRACK="onPushTrack",e.ON_REMOVE_TRACK="onRemoveTrack",e.ON_CUSTOM_MESSAGE="onCustomMessage",e.NODE_CHANGE="nodeChange",e.USER_MESSAGE_RECEIVED="userMessageReceived",e.USER_BINARY_MESSAGE_RECEIVED="userBinaryMessageReceived",e.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM="userMessageReceivedOutsideRoom",e.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM="userBinaryMessageReceivedOutsideRoom",e.POST_PROCESSING_MESSAGE="postProcessingMessage",e.ON_USER_TOKEN_WILL_EXPIRE="onUserTokenWillExpire",e.STREAM_CONTROL_MESSAGE="streamControlMessage",e.ON_SPEAKER_CHANGE="onSpeakerChange",e.ON_STREAM_FAILED="streamFailed",e.ON_NOTIFY_RECONNECT="notifyReconnect",e.ON_FORWARD_DST_ROOM_USER_KICK="onForwardDstRoomUserKick",e}(Rj||{}),Aj=function(e){return e.RSCP="RSCP",e.RTT="RTT",e.SSC="SSC",e}(Aj||{}),wj=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ON_VENDOR_CONNECTION_STATE_CHANGE="onVendorConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e}(wj||{}),Cj=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(Cj||{}),xj=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(xj||{}),Oj=new Mw("Locker",2),Nj=1,Dj=function(){function e(t){var r;Vl(this,e),Jd(this,"lockingPromise",Yf.resolve()),Jd(this,"locks",0),Jd(this,"name",""),Jd(this,"lockId",void 0),this.lockId=Nj++,t&&(this.name=t),Oj.info(Om(r="[lock-".concat(this.name,"-")).call(r,this.lockId,"] is created."))}return Ul(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t,r,n=this;this.locks+=1,Oj.info(Om(e=Om(t="[lock-".concat(this.name,"-")).call(t,this.lockId,"] locked, current queue ")).call(e,this.locks,"."));var i=new Yf((function(e){r=function(){var t,r;n.locks-=1,Oj.info(Om(t=Om(r="[lock-".concat(n.name,"-")).call(r,n.lockId,"] unlocked, current queue ")).call(t,n.locks,".")),e()}})),o=this.lockingPromise.then((function(){return r}));return this.lockingPromise=this.lockingPromise.then((function(){return i})),o}}]),e}(),Pj=function(e){return e.RESUBSCRIBE="resubscribe",e.STREAM_FAILED="stream_failed",e.SUBSCRIBE_PUSH_TRACK="subscribe_push_track",e.REMOVE_PUSH_TRACK="remove_push_track",e.VIDEO_FIRST_FRAME="video_first_frame",e.ON_USER_PUBLISH_STATE_CHANGE="on_user_publish_state_change",e.ON_USER_START_AUDIO_CAPTURE="on_user_start_audio_capture",e.ON_USER_STOP_AUDIO_CAPTURE="on_user_stop_audio_capture",e.ON_USER_START_VIDEO_CAPTURE="on_user_start_video_capture",e.ON_USER_STOP_VIDEO_CAPTURE="on_user_stop_video_capture",e.ON_SEI_MESSAGED_RECEIVED="on_sei_messaged_received",e.ON_PUBLISH_RESULT="on_publish_result",e.ON_UPDATE_TOKEN_SUCCESS="on_update_token_success",e.ON_REMOTE_STREAM_STATS="ON_REMOTE_STREAM_STATS",e.ON_LOCAL_STREAM_STATS="ON_LOCAL_STREAM_STATS",e.ON_USER_LEAVE="on_user_leave",e.ON_ROOM_ERROR="on_room_error",e.ON_NETWORK_QUALITY="on_network_quality",e.ON_SIMULCAST_SUBSCRIBE_FALLBACK="on_simulcast_subscribe_fallback",e.ON_REMOTE_VIDEO_SIZE_CHANGED="on_remote_video_size_changed",e.RECONNECT_FAILED="reconnect_failed",e.ON_SUBTITLE_STATE_CHANGED="ON_SUBTITLE_STATE_CHANGED",e.ON_SUBTITLE_MESSAGE_RECEIVED="ON_SUBTITLE_MESSAGE_RECEIVED",e.ON_VIDEO_STREAM_BANNED="ON_VIDEO_STREAM_BANNED",e.ON_AUDIO_STREAM_BANNED="ON_AUDIO_STREAM_BANNED",e.ON_FORWARD_STREAM_ERROR="ON_FORWARD_STREAM_ERROR",e.ON_REJOIN_WITH_TCP="ON_REJOIN_WITH_TCP",e.ON_ICE_CONNECT_WITH_TCP="ON_ICE_CONNECT_WITH_TCP",e}(Pj||{}),Mj=function(e){return e[e.START=1]="START",e[e.START_SUCCESS=2]="START_SUCCESS",e[e.START_FAILED=3]="START_FAILED",e[e.UPDATE=4]="UPDATE",e[e.UPDATE_SUCCESS=5]="UPDATE_SUCCESS",e[e.UPDATE_FAILED=6]="UPDATE_FAILED",e[e.STOP=7]="STOP",e[e.STOP_SUCCESS=8]="STOP_SUCCESS",e[e.STOP_FAILED=9]="STOP_FAILED",e}(Mj||{}),Lj=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(Lj||{}),Uj=function(e){return e[e.SUB=0]="SUB",e[e.UNSUB=1]="UNSUB",e}(Uj||{}),Vj=(Jd(fj={},bl.communication,[0]),Jd(fj,bl.chat,[0]),Jd(fj,bl.chatRoom,[1,"IES_chatroom"]),Jd(fj,bl.coHost,[1,"IES_PK"]),Jd(fj,bl.meeting,[16]),Jd(fj,bl.classRoom,[0]),fj),Fj=GM(),Bj=function(e){DI(s,e);var t,r,n,i,o,a=QI(s);function s(e,t){var r;return Vl(this,s),Jd(tI(r=a.call(this,e,t)),"peerConnectionId",XO()),Jd(tI(r),"peerConnectionMode",1),Jd(tI(r),"name","vendor"),Jd(tI(r),"direction","up"),Jd(tI(r),"stream",void 0),t.on("ice_state",(function(e){r._report("rtc_ice_state",{pc_session_id:r.peerConnectionId,direction:r.direction,error_code:0,ice_state:e.toUpperCase(),message:"",peer_connection_id:r.peerConnectionId,stream_id:"",stream_user_id:""})})),r}return Ul(s,[{key:"publish",value:(o=Rm(km().mark((function e(t){var r,n,i,o,a,c,u,d,l,h,v=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.enableSimulcast=!1,this.stream=t,r=OI(CI(s.prototype),"internalPublish",this).call(this,t),n=r.videoDescriptions,i=r.subVideoDescriptions,o=r.audioTransceiverInit,a=r.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(o.track,o.init),t.videoTransceiver=this._peerConnection.addTransceiver(a.track,a.init),Fj&&(t.initAudioEncodedTransform(),t.initVideoEncodedTransform()),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:(null==t?void 0:t.vendorCode)||0}),e.next=9,this._peerConnection.createOffer();case 9:return c=e.sent,u=WO(),d=QM.parse(c.sdp),Array.isArray(d.media)&&(d.media=jm(l=d.media).call(l,(function(e){var r,n,i,o,a;if("video"===e.type)null!==(r=v._context)&&void 0!==r&&null!==(n=r.serverConfig)&&void 0!==n&&n.videoCodec&&EL(e,null===(i=v._context)||void 0===i||null===(o=i.serverConfig)||void 0===o?void 0:o.videoCodec),(TN||PN)&&Array.isArray(e.ext)&&(e.ext=Gs(a=e.ext).call(a,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&mT(t).call(t,"video-orientation"))}))),TN||v.addBitrateLimit(e,t.videoEncodeConfig[0].maxKbps);else if("audio"===e.type){var s,c=null==e?void 0:yE(s=e.rtp).call(s,(function(e){return"opus"===e.codec}));if(c&&e.fmtp){var u,d,l=yE(u=e.fmtp).call(u,(function(e){return e.payload===c.payload}));l&&null!==(d=v._context)&&void 0!==d&&d.audioProfileManager&&(l.config=v._context.audioProfileManager.getOpusConfigStr(l.config))}}return e}))),h=new RTCSessionDescription({type:"offer",sdp:QM.write(d)}),e.prev=14,e.next=17,this._peerConnection.setLocalDescription(h);case 17:this._report("rtc_set_description",{error_code:0,message:h.sdp||"",is_local:"1",direction:"up",stream_id:"",stream_user_id:"",elapse:WO()-u},{type:"offer"}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(14),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+h.sdp,is_local:"1",direction:"up",stream_id:"",stream_user_id:"",elapse:WO()-u},{type:"offer"}),e.t0;case 24:return e.abrupt("return",{partialSdp:h.sdp||"",audioMid:"0",videoMid:"1",type:"offer",semantics:"unified-plan",videoDescriptions:n,subVideoDescriptions:i,audioTransceiverInit:o,videoTransceiverInit:a,peerConnectionMode:this.peerConnectionMode,peerConnectionId:this.peerConnectionId});case 25:case"end":return e.stop()}}),e,this,[[14,20]])}))),function(e){return o.apply(this,arguments)})},{key:"subscribe",value:(i=Rm(km().mark((function e(t){var r,n,i,o,a,s=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.stream=t,this.direction="down",t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"}),Fj&&(t.initAudioEncodedTransform(),t.initVideoEncodedTransform()),this._report("rtc_begin_create_offer",{direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:t.vendorCode||0}),e.next=8,this._peerConnection.createOffer();case 8:return r=e.sent,n=WO(),i=QM.parse(r.sdp),Array.isArray(i.media)&&(i.media=jm(o=i.media).call(o,(function(e){if("audio"===e.type){var t,r=null==e?void 0:yE(t=e.rtp).call(t,(function(e){return"opus"===e.codec}));if(r&&null!=e&&e.fmtp){var n,i=null==e?void 0:yE(n=e.fmtp).call(n,(function(e){return e.payload===r.payload}));i&&s._context&&(i.config+=";stereo=1;sprop-stereo=1")}}return e}))),a=new RTCSessionDescription({type:"offer",sdp:QM.write(i)}),e.prev=13,e.next=16,this._peerConnection.setLocalDescription(a);case 16:this._report("rtc_set_description",{error_code:0,message:a.sdp||"",is_local:"1",direction:"down",stream_id:t.streamId,stream_user_id:t.userId,elapse:WO()-n},{type:"offer"}),e.next=23;break;case 19:throw e.prev=19,e.t0=e.catch(13),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+a.sdp,is_local:"1",direction:"down",stream_id:t.streamId,stream_user_id:t.userId,elapse:WO()-n},{type:"offer"}),e.t0;case 23:return e.abrupt("return",{partialSdp:a.sdp||"",audioMid:"0",videoMid:"1",type:"offer",semantics:"unified-plan",peerConnectionMode:this.peerConnectionMode,peerConnectionId:this.peerConnectionId});case 24:case"end":return e.stop()}}),e,this,[[13,19]])}))),function(e){return i.apply(this,arguments)})},{key:"handleAck",value:(n=Rm(km().mark((function e(t){var r,n,i,o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.action!==OV.publish&&t.action!==OV.subscribe){e.next=16;break}return n=new RTCSessionDescription({sdp:null===(r=t.signalingAck)||void 0===r?void 0:r.sdp,type:"answer"}),i=WO(),e.prev=3,e.next=6,this._peerConnection.setRemoteDescription(n);case 6:this._report("rtc_set_description",{error_code:0,message:n.sdp||"",is_local:"1",direction:"down",stream_id:null===(o=t.stream)||void 0===o?void 0:o.userId,stream_user_id:(null===(a=t.stream)||void 0===a?void 0:a.streamId)||"",elapse:WO()-i},{type:"answer"}),e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(3),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+n.sdp,is_local:"1",direction:"down",stream_id:null===(s=t.stream)||void 0===s?void 0:s.userId,stream_user_id:(null===(c=t.stream)||void 0===c?void 0:c.streamId)||"",elapse:WO()-i},{type:"offer"}),e.t0;case 13:"function"==typeof t.onSuccess&&t.onSuccess(),e.next=17;break;case 16:t.action!==OV.unpublish&&t.action!==OV.unsubscribe||this.destroy();case 17:return e.abrupt("return","");case 18:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(e){return n.apply(this,arguments)})},{key:"destroy",value:function(){this.peer.destroy(),OI(CI(s.prototype),"destroy",this).call(this)}},{key:"getDefaultSdp",value:(r=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{sdp:"",type:"offer",semantics:""});case 1:case"end":return e.stop()}}),e)}))),function(){return r.apply(this,arguments)})},{key:"connect",value:function(){throw new Error("Method not implemented.")}},{key:"rollback",value:(t=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{this._peerConnection.close()}catch(t){}case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),s}(kL),jj=function(e){return e[e.AUTOPLAY_FAILED=-1e3]="AUTOPLAY_FAILED",e[e.TRACK_ERROR=-1001]="TRACK_ERROR",e[e.Fetch_MODIFY=-1002]="Fetch_MODIFY",e[e.BLACK_BROWSER=-1003]="BLACK_BROWSER",e[e.DC_SEND_ERROR=-1004]="DC_SEND_ERROR",e}(jj||{}),Gj={start_interval:100,multiplier:2,max_interval:3e4},Hj=function(){function e(){Vl(this,e),Jd(this,"_times",0),Jd(this,"_config",Gj),Jd(this,"initTs",WO())}return Ul(e,[{key:"getRetryDelay",value:function(){return Math.min(this._config.max_interval,Math.pow(this._config.multiplier,this._times++)*this._config.start_interval)}},{key:"setConfig",value:function(e){this._config=e}},{key:"reset",value:function(){this._times=0}}]),e}(),zj=new Mw("ICERequest",4),Kj=function(){function e(t){Vl(this,e),Jd(this,"_reconnectTimer",void 0),Jd(this,"_abortControllers",[]),Jd(this,"_monitor",void 0),Jd(this,"_groupConfigId",XO()),Jd(this,"_retryLimiter",new Hj),Jd(this,"_timer",void 0),this._ctx=t,this._monitor=VO(t.id)}var t,r,n,i;return Ul(e,[{key:"getICENode",value:(i=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return zj.info("getICENode","invoke"),e.prev=1,e.next=4,this._getAccessWithRetry(t);case 4:if(0!==(r=e.sent).length){e.next=7;break}throw"server return empty nodes.";case 7:e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(1),this._reportRtcInvokeStatus("es.join.getNodeFailed",e.t0),new mA(vA.ICE_SERVER_WRONG,"get ICE config failed: ".concat(e.t0),e.t0);case 13:return zj.success("getICENode","success"),this._reportRtcInvokeStatus("es.join.getNodeSuccess",r),e.abrupt("return",r);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return i.apply(this,arguments)})},{key:"_getAccessWithRetry",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return 0!==r&&zj.info("_getAccessWithRetry()","invoke feedbackInfo: %o, 201count: %o",e,r),new Yf((function(n,i){t._getAccessNode(e).then((function(e){t._retryLimiter.reset(),n(e)})).catch((function(o){if(Array.isArray(o)&&o.length>0){if(QR(o).call(o,(function(e){return 400<=e.code&&e.code<500}))>-1)return t._retryLimiter.reset(),i("HTTP request failed(4xx)");if(o.every((function(e){var t;return 201===e.code||201===(null===(t=e.error)||void 0===t?void 0:t.code)}))&&r++,3===r)return t._retryLimiter.reset(),i("HTTP request failed(201)")}var a=t._retryLimiter.getRetryDelay();zj.warn("_getAccessWithRetry()","_getAccessWithRetry error, will retry after ".concat(a,"ms"),o),t._reconnectTimer=self.setTimeout((function(){t._getAccessWithRetry(e,r).then(n).catch(i)}),a)}))}))}},{key:"_getAccessNode",value:(n=Rm(km().mark((function e(t){var r=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Yf((function(e,n){var i=$N.getAccessNode(r._ctx.appId);i?(zj.info("getAccessNode","use cache node."),e(Array.isArray(i)?i:[i]),r._timer=window.setTimeout((function(){r._getAccessNodeFromServer(t),r._reportRtcInvokeStatus("es.R.node.cache",i),delete r._timer}),0)):r._getAccessNodeFromServer(t).then(e).catch(n)})));case 1:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"_getAccessNodeFromServer",value:(r=Rm(km().mark((function e(t){var r,n,i,o=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this._getAccessUrls(),n=r.urls,i=r.needFallback,e.abrupt("return",this.getICEConfigFromServer(n,t).then((function(e){var t=e.nodes;return!o._ctx.useCloudProxy&&$N.setAccessNode(o._ctx.appId,t,e.ttl||11200),e.dispatchDomains&&!o._ctx.useCloudProxy&&$N.setAccessUrls(e.dispatchDomains),t})).catch((function(e){if(i)return o._reportRtcInvokeStatus("es.R.req.fallback",""),$N.clearAccessUrls(),o._getAccessNodeFromServer(t);throw e})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_getAccessUrls",value:function(){var e=$N.getAccessUrls()||[],t=!0;return this._reportRtcInvokeStatus("es.R.req.cache.urls",e),0===e.length&&(e=aD.ICE_CONFIG_REQUEST_URLS,t=!1,this._reportRtcInvokeStatus("es.R.req.external.urls",e)),0===e.length&&(e=aD.ICE_CONFIG_REQUEST_URLS_INTERNAL,t=!1,this._reportRtcInvokeStatus("es.R.req.internal.urls",e)),{urls:e,needFallback:t}}},{key:"getICEConfigFromServer",value:(t=Rm(km().mark((function e(t,r){var n,i,o,a,s,c=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=XO(),o={appID:this._ctx.appId,deviceID:$N.getDeviceId(),connectSessionID:i,os:"web",sdkVersion:aD.VERSION,isOversea:aD.OVERSEA,expectedAddr:cD("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC},r&&(o.feedbackInfo=r,delete o.expectedAddr),a=Date.now(),null===(n=this._monitor)||void 0===n||n.report("rtc_get_access",{error_code:0,message:Mm(o),elapse:0,type:"request",host:t.join(","),config_id:i,group_config_id:this._groupConfigId}),s=jm(t).call(t,function(){var e=Rm(km().mark((function e(t,r){var n,i,a,s,u;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new AbortController,c._abortControllers.push(i),e.prev=2,e.next=5,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:Mm(o),signal:i.signal});case 5:a=e.sent,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(2),gw(fetch)||null===(s=c._monitor)||void 0===s||s.report("rtc_error",{error_code:jj.Fetch_MODIFY,message:"get access failed, possibly due to modifying the browser's Fetch API."},{origin_error:e.t0}),e.t0;case 12:if(c._abortControllers=Gs(n=c._abortControllers).call(n,(function(e){return e!==i})),200===a.status){e.next=15;break}throw{message:a.statusText,code:a.status};case 15:return e.next=17,a.json();case 17:if(200===(u=e.sent).code){e.next=20;break}throw u;case 20:if(0!==u.nodes.length){e.next=22;break}throw{code:u.code,message:Mm(u)};case 22:return e.abrupt("return",{url:t,result:u});case 23:case"end":return e.stop()}}),e,null,[[2,8]])})));return function(t,r){return e.apply(this,arguments)}}()),e.abrupt("return",cN(s).then((function(e){var t,r=e.result,n=e.url;return null===(t=c._monitor)||void 0===t||t.report("rtc_get_access",{error_code:200,message:Mm(r),elapse:Date.now()-a,type:"response",host:n,config_id:i,group_config_id:c._groupConfigId}),r})).catch((function(e){var r,n,o,s;throw null===(r=c._monitor)||void 0===r||r.report("rtc_get_access",{error_code:Number((null===(n=e[0])||void 0===n?void 0:n.code)||(null===(o=e[0])||void 0===o?void 0:o.server_code)),message:null===(s=e[0])||void 0===s?void 0:s.message,elapse:Date.now()-a,type:"response",host:t.join(","),config_id:i,group_config_id:c._groupConfigId},{error:Mm(e)}),e})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._abortControllers.forEach((function(e){return e.abort()})),this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer),this._timer&&(window.clearTimeout(this._timer),delete this._timer)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0;null===(r=this._monitor)||void 0===r||r.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:n,stream_id:"",elapse:0,group_config_id:this._groupConfigId},i)}}]),e}(),Xj={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",encodedInsertableStreams:!!GM()||void 0},Wj=function(e){return e[e.DC_ERROR=0]="DC_ERROR",e[e.DC_CLOSE=1]="DC_CLOSE",e[e.ICE_FAILED=2]="ICE_FAILED",e[e.DESTROY=3]="DESTROY",e[e.TIMEOUT=4]="TIMEOUT",e}(Wj||{}),qj=0,Yj=function(e){DI(s,e);var t,r,n,i,o,a=QI(s);function s(e,t){var r;return Vl(this,s),Jd(tI(r=a.call(this)),"uuid",(qj++).toString()),Jd(tI(r),"_peerConnectionId",""),Jd(tI(r),"audioTrack4ff",void 0),Jd(tI(r),"_pc",void 0),Jd(tI(r),"_dc",void 0),Jd(tI(r),"_iceNode",void 0),Jd(tI(r),"_initSctpEvents",!1),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_offerIce",{}),Jd(tI(r),"_answerIce",{}),Jd(tI(r),"_offerSession",void 0),Jd(tI(r),"_answerSession",void 0),Jd(tI(r),"_offerMlines",[]),Jd(tI(r),"_answerMlines",[]),Jd(tI(r),"_connectReject",void 0),Jd(tI(r),"_logger",new Mw("PeerConnection_".concat(r.uuid),4)),r._ctx=e,r._groupConnectionId=t,r._monitor=VO(e.id),r._pc=new RTCPeerConnection(Xj),r._pc.ontrack=function(e){var t,n,i,o,a=null===(t=e.streams)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.id;r._print("pc.ontrack",Om(i=Om(o="".concat(e.track.kind," ")).call(o,e.track.id," ")).call(i,a)),"ff-stream"===a&&(r.audioTrack4ff=e.track),r.emit("ontrack",e)},r._pc.onconnectionstatechange=function(e){var t;r._print("onconnectionstatechange",Om(t="".concat(r._pc.connectionState,". ice -> ")).call(t,r._pc.iceConnectionState)),"failed"!==r._pc.iceConnectionState&&"closed"!==r._pc.iceConnectionState&&"failed"!==r._pc.connectionState||r.emit("disconnect","ice failed")},r._pc.oniceconnectionstatechange=function(){var e=r._pc.iceConnectionState;r._report("rtc_pre_ice_state",{message:e,ice_state:e.toUpperCase()}),r.emit("ice_state",e)},r}return Ul(s,[{key:"getOriginRTCPeerConnection",value:function(){return this._pc}},{key:"getOriginRTCDataChannel",value:function(){return this._dc}},{key:"getConnectionId",value:function(){return this._peerConnectionId}},{key:"getGroupConnectionId",value:function(){return this._groupConnectionId}},{key:"connect",value:(o=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._print("connect","invoke. %o",t),this._iceNode=t,this._dc=this._pc.createDataChannel("signaling",{negotiated:!0,id:100}),this._dc.binaryType="arraybuffer",e.next=6,this._genIceInfo(t);case 6:return r=e.sent,n=r.offerIce,i=r.answerIce,this._offerIce=n,this._answerIce=i,this._peerConnectionId=i.iceUfrag||"",EN&&(this._pc.addTransceiver("audio",{direction:"recvonly"}),this._pc.addTransceiver("video",{direction:"recvonly"})),e.next=15,this._pc.createOffer();case 15:if(o=e.sent,a=QM.parse(o.sdp),s=eI(a.media,1),c=s[0],this._offerIce.fingerprint=a.fingerprint||c.fingerprint,!EN){e.next=30;break}return a.media=jm(u=a.media).call(u,(function(e){var t,r,n=Zd(Zd({},e),h._offerIce);return"video"===n.type&&(n.ext=null===(t=n.ext)||void 0===t?void 0:Gs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),n.rtcpFb=null===(r=n.rtcpFb)||void 0===r?void 0:Gs(r).call(r,(function(e){return"goog-remb"!==e.type}))),n})),(l=Zd({},a)).fingerprint=this._answerIce.fingerprint,l.media=jm(d=l.media).call(d,(function(e){return delete(e=Zd(Zd({},e),h._answerIce)).bundleOnly,e.port=9,"application"===e.type?e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}:("audio"===e.type&&(e.msid="ff-stream ff-stream-audio"),e.direction="sendonly"),e})),e.next=26,this.setLocalDescription(QM.write(a));case 26:return e.next=28,this.setRemoteDescription(QM.write(l));case 28:e.next=38;break;case 30:delete a.media,this._offerSession=Zd({},a),this._answerSession=Zd({},a),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),this._offerMlines=[Zd(Zd(Zd({},c),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[Zd(Zd(Zd({},c),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription();case 38:return e.next=40,new Yf((function(e,t){h._connectReject=t,h._dc.onopen=function(){h._print("connect","dataChannel open"),h._reportRtcInvokeStatus("es.dc.open",""),e(""),delete h._connectReject},h._dc.onerror=function(e){var t,r;h._report("rtc_signaling_msg_error",{error_code:e.error.sdpLineNumber,message:e.error.errorDetail,reason:"invalid data"}),h._reportRtcInvokeStatus("es.dc.error",""),null===(t=h._connectReject)||void 0===t||t.call(h,{message:"dc.onerror, ".concat(null===(r=e.error)||void 0===r?void 0:r.errorDetail),code:0}),h.emit("disconnect","dc onerror"),delete h._connectReject},h._dc.onclose=function(e){var t;h._reportRtcInvokeStatus("es.dc.close",""),null===(t=h._connectReject)||void 0===t||t.call(h,{message:"dc.onclose",code:1}),h.emit("disconnect","dc onclose"),delete h._connectReject},h._pc.addEventListener("connectionstatechange",(function(e){var t,r;"failed"!==h._pc.iceConnectionState&&"closed"!==h._pc.iceConnectionState&&"failed"!==h._pc.connectionState||(null===(t=h._connectReject)||void 0===t||t.call(h,{message:Om(r="pc.connectionstatechange -> ".concat(h._pc.connectionState,", ice -> ")).call(r,h._pc.iceConnectionState),code:2}),delete h._connectReject)})),setTimeout((function(){var e;null===(e=h._connectReject)||void 0===e||e.call(h,{code:4,message:"connect timeout"}),delete h._connectReject}),8e3)}));case 40:return this._print("connect","dataChannel establish success"),e.abrupt("return",this._dc);case 42:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"setDescription",value:(i=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._print("setDescription","invoke."),this._offerSession.media=this._offerMlines,this._answerSession.media=this._answerMlines,r=[],this._offerMlines.forEach((function(e){"inactive"!==e.direction&&r.push(e.mid)})),this._offerSession.groups&&this._answerSession.groups&&(this._offerSession.groups[0].mids=r.join(" "),this._answerSession.groups[0].mids=r.join(" ")),n=WO(),t&&this._report("rtc_begin_create_offer",{direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,pc_session_id:this._peerConnectionId,vendor_mode:0}),e.next=10,this._pc.createOffer();case 10:return t&&this._report("rtc_create_offer",{error_code:0,direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,elapse:WO()-n}),e.next=13,this.setLocalDescription(QM.write(this._offerSession),t);case 13:return e.next=15,this.setRemoteDescription(QM.write(this._answerSession),t);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setLocalDescription",value:(n=Rm(km().mark((function e(t,r){var n,i,o,a=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=WO(),e.prev=1,e.next=4,this._pc.setLocalDescription(new RTCSessionDescription({type:"offer",sdp:t}));case 4:this._report("rtc_set_description",{error_code:0,message:t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:WO()-n},{type:"offer"}),this._initSctpEvents||(this._initSctpEvents=!0,(o=null===(i=this._pc)||void 0===i?void 0:i.sctp)&&(o.onstatechange=function(){a._reportRtcInvokeStatus("sctp","sctp state change TO: ".concat(o.state))},o.transport&&(o.transport.onstatechange=function(){var e;a._reportRtcInvokeStatus("dtls","dtls state change TO: ".concat(null==o||null===(e=o.transport)||void 0===e?void 0:e.state))}))),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),console.error("setLocal",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:"",stream_user_id:"",elapse:WO()-n},{type:"offer"});case 12:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e,t){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(r=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=WO(),e.prev=1,e.next=4,this._pc.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:t}));case 4:this._report("rtc_set_description",{error_code:0,message:t,is_local:"0",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:WO()-n},{type:"answer"}),e.next=11;break;case 7:e.prev=7,e.t0=e.catch(1),console.error("setRemote",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"0",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:WO()-n},{type:"answer"});case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"disconnect",value:function(){var e,t;null===(e=this._connectReject)||void 0===e||e.call(this,{code:3,message:"invoke destroy()"}),delete this._connectReject,this._pc.close(),null===(t=this._dc)||void 0===t||t.close(),this._pc.ontrack=null}},{key:"destroy",value:function(){this._print("destroy",this._peerConnectionId),OI(CI(s.prototype),"removeAllListeners",this).call(this),this.disconnect()}},{key:"_genIceInfo",value:(t=Rm(km().mark((function e(t){var r,n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={iceUfrag:null===(r=t.iceParams)||void 0===r?void 0:r.clientIceUfrag,icePwd:null===(n=t.iceParams)||void 0===n?void 0:n.clientIcePwd,iceOptions:"renomination"},e.next=3,gL(t);case 3:return o=e.sent,e.abrupt("return",{offerIce:i,answerIce:o});case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"_print",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];(t=this._logger).info.apply(t,Om(r=["".concat(e)]).call(r,i))}},{key:"_report",value:function(e,t,r){var n,i,o,a;null===(n=this._monitor)||void 0===n||n.report(e,Zd(Zd({},t),{},{connection_id:this._peerConnectionId,group_connection_id:this._groupConnectionId}),Zd(Zd({},r),{},{tcp_only:null===(i=this._iceNode)||void 0===i?void 0:i.iceConfig.tcpOnly,ms_addr:Mm((null===(o=this._iceNode)||void 0===o?void 0:jm(a=o.publicIPs).call(a,(function(e){return{ip:e.ip,tcp:e.tcpPorts,udp:e.udpPorts}})))||[])}))}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)}}],[{key:"checkSupported",value:function(){if(!RTCPeerConnection)throw new mA(vA.NOT_SUPPORTED,"missing RTCPeerConnection API.");["addTransceiver","createDataChannel","createOffer","setLocalDescription","setRemoteDescription"].forEach((function(e){var t,r;if(null===(t=RTCPeerConnection)||void 0===t||null===(r=t.prototype)||void 0===r||!r[e])throw new mA(vA.NOT_SUPPORTED,"missing peer.".concat(e," API."))}))}}]),s}(UD);function Jj(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=an(e);for(n=0;n<o.length;n++)r=o[n],xE(t).call(t,r)>=0||(i[r]=e[r]);return i}(e,t);if(xs){var o=xs(e);for(n=0;n<o.length;n++)r=o[n],xE(t).call(t,r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var Qj=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(Qj||{}),Zj=function(e){return e[e.P2P=0]="P2P",e[e.SIGNAL=1]="SIGNAL",e[e.BROADCAST=2]="BROADCAST",e[e.BUSINESS_SERVER=3]="BUSINESS_SERVER",e}(Zj||{}),$j=function(e){return e[e.SUCCESS=0]="SUCCESS",e[e.TIMEOUT=1]="TIMEOUT",e[e.BROKEN=2]="BROKEN",e[e.NO_RECEIVER=3]="NO_RECEIVER",e[e.NO_RELAYPATH=4]="NO_RELAYPATH",e[e.EXCEED_QPS=5]="EXCEED_QPS",e[e.SEND_TO_SERVER_ERROR=17]="SEND_TO_SERVER_ERROR",e[e.SERVER_RESPONSE_ERROR=18]="SERVER_RESPONSE_ERROR",e[e.NOT_JOIN=100]="NOT_JOIN",e[e.NOT_LOGIN=105]="NOT_LOGIN",e[e.SERVER_PARAMS_NOTSET=106]="SERVER_PARAMS_NOTSET",e[e.UNKNOWN=1e3]="UNKNOWN",e}($j||{}),eG=(Jd(mj={},0,[0,"success"]),Jd(mj,1,[vA.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),Jd(mj,2,[vA.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),Jd(mj,3,[vA.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),Jd(mj,4,[vA.USER_MESSAGE_NO_RECEIVER,"cannot find relay path."]),Jd(mj,5,[vA.USER_MESSAGE_EXCEED_QPS,"cannot find relay path."]),Jd(mj,17,[vA.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),Jd(mj,18,[vA.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),Jd(mj,100,[vA.USER_MESSAGE_NOT_JOIN,"not join room"]),Jd(mj,105,[vA.USER_MESSAGE_NOT_LOGIN,"not login."]),Jd(mj,106,[vA.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),Jd(mj,1e3,[vA.USER_MESSAGE_UNKNOWN,"unknown."]),mj),tG=["msg"],rG=new Mw("DataChannelSignaling",3),nG=[],iG=function(e){return e[e.C2S=0]="C2S",e[e.C2C=1]="C2C",e[e.C2GW=2]="C2GW",e[e.C2CDirect=3]="C2CDirect",e[e.C2RTM=4]="C2RTM",e}(iG||{}),oG=function(e){DI(a,e);var t,r,n,i,o=QI(a);function a(e,t){var r;return Vl(this,a),Jd(tI(r=o.call(this)),"_singlingCache",new $S),Jd(tI(r),"_p2pCache",new $S),Jd(tI(r),"_rttIds",{}),Jd(tI(r),"_p2pMessageId",1),Jd(tI(r),"_clearDataChannelListener",void 0),Jd(tI(r),"_monitor",void 0),r.id=e,r._dataChannel=t,r._clearDataChannelListener=r._handleHandler(),r._monitor=VO(e),r}return Ul(a,[{key:"destroy",value:function(){var e=this;this._dataChannel&&(this._clearDataChannelListener(),this._dataChannel.close()),this._singlingCache.forEach((function(t,r){t.error(new mA(vA.OPERATION_CANCEL,"disconnect")),e._singlingCache.delete(r)})),this._singlingCache.clear(),this._p2pCache.clear(),this._p2pMessageId=1,this._rttIds={}}},{key:"sendSignaling",value:function(e,t,r){var n,i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:6e4;return null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:Mm(t),signaling_event:"call-".concat(e),signaling_type:"Send",stream_id:t.streamId,stream_user_id:t.streamUserId,direction:"up"}),new Yf((function(n,a){var s,c=i._genHeader(r);c.id=JO();var u=c.id.join("-"),d="customMessage"===e;d&&wO.samplingOne2ManyMsg(i.id,Number(c.id.join("")),t);var l=setTimeout((function(){i._singlingCache.delete(u),a(new mA(vA.TIME_OUT,"".concat(e," message time out"))),d&&wO.updateOne2ManyMsgAck(i.id,t,999)}),o);i._singlingCache.set(u,{signalingType:e,success:function(e){clearTimeout(l),n(e),d&&wO.updateOne2ManyMsgAck(i.id,t,0)},error:function(e){clearTimeout(l),a(e),d&&wO.updateOne2ManyMsgAck(i.id,t,e.code)}}),rG.info("Signal",Om(s=">>>>>> [".concat(e,"][")).call(s,u,"]"),t),i._sendMessage(e,c,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(i=Rm(km().mark((function e(t,r){var n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,i=Jj(t,tG),o=n instanceof ArrayBuffer,e.t0=this,e.t1=wO,e.t2=this.id,e.t3=Zd,e.t4=Zd({ver:1,id:this._p2pMessageId++,time:Date.now(),dir:Qj.SEND,type:Zj.P2P,err:$j.SUCCESS},i),e.t5={},e.t6=o,!o){e.next=15;break}return e.next=12,YO.ab2b64str(n);case 12:e.t7=e.sent,e.next=16;break;case 15:e.t7=n;case 16:return e.t8=e.t7,e.t9={binary:e.t6,msg:e.t8},e.t10=(0,e.t3)(e.t4,e.t5,e.t9),e.t11=e.t1.samplingP2PMsg.call(e.t1,e.t2,e.t10),e.t12=r,e.abrupt("return",e.t0._sendP2PMessage.call(e.t0,e.t11,e.t12));case 22:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"_sendP2PMessage",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return ZO(e.msg)?this._rttIds[e.id]=e.id:e.dir===Qj.SEND&&rG.info("_sendP2PMessage [DC Signaling p2p >>]",Mm(e)),new Yf((function(n,i){var o=t._genHeader(Zd(Zd({needAck:!0,functionType:1},r),{},{id:JO()}));if(e.dir===Qj.SEND){var a=setTimeout((function(){t._p2pCache.delete(e.id),i(new mA(vA.USER_MESSAGE_TIMEOUT,"P2P message timeout")),wO.updateP2PMsgAck(t.id,e,999)}),12e3);t._p2pCache.set(e.id,{success:function(r,i){clearTimeout(a),n(i),wO.updateP2PMsgAck(t.id,e,0)},error:function(r){var n;clearTimeout(a),wO.updateP2PMsgAck(t.id,e,r.err);var o=eI(eG[r.err]||[vA.USER_MESSAGE_UNKNOWN,Om(n="err: ".concat(r.err,", msg: ")).call(n,r.msg)],2),s=o[0],c=o[1];i({err:r.err,code:s,message:r.msg||c})}})}try{t._sendMessage("p2p",o,e)}catch(s){throw s.code===vA.NOT_CONNECTED_YET&&(s.code=vA.USER_MESSAGE_BROKEN),s}}))}},{key:"_sendMessage",value:function(e,t,r){var n;if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new mA(vA.NOT_CONNECTED_YET,"DataChannel not open");var i=t.version+(Number(t.zip)<<5)+(Number(t.encrypt)<<6),o=Number(t.needAck)+(Number(t.direction)<<1)+(Number(t.functionType)<<2)+(Number(t.binary)<<6),a=YO.str2ab(Mm([e,r])),s=qO(Uint8Array,Om(n=[i,o]).call(n,JT(t.id||[])),new Uint8Array(a));try{this._dataChannel.send(s.buffer)}catch(u){var c;throw null===(c=this._monitor)||void 0===c||c.report("rtc_error",{message:"datachannel send error: ".concat(u.message),error_code:jj.DC_SEND_ERROR}),u}"p2p"===e?wO.updateP2PMsgReq(this.id,r,s.buffer.byteLength):"customMessage"===e&&wO.updateOne2ManyMsgReq(this.id,r,s.buffer.byteLength)}},{key:"_dispartData",value:function(e){var t=new Uint8Array(e),r=0,n=t[r++],i=t[r++],o={version:15&n,zip:16==(16&n),encrypt:32==(32&n),needAck:1==(1&i),direction:(2&i)>>1,functionType:(60&i)>>2,binary:64==(64&i)};if(o.needAck||1===o.direction){for(;r<=6;r++)if(128!=(128&t[r])){r++;break}o.id=qT(Tm(t).call(t,2,r))}return{header:o,data:Tm(t).call(t,r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n,i,o=this._genHeader({needAck:!0,direction:1,id:jm(n=e.split("-")).call(n,(function(e){return Number(e)}))});mT(nG).call(nG,t)||rG.info("Signal",Om(i=">>>>>> [".concat(t,"-res][")).call(i,e,"]"));this._sendMessage("".concat(t,"-res"),o,r)}},{key:"_handleMessage",value:(n=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=Date.now(),n=t.byteLength,i=this._dispartData(t),o=i.data,(a=i.header).zip&&((s=new _O.Inflate).push(o,!0),o=s.result),c=YO.ab2str(o),u=[],e.prev=8,u=JSON.parse(c),e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(8),e.t0 instanceof Error&&(null===(d=this._monitor)||void 0===d||d.report("rtc_signaling_msg_error",{error_code:-1,message:e.t0.message,reason:"message parse failed"})),e.abrupt("return");case 16:e.t1=a.functionType,e.next=0===e.t1?19:1===e.t1?21:2===e.t1?23:25;break;case 19:return this.C2S(a,u,c,n,r),e.abrupt("break",26);case 21:return this.C2C(u,n,r),e.abrupt("break",26);case 23:return this.C2GW(a,u,c),e.abrupt("break",26);case 25:return e.abrupt("break",26);case 26:case"end":return e.stop()}}),e,this,[[8,12]])}))),function(e){return n.apply(this,arguments)})},{key:"C2S",value:(r=Rm(km().mark((function e(t,r,n,i,o){var a,s,c,u,d;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=(null===(a=t.id)||void 0===a?void 0:a.join("-"))||"",1!==t.direction){e.next=5;break}this._handleAckMessage(s,r[0]||{},n),e.next=18;break;case 5:if(!Array.isArray(r)){e.next=18;break}if(u=r[0],r=r[1],mT(nG).call(nG,u)||rG.info("Signal","<<<<<< ".concat(u),r,s),this._feedbackSignaling(s,u,u===Rj.ON_CUSTOM_MESSAGE?Zd(Zd({},r),{},{message:""}):""),!r.binary||"string"!=typeof r.message){e.next=14;break}return e.next=13,YO.b64str2ab(r.message);case 13:r.message=e.sent;case 14:d=Date.now(),this.emit(u,Zd({},r)),u===Rj.ON_CUSTOM_MESSAGE&&wO.reportOne2ManyMsgRecv(this.id,r,{msg_size:i,recv_msg_ts:o,fwd_msg_ts:d}),null===(c=this._monitor)||void 0===c||c.report("rtc_signaling",{error_code:0,message:n,signaling_event:"on-".concat(u),signaling_type:"Recv",stream_id:r.streamId,stream_user_id:r.clientId,direction:"down"});case 18:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"C2C",value:(t=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,v,_,p,f;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Array.isArray(t)&&(t=t[1]),c=null===(i=t)||void 0===i?void 0:i.id,this._rttIds[c]||(null===(o=t)||void 0===o?void 0:o.dir)===Qj.FEEDBACK||ZO(null===(a=t)||void 0===a?void 0:a.msg)?delete this._rttIds[c]:rG.info("Signal","<<<<<< p2p response",t),e.t0=t.dir,e.next=e.t0===Qj.SEND?6:e.t0===Qj.FEEDBACK?46:48;break;case 6:if(u=Date.now(),ZO(null===(s=t)||void 0===s?void 0:s.msg)){e.next=43;break}if(l=(d=t).binary,h=d.msg,v=d.room,_=d.to,p=d.from,f=""===v?l?Rj.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:Rj.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:l?Rj.USER_BINARY_MESSAGE_RECEIVED:Rj.USER_MESSAGE_RECEIVED,_){e.next=27;break}if(e.t1=this,e.t2=Rj.ON_CUSTOM_MESSAGE,e.t3=p,e.t4=l,!l){e.next=21;break}return e.next=18,YO.b64str2ab(h);case 18:e.t5=e.sent,e.next=22;break;case 21:e.t5=h;case 22:e.t6=e.t5,e.t7={clientId:e.t3,binary:e.t4,message:e.t6},e.t1.emit.call(e.t1,e.t2,e.t7),e.next=43;break;case 27:if(e.t8=this,e.t9=f,e.t10=Zd,e.t11=Zd({},t),e.t12={},!l){e.next=38;break}return e.next=35,YO.b64str2ab(h);case 35:e.t13=e.sent,e.next=39;break;case 38:e.t13=h;case 39:e.t14=e.t13,e.t15={msg:e.t14},e.t16=(0,e.t10)(e.t11,e.t12,e.t15),e.t8.emit.call(e.t8,e.t9,e.t16);case 43:return this._sendP2PMessage(Zd(Zd({},t),{},{dir:Qj.FEEDBACK,msg:""})),wO.reportP2PMsgRecv(this.id,t,{msg_size:r,recv_msg_ts:n,fwd_msg_ts:u}),e.abrupt("break",49);case 46:return this._handleP2PMsgFeedback(t),e.abrupt("break",49);case 48:return e.abrupt("break",49);case 49:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"C2GW",value:function(e,t,r){if(1===e.direction){var n,i=(null===(n=e.id)||void 0===n?void 0:n.join("-"))||"";this._handleAckMessage(i,t[0]||{},r)}else{var o=eI(t,2),a=o[0],s=o[1],c=void 0===s?{}:s;if("RXMediaMsg"===a){var u,d=c.type,l=c.data;switch(null===(u=this._monitor)||void 0===u||u.report("rtc_signaling",{error_code:0,message:r,signaling_event:"on-".concat(d),signaling_type:"Recv",stream_id:"",stream_user_id:"",direction:"down"}),d){case"RSCP":try{var h=JSON.parse(l);Array.isArray(h)&&this.emit(d,h)}catch(p){}break;case"RTT":try{var v=JSON.parse(l);v.length&&this.emit(d,v[0])}catch(p){}break;case"SSC":try{var _=JSON.parse(l);_.length&&this.emit(d,_[0])}catch(p){}}}}}},{key:"_handleHandler",value:function(){var e=this,t=function(e){rG.warn("_handleHandler","dataChannel close",e)},r=function(e){rG.error("_handleHandler","dataChannel error",e)},n=function(t){e._handleMessage(t.data)};return this._dataChannel.addEventListener("close",t),this._dataChannel.addEventListener("error",r),this._dataChannel.addEventListener("message",n),function(){e._dataChannel.removeEventListener("close",t),e._dataChannel.removeEventListener("error",r),e._dataChannel.removeEventListener("message",n)}}},{key:"_genHeader",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Zd({version:2,zip:!1,encrypt:!1,needAck:!0,direction:0,functionType:0,binary:!1},e)}},{key:"_handleAckMessage",value:function(e,t,r){var n,i,o=this._singlingCache.get(e);o&&(this._singlingCache.delete(e),200===t.code?o.success(t):o.error(t),rG.info("Signal",Om(i="<<<<<< [".concat(o.signalingType,"-ack] ")).call(i,e),t));null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:r,signaling_event:null==o?void 0:o.signalingType,signaling_type:"Ack",stream_id:"",stream_user_id:"",direction:"down"})}},{key:"_handleP2PMsgFeedback",value:function(e){var t=this._p2pCache.get(e.id);t&&(this._p2pCache.delete(e.id),e.err===$j.SUCCESS?t.success(e.id,e):t.error(e))}}]),a}(PD.exports.EventEmitter),aG=new Mw("ConnectionManager",3),sG=function(e){DI(o,e);var t,r,n,i=QI(o);function o(e){var t;return Vl(this,o),Jd(tI(t=i.call(this)),"id",void 0),Jd(tI(t),"_monitor",void 0),Jd(tI(t),"_getAccessManager",void 0),Jd(tI(t),"_connectionPool",new $S),Jd(tI(t),"_curConnection",void 0),Jd(tI(t),"_hasReportBrowerWarning",!1),Jd(tI(t),"_reconnectTimer",void 0),Jd(tI(t),"_connecting",!1),Jd(tI(t),"_isFirstTimeConnected",!0),Jd(tI(t),"_feedbackNodes",[]),Jd(tI(t),"_preIceStartTime",-1),Jd(tI(t),"_tcpOnlyTimer",void 0),Jd(tI(t),"_destroyed",!1),t._ctx=e,aG.info("constructor","invoke"),t.id=e.id,t._monitor=VO(t.id),t._getAccessManager=new Kj(e),t}return Ul(o,[{key:"connect",value:function(){var e=this;aG.info("connect","invoke");try{Yj.checkSupported()}catch(t){this.safeEmit("disconnected",t)}this._connecting||(this._onConnectStart("init"),Yf.resolve().then((function(){return e.emit("__onGetIceConfigHook")})),this._getAccess())}},{key:"reconnectByNodeChange",value:(n=Rm(km().mark((function e(t){var r,n,i,o,a,s;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:aG.info("reconnectByNodeChange","invoke %o",t),o=t.nodes,a=t.reason,null===(r=this._monitor)||void 0===r||r.report("rtc_node_change",{error_code:0,message:Mm(t),reason:Mm(a)}),$N.clearAccessNode(this._ctx.appId),s=(null===(n=this._curConnection)||void 0===n||null===(i=n.node.publicIPs[0])||void 0===i?void 0:i.ip)||"",this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart("node change"),Array.isArray(o)&&o.length>0?this._startIceConnect(o):this._getAccess([{feedbackIP:s,feedbackReason:{type:"NODE_CHANGED",reason:a}}]);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"reconnect",value:(r=Rm(km().mark((function e(t){var r,n=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],aG.info("reconnect","invoke. ".concat(r?"ICE over TCP":"")),this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart(t),this._getAccess(void 0,r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){aG.info("destroy","invoke"),this._destroyed=!0,this.safeEmit("disconnected",new mA(vA.OPERATION_CANCEL,"destroy")),OI(CI(o.prototype),"removeAllListeners",this).call(this),this._clearReconnectTimer(),this._clearConnectionPool(),this._getAccessManager.destroy(),this._closeCurrentConnection()}},{key:"_getAccess",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._getAccessManager.getICENode(e).then((function(e){t.emit("__onGetIceSuccessHook",e),t._startIceConnect(e,r)})).catch((function(e){t.safeEmit("disconnected",e)})).finally((function(){t._feedbackNodes=[]}))}},{key:"_startIceConnect",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this._destroyed){aG.info("_startIceConnect","invoke");var n=fw();this._preIceStartTime=WO();var i=this._ctx.joinRoomConfig.useTcpJoin,o=this._ctx.joinRoomConfig.useTcpJoinDelay,a=function(){var e=Rm(km().mark((function e(i){var o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r&&((i=vj(i)).iceConfig.tcpOnly=!0),o={node:i},e.prev=2,a=new Yj(t._ctx,n),o.pc=a,t._connectionPool.set(a.uuid,o),e.next=8,a.connect(i);case 8:return s=e.sent,c=new oG(t.id,s),o.signaling=c,e.next=13,c.sendPingSignaling();case 13:t._onConnectSuccess({node:i,pc:a,signaling:c,dc:s}),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(2),t._onConnectionFailed(o,e.t0);case 19:case"end":return e.stop()}}),e,null,[[2,16]])})));return function(t){return e.apply(this,arguments)}}();this.emit("__onIceConnectStartHook"),e.forEach(a),i&&!r&&(aG.info("_startIceConnect","tcp-only will try after ".concat(o,"ms")),this._tcpOnlyTimer=window.setTimeout((function(){t.emit("connectWidthTcp"),e.forEach((function(e){(e=vj(e)).iceConfig.tcpOnly=!0,a(e)})),delete t._tcpOnlyTimer}),o))}}},{key:"_onConnectSuccess",value:function(e){var t,r,n,i=this;(aG.info("connect","peer_%s connect success.",e.pc.uuid),this.emit("__onIceConnectSuccessHook",e),this._curConnection)?(e.pc.destroy(),null===(t=e.signaling)||void 0===t||t.destroy(),this._connectionPool.delete(e.pc.uuid)):(this._curConnection=e,this._addConnectionHandler(e.pc,e.dc),null===(r=this._monitor)||void 0===r||r.set({connection_id:e.pc.getConnectionId(),rtc_vid:(null===(n=e.node.iceConfig)||void 0===n?void 0:n._abtest_vid)||""}),this._connectionPool.delete(e.pc.uuid),this._feedbackNodes.forEach((function(e){return i._feedbackBySignaling(e)})),this._feedbackNodes=[],this._onConnectEnded(e))}},{key:"_onConnectionFailed",value:function(e,t){var r,n,i=this;(aG.info("connect","peer_%s connect failed. %s",(null===(r=e.pc)||void 0===r?void 0:r.uuid)||"",t.message),this.emit("__onIceConnectFailedHook",e),t.code!==Wj.DESTROY&&t.code!==vA.OPERATION_CANCEL)&&(this._curConnection?this._feedbackBySignaling(e.node):this._feedbackNodes.push(e.node),aG.info("connect","remove cache node"),$N.deleteAccessNode(this._ctx.appId,e.node),e.pc&&(this._connectionPool.delete(e.pc.uuid),e.pc.destroy()),null===(n=e.signaling)||void 0===n||n.destroy());0!==this._connectionPool.size||this._curConnection||this._destroyed||(aG.error("connect","establish peerConnection failed"),this._checkBrowserUA(),WO()-this._preIceStartTime<1e3?(this._clearReconnectTimer(),this._reconnectTimer=window.setTimeout((function(){delete i._reconnectTimer,i._reconnectWithIceFailed(i._feedbackNodes)}),1e3)):this._reconnectWithIceFailed(this._feedbackNodes))}},{key:"_feedbackBySignaling",value:function(e){var t;null===(t=this._curConnection)||void 0===t||t.signaling.sendSignaling("scheduleMessage",{type:"feedback",body:{feedbackIP:e.publicIPs[0].ip,feedbackReason:{type:"ICE_FAILED",reason:{}}}})}},{key:"_reconnectWithIceFailed",value:(t=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._onConnectStart("ice failed"),aG.warn("reconnect","because of ice failed"),this._getAccess(jm(t).call(t,(function(e){return{feedbackIP:e.publicIPs[0].ip,feedbackReason:{type:"ICE_FAILED",reason:{}}}})));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_checkBrowserUA",value:function(){var e;!this._hasReportBrowerWarning&&this._ctx.joinRoomConfig.isBlackBrower()&&(this._hasReportBrowerWarning=!0,null===(e=this._monitor)||void 0===e||e.report("rtc_error",{error_code:jj.BLACK_BROWSER,message:"failed to establish data-channel, and the current browser is on the browser blacklist."}))}},{key:"_onConnectStart",value:function(e){var t;aG.info("_onConnectStart","invoke, reason: ".concat(e)),this._connecting=!0,this.safeEmit(this._isFirstTimeConnected?"connecting":"reconnecting");var r,n=fw();(null===(t=this._monitor)||void 0===t||t.set({connect_session_id:n}),this._isFirstTimeConnected)||(null===(r=this._monitor)||void 0===r||r.report("rtc_reconnect",{error_code:1002,message:"peerconnection reconnecting",reconnect_id:n,reconnect_type:"peerconnection"},{reason:e}))}},{key:"_onConnectEnded",value:function(e){var t;(aG.info("_onConnectEnded","invoke"),this._connecting=!1,this._isFirstTimeConnected=!1,this.safeEmit("connected",e),this._isFirstTimeConnected)||(null===(t=this._monitor)||void 0===t||t.report("rtc_reconnected",{message:"peerconnection reconnected",reconnect_type:"peerconnection"}));e.node.iceConfig.tcpOnly&&(aG.info("_onConnectEnded","use tcp only"),jO(this._ctx.id,"connected_with_tcp_only",Mm(e.node))),this._tcpOnlyTimer&&(window.clearTimeout(this._tcpOnlyTimer),delete this._tcpOnlyTimer),this._clearConnectionPool()}},{key:"_addConnectionHandler",value:function(e,t){var r=this;e.on("disconnect",(function(e){r._closeCurrentConnection(),r._clearReconnectTimer(),navigator.onLine?r.reconnect(e):r._reconnectTimer=window.setTimeout((function(){return r.reconnect(e)}),3e3)}))}},{key:"_closeCurrentConnection",value:function(){var e,t;null===(e=this._curConnection)||void 0===e||e.pc.destroy(),null===(t=this._curConnection)||void 0===t||t.signaling.destroy(),delete this._curConnection}},{key:"_clearConnectionPool",value:function(){var e=this;this._connectionPool.forEach((function(t,r){var n,i;null===(n=t.pc)||void 0===n||n.destroy(),null===(i=t.signaling)||void 0===i||i.destroy(),e._connectionPool.delete(r)}))}},{key:"_clearReconnectTimer",value:function(){this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer)}}]),o}(UD),cG=ad,uG=tc,dG=function(e,t,r,n){for(var i,o=n>1?void 0:n?uG(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&cG(t,r,o),o},lG=new Mw("MediaServerClient",2),hG=6e4,vG=function(e){return e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTED="connected",e.CONNECTING="connecting",e}(vG||{}),_G=function(e,t){lG.info(e,"userId: %o, subAudio: %o, subVideo: %o, audioMid: %o, videoMid: %o, sequenceId: %o",t.userId,t.subAudio,t.subVideo,t.audioMid,t.videoMid,t.sequenceId)},pG=function(e){DI(k,e);var t,r,n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T=QI(k);function k(e){var t;return Vl(this,k),Jd(tI(t=T.call(this)),"id",void 0),Jd(tI(t),"_token",void 0),Jd(tI(t),"_roomId",void 0),Jd(tI(t),"_roomAttributes",void 0),Jd(tI(t),"_vendorConfig",{enableMultiVendor:!1,vendorCode:0}),Jd(tI(t),"_clientId",void 0),Jd(tI(t),"_businessId",void 0),Jd(tI(t),"_userInfo",void 0),Jd(tI(t),"_authorization",void 0),Jd(tI(t),"_sessionId",""),Jd(tI(t),"_liveControlMessage",void 0),Jd(tI(t),"isReconnecting",!1),Jd(tI(t),"_ontrackCallbackMap",new $S),Jd(tI(t),"_subResolves",{}),Jd(tI(t),"supportConcurrent",!1),Jd(tI(t),"_handler",void 0),Jd(tI(t),"_pubSubLock",void 0),Jd(tI(t),"_joinLeaveLock",void 0),Jd(tI(t),"_state",void 0),Jd(tI(t),"_dataChannelSignal",void 0),Jd(tI(t),"_joinRoomStartTs",void 0),Jd(tI(t),"_subConfig",{}),Jd(tI(t),"_monitor",void 0),Jd(tI(t),"_roomProfile",bl.communication),Jd(tI(t),"_context",void 0),Jd(tI(t),"_subStreamQueue",{}),Jd(tI(t),"_connectionManager",void 0),Jd(tI(t),"_joinRoom5xxTimer",void 0),Jd(tI(t),"_joinResolve",void 0),Jd(tI(t),"_joinReject",void 0),lG.info("constructor","invoke"),t.id=e.id,t._monitor=VO(t.id),t._pubSubLock=new Dj("pubSubLock"),t._joinLeaveLock=new Dj("joinLeaveLock"),t._state="disconnected",t._roomAttributes={multiChatMode:!1,bigRoomMode:!1},t._context=e,t.on("SUB_END",(function(e){return t._handleSubStreamQueue(e)})),t._connectionManager=new sG(e),t._addConnectHandler(),t}return Ul(k,[{key:"_addSignalEventHandler",value:function(){var e,t,r=this;[Rj.ON_ADD_STREAM,Rj.ON_ADD_STREAM_LIST,Rj.ON_REMOVE_STREAM,Rj.ON_REMOVE_STREAM_LIST,Rj.USER_CONNECTION,Rj.USER_CONNECTION_LIST,Rj.USER_DISCONNECTION,Rj.USER_DISCONNECTION_LIST,Rj.ON_UPDATE_STREAM_ATTRIBUTES,Rj.ON_UPDATE_ROOM_ATTRIBUTES,Rj.ON_PUSH_TRACK,Rj.ON_REMOVE_TRACK,Rj.ON_CUSTOM_MESSAGE,Rj.USER_MESSAGE_RECEIVED,Rj.USER_BINARY_MESSAGE_RECEIVED,Rj.POST_PROCESSING_MESSAGE,Rj.ON_USER_TOKEN_WILL_EXPIRE,Rj.STREAM_CONTROL_MESSAGE,Rj.ON_UPDATE_USER_ATTRIBUTES,Rj.ON_SPEAKER_CHANGE,Aj.RSCP,Aj.RTT,Rj.ON_STREAM_FAILED,Rj.ON_NOTIFY_RECONNECT,Aj.SSC,Rj.ON_FORWARD_DST_ROOM_USER_KICK].forEach((function(e){var t;null===(t=r._dataChannelSignal)||void 0===t||t.on(e,(function(t){r.safeEmit(e,t)}))})),null===(e=this._dataChannelSignal)||void 0===e||e.on(Rj.NODE_CHANGE,(function(e){r._connectionManager.reconnectByNodeChange(e)})),null===(t=this._dataChannelSignal)||void 0===t||t.on(Rj.ON_NOTIFY_RECONNECT,(function(){r._connectionManager.reconnect("recv notifyReconnect signaling")}))}},{key:"_removeSignalEventHandler",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.removeAllListeners(),null===(t=this._handler)||void 0===t||t.removeAllListeners()}},{key:"connectionState",get:function(){return this._state},set:function(e){this._state!==e&&(this.safeEmit(wj.ON_CONNECTION_STATE_CHANGE,{prev:this._state,next:e}),this._state=e)}},{key:"businessId",set:function(e){this._businessId=e}},{key:"setLiveControlMessage",value:function(e){this._liveControlMessage=e}},{key:"connect",value:function(){var e=this;return new Yf((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"join",value:(E=Rm(km().mark((function e(t){var r,n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return lG.info("join()","info: %o",t),this._token=t.token,this._roomId=t.roomId,this._clientId=t.userInfo.userId,this._businessId=t.userInfo.businessId,this._userInfo=t.userInfo,this._roomProfile=t.roomProfile,this._reportJoinRoomStart(),e.next=10,new Yf((function(e,t){n._joinResolve=e,n._joinReject=t,(n._handler?Yf.resolve():n.connect()).then((function(){n._callJoinRoom()})).catch((function(e){var t=Array.isArray(e)&&e.length>0?e[0]:e;n._joinRoomFailed(t.message)}))}));case 10:return r=e.sent,e.abrupt("return",r);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"_callJoinRoom",value:(b=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,v,_,p,f,m=this,g=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=g.length>0&&void 0!==g[0]&&g[0],lG.info("_callJoinRoom","invoke"),e.t0=YO.token2auth(this._context.appId,this._roomId,this._clientId,this._token),e.t1=this._sessionId,e.t2=Date.now(),e.t3=this._liveControlMessage,e.t4={extra_info:this._userInfo.extraInfo,role:this._userInfo.role},e.next=9,null===(t=this._handler)||void 0===t?void 0:t.getDefaultSdp();case 9:return e.t5=e.sent,e.next=12,CM(cD("PUB_SUB_MODE"));case 12:return e.t6=e.sent,e.t7=window.navigator.userAgent,e.t8=aD.VERSION,e.t9=$N.getDeviceId(),e.t10=this._context.appId,e.t11=this._roomId,e.t12=this._clientId,e.t13=this._businessId,e.t14=this._context.useCloudProxy,e.t15=Vj[this._roomProfile]?"".concat(Vj[this._roomProfile][0]):"0",e.t16={supportedCodecs:e.t6,deviceType:"web",userAgent:e.t7,sdkVersion:e.t8,deviceId:e.t9,appId:e.t10,roomId:e.t11,userId:e.t12,businessId:e.t13,enableCloudProxy:e.t14,channelProfile:e.t15},e.t17={supportTokenExpireCallBack:!0,enableSceneConfigV2:!0,enableUnBundleMode:!0,enableAudioMux:!0,enableBigRoomMode:!0,needNegotiateSDP:!0,supportMultiVendor:!0},n={Authorization:e.t0,sessionId:e.t1,timestamp:e.t2,controlMessage:e.t3,userAttributes:e.t4,sdpInfo:e.t5,params:e.t16,options:e.t17},e.prev=25,e.t18=jO,e.t19=this.id,e.t20=Mm,e.next=31,xM();case 31:e.t21=e.sent,e.t22=cD("PUB_SUB_MODE")||"recv_and_send",e.t23={supportedCodecsSdpOffer:e.t21,pubSubMode:e.t22},e.t24=(0,e.t20)(e.t23),(0,e.t18)(e.t19,"MediaClient.internalGetSupportedCodecsSdpOffer",e.t24),e.next=40;break;case 38:e.prev=38,e.t25=e.catch(25);case 40:return Yf.resolve().then((function(){return m.emit("onSendingJoinMessageHook")})),e.prev=41,o=r?"reconnected":"joinRoom",e.next=45,this._joinRoomWithRetry(o,n);case 45:a=e.sent,lG.success("join","send join message success"),s=a.config||{},c=s.engine_WEB,this.connectionState="connected",this._authorization=n.Authorization,$N.setEngineWebConfig(this._context.appId,this._roomId,c),this._context&&(this._context.serverConfig={videoCodec:(null==c?void 0:c.video_codec)||"H264",audioRed:!(null==c||!c.pub_audio_red),muteReplaceUnsub:!(null===(u=a.config)||void 0===u||!u.mute_replace_unsub),simulcastOnDemand:!(EN||!1===(null===(d=a.config)||void 0===d||null===(l=d.engine_VPM)||void 0===l||null===(h=l.ondemand)||void 0===h?void 0:h.enable)),forceUniHandler:1===(null==a||null===(v=a.config)||void 0===v||null===(_=v.vendor_param)||void 0===_?void 0:_.vendor_stream_sub_mode)},"boolean"==typeof(null==c?void 0:c.av_sync)&&(this._context.avSync=c.av_sync)),a.vendorConfig&&(this._vendorConfig=a.vendorConfig),bV.audioStallConfig=c,null!=a&&null!==(i=a.relayMessage)&&void 0!==i&&i.sdp&&(null===(p=this._handler)||void 0===p||p.createAVMlineAnswerTpl(a.relayMessage.sdp)),this.emit("joinSuccess",{joinRes:a,reconnect:r}),this._joinRoomSuccess(a),e.next=62;break;case 59:e.prev=59,e.t26=e.catch(41),(null===e.t26||void 0===e.t26?void 0:e.t26.code)>=700&&(null===e.t26||void 0===e.t26?void 0:e.t26.code)<800?this._joinRoomFailed("token_error",vA.INVALID_TOKEN):(null===e.t26||void 0===e.t26?void 0:e.t26.code)===vA.TIME_OUT&&this._context.joinRoomConfig.useTcpAfterJoinTimeout?(f="joinRoom timeout, retry with tcp only",lG.error("join",f),this.safeEmit(Pj.ON_REJOIN_WITH_TCP),this._connectionManager.reconnect(f,!0)):e.t26.code===vA.OPERATION_CANCEL&&"connecting"===this.connectionState||this._joinRoomFailed((null===e.t26||void 0===e.t26?void 0:e.t26.message)||"signaling_error");case 62:case"end":return e.stop()}}),e,this,[[25,38],[41,59]])}))),function(){return b.apply(this,arguments)})},{key:"publish",value:(S=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k,I,R,A,w,C,x,O,N,D,P=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(lG.info("publish()","localStream: %o",t),r=t.videoTrack,n=t.audioTrack,i=WO(),o="",a="",s=this._handler,e.prev=7,!this._vendorConfig.enableMultiVendor){e.next=20;break}return T=new Yj(this._context,""),t.vendorHandler=new Bj(this._context,T),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),e.next=14,t.vendorHandler.publish(t);case 14:E=e.sent,(s=t.vendorHandler).on("ice_state",(function(e){P.emit(wj.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:ll.CONNECTION_STATE_CONNECTING,connected:ll.CONNECTION_STATE_CONNECTED,disconnected:ll.CONNECTION_STATE_RECONNECTING}[e],userId:P._clientId})})),T.once("disconnect",Rm(km().mark((function e(){var r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=s)||void 0===r||r.removeAllListeners(),"connected"===(null===(n=P._handler)||void 0===n||null===(i=n.pc)||void 0===i?void 0:i.iceConnectionState)){e.next=4;break}return lG.error("vendor ice failed",t.streamId),e.abrupt("return");case 4:t.clean(),P.unpublish(t),P.publish(t);case 7:case"end":return e.stop()}}),e)})))),e.next=23;break;case 20:return e.next=22,null===(k=this._handler)||void 0===k?void 0:k.publish(t);case 22:E=e.sent;case 23:if(null===(c=t.observer)||void 0===c||c.setHandler(s),E){e.next=26;break}throw new mA(vA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 26:if("H264"!==(null===(u=this._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.videoCodec)){e.next=32;break}return e.next=29,VM();case 29:if(e.sent){e.next=32;break}throw new mA(vA.PUBLISH_FAILED,"h264 is not supported");case 32:return o=E.audioMid,a=E.videoMid,t.pubAttributes={localaudio:!!n,localvideo:!!r,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(r instanceof MU),extaudio:!!(n instanceof LU)},I={attributes:Zd({videoDescriptions:E.videoDescriptions},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:o,videoMid:a,sdpInfo:{msid:t.stream.id,type:E.type,sdp:E.partialSdp,semantics:E.semantics},peerConnectionMode:null===(l=E)||void 0===l?void 0:l.peerConnectionMode,supportMultiVendor:!0},(R=!this._vendorConfig.enableMultiVendor&&t.enableSimulcast&&(null===(h=this._context)||void 0===h||null===(v=h.serverConfig)||void 0===v?void 0:v.simulcastOnDemand)&&(null===(_=E.subVideoDescriptions)||void 0===_?void 0:_.length))&&(I.attributes.subVideoDescriptions=E.subVideoDescriptions),null!==(p=E)&&void 0!==p&&p.peerConnectionId&&(I.peerConnectionId=E.peerConnectionId),e.next=41,null===(f=this._dataChannelSignal)||void 0===f?void 0:f.sendSignaling("publish",I);case 41:if(200===(null==(A=e.sent)?void 0:A.code)){e.next=44;break}throw new mA(vA.PUBLISH_FAILED,(null==A?void 0:A.message)||"publish failed");case 44:if(null===(m=this._monitor)||void 0===m||m.report("rtc_recv_answer",{error_code:0,answer_type:null==A?void 0:A.relayMessage.type,sequence_id:(null==A||null===(g=A.relayMessage)||void 0===g?void 0:g.sequenceId)||0,message:null==A||null===(y=A.relayMessage)||void 0===y?void 0:y.sdp,direction:"up",stream_id:"",stream_user_id:"",pc_session_id:(null===(S=s)||void 0===S?void 0:S.peerConnectionId)||""}),w=new Yf((function(e,r){var n,i,c,u,d,l;null===(n=s)||void 0===n||n.handleAck({action:OV.publish,streamId:A.streamId,audioMid:o,videoMid:a,audioTransceiverInit:null===(i=E)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(c=E)||void 0===c?void 0:c.videoTransceiverInit,signalingAck:{sdp:null==A||null===(u=A.relayMessage)||void 0===u?void 0:u.sdp,sequenceId:null==A||null===(d=A.relayMessage)||void 0===d?void 0:d.sequenceId},sdp:null===(l=E)||void 0===l?void 0:l.sdp,stream:t,onSuccess:function(){lG.info("publish()","publish success"),e(0)}})})),e.t0=!EN,!e.t0){e.next=50;break}return e.next=50,w;case 50:return R&&this.emit(Aj.RSCP,[{StreamIds:[t.stream.id],Metadata:{VideoIndex:0}}],!0),t.streamId=A.streamId,t.videoMid=a,t.audioMid=o,t.subVideoDescriptions=E.subVideoDescriptions,null===(b=this._monitor)||void 0===b||b.report("rtc_publish_stat",{result:"success",is_screen:"0",start:i,message:"unknown"}),e.abrupt("return");case 59:return e.prev=59,e.t1=e.catch(7),e.t1 instanceof Error?null===(x=this._monitor)||void 0===x||x.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:i,message:Om(O="".concat(e.t1.name,": ")).call(O,e.t1.message)}):e.t1 instanceof mA&&(null===(N=this._monitor)||void 0===N||N.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:i,message:Om(D="".concat(e.t1.code,": ")).call(D,e.t1.message)})),e.next=64,null===(C=s)||void 0===C?void 0:C.rollback(t.stream.id,t);case 64:throw e.t1;case 65:case"end":return e.stop()}}),e,this,[[7,59]])}))),function(e){return S.apply(this,arguments)})},{key:"updatePubTrack",value:(y=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k,I,R,A,w,C,x,O;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(lG.info("updatePubTrack()","localStream: %o",t),n=t.videoTrack,i=t.audioTrack,o=t.pubAudio,a=t.pubVideo,s=t.vendorHandler||this.handler,c=null==i?void 0:i.getTrack("preprocessing"),u=null==n?void 0:n.getTrack("preprocessing"),!a||!u){e.next=10;break}return e.next=8,null===(d=t.videoTransceiver)||void 0===d?void 0:d.sender.replaceTrack(u);case 8:e.next=12;break;case 10:return e.next=12,null===(l=t.videoTransceiver)||void 0===l?void 0:l.sender.replaceTrack(null);case 12:if(null==s||s.updateMaxBitrate(t),!o||!c){e.next=20;break}return v=i.mixType,(_=i.mixedAudioTrack)&&v!==Nl.PLAYOUT&&c.enabled&&(c=_),e.next=18,null===(h=t.audioTransceiver)||void 0===h?void 0:h.sender.replaceTrack(c);case 18:e.next=23;break;case 20:return e.next=22,null===(p=t.audioTransceiver)||void 0===p?void 0:p.sender.replaceTrack(null);case 22:jO(this.id,"MediaClient.updatePubTrack(audio)","null");case 23:try{jO(this.id,"MediaClient.updatePubTrack",Mm({audioStreamTrack:_N(c),videoStreamTrack:_N(u)}))}catch(uW){}for(m={},g=0,y=RA(f={localaudio:!!i,localvideo:!!n,videostream:a,audiostream:o,extvideo:!!(n instanceof MU),extaudio:!!(i instanceof LU)});g<y.length;g++)S=eI(y[g],2),b=S[0],(E=S[1])!==dI(t.pubAttributes,b)&&XD(m,b,E);if(an(m).length){e.next=29;break}return e.abrupt("return");case 29:return t.observer&&(T=t.observer,k=m.audiostream,I=m.videostream,R=m.localaudio,A=m.localvideo,w=m.extaudio,C=m.extvideo,void 0!==A?void 0!==C?T.setPushVideo(C):T.setEnableVideo(A):void 0!==I&&T.setUnmuteVideo(I),void 0!==R?void 0!==w?T.setPushAudio(w):T.setEnableAudio(R):void 0!==k&&T.setUnmuteAudio(k)),t.pubAttributes=f,x={roomId:this._roomId,streamId:t.streamId,attributes:m},e.next=34,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateStreamAttributes",x);case 34:if(200===(null==(O=e.sent)?void 0:O.code)){e.next=37;break}throw new mA(vA.UPDATE_TRACK_FAILED,(null==O?void 0:O.message)||"update track failed");case 37:if(!EN){e.next=40;break}return e.next=40,null==s?void 0:s.setCurrentDescription();case 40:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"updateToken",value:(g=Rm(km().mark((function e(t){var r,n,i,o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(lG.info("updateToken()","newToken: %o",t),this._token=t,this._context.appId&&null!==(r=this._userInfo)&&void 0!==r&&r.userId&&this._roomId){e.next=4;break}return e.abrupt("return");case 4:return i={roomId:this._roomId,userId:null===(n=this._userInfo)||void 0===n?void 0:n.userId,appId:this._context.appId,token:"Bearer ".concat(t)},e.prev=5,e.next=8,null===(o=this._dataChannelSignal)||void 0===o?void 0:o.sendSignaling("updateToken",i);case 8:if(200===(null==(a=e.sent)?void 0:a.code)){e.next=11;break}throw new mA(vA.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 11:e.next=16;break;case 13:throw e.prev=13,e.t0=e.catch(5),new mA(vA.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 16:case"end":return e.stop()}}),e,this,[[5,13]])}))),function(e){return g.apply(this,arguments)})},{key:"unpublish",value:(m=Rm(km().mark((function e(t){var r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return lG.info("unpublish()","localStream: %o",t),n={roomId:this._roomId,initStreamId:t.initStreamId,streamId:t.streamId},null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unpublish",n),i=t.vendorHandler||this._handler,e.next=6,null==i?void 0:i.handleAck({action:OV.unpublish,audioMid:t.audioMid,videoMid:t.videoMid,stream:t,streamId:t.streamId});case 6:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"subscribe",value:(f=Rm(km().mark((function e(t,r,n){var i=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Yf(function(){var e=Rm(km().mark((function e(o,a){var s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k,I,R,A,w,C,x,O,N,D,P,M,L,U,V,F,B,j,G,H,z,K,X,W,q,Y,J,Q,Z,$;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.streamState!==RV.SUB_ED){e.next=2;break}return e.abrupt("return",i._updateSubTrack(t,r,Uj.SUB).then(o,a));case 2:if(t.streamState!==RV.SUB_ING){e.next=7;break}return i._subStreamQueue[t.streamId]||(i._subStreamQueue[t.streamId]=[]),lG.info("_subStreamQueue","streamId: %o, enqueue",t.streamId),i._subStreamQueue[t.streamId].push({fn:i.subscribe,args:[t,r,n],resolve:o,reject:a}),e.abrupt("return");case 7:if(lG.info("subscribe()","mediaType: %o",r),_G("subscribe()",t),t.streamState=RV.SUB_ING,c=!1,u=!1,dN(r)&&(u=!0),lN(r)&&(c=!0),c||!i.multiChatMode()){e.next=17;break}return t.streamState=RV.INIT,i.emit("SUB_END",t.streamId),e.abrupt("return",o(null));case 17:if(d=WO(),l=t.subVideo,h=[],v=!i.multiChatMode(),i._subResolves[t.streamId]||(i._subResolves[t.streamId]=[]),h.push(new Yf((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mA(vA.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),hG);t.on("ontrack",(function r(i){"video"===i.mediaType&&(lG.success("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v&&h.push(new Yf((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mA(vA.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),hG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(lG.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),_=function(e){t.ontrack(e)},null===(s=i._handler)||void 0===s||s.on("ontrack",_),i._ontrackCallbackMap.set(t,_),p=i._handler,e.prev=28,null!==(f=i._context.serverConfig)&&void 0!==f&&f.forceUniHandler||!t.enableVendorMode){e.next=42;break}return V=new Yj(i._context,""),t.vendorHandler=new Bj(i._context,V),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),(p=t.vendorHandler).on("ontrack",_),e.next=37,t.vendorHandler.subscribe(t);case 37:U=e.sent,p.on("ice_state",(function(e){i.emit(wj.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:ll.CONNECTION_STATE_CONNECTING,connected:ll.CONNECTION_STATE_CONNECTED,disconnected:ll.CONNECTION_STATE_RECONNECTING}[e],userId:t.userId})})),V.once("disconnect",Rm(km().mark((function e(){var r,n,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=p)||void 0===r||r.removeAllListeners(),"connected"===(null===(n=i._handler)||void 0===n||null===(o=n.pc)||void 0===o?void 0:o.iceConnectionState)){e.next=4;break}return lG.error("vendor ice failed",t.streamId),e.abrupt("return");case 4:return t.resetHasSubscribed(),i.unsubscribe(t,ul.AUDIO_AND_VIDEO,!0),e.next=8,i.subscribe(t,t.subMediaType);case 8:i.emit(Pj.RESUBSCRIBE,{stream:t});case 9:case"end":return e.stop()}}),e)})))),e.next=45;break;case 42:return e.next=44,null===(F=i._handler)||void 0===F?void 0:F.subscribe(t,{multiChatMode:i.multiChatMode()});case 44:U=e.sent;case 45:if(null===(m=t.observer)||void 0===m||m.setHandler(p),U){e.next=48;break}throw new mA(vA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 48:return B=U.audioMid,j=U.videoMid,t.subVideo=c,G={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},H={audio:!i.multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:j,audioMid:B,sdpInfo:{sdp:null===(g=U)||void 0===g?void 0:g.partialSdp,semantics:null===(y=U)||void 0===y?void 0:y.semantics,type:null===(S=U)||void 0===S?void 0:S.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!i.multiChatMode()||u,video:c},qualityLayer:G},extra:{enableSendRTT:!0},peerConnectionMode:null===(b=U)||void 0===b?void 0:b.peerConnectionMode,supportMultiVendor:!0},null!==(E=U)&&void 0!==E&&E.peerConnectionId&&(H.peerConnectionId=U.peerConnectionId),z=i._context||{},K=z.subscribeFallbackOption,X=z.userPriority,"number"==typeof K&&(H.config.fallbackOption=K),X.has(t.userId)&&(H.config.priority=X.get(t.userId)),null!==(T=U)&&void 0!==T&&T.allSsrc&&(H.extra.subscribeSSRC=U.allSsrc),e.next=60,null===(k=i._dataChannelSignal)||void 0===k?void 0:k.sendSignaling("subscribe",H);case 60:if(200===(null==(W=e.sent)?void 0:W.code)){e.next=63;break}throw new mA(vA.SUBSCRIBE_FAILED,(null==W?void 0:W.message)||"subscribe failed");case 63:return q=null==W?void 0:W.relayMessage,Y=q.audioMid,J=q.videoMid,Jd(I={},B,Y),Jd(I,j,J),Q=I,lG.info("sub midmap",t.userId,Q),t.videoMid=j,t.audioMid=B,t.subMediaType=r,t.streamState=RV.SUB_ED,t.subLayer=G,null===(R=i._monitor)||void 0===R||R.report("rtc_recv_answer",{error_code:0,answer_type:null==W||null===(A=W.relayMessage)||void 0===A?void 0:A.type,sequence_id:(null==W||null===(w=W.relayMessage)||void 0===w?void 0:w.sequenceId)||0,message:null==W||null===(C=W.relayMessage)||void 0===C?void 0:C.sdp,direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:(null===(x=p)||void 0===x?void 0:x.peerConnectionId)||""}),e.next=74,null===(O=p)||void 0===O?void 0:O.handleAck({action:OV.subscribe,streamId:t.streamId,audioMid:B,videoMid:j,audioTransceiverInit:null===(N=U)||void 0===N?void 0:N.audioTransceiverInit,videoTransceiverInit:null===(D=U)||void 0===D?void 0:D.videoTransceiverInit,signalingAck:{sdp:null==W||null===(P=W.relayMessage)||void 0===P?void 0:P.sdp,sequenceId:null==W||null===(M=W.relayMessage)||void 0===M?void 0:M.sequenceId},stream:t,sdp:U.sdp,generatorSsrc:!!U.allSsrc});case 74:return e.next=76,Yf.all(h);case 76:i.multiChatMode()||(t.subAudio=u),null===(L=i._monitor)||void 0===L||L.report("rtc_subscribe_stat",{result:"success",start:d,message:"unknown",stream_user_id:t.userId}),i._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return i.emit("onRemoteStreamStats",e)}),p),o(null),i.emit("SUB_END",t.streamId),e.next=92;break;case 83:return e.prev=83,e.t0=e.catch(28),e.t0 instanceof Error&&(null===($=i._monitor)||void 0===$||$.report("rtc_subscribe_stat",{result:"fail",start:d,message:e.t0.message,stream_user_id:t.userId})),t.subVideo=l,t.streamState=RV.INIT,e.next=90,null===(Z=p)||void 0===Z?void 0:Z.rollback(t.streamId,t);case 90:a(e.t0),i.emit("SUB_END",t.streamId);case 92:case"end":return e.stop()}}),e,null,[[28,83]])})));return function(t,r){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e)}))),function(e,t,r){return f.apply(this,arguments)})},{key:"_handleSubStreamQueue",value:function(e){var t,r=this;if(null!==(t=this._subStreamQueue[e])&&void 0!==t&&t.length){lG.info("_subStreamQueue","streamId: %o, exec",e);var n=this._subStreamQueue[e].shift(),i=n.fn,o=n.args,a=n.resolve,s=n.reject;i.apply(this,o).then(a,s).finally((function(){return r._handleSubStreamQueue(e)}))}else lG.warn("_subStreamQueue","streamId: %o, END",e)}},{key:"controlMessage",value:(p=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return lG.info("controlMessage()","params: %o",t),n=t,"transcode"===t.type&&(n.roomId=this._roomId),e.next=5,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("controlMessage",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"updateUserAttributes",value:(_=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return lG.info("updateUserAttributes()","attributes: %o",t),e.next=3,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateUserAttributes",{roomId:this._roomId,sessionId:this._sessionId,attributes:t});case 3:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"updateSubTrack",value:(v=Rm(km().mark((function e(t,r,n){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._updateSubTrack(t,r,n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return v.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(h=Rm(km().mark((function e(t,r){var n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(lG.info("updateSubTrack()","subLayer: %o",r),t.subLayer.spatialLayer!==r.spatialLayer||t.subLayer.spatialSubLayer!==r.spatialSubLayer){e.next=4;break}return lG.warn("updateSubTrack()","subLayer no change"),e.abrupt("return");case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{qualityLayer:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(o=e.sent)?void 0:o.code)){e.next=10;break}throw new mA(vA.UPDATE_TRACK_FAILED,(null==o?void 0:o.message)||"update track failed");case 10:return t.subLayer=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"updateSubPriority",value:(l=Rm(km().mark((function e(t,r){var n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(lG.info("updateSubPriority()","priority: %o",r),t.priority!==r){e.next=4;break}return lG.warn("updateSubPriority()","priority no change"),e.abrupt("return",t);case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{priority:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(o=e.sent)?void 0:o.code)){e.next=10;break}throw new mA(vA.UPDATE_TRACK_FAILED,(null==o?void 0:o.message)||"update track failed");case 10:return t.priority=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"_updateSubTrack",value:(d=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d,l;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(lG.info("updateSubTrack()","mediaType: %o",r),_G("updateSubTrack()",t),!this.multiChatMode()||r!==ul.AUDIO){e.next=5;break}return lG.warn("updateSubTrack","multiChatMode mediaType only audio"),e.abrupt("return",t);case 5:return a=0,a=n===Uj.SUB?t.subMediaType|r:t.subMediaType-(t.subMediaType&r),lG.info("updateSubTrack","prev: %o, direction: %o, mediaType: %o, newMediaType: %o",t.subMediaType,n,r,a),t.subMediaType===a&&lG.info("updateSubTrack","mediaType no change"),s=!1,c=!1,dN(a)&&(c=!0),lN(a)&&(s=!0),u={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:s,audio:!!this.multiChatMode()||c}}},e.next=15,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("updateSubscribe",u);case 15:if(200===(null==(d=e.sent)?void 0:d.code)){e.next=18;break}throw new mA(vA.UPDATE_TRACK_FAILED,(null==d?void 0:d.message)||"update track failed");case 18:return this.multiChatMode()||(null===(l=t.observer)||void 0===l||l.setUnmuteAudio(c),t.subAudio=c),null===(o=t.observer)||void 0===o||o.setUnmuteVideo(s),t.subVideo=s,t.subMediaType=a,e.abrupt("return",t);case 23:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return d.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(u=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return lG.info("subscribe4pushTrack()","streamInfo: %o",r),_G("subscribe4pushTrack()",t),t.subAudio=!0,e.next=5,null===(n=this._handler)||void 0===n?void 0:n.subscribe(t,{multiChatMode:this.multiChatMode()});case 5:if(a=e.sent){e.next=8;break}throw new mA(vA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 8:return s=a.audioMid,c=a.videoMid,(u=[]).push(new Yf((function(e,r){var n=setTimeout((function(){return r(new mA(vA.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),hG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(lG.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),d=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",d),this._ontrackCallbackMap.set(t,d),e.next=17,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:OV.pushtrack,streamId:t.streamId,audioMid:s,videoMid:c,stream:t,audioTransceiverInit:null==a?void 0:a.audioTransceiverInit,videoTransceiverInit:null==a?void 0:a.videoTransceiverInit,signalingAck:null==r?void 0:r.message,sdp:a.sdp});case 17:return e.next=19,Yf.all(u);case 19:this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return l.emit("onRemoteStreamStats",e)}),this._handler);case 20:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(c=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(_G("unsubscribe4removeTrack()",t),lG.info("unsubscribe4removeTrack()","sequenceId: ",r.sequenceId,"trackType: ",n),!(r.sequenceId<t.sequenceId)){e.next=5;break}return lG.warn("unsubscribe4removeTrack()","sequenceId return"),e.abrupt("return");case 5:return u=!!((c=n+1)&ul.AUDIO),d=!!(c&ul.VIDEO),e.next=10,null===(i=this._handler)||void 0===i?void 0:i.handleAck({action:OV.removetrack,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 10:null===(o=t.observer)||void 0===o||o.setPushTrack(!1),null===(a=t.observer)||void 0===a||a.setUnmuteAudio(!u),t.subAudio=!u,null===(s=t.observer)||void 0===s||s.setUnmuteVideo(!d),t.subVideo=!d,t.subMediaType=t.subMediaType-(t.subMediaType&c),t.virtual&&(t.clean(),t.resetHasSubscribed(),t.statsReport.unsubscribe());case 17:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return c.apply(this,arguments)})},{key:"unsubscribe",value:(s=Rm(km().mark((function e(t,r){var n,i,o=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>2&&void 0!==o[2]&&o[2],_G("unsubscribe()",t),!n){e.next=4;break}return e.abrupt("return",this._unsubscribe(t,r));case 4:if(!this.multiChatMode()||!lN(r)){e.next=6;break}return e.abrupt("return",this._unsubscribe(t,r));case 6:if(i=t.subMediaType-(t.subMediaType&r),this.multiChatMode()||i!==cV.NONE){e.next=9;break}return e.abrupt("return",this._unsubscribe(t,r));case 9:return e.abrupt("return",this._updateSubTrack(t,r,Uj.UNSUB));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"_unsubscribe",value:(a=Rm(km().mark((function e(t,r){var n,i,o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subConfig.muteReplaceUnsub){e.next=2;break}return e.abrupt("return",this._updateSubTrack(t,r,Uj.UNSUB));case 2:return a={roomId:this._roomId,streamId:t.streamId,userId:t.userId},s=t.vendorHandler||this.handler,null===(n=this._dataChannelSignal)||void 0===n||n.sendSignaling("unsubscribe",a).catch((function(){})),t.streamState=RV.INIT,this._subStreamQueue[t.streamId]&&(this._subStreamQueue[t.streamId].forEach((function(e){return(0,e.resolve)(null)})),delete this._subStreamQueue[t.streamId]),t.subVideo=!1,null===(i=t.observer)||void 0===i||i.setSubscribeVideo(!1),!this.multiChatMode()&&(null===(o=t.observer)||void 0===o||o.setSubscribeAudio(!1)),e.next=12,null==s?void 0:s.handleAck({action:OV.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 12:c=e.sent,this._subResolves[c]&&this._subResolves[c].forEach((function(e){return e(0)})),lG.info("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 18:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"removeOnTrackListener",value:function(e){var t=this._ontrackCallbackMap.get(e);if(t){var r=e.vendorHandler||this._handler;null==r||r.off("ontrack",t),this._ontrackCallbackMap.delete(e)}}},{key:"handleRemoveStream",value:(o=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(_G("handleRemoveStream()",t),t.subVideo=!1,t.streamState!==RV.INIT){e.next=4;break}return e.abrupt("return");case 4:this.unsubscribe(t,ul.AUDIO_AND_VIDEO,!0);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"leave",value:(i=Rm(km().mark((function e(){var t,r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(lG.info("leave()"),this._stopJoinRoom5xxRetry(),this._joinRoomFailed("leave_room"),"connected"!==this.connectionState){e.next=20;break}return t={Authorization:this._authorization,roomId:this._roomId,sessionId:this._sessionId},e.next=7,this._joinLeaveLock.lock();case 7:return r=e.sent,e.prev=8,e.next=11,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("leaveRoom",t);case 11:r(),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(8),r(),e.t0;case 18:e.next=21;break;case 20:return e.abrupt("return",Yf.reject(new mA(vA.NOT_CONNECTED_YET,"server not connected")));case 21:case"end":return e.stop()}}),e,this,[[8,14]])}))),function(){return i.apply(this,arguments)})},{key:"subscribePublicStream",value:(n=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this._handler)||void 0===r?void 0:r.subscribe(t,{multiChatMode:!1});case 2:if(s=e.sent){e.next=5;break}throw new mA(vA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return c=WO(),u=s.audioMid,d=s.videoMid,e.t0=this._context.appId,e.t1=t.streamId,e.t2=u,e.t3=d,e.t4={sdp:null==s?void 0:s.partialSdp,semantics:null==s?void 0:s.semantics,type:null==s?void 0:s.type},e.next=15,CM();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=aD.VERSION,e.t8=$N.getDeviceId(),e.t9=this._context.appId,e.t10=this._businessId,e.t11=this._context.useCloudProxy,e.t12={supportedCodecs:e.t5,deviceType:"web",userAgent:e.t6,sdkVersion:e.t7,deviceId:e.t8,appId:e.t9,businessId:e.t10,enableCloudProxy:e.t11},e.t13={enableMediaType:{audio:!0,video:!0},qualityLayer:{spatialLayer:0,temporalLayer:0}},l={appId:e.t0,streamId:e.t1,audio:!0,video:!0,data:!0,audioMid:e.t2,videoMid:e.t3,sdpInfo:e.t4,params:e.t12,config:e.t13},e.next=27,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("startPullStream",l);case 27:return h=e.sent,v=[],this._subResolves[t.streamId]=[],v.push(new Yf((function(e,r){g._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mA(vA.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),hG);t.on("ontrack",(function r(i){"video"===i.mediaType&&(lG.success("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v.push(new Yf((function(e,r){g._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mA(vA.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),hG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(lG.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),_=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",_),this._ontrackCallbackMap.set(t,_),p=null==h?void 0:h.relayMessage,f=p.sequenceId,m=p.sdp,t.videoMid=d,t.audioMid=u,t.sequenceId=f,t.streamState=RV.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=44,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:OV.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:{sdp:m,sequenceId:f},stream:t});case 44:return e.next=46,Yf.all(v);case 46:null===(a=this._monitor)||void 0===a||a.report("rtc_subscribe_stat",{result:"success",start:c,message:"unknown",stream_user_id:t.userId}),this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return g.emit("onRemoteStreamStats",e)}),this._handler);case 48:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unsubscribePublicStream",value:(r=Rm(km().mark((function e(t){var r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return _G("unsubscribePublicStream()",t),n={appId:this._context.appId,streamId:t.streamId},e.prev=2,e.next=5,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("stopPullStream",n);case 5:e.next=9;break;case 7:e.prev=7,e.t0=e.catch(2);case 9:return t.streamState=RV.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._handler)||void 0===r?void 0:r.handleAck({action:OV.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 14:t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;lG.info("destroy()"),this._joinRoomFailed("leave_room"),this._token=void 0,this._roomId=void 0,this._clientId=void 0,this._authorization=void 0,this._sessionId="",this._stopJoinRoom5xxRetry(),null===(e=this._handler)||void 0===e||e.destroy(),this._handler=void 0,null===(t=this._dataChannelSignal)||void 0===t||t.destroy(),this._dataChannelSignal=void 0,this._connectionManager.destroy(),null===(r=this._monitor)||void 0===r||r.set({connection_id:""}),this._removeSignalEventHandler(),this.removeAllListeners(),this.connectionState="disconnected"}},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendP2PMessage({to:e,from:this._userInfo.userId,room:this._roomId,app:this._context.appId,msg:t})}},{key:"sendRoomMessage",value:function(e){var t;return null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("customMessage",e)}},{key:"_joinRoomWithRetry",value:function(e,t,r){var n=this;return new Yf((function(i,o){n._dataChannelSignal.sendSignaling(e,t,void 0,1e4).then((function(e){n.emit("onJoinRoomAck",e),i(e)})).catch((function(a){if(r=r||new Hj,a.code>=500&&a.code<600&&WO()-r.initTs<6e4){var s,c=r.getRetryDelay();return lG.warn("_joinRoomWithRetry",Om(s="joinRoom failed(code: ".concat(a.code,"), will retry after ")).call(s,c,"ms")),void(n._joinRoom5xxTimer=window.setTimeout((function(){delete n._joinRoom5xxTimer,n._joinRoomWithRetry(e,t,r).then(i).catch(o)}),c))}o(a)}))}))}},{key:"_stopJoinRoom5xxRetry",value:function(){this._joinRoom5xxTimer&&(clearTimeout(this._joinRoom5xxTimer),delete this._joinRoom5xxTimer)}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n,i;lG.info("connectStateChange","connected"),e.connectionState="connected",null===(r=e._dataChannelSignal)||void 0===r||r.destroy(),null===(n=e._handler)||void 0===n||n.destroy(),e._handler=Tj(e._context,t.pc),e._dataChannelSignal=t.signaling,e.supportConcurrent="chrome"===(null===(i=e._handler)||void 0===i?void 0:i.name),e._addSignalEventHandler(),e.isReconnecting&&(e._reportJoinRoomStart(),e._callJoinRoom(!0))})),this._connectionManager.on("disconnected",(function(t){e.connectionState="disconnected",lG.error("connectStateChange","disconnected. %o",t),e.isReconnecting&&e.safeEmit(Pj.RECONNECT_FAILED)})),this._connectionManager.on("connecting",(function(){var t;e.isReconnecting=!1,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e.connectionState="connecting",lG.info("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(){var t;e.connectionState="disconnected",e.isReconnecting=!0,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e.connectionState="connecting",lG.warn("connectStateChange","reconnecting"),e.safeEmit("reconnecting")})),this._connectionManager.on("connectWidthTcp",(function(){e.safeEmit(Pj.ON_ICE_CONNECT_WITH_TCP)})),["__onGetIceConfigHook","__onIceConnectSuccessHook"].forEach((function(t){e._connectionManager.on(t,(function(){return e.emit(t)}))}))}},{key:"_reportJoinRoomStart",value:function(){var e;this._joinRoomStartTs=WO(),this.emit("__joinRoomStartReport"),null===(e=this._monitor)||void 0===e||e.report("join_room",{type:"begin",start:this._joinRoomStartTs,result:!1,reason:""},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC})}},{key:"_joinRoomSuccess",value:function(e){var t,r;(this._joinReject&&this._joinResolve&&(this._joinResolve(e),delete this._joinReject,delete this._joinResolve),this._joinRoomStartTs)&&(this.emit("__joinRoomSuccessReport"),null===(t=this._monitor)||void 0===t||t.report("join_room",{type:"end",start:this._joinRoomStartTs,result:!0,reason:""},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC}),null===(r=this._monitor)||void 0===r||r.report("rtc_join_room",{error_code:0,deviceModel:"web",deviceManufacturer:"web",elapse:WO()-this._joinRoomStartTs}),delete this._joinRoomStartTs)}},{key:"_joinRoomFailed",value:function(e,t){var r;(this._joinReject&&this._joinResolve&&(this._joinReject(new mA(t||vA.JOIN_ROOM_FAILED,e)),delete this._joinReject,delete this._joinResolve),this._joinRoomStartTs)&&(this.emit("__joinRoomFailedReport"),null===(r=this._monitor)||void 0===r||r.report("join_room",{type:"end",start:this._joinRoomStartTs,result:!1,reason:e},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC}),delete this._joinRoomStartTs)}},{key:"multiChatMode",value:function(){var e;return null===(e=this._roomAttributes)||void 0===e?void 0:e.multiChatMode}},{key:"sendForwardStreamSignal",value:(t=Rm(km().mark((function e(t,r,n){var i,o,a=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o={forwardStreamType:t,roomId:r},("start"===t||"update"===t)&&(o.dstRoomInfos=null==n?void 0:jm(n).call(n,(function(e){return{dstRoomId:e.roomId,dstToken:YO.token2auth(a._context.appId,e.roomId,a._clientId,e.token)}}))),e.abrupt("return",null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("forwardStream",o));case 4:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"handler",get:function(){return this._handler}},{key:"roomAttributes",get:function(){return this._roomAttributes},set:function(e){this._roomAttributes=e}},{key:"vendorConfig",get:function(){return this._vendorConfig}}]),k}(UD);function fG(e,t,r){var n=r.value;return r.value=Rm(km().mark((function e(){var r,i,o,a=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._handler||"connected"!==this._state){e.next=6;break}for(r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=4,n.apply(this,i);case 4:e.next=7;break;case 6:throw new mA(vA.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 7:case"end":return e.stop()}}),e,this)}))),r}function mG(e,t,r){var n=r.value;return r.value=Rm(km().mark((function e(){var t,r,i,o,a=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._pubSubLock.lock();case 2:for(t=e.sent,this.supportConcurrent&&t(),e.prev=4,r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=8,n.apply(this,i);case 8:return e.abrupt("return",e.sent);case 9:return e.prev=9,this.supportConcurrent||t(),e.finish(9);case 12:case"end":return e.stop()}}),e,this,[[4,,9,12]])}))),r}dG([function(e,t,r){var n=r.value;return r.value=Rm(km().mark((function e(){var t,r,i,o,a=this,s=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=s.length,r=new Array(t),i=0;i<t;i++)r[i]=s[i];return o=!1,e.abrupt("return",new Yf(function(){var e=Rm(km().mark((function e(t,i){var s;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a.on("INTERRUPT",(function(){o=!0,i(new mA(vA.OPERATION_CANCEL,"operation not finish when leave"))})),e.prev=1,e.next=4,n.apply(a,r);case 4:s=e.sent,t(s),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o||i(e.t0);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t,r){return e.apply(this,arguments)}}()));case 3:case"end":return e.stop()}}),e)}))),r}],pG.prototype,"join",1),dG([mG,fG],pG.prototype,"publish",1),dG([mG,fG],pG.prototype,"updatePubTrack",1),dG([mG,fG],pG.prototype,"unpublish",1),dG([mG,fG],pG.prototype,"subscribe",1),dG([fG],pG.prototype,"controlMessage",1),dG([fG],pG.prototype,"updateUserAttributes",1),dG([fG],pG.prototype,"updateSubTrack",1),dG([fG],pG.prototype,"updateSubTrackLayer",1),dG([fG],pG.prototype,"updateSubPriority",1),dG([mG,fG],pG.prototype,"subscribe4pushTrack",1),dG([mG,fG],pG.prototype,"unsubscribe4removeTrack",1),dG([mG,fG],pG.prototype,"unsubscribe",1),dG([fG],pG.prototype,"handleRemoveStream",1),dG([mG],pG.prototype,"subscribePublicStream",1),dG([mG],pG.prototype,"unsubscribePublicStream",1);var gG,yG=function(){var e=Rm(km().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,v,_,p,f,m,g;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u="",d=-1,l="video"===t?null==n||null===(o=n.videoTrack)||void 0===o?void 0:o.getOrgTrack():null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.getOrgTrack(),h="video"===t?null==n||null===(s=n.videoTransceiver)||void 0===s?void 0:s.receiver:null==n||null===(c=n.audioTransceiver)||void 0===c?void 0:c.receiver,e.prev=5,e.t0=null==r?void 0:r.pc,!e.t0){e.next=11;break}return e.next=10,qM(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return _=e.t0,p=yE(v=_||[]).call(v,(function(e){return"inbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(f=e.sent,m=[],null==f||f.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==(null==_?void 0:_.length)||0===m.length){e.next=22;break}return e.next=21,qM(r.pc);case 21:g=e.sent;case 22:u=Mm({type:t,reports:jm(_).call(_,(function(e){return e.type})),reports2:m,pc:(null==r?void 0:r.pc)||null,track:(null==l?void 0:l.id)||null,bytes:null==p?void 0:p.bytesReceived,framesReceived:null==p?void 0:p.framesReceived,packetsReceived:null==p?void 0:p.packetsReceived,allReports:g}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Mm(e.t1);case 29:null==i||i.report("rtc_invoke_status",{sdk_api_name:"first_frame_recv_timeout",error_code:d,message:u,stream_id:(null==n?void 0:n.streamId)||"",stream_user_id:null==n?void 0:n.userId,elapse:0}),e.next=34;break;case 32:e.prev=32,e.t2=e.catch(0);case 34:case"end":return e.stop()}}),e,null,[[0,32],[5,25]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),SG=function(){var e=Rm(km().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,v,_,p,f,m,g;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u="",d=-1,l="video"===t?null==n||null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack("preprocessing"):null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.getTrack("preprocessing"),h="video"===t?null==n||null===(s=n.videoTransceiver)||void 0===s?void 0:s.sender:null==n||null===(c=n.audioTransceiver)||void 0===c?void 0:c.sender,e.prev=5,e.t0=null==r?void 0:r.pc,!e.t0){e.next=11;break}return e.next=10,qM(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return _=e.t0,p=yE(v=_||[]).call(v,(function(e){return"outbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(f=e.sent,m=[],null==f||f.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==_.length||0===m.length){e.next=22;break}return e.next=21,qM(r.pc);case 21:g=e.sent;case 22:u=Mm({type:t,reports:jm(_).call(_,(function(e){return e.type})),reports2:m,pc:(null==r?void 0:r.pc)||null,track:(null==l?void 0:l.id)||null,bytes:null==p?void 0:p.bytesSent,framesSent:null==p?void 0:p.framesSent,packetsSent:null==p?void 0:p.packetsSent,allReports:g}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Mm(e.t1);case 29:null==i||i.report("rtc_invoke_status",{sdk_api_name:"first_frame_send_timeout",error_code:d,message:u,stream_id:(null==n?void 0:n.streamId)||"",stream_user_id:null==n?void 0:n.userId,elapse:0}),e.next=34;break;case 32:e.prev=32,e.t2=e.catch(0);case 34:case"end":return e.stop()}}),e,null,[[0,32],[5,25]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),bG=new Mw("RecvFrameObserver",0),EG=function(e){DI(a,e);var t,r,n,i,o=QI(a);function a(e,t){var r;return Vl(this,a),Jd(tI(r=o.call(this)),"_audioEventSessionId",QO()),Jd(tI(r),"_videoEventSessionId",QO()),Jd(tI(r),"_handler",void 0),Jd(tI(r),"_stream",void 0),Jd(tI(r),"_firstAudioFrameTimer",void 0),Jd(tI(r),"_firstVideoFrameTimer",void 0),Jd(tI(r),"_transportDelayInterval",void 0),Jd(tI(r),"_transportDelay",void 0),Jd(tI(r),"_firstVideoFrameInterval",void 0),Jd(tI(r),"_firstAudioFrameInterval",void 0),Jd(tI(r),"_isScreen",!1),Jd(tI(r),"_audioFirstFrameState",0),Jd(tI(r),"_videoFirstFrameState",0),Jd(tI(r),"_timeout",1e4),Jd(tI(r),"_currentAudioRecv",{startTime:0,eventSessionId:0,type:"login"}),Jd(tI(r),"_currentVideoRecv",{startTime:0,eventSessionId:0,type:"login"}),Jd(tI(r),"_login",!1),Jd(tI(r),"_unMuteAudio",!1),Jd(tI(r),"_enableAudio",!1),Jd(tI(r),"_unMuteVideo",!1),Jd(tI(r),"_enableVideo",!1),Jd(tI(r),"_remoteUnmuteAudio",!1),Jd(tI(r),"_remoteUnmuteVideo",!1),Jd(tI(r),"_audioExternal",!1),Jd(tI(r),"_pushAudio",!1),Jd(tI(r),"_videoExternal",!1),Jd(tI(r),"_pushVideo",!1),Jd(tI(r),"_autoSubscribeVideo",!1),Jd(tI(r),"_autoSubscribeAudio",!1),Jd(tI(r),"_autoSubscribe",!1),Jd(tI(r),"_publishVideo",!1),Jd(tI(r),"_publishAudio",!1),Jd(tI(r),"_subscribeAudio",!1),Jd(tI(r),"_subscribeVideo",!1),Jd(tI(r),"_subscribe",!1),Jd(tI(r),"_pushTrack",!1),Jd(tI(r),"_multiChatMode",!1),Jd(tI(r),"_monitor",void 0),r._stream=e,r._handler=t,r.getTransportDelay(),r._monitor=VO(e.engineId),r}return Ul(a,[{key:"beginRecvFrame",value:(i=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:i=this._transportDelay,o=!0,xE(n=["login","unmute","subscribe","push_track"]).call(n,r)>=0&&(i=0,o=!1),"audio"===t?(o||this._audioEventSessionId++,this._currentAudioRecv={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:r},v={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(a=this._stream)||void 0===a||!a.isScreen),start:null===(s=this._currentAudioRecv)||void 0===s?void 0:s.startTime,event_session_id:this._audioEventSessionId,stream_user_id:null===(c=this._stream)||void 0===c?void 0:c.userId,transport_delay:i,vendor_mode:(null===(u=this._stream)||void 0===u?void 0:u.vendorCode)||0,pc_session_id:(null===(d=this._stream)||void 0===d?void 0:d.pcSessionId)||(null===(l=this._handler)||void 0===l?void 0:l.peerConnectionId)},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){yG("audio",E._handler,E._stream,E._monitor),E.stopRecvFrame("audio","timeout"),E._firstAudioFrameInterval&&window.clearInterval(E._firstAudioFrameInterval)}),this._timeout),bG.info("rtcFirstFrameRecv",Mm(v)),null===(h=this._monitor)||void 0===h||h.report("rtc_first_frame",v),this._watchForFirstAudioFrameRecv(),this._audioFirstFrameState=1,this._login=!0,this._unMuteAudio=!0,this._enableAudio=!0,this._remoteUnmuteAudio=!0):"video"===t&&(o||this._videoEventSessionId++,this._currentVideoRecv={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:r},b={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(_=this._stream)||void 0===_||!_.isScreen),start:null===(p=this._currentVideoRecv)||void 0===p?void 0:p.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(f=this._stream)||void 0===f?void 0:f.userId,transport_delay:i,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(g=this._stream)||void 0===g?void 0:g.pcSessionId)||(null===(y=this._handler)||void 0===y?void 0:y.peerConnectionId)},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){yG("video",E._handler,E._stream,E._monitor),E.stopRecvFrame("video","timeout"),E._firstVideoFrameInterval&&window.clearInterval(E._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),bG.info("rtcFirstFrameRecv",Mm(b)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",b),this._videoFirstFrameState=1,this._login=!0,this._unMuteVideo=!0,this._enableVideo=!0,this._remoteUnmuteVideo=!0);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"stopRecvFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c,u;if(1!==this._audioFirstFrameState)return;var d={event_type:"recv_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioRecv)||void 0===n?void 0:n.startTime,reason:t,result:!1,stream_user_id:null===(i=this._stream)||void 0===i?void 0:i.userId,event_session_id:this._audioEventSessionId,type:null===(o=this._currentAudioRecv)||void 0===o?void 0:o.type,vendor_mode:(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,pc_session_id:(null===(s=this._stream)||void 0===s?void 0:s.pcSessionId)||(null===(c=this._handler)||void 0===c?void 0:c.peerConnectionId)};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,bG.info("rtcFirstFrameRecv",Mm(d)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",d),this._audioFirstFrameState=2}else if("video"===e){var l,h,v,_,p,f,m,g;if(1!==this._videoFirstFrameState)return;var y={event_type:"recv_end",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),start:null===(h=this._currentVideoRecv)||void 0===h?void 0:h.startTime,reason:t,result:!1,stream_user_id:null===(v=this._stream)||void 0===v?void 0:v.userId,event_session_id:this._videoEventSessionId,type:null===(_=this._currentVideoRecv)||void 0===_?void 0:_.type,vendor_mode:(null===(p=this._stream)||void 0===p?void 0:p.vendorCode)||0,pc_session_id:(null===(f=this._stream)||void 0===f?void 0:f.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId)};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,bG.info("rtcFirstFrameRecv",Mm(y)),null===(g=this._monitor)||void 0===g||g.report("rtc_first_frame",y),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:if(r=this._transportDelay,"audio"!==t){e.next=19;break}if(1===this._audioFirstFrameState){e.next=6;break}return e.abrupt("return");case 6:if(this._currentAudioRecv){e.next=8;break}return e.abrupt("return");case 8:d=this._currentAudioRecv,l=d.type,h=d.startTime,xE(n=["login","unmute","subscribe","push_track"]).call(n,l)>=0&&(r=0),v={event_type:"recv_end",media_type:t,start:h,result:!0,is_screen:!(null===(i=this._stream)||void 0===i||!i.isScreen),stream_user_id:null===(o=this._stream)||void 0===o?void 0:o.userId,event_session_id:this._audioEventSessionId,type:l,transport_delay:r,vendor_mode:(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,pc_session_id:(null===(s=this._stream)||void 0===s?void 0:s.pcSessionId)||(null===(c=this._handler)||void 0===c?void 0:c.peerConnectionId)},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),bG.info("rtcFirstFrameRecv",Mm(v)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",v),this.emit("recvAudioFirstFrame"),this._audioFirstFrameState=3,e.next=33;break;case 19:if("video"!==t){e.next=33;break}if(1===this._videoFirstFrameState){e.next=22;break}return e.abrupt("return");case 22:if(this._currentVideoRecv){e.next=24;break}return e.abrupt("return");case 24:b=this._currentVideoRecv,E=b.type,T=b.startTime,xE(_=["login","unmute","subscribe","push_track"]).call(_,E)>=0&&(r=0),k={event_type:"recv_end",media_type:t,is_screen:!(null===(p=this._stream)||void 0===p||!p.isScreen),start:T,result:!0,stream_user_id:null===(f=this._stream)||void 0===f?void 0:f.userId,event_session_id:this._videoEventSessionId,type:E,transport_delay:r,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(g=this._stream)||void 0===g?void 0:g.pcSessionId)||(null===(y=this._handler)||void 0===y?void 0:y.peerConnectionId)},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),bG.info("rtcFirstFrameRecv",Mm(k)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",k),this.emit("recvVideoFirstFrame"),this._videoFirstFrameState=3;case 33:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setLogin",value:function(e){var t,r,n,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0,video:!0};this._login!==e&&(this._login=e,e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&o.audio&&this.beginRecvFrame("audio","login"),e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&o.video&&this.beginRecvFrame("video","login"),!e&&null!==(n=this._stream)&&void 0!==n&&n.hasAudio&&this.stopRecvFrame("audio","leave_room"),!e&&null!==(i=this._stream)&&void 0!==i&&i.hasVideo&&this.stopRecvFrame("video","leave_room"))}},{key:"setUnmuteAudio",value:function(e){var t,r,n;if(this._unMuteAudio!==e){this._unMuteAudio=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasAudio);null!==(r=this._stream)&&void 0!==r&&r.audioHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.audioHasPublish&&(this._unMuteAudio&&i?this.beginRecvFrame("audio","unmute"):i&&this.stopRecvFrame("audio","mute"))}}},{key:"setRemoteUnmuteAudio",value:function(e){this._remoteUnmuteAudio!==e&&(this._remoteUnmuteAudio=e,this._remoteUnmuteAudio?this.beginRecvFrame("audio","remote_unmute"):this.stopRecvFrame("audio","remote_mute"))}},{key:"setEnableAudio",value:function(e){this._enableAudio!==e&&(this._enableAudio=e,this._enableAudio?this.beginRecvFrame("audio","enable"):this.stopRecvFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t,r,n;if(this._unMuteVideo!==e){this._unMuteVideo=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasVideo);null!==(r=this._stream)&&void 0!==r&&r.videoHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.videoHasPublish&&(this._unMuteVideo&&i?this.beginRecvFrame("video","unmute"):i&&this.stopRecvFrame("video","mute"))}}},{key:"setHandler",value:function(e){this._handler=e}},{key:"setRemoteUnmuteVideo",value:function(e){this._remoteUnmuteVideo!==e&&(this._remoteUnmuteVideo=e,this._remoteUnmuteVideo?this.beginRecvFrame("video","remote_unmute"):this.stopRecvFrame("video","remote_mute"))}},{key:"setEnableVideo",value:function(e){this._enableVideo!==e&&(this._enableVideo=e,this._enableVideo?this.beginRecvFrame("video","enable"):this.stopRecvFrame("video","disable"))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal=e}},{key:"setPushAudio",value:function(e){var t;this._audioExternal&&this._pushAudio!==e&&(this._pushAudio=e),this._pushAudio&&this.beginRecvFrame("audio","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.beginRecvFrame("audio","push")}},{key:"setExternalVideoSource",value:function(e){this._videoExternal=e}},{key:"setPushVideo",value:function(e){var t;this._videoExternal&&this._pushVideo!==e&&(this._pushVideo=e),this._pushVideo&&this.beginRecvFrame("video","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.beginRecvFrame("video","push")}},{key:"setPublishVideo",value:function(e){var t;this._publishVideo!==e&&(this._publishVideo=e),this._publishVideo&&this.beginRecvFrame("video","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unpublish")}},{key:"setPublishAudio",value:function(e){var t;this._publishAudio!==e&&(this._publishAudio=e),this._publishAudio&&this.beginRecvFrame("audio","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","unpublish")}},{key:"setAutoSubscribe",value:function(e){this._autoSubscribe=e}},{key:"setAutoSubscribeVideo",value:function(e){this._autoSubscribeVideo=e}},{key:"setAutoSubscribeAudio",value:function(e){this._autoSubscribeAudio=e}},{key:"setSubscribeAudio",value:function(e){var t,r;this._autoSubscribeAudio||this._subscribeAudio===e||(this._subscribe=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasAudio&&this.beginRecvFrame("audio","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","unsubscribe")}},{key:"setSubscribeVideo",value:function(e){var t,r;this._autoSubscribeVideo||this._subscribeVideo===e||(this._subscribeVideo=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&this.beginRecvFrame("video","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unsubscribe")}},{key:"setPushTrack",value:function(e){var t;this._pushTrack!==e&&(e&&!this._isScreen&&this.beginRecvFrame("audio","push_track"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","remove_track"))}},{key:"setMultiChatMode",value:function(e){this._multiChatMode=e}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"_watchForFirstVideoFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(Rm(km().mark((function n(){var i,o,a,s,c,u,d,l;return km().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a||!a.getTrack()){n.next=12;break}return n.next=3,qM(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.videoTrack)||void 0===u?void 0:u.getTrack());case 3:if(d=n.sent,!(l=yE(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(l.framesReceived>t||l.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=l.framesReceived,r=l.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"_watchForFirstAudioFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(Rm(km().mark((function n(){var i,o,a,s,c,u,d,l;return km().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a||!a.getOrgTrack()){n.next=12;break}return n.next=3,qM(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.getOrgTrack());case 3:if(d=n.sent,!(l=yE(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(l.totalSamplesReceived>t||l.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=l.totalSamplesReceived,r=l.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"getTransportDelay",value:(r=Rm(km().mark((function e(){var t=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelayIntl();case 2:window.clearInterval(this._transportDelayInterval),this._transportDelayInterval=window.setInterval(Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getTransportDelayIntl();case 2:case"end":return e.stop()}}),e)}))),2e3);case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getTransportDelayIntl",value:(t=Rm(km().mark((function e(){var t,r,n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc){e.next=7;break}return e.next=3,qM(null===(r=this._handler)||void 0===r?void 0:r.pc);case 3:n=e.sent,i=yE(n).call(n,(function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(o=yE(n).call(n,(function(e){return"candidate-pair"===e.type&&"succeeded"===e.state&&e.id===(null==i?void 0:i.selectedCandidatePairId)})))&&(this._transportDelay=Math.round(1e3*o.currentRoundTripTime/2));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"setDisconnect",value:function(){this.stopRecvFrame("audio","connection_lost"),this.stopRecvFrame("video","connection_lost"),this.reset()}},{key:"reset",value:function(){this._currentAudioRecv={startTime:0,eventSessionId:0,type:"login"},this._currentVideoRecv={startTime:0,eventSessionId:0,type:"login"},this._login=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._remoteUnmuteAudio=!1,this._remoteUnmuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoSubscribeVideo=!1,this._autoSubscribeAudio=!1,this._autoSubscribe=!1,this._subscribeAudio=!1,this._subscribeVideo=!1,this._subscribe=!1,this._pushTrack=!1,this._multiChatMode=!1,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._transportDelayInterval&&window.clearInterval(this._transportDelayInterval)}},{key:"audioFirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}},{key:"FirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}}]),a}(PD.exports.EventEmitter),TG=new Mw("SendFrameObserver",0),kG=function(){function e(t,r){Vl(this,e),Jd(this,"_audioEventSessionId",QO()),Jd(this,"_videoEventSessionId",QO()),Jd(this,"_pcSessionId",void 0),Jd(this,"_handler",void 0),Jd(this,"_firstAudioFrameTimer",void 0),Jd(this,"_firstVideoFrameTimer",void 0),Jd(this,"_stream",void 0),Jd(this,"_firstVideoFrameInterval",void 0),Jd(this,"_firstAudioFrameInterval",void 0),Jd(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:"login"}),Jd(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:"login"}),Jd(this,"_login",!1),Jd(this,"_publisher",!1),Jd(this,"_unMuteAudio",!1),Jd(this,"_enableAudio",!1),Jd(this,"_unMuteVideo",!1),Jd(this,"_enableVideo",!1),Jd(this,"_audioExternal",!1),Jd(this,"_pushAudio",!1),Jd(this,"_videoExternal",!1),Jd(this,"_pushVideo",!1),Jd(this,"_autoPublish",!1),Jd(this,"_publish",!1),Jd(this,"_timeout",1e4),Jd(this,"_audioFirstFrameState",0),Jd(this,"_videoFirstFrameState",0),Jd(this,"_monitor",void 0),this._stream=t,this._handler=r,this._monitor=VO(t.engineId)}var t,r;return Ul(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if("audio"===e){var n,i,o,a,s,c,u;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var d={event_type:"begin_send",media_type:e,is_screen:!(null===(n=this._stream)||void 0===n||!n.isScreen),type:t,start:this._currentAudioSend.startTime,event_session_id:this._audioEventSessionId,vendor_mode:(null===(i=this._stream)||void 0===i?void 0:i.vendorCode)||0,pc_session_id:(null===(o=this._stream)||void 0===o?void 0:o.pcSessionId)||(null===(a=this._handler)||void 0===a?void 0:a.peerConnectionId),capture_session_id:null===(s=this._stream)||void 0===s||null===(c=s.audioTrack)||void 0===c?void 0:c.captureSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){SG("audio",r._handler,r._stream,r._monitor),r.stopSendFrame("audio","timeout"),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),TG.info("rtcFirstFrameSend",Mm(d)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",d),this._watchForFirstAudioFrameSend(),this._audioFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteAudio=!0,this._pushAudio||(this._enableAudio=!0)}else if("video"===e){var l,h,v,_,p,f,m;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var g={event_type:"begin_send",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),type:t,start:this._currentVideoSend.startTime,event_session_id:this._videoEventSessionId,vendor_mode:(null===(h=this._stream)||void 0===h?void 0:h.vendorCode)||0,pc_session_id:(null===(v=this._stream)||void 0===v?void 0:v.pcSessionId)||(null===(_=this._handler)||void 0===_?void 0:_.peerConnectionId),capture_session_id:null===(p=this._stream)||void 0===p||null===(f=p.videoTrack)||void 0===f?void 0:f.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){SG("video",r._handler,r._stream,r._monitor),r.stopSendFrame("video","timeout"),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),TG.info("rtcFirstFrameSend",Mm(g)),null===(m=this._monitor)||void 0===m||m.report("rtc_first_frame",g),this._videoFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteVideo=!0,this._pushVideo||(this._enableVideo=!0)}}},{key:"stopSendFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c,u,d;if(1!==this._audioFirstFrameState)return;var l={event_type:"sent_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioSend)||void 0===n?void 0:n.startTime,reason:t,result:!1,event_session_id:this._audioEventSessionId,type:null===(i=this._currentAudioSend)||void 0===i?void 0:i.type,vendor_mode:(null===(o=this._stream)||void 0===o?void 0:o.vendorCode)||0,pc_session_id:(null===(a=this._stream)||void 0===a?void 0:a.pcSessionId)||(null===(s=this._handler)||void 0===s?void 0:s.peerConnectionId),capture_session_id:null===(c=this._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.captureSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,TG.info("rtcFirstFrameSend",Mm(l)),null===(d=this._monitor)||void 0===d||d.report("rtc_first_frame",l),this._audioFirstFrameState=2}else if("video"===e){var h,v,_,p,f,m,g,y,S;if(1!==this._videoFirstFrameState)return;var b={event_type:"sent_end",media_type:e,start:null===(h=this._currentVideoSend)||void 0===h?void 0:h.startTime,is_screen:!(null===(v=this._stream)||void 0===v||!v.isScreen),reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(_=this._currentVideoSend)||void 0===_?void 0:_.type,vendor_mode:(null===(p=this._stream)||void 0===p?void 0:p.vendorCode)||0,pc_session_id:(null===(f=this._stream)||void 0===f?void 0:f.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId),capture_session_id:null===(g=this._stream)||void 0===g||null===(y=g.videoTrack)||void 0===y?void 0:y.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,TG.info("rtcFirstFrameSend",Mm(b)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",b),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if("audio"===e){var t,r,n,i,o,a,s;if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var c=this._currentAudioSend,u=c.type,d=c.startTime,l={event_type:"sent_end",media_type:e,is_screen:!(null===(t=this._stream)||void 0===t||!t.isScreen),start:d,result:!0,event_session_id:this._audioEventSessionId,type:u,vendor_mode:(null===(r=this._stream)||void 0===r?void 0:r.vendorCode)||0,pc_session_id:(null===(n=this._stream)||void 0===n?void 0:n.pcSessionId)||(null===(i=this._handler)||void 0===i?void 0:i.peerConnectionId),capture_session_id:null===(o=this._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a?void 0:a.captureSessionId};delete this._currentAudioSend,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),TG.info("rtcFirstFrameSend",Mm(l)),null===(s=this._monitor)||void 0===s||s.report("rtc_first_frame",l),this._audioFirstFrameState=3}else if("video"===e){var h,v,_,p,f,m,g;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var y=this._currentVideoSend,S=y.type,b=y.startTime,E={event_type:"sent_end",media_type:e,is_screen:!(null===(h=this._stream)||void 0===h||!h.isScreen),start:b,result:!0,event_session_id:this._videoEventSessionId,type:S,vendor_mode:(null===(v=this._stream)||void 0===v?void 0:v.vendorCode)||0,pc_session_id:(null===(_=this._stream)||void 0===_?void 0:_.pcSessionId)||(null===(p=this._handler)||void 0===p?void 0:p.peerConnectionId),capture_session_id:null===(f=this._stream)||void 0===f||null===(m=f.videoTrack)||void 0===m?void 0:m.captureSessionId};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),TG.info("rtcFirstFrameSend",Mm(E)),null===(g=this._monitor)||void 0===g||g.report("rtc_first_frame",E),this._videoFirstFrameState=3}}},{key:"setLogin",value:function(e){if(this._login!==e){var t,r;if(this._login=e,e)null!==(t=this._stream)&&void 0!==t&&t.videoTrack&&this.beginSendFrame("video","login"),null!==(r=this._stream)&&void 0!==r&&r.audioTrack&&this.beginSendFrame("audio","login");!e&&this._audioSending&&this.stopSendFrame("audio","leave_room"),!e&&this._videoSending&&this.stopSendFrame("video","leave_room")}}},{key:"setPublish",value:function(e){if(this._publish!==e){var t,r;if(this._publish=e,e)(null===(t=this._stream)||void 0===t?void 0:t.videoTrack)&&this._stream.pubVideo&&this.beginSendFrame("video","publish"),(null===(r=this._stream)||void 0===r?void 0:r.audioTrack)&&this._stream.pubAudio&&this.beginSendFrame("audio","publish");!e&&this._audioSending&&this.stopSendFrame("audio","unpublish"),!e&&this._videoSending&&this.stopSendFrame("video","unpublish")}}},{key:"setUnmuteAudio",value:function(e){var t;this._unMuteAudio!==e&&(this._unMuteAudio=e,null!==(t=this._stream)&&void 0!==t&&t.audioHasCapture&&(e&&this.beginSendFrame("audio","unmute"),!e&&this._audioSending&&this.stopSendFrame("audio","mute")))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubAudio&&(this._enableAudio=e,e&&this.beginSendFrame("audio","enable"),!e&&this._audioSending&&this.stopSendFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t;this._unMuteVideo!==e&&(this._unMuteVideo=e,null!==(t=this._stream)&&void 0!==t&&t.videoHasCapture&&(e&&this.beginSendFrame("video","unmute"),!e&&this._videoSending&&this.stopSendFrame("video","mute")))}},{key:"setEnableVideo",value:function(e){var t;this._enableVideo!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubVideo&&(this._enableVideo=e,e&&this.beginSendFrame("video","enable"),!e&&this._videoSending&&this.stopSendFrame("video","disable"))}},{key:"setPushAudio",value:function(e){this._pushAudio!==e&&(this._pushAudio=e,e&&this.beginSendFrame("audio","push"),!e&&this._audioSending&&this.stopSendFrame("audio","stop_push"))}},{key:"setPushVideo",value:function(e){this._pushVideo!==e&&(this._pushVideo=e,e&&this.beginSendFrame("video","push"),!e&&this._videoSending&&this.stopSendFrame("video","stop_push"))}},{key:"setAutoPublish",value:function(e){this._autoPublish=e}},{key:"setPublisher",value:function(e){this._publisher!==e&&(this._publisher=e,!e&&this._audioSending&&this.stopSendFrame("audio","audience"),!e&&this._videoSending&&this.stopSendFrame("video","audience"))}},{key:"setDisconnect",value:function(){this._audioSending&&this.stopSendFrame("audio","connection_lost"),this._videoSending&&this.stopSendFrame("video","connection_lost"),this.reset()}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"setPCSessionId",value:function(e){this._pcSessionId=e}},{key:"setHandler",value:function(e){this._handler=e}},{key:"_getFirstVideoFrameStats",value:(r=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.videoTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=6;break}return e.next=3,qM(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a?void 0:a.getTrack("preprocessing"));case 3:return s=e.sent,c=Gs(s).call(s,(function(e){return"outbound-rtp"===e.type})),e.abrupt("return",c);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=Rm(km().mark((function e(){var t,r,n,i,o,a,s;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.audioTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=5;break}return e.next=3,qM(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a?void 0:a.getTrack("preprocessing"));case 3:return s=e.sent,e.abrupt("return",yE(s).call(s,(function(e){return"outbound-rtp"===e.type})));case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_watchForFirstVideoFrameSend",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(Rm(km().mark((function n(){var i,o,a;return km().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e._getFirstVideoFrameStats();case 2:if(i=n.sent,o=0,a=0,null==i||jm(i).call(i,(function(e){o+=e.framesSent,a+=e.packetsSent})),!(i&&i.length>0&&(o>t||a>r))){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=o,r=a,n.abrupt("return");case 10:e.sendFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),100)}},{key:"_watchForFirstAudioFrameSend",value:function(){var e=this,t=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(Rm(km().mark((function r(){var n;return km().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e._getFirstAudioFrameStats();case 2:if(!((n=r.sent)&&n.packetsSent>t)){r.next=9;break}if(-1!==t){r.next=7;break}return t=n.packetsSent,r.abrupt("return");case 7:e.sendFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 9:case"end":return r.stop()}}),r)}))),100)}},{key:"reset",value:function(){this._login=!1,this._publisher=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoPublish=!1,this._publish=!1,this._audioFirstFrameState=0,this._videoFirstFrameState=0,this._currentAudioSend={startTime:0,eventSessionId:0,type:"login"},this._currentVideoSend={startTime:0,eventSessionId:0,type:"login"},window.clearTimeout(this._firstAudioFrameTimer),window.clearTimeout(this._firstVideoFrameTimer),window.clearInterval(this._firstAudioFrameInterval),window.clearInterval(this._firstVideoFrameInterval)}},{key:"destroy",value:function(){this.reset(),delete this._stream,delete this._handler}},{key:"_audioSending",get:function(){return 1===this._audioFirstFrameState}},{key:"_videoSending",get:function(){return 1===this._videoFirstFrameState}}]),e}(),IG=(Jd(gG={},"audio",{delay:1200,stallRadio:.3}),Jd(gG,"video",{delay:1200,stallRadio:.6}),Jd(gG,"screen_audio",{delay:1600,stallRadio:.8}),Jd(gG,"screen_video",{delay:1600,stallRadio:.8}),gG),RG=function(){function e(){Vl(this,e),Jd(this,"_preUplinkStats",new $S),Jd(this,"_preDownlinkStats",new $S),Jd(this,"_timer",void 0),Jd(this,"_delayTimer",void 0),Jd(this,"_msc",void 0),Jd(this,"reportor",void 0)}return Ul(e,[{key:"updateUplinkStats",value:function(e){var t=e.audioStats,r=e.videoStats,n=e.isScreen;if(t.sendKBitrate>0&&t.rtt){var i,o,a=n?"screen_audio":"audio",s=t.rtt,c=t._fractionLost,u=t._retransmittedRate,d=this._getQosLevel(s,c||0,u||0),l=this._preUplinkStats.get(a)||[d];this._preUplinkStats.set(a,Tm(i=Om(o=[]).call(o,JT(l),[d])).call(i,-2))}if(r.sentKBitrate>0&&r.rtt){var h,v,_=n?"screen_video":"video",p=r._fractionLost,f=r.rtt,m=r._sendBandWidth,g=r._retransmittedRate;0===m&&(p=Math.max(.65,p));var y=this._getQosLevel(f,p||0,g||0),S=this._preUplinkStats.get(_)||[y];this._preUplinkStats.set(_,Tm(h=Om(v=[]).call(v,JT(S),[y])).call(h,-2))}this._startNetworkQualityReport()}},{key:"updateDownlinkStats",value:function(e,t){if(t){var r,n,i=this._getStreamActiveState(t),o=i.audioActive,a=i.videoActive,s=e.audioStats,c=e.videoStats,u=e.isScreen,d=e.userId;if(o)if(0===s.receivedKBitrate)r=yl.VBAD;else{var l=s.rtt,h=s.audioLossRate,v=s.stallDuration,_=s.statsInterval,p=s.e2eDelay,f=v/_,m=u?"screen_audio":"audio",g=this._getQosLevel(l,h||0,c._retransmittedRate||0),y=this._getDownlinkQoE(m,f,p);r=this._getNetworkQuality(g,y)}if(a)if(0===c.receivedKBitrate||0===c.rtt)n=yl.VBAD;else{var S=c.rtt,b=c.videoLossRate,E=c.stallDuration,T=c.statsInterval,k=c.e2eDelay,I=c._retransmittedRate,R=E/T,A=u?"screen_video":"video",w=this._getQosLevel(S,b||0,I||0),C=this._getDownlinkQoE(A,R,k);n=this._getNetworkQuality(w,C)}var x=r&&n?Math.ceil((r+n)/2):r||n;if(x){var O,N,D,P=Om(O="".concat(d)).call(O,u?"_screen":""),M=this._preDownlinkStats.get(P)||[x];this._preDownlinkStats.set(P,Tm(N=Om(D=[]).call(D,JT(M),[x])).call(N,-2)),this._startNetworkQualityReport()}}}},{key:"setMSC",value:function(e){this._msc=e}},{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._delayTimer&&(window.clearTimeout(this._delayTimer),delete this._delayTimer),this._preUplinkStats.clear(),this._preDownlinkStats.clear()}},{key:"_startNetworkQualityReport",value:function(){var e=this;this._delayTimer||this._timer||(this._preUplinkStats.size>0||this._preDownlinkStats.size>0)&&(this._delayTimer=window.setTimeout((function(){delete e._delayTimer,e._reportNetworkQuality(),e._timer=window.setInterval((function(){e._reportNetworkQuality()}),2e3)}),300))}},{key:"_reportNetworkQuality",value:function(){var e,t,r,n,i,o=this;if(mT(e=["connected","connecting"]).call(e,null===(t=this._msc)||void 0===t||null===(r=t.handler)||void 0===r?void 0:r.getConnectionState())){var a,s,c,u=this._getBetterQualityAndRemoveOldest("audio","up"),d=this._getBetterQualityAndRemoveOldest("video","up");n=u&&d?Math.ceil((u+d)/2):u||d||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||yl.EXCELLENT;var l=Gs(a=jm(s=qT(sw(c=this._preDownlinkStats).call(c))).call(s,(function(e){return o._getBetterQualityAndRemoveOldest(e,"down")}))).call(a,(function(e){return e}));i=Math.ceil(vb(l).call(l,(function(e,t){return t+e}),0)/l.length)||yl.UNKNOWN}else n=i=yl.DOWN;navigator.onLine||(n=yl.DOWN,i=yl.DOWN),"function"==typeof this.reportor&&this.reportor(n,i)}},{key:"_getNetworkQuality",value:function(e,t){return 1===t?Math.max(e-2,1):2===t?e:Math.min(e+1,5)}},{key:"_getQosLevel",value:function(e,t,r){var n;return n=(!e||e<=250)&&t<=.15?1:(!e||e<=500)&&t<=.3?2:(!e||e<=750)&&t<=.45?3:(!e||e<=1e3)&&t<=.6?4:5,r>.5?n=Math.max(n,4):r>.35?n=Math.max(n,3):r>.15&&(n=Math.max(n,2)),n}},{key:"_getUplinkQoE",value:function(e,t){var r=0;switch(e){case"audio":case"video":r=t<.05?1:t<.1?2:3;break;case"screen_video":case"screen_audio":r=t<.04?1:t<.08?2:3}return r}},{key:"_getDownlinkQoE",value:function(e,t,r){var n=IG[e];return t>n.stallRadio||r>n.delay||t>n.stallRadio/2&&r>n.delay/2?3:(t>n.stallRadio/2||n.delay,2)}},{key:"_getBetterQualityAndRemoveOldest",value:function(e,t){var r=yl.UNKNOWN,n="up"===t?this._preUplinkStats:this._preDownlinkStats,i=n.get(e);if(i){var o=Gs(i).call(i,(function(e){return e}));o.length>0&&(r=Math.min.apply(Math,JT(o))),i.shift(),0===i.length&&n.delete(e)}return r}},{key:"_getStreamActiveState",value:function(e){var t=e.subMediaType,r=e._attributes,n=e.subVideo;return{audioActive:e.subAudio&&dN(t)&&r.localaudio&&r.audiostream,videoActive:n&&lN(t)&&r.localvideo&&r.videostream}}}]),e}(),AG=function(){function e(t){Vl(this,e),Jd(this,"_timer",void 0),Jd(this,"_remoteVideoSizeCache",{}),Jd(this,"_remoteScreenSizeCache",{}),Jd(this,"onchange",void 0),this._room=t,this._start()}return Ul(e,[{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._remoteVideoSizeCache={},this._remoteScreenSizeCache={}}},{key:"_start",value:function(){var e=this;this._timer||(this._timer=window.setInterval((function(){var t={},r={};e._room.remoteStreams.forEach((function(n,i){n.forEach((function(n){var o,a=null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack();if(a){var s=n.isScreen?e._remoteScreenSizeCache:e._remoteVideoSizeCache,c=s[i]||{},u=c.width,d=void 0===u?0:u,l=c.height,h=void 0===l?0:l,v=a.getSettings(),_=v.width,p=void 0===_?0:_,f=v.height,m=void 0===f?0:f;h===m&&d===p||"function"==typeof e.onchange&&e.onchange(i,n.isScreen,p,m),delete s[i],(n.isScreen?r:t)[i]={width:p,height:m}}}))})),an(e._remoteVideoSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!1,0,0)})),an(e._remoteScreenSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),wG=qT((new TextEncoder).encode("subt")),CG={1:vA.SUBTITLE_ERR_POSTPROCESS,2:vA.SUBTITLE_ERR_CONNECTION_ERROR,3:vA.SUBTITLE_ERR_PROCESS_ERROR},xG=new Mw("SubtitleTool",1),OG=function(e){if(e.extraInfo)try{var t,r=JSON.parse(e.extraInfo);r.source_language&&xE(t=["zh","en","ja"]).call(t,r.source_language)}catch(a){}else{var n,i,o=(null===(n=navigator.language)||void 0===n?void 0:n.substring(0,2))||"";xE(i=["zh","en","ja"]).call(i,o)>-1&&(e.extraInfo=Mm({source_language:o}))}},NG=function(){function e(t){var r,n,i;Vl(this,e),Jd(this,"_taskId",void 0),Jd(this,"_appId",void 0),Jd(this,"_roomId",void 0),Jd(this,"_userId",void 0),Jd(this,"onEvent",void 0),Jd(this,"onMessage",void 0),Jd(this,"_preConfig",void 0),Jd(this,"_timer",void 0),this._room=t,this._appId=null===(r=this._room._roomInfo)||void 0===r?void 0:r.appId,this._roomId=null===(n=this._room._roomInfo)||void 0===n?void 0:n.roomId,this._userId=null===(i=this._room._roomInfo)||void 0===i?void 0:i.userInfo.userId}var t,r,n;return Ul(e,[{key:"start",value:(n=Rm(km().mark((function e(t){var r=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(xG.info("start","Invoke config: %o",t),pD(t.mode,"mode",[Rl.ASR_ONLY,Rl.ASR_AND_TRANSLATION]),t.mode!==Rl.ASR_AND_TRANSLATION||-1!==xE(PG).call(PG,t.targetLanguage||"")){e.next=4;break}throw new mA(vA.INVALID_PARAMS,"Invalid targetLanguage.");case 4:if(!this._taskId){e.next=6;break}throw new mA(vA.SUBTITLE_ALREADY_ON,"Already turned on subtitle");case 6:return this._preConfig=t,this._taskId=(Date.now().toString()+this._roomId+this._userId).substring(0,20),e.next=10,this._room.subtitleControlMessage(this._genSubtitleSignaling("started",t,this._taskId));case 10:this._preConfig=t,this._timer=self.setTimeout((function(){var e;null===(e=r.onEvent)||void 0===e||e.call(r,{event:Al.ERROR,errorCode:vA.TIME_OUT,errorMessage:"start subtitle timeout."}),delete r._timer,r.stop()}),3e4);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"update",value:(r=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(pD(t.mode,"mode",[Rl.ASR_ONLY,Rl.ASR_AND_TRANSLATION]),t.mode!==Rl.ASR_AND_TRANSLATION||-1!==xE(PG).call(PG,t.targetLanguage||"")){e.next=3;break}throw new mA(vA.INVALID_PARAMS,"Invalid targetLanguage.");case 3:if(!this._taskId){e.next=5;break}throw new mA(vA.SUBTITLE_ALREADY_ON,"Already started subtitle");case 5:if(this._taskId){e.next=7;break}throw new mA(vA.SUBTITLE_NOT_TURNED_ON,"Start subtitle first.");case 7:if((null===(r=this._preConfig)||void 0===r?void 0:r.mode)===t.mode&&this._preConfig.targetLanguage===t.targetLanguage){e.next=11;break}return this._preConfig=t,e.next=11,this._room.subtitleControlMessage(this._genSubtitleSignaling("update",t,this._taskId));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stop",value:function(){var e=this;xG.info("stop","Invoke"),this._taskId&&this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId}).finally((function(){var t;delete e._taskId,null===(t=e.onEvent)||void 0===t||t.call(e,{event:Al.STOPPED}),e._clearTimer()}))}},{key:"reconnect",value:(t=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._taskId||!this._preConfig){e.next=5;break}return e.next=3,this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId});case 3:delete this._taskId,this.start(this._preConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getConfig",value:function(){return this._preConfig}},{key:"destroy",value:function(){xG.info("destroy","Invoke"),this.stop(),delete this._preConfig,delete this._taskId}},{key:"onResult",value:function(e){var t=e.body,r=t.error,n=t.errorMessage,i=t.eventType;if(0!==r){var o,a=new mA(CG[r]||vA.SUBTITLE_ERR_UNKNOWN,n||"");null===(o=this.onEvent)||void 0===o||o.call(this,{event:Al.ERROR,errorCode:a.code,errorMessage:a.message}),this._clearTimer()}else if("SubtitleStarted"===i){var s;null===(s=this.onEvent)||void 0===s||s.call(this,{event:Al.STARTED}),this._clearTimer()}}},{key:"onMessageRecv",value:function(e){if(this._taskId&&this._preConfig){var t=DG(e);if(t&&t.length>0){var r,n=this._preConfig,i=n.mode,o=n.targetLanguage,a=[];if(t.forEach((function(e){i===Rl.ASR_ONLY?e.mode===i&&a.push(e):i===Rl.ASR_AND_TRANSLATION&&(e.language!==o&&e.mode!==Rl.ASR_ONLY||a.push(e),e.mode===Rl.ASR_ONLY&&e.language===o&&a.push(Zd(Zd({},e),{},{mode:Rl.ASR_AND_TRANSLATION})))})),a.length>0)null===(r=this.onMessage)||void 0===r||r.call(this,a)}return!!t}return!1}},{key:"_genSubtitleSignaling",value:function(e,t,r){return{taskId:r,type:"subtitle",action:e,roomId:this._roomId,appId:this._appId,userId:this._userId,subtitleMeta:{subtitleConfig:{mode:t.mode,usersConfig:[{userId:this._userId,targetLanguages:[t.targetLanguage||""]}]},vendorConfig:{type:0}}}}},{key:"_clearTimer",value:function(){this._timer&&(self.clearTimeout(this._timer),delete this._timer)}}]),e}(),DG=function(e){var t=e.message;if(t instanceof ArrayBuffer&&t.byteLength>8)try{var r=new DataView(t,0),n=0;if(wG.every((function(e){return r.getUint8(n++)===e}))){var i=r.getUint32(n);if(n+=4,i===r.byteLength-8){var o=YO.ab2str(Tm(t).call(t,8)),a=JSON.parse(o),s=a.data;if("subtitle"===a.type)return s}}}catch(c){}return!1},PG=["zh","zh-Hant","tn","vi","iu","it","id","hi","en","ho","he","es","el","uk","ur","tk","tr","ti","ty","tl","to","th","ta","te","sl","sk","ss","eo","sm","sg","st","sv","ja","tw","qu","pt","pa","no","nb","nr","my","bn","mn","mh","mk","ml","mr","ms","lu","ro","lt","lv","lo","kj","hr","kn","ki","cs","ca","nl","ko","ht","gu","ka","kl","km","lg","kg","fi","fj","fr","ru","ng","de","tt","da","ts","cv","fa","bs","pl","bi","nd","ba","bg","az","ar","af","sq","ab","os","ee","et","ay","lzh","am","ckb","cy","gl","ha","hy","ig","kmr","ln","nso","ny","om","sn","so","sr","sw","xh","yo","zu"],MG=ad,LG=tc,UG=function(e,t,r,n){for(var i,o=n>1?void 0:n?LG(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&MG(t,r,o),o},VG=function(){function e(t){Vl(this,e),Jd(this,"_forwardDstRooms",new $S),Jd(this,"forwardStreamState","stopped"),Jd(this,"_monitor",void 0),this._room=t,this._monitor=VO(this._room.id)}var t,r,n,i,o,a;return Ul(e,[{key:"startForwardStream2Rooms",value:(a=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("running"!==this.forwardStreamState&&"paused"!==this.forwardStreamState){e.next=2;break}throw new mA(vA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke startForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("start",this._room.roomInfo.roomId,t);case 4:return r=e.sent,this._updateDstRooms(t,r),n=this._transformForwardStreamResult(r),this.forwardStreamState="running",e.abrupt("return",n);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(o=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new mA(vA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke updateForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:if(r=this._mockForwardStreamResult(t),"running"!==this.forwardStreamState){e.next=7;break}return e.next=6,this._sendForwardStreamSignaling("update",this._room._roomInfo.roomId,t);case 6:r=e.sent;case 7:return this._updateDstRooms(t,r),n=this._transformForwardStreamResult(r),e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(i=Rm(km().mark((function e(){var t,r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new mA(vA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke stopForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:if(r=this._mockForwardStreamResult([]),"running"!==this.forwardStreamState){e.next=7;break}return e.next=6,this._sendForwardStreamSignaling("stop",this._room._roomInfo.roomId);case 6:r=e.sent;case 7:if(this._updateDstRooms([],r),!(JT(sw(t=this._forwardDstRooms).call(t)).length>0)){e.next=10;break}throw new mA(vA.UNEXPECTED_ERROR,"stopforwardstream failed: ".concat(Mm(r)));case 10:return n=this._transformForwardStreamResult(r),this.forwardStreamState="stopped",e.abrupt("return",n);case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"pauseForwardStream2AllRooms",value:(n=Rm(km().mark((function e(){var t,r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("paused"!==this.forwardStreamState&&"stopped"!==this.forwardStreamState){e.next=2;break}throw new mA(vA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke pauseForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("stop",this._room._roomInfo.roomId);case 4:return t=e.sent,r=this._transformForwardStreamResult(t),this.forwardStreamState="paused",e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(r=Rm(km().mark((function e(){var t,r,n,i,o=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o.length>0&&void 0!==o[0]&&o[0]||!mT(t=["running","stopped"]).call(t,this.forwardStreamState)){e.next=3;break}throw new mA(vA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke resumeForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 3:return r=this._getDstRooms(),e.next=6,this._sendForwardStreamSignaling("start",this._room._roomInfo.roomId,r);case 6:return n=e.sent,this._updateDstRooms(r,n),i=this._transformForwardStreamResult(n),this.forwardStreamState="running",e.abrupt("return",i);case 11:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"resumeFromReconnect",value:function(){var e=this;"running"===this.forwardStreamState&&this.resumeForwardStream2AllRooms(!0).then((function(t){t.forEach((function(t){t.state===wl.FORWARD_STREAM_STATE_FAILURE&&e._room.safeEmit(Pj.ON_FORWARD_STREAM_ERROR,t)}))}))}},{key:"onForwardDstRoomUserKick",value:function(e){var t=[{dstRoomId:e.dstRoomId,code:200,forwardStreamType:"stop"}];this._updateDstRooms([],t),this._room.safeEmit(Pj.ON_FORWARD_STREAM_ERROR,{roomId:e.dstRoomId,state:wl.FORWARD_STREAM_STATE_FAILURE,error:Cl.FORWARD_STREAM_ERROR_REMOTE_KICKED})}},{key:"clear",value:function(){this._forwardDstRooms.clear(),this.forwardStreamState="stopped"}},{key:"_mockForwardStreamResult",value:function(e){var t=this,r=[];return this._forwardDstRooms.forEach((function(e,t){r.push({dstRoomId:t,forwardStreamType:"stop",code:200})})),e.forEach((function(e){var n,i=QR(r).call(r,(function(t){return t.dstRoomId===e.roomId}));-1===i?r.push({dstRoomId:e.roomId,forwardStreamType:"start",code:e.roomId===(null===(n=t._room.roomInfo)||void 0===n?void 0:n.roomId)?400:200}):r[i].forwardStreamType="update"})),r}},{key:"_transformForwardStreamResult",value:function(e){e||(e=[]);var t,r=[],n=$k(e);try{for(n.s();!(t=n.n()).done;){var i=t.value,o=i.dstRoomId,a=i.code,s={roomId:o,state:wl.FORWARD_STREAM_STATE_SUCCESS,error:Cl.FORWARD_STREAM_ERROR_OK};200===a||(400===a?(s.state=wl.FORWARD_STREAM_STATE_FAILURE,s.error=Cl.FORWARD_STREAM_ERROR_REMOTE_KICKED):a>=700&&a<800?(s.state=wl.FORWARD_STREAM_STATE_FAILURE,s.error=Cl.FORWARD_STREAM_ERROR_INVALID_TOKEN):(s.state=wl.FORWARD_STREAM_STATE_FAILURE,s.error=Cl.FORWARD_STREAM_ERROR_RESPONSE)),r.push(s)}}catch(c){n.e(c)}finally{n.f()}return r}},{key:"_updateDstRooms",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];0===(null==r?void 0:r.length)&&this._forwardDstRooms.clear(),r.forEach((function(r){var n=r.dstRoomId,i=r.code,o=r.forwardStreamType;if(200===i)if("stop"===o)t._forwardDstRooms.delete(n);else{var a,s=yE(e).call(e,(function(e){return e.roomId===n}));if(!s&&!t._forwardDstRooms.has(n))throw new mA(vA.UNEXPECTED_ERROR,"unknow roomid ".concat(n," in signaling return"));var c=null!==(a=t._forwardDstRooms.get(n))&&void 0!==a?a:{token:void 0};c=wb(c,s),t._forwardDstRooms.set(n,c)}else t._forwardDstRooms.has(n)&&t._forwardDstRooms.delete(n)}))}},{key:"_getDstRooms",value:function(){var e=[];return this._forwardDstRooms.forEach((function(t,r){e.push({roomId:r,token:t.token})})),e}},{key:"_sendForwardStreamSignaling",value:(t=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="".concat(QO()),"stop"!==t&&(a=jm(n).call(n,(function(e){return e.roomId})),null===(o=this._monitor)||void 0===o||o.report("rtc_forward_stream",{type:"begin",dst_rooms:"{ ".concat(jm(a).call(a,(function(e){return'"'.concat(e,'"')})).join(",")," }"),event_session_id:i})),e.next=4,this._room._mediaServerClient.sendForwardStreamSignal(t,r,n);case 4:if(s=e.sent,c=[],200===(null==s?void 0:s.code)){e.next=9;break}throw"stop"!==t&&(null==n||n.forEach((function(e){c.push({dst_room_id:e.roomId,result:"server error ".concat(null==s?void 0:s.code)})})),null===(u=this._monitor)||void 0===u||u.report("rtc_forward_stream",{type:"end",dst_rooms:Mm(c),event_session_id:i})),new mA(vA.UNEXPECTED_ERROR,"server side internal error, error code: ".concat(s));case 9:return"stop"!==t&&(null===(d=s.forwardStreamResults)||void 0===d||d.forEach((function(e){c.push({dst_room_id:e.dstRoomId,result:"dst room lost"})})),null===(l=s.forwardStreamResults)||void 0===l||l.forEach((function(e){var t=yE(c).call(c,(function(t){return t.dst_room_id===e.dstRoomId}));t&&(200===e.code?"update"===e.forwardStreamType?t.result="update":t.result="success":t.result="server error ".concat(e.code))})),null===(h=this._monitor)||void 0===h||h.report("rtc_forward_stream",{type:"end",dst_rooms:Mm(c),event_session_id:i})),e.abrupt("return",s.forwardStreamResults);case 11:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})}]),e}();function FG(e,t,r){var n=r.value;return r.value=Rm(km().mark((function e(){var r,i,o,a,s=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=this._room._roomInfo)||void 0===r||!r.roomId){e.next=7;break}for(i=s.length,o=new Array(i),a=0;a<i;a++)o[a]=s[a];return e.next=4,n.apply(this,o);case 4:return e.abrupt("return",e.sent);case 7:throw new mA(vA.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 8:case"end":return e.stop()}}),e,this)}))),r}UG([FG],VG.prototype,"startForwardStream2Rooms",1),UG([FG],VG.prototype,"updateForwardStream2Rooms",1),UG([FG],VG.prototype,"stopForwardStream2Rooms",1),UG([FG],VG.prototype,"pauseForwardStream2AllRooms",1),UG([FG],VG.prototype,"resumeForwardStream2AllRooms",1);var BG=new Mw("Room",1),jG={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1,publishTime:0},GG=function(e){DI(O,e);var t,r,n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k,I,R,A,w,C,x=QI(O);function O(e,t){var r;return Vl(this,O),Jd(tI(r=x.call(this)),"id",void 0),Jd(tI(r),"_mediaServerClient",void 0),Jd(tI(r),"_localStream",void 0),Jd(tI(r),"_localScreenStream",void 0),Jd(tI(r),"_remoteUsers",new $S),Jd(tI(r),"_remoteStreams",new $S),Jd(tI(r),"_remoteStreamStreamIdUserIdMap",{}),Jd(tI(r),"_virtualStreams",[]),Jd(tI(r),"_context",void 0),Jd(tI(r),"_sessionId",void 0),Jd(tI(r),"_connectionLostTimer",void 0),Jd(tI(r),"_serverConfig",void 0),Jd(tI(r),"_roomConfig",void 0),Jd(tI(r),"_roomInfo",void 0),Jd(tI(r),"_userDuplicateLoginTimerMap",new $S),Jd(tI(r),"_networkQualityManager",void 0),Jd(tI(r),"_videoSizeObserver",void 0),Jd(tI(r),"_hasPublished",!1),Jd(tI(r),"_subtitleTool",void 0),Jd(tI(r),"_csrcUserIdMap",void 0),Jd(tI(r),"_publishOnDemandItem",void 0),Jd(tI(r),"_onceTriggerBySignal",!1),Jd(tI(r),"_pubTransceiverReady",!1),Jd(tI(r),"_publishOnDemandBusy",!1),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_forwardStreamManager",void 0),BG.info("constructor","invoke"),r.id=t.id,r._roomConfig=e,r._mediaServerClient=new pG(t),r._networkQualityManager=new RG,r._networkQualityManager.reportor=r._reportNetworkQuality.bind(tI(r)),r._videoSizeObserver=new AG(tI(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(tI(r)),r._context=t,r._csrcUserIdMap={},r._monitor=VO(r.id),r._forwardStreamManager=new VG(tI(r)),r._addHandlerEventHandler(),r}return Ul(O,[{key:"hasScreenPublished",get:function(){var e;return null===(e=this._localScreenStream)||void 0===e?void 0:e.hasPublished}},{key:"hasPublished",get:function(){var e;return null===(e=this._localStream)||void 0===e?void 0:e.hasPublished}},{key:"connectionState",get:function(){return this._mediaServerClient.connectionState}},{key:"remoteUsers",get:function(){return this._remoteUsers}},{key:"remoteStreams",get:function(){return this._remoteStreams}},{key:"localStream",get:function(){return this._localStream}},{key:"localScreenStream",get:function(){return this._localScreenStream}},{key:"roomInfo",get:function(){return this._roomInfo}},{key:"roomConfig",set:function(e){this._roomConfig=e}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k,I,R,A,w,C,x,O,N,D=this;null===(e=this._mediaServerClient)||void 0===e||e.on(Rj.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on(Rj.ON_ADD_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return D._onAddStream(e)}))})),null===(r=this._mediaServerClient)||void 0===r||r.on(Rj.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(Rj.ON_REMOVE_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return D._onRemoveStream(e)}))})),null===(i=this._mediaServerClient)||void 0===i||i.on(Rj.USER_CONNECTION,this._onUserConnection.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(Rj.USER_CONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return D._onUserConnection(e)}))})),null===(a=this._mediaServerClient)||void 0===a||a.on(Rj.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(Rj.USER_DISCONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return D._onUserDisconnection(e)}))})),null===(c=this._mediaServerClient)||void 0===c||c.on(Rj.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(u=this._mediaServerClient)||void 0===u||u.on(Rj.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(Rj.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(Rj.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(Rj.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(Rj.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(Rj.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(Rj.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(Rj.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(Rj.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(Rj.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(Rj.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(Aj.RSCP,(function(e,t){!!yE(e).call(e,(function(e){var t,r,n;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:mT(t).call(t,null===(r=D._localStream)||void 0===r||null===(n=r.stream)||void 0===n?void 0:n.id)}))&&(t?D._pubTransceiverReady=!0:D._onceTriggerBySignal=!0,t&&D._onceTriggerBySignal||(D._publishOnDemandItem=e),D._pubTransceiverReady&&D._onPublishOnDemand())})),null===(b=this._mediaServerClient)||void 0===b||b.on(Aj.RTT,this._onRTT.bind(this)),null===(E=this._mediaServerClient)||void 0===E||E.on(Aj.SSC,this._onSSC.bind(this)),null===(T=this._mediaServerClient)||void 0===T||T.on(wj.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(k=this._mediaServerClient)||void 0===k||k.on(wj.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return D.emit(wj.ON_VENDOR_CONNECTION_STATE_CHANGE,e)})),null===(I=this._mediaServerClient)||void 0===I||I.on(Rj.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),null===(R=this._mediaServerClient)||void 0===R||R.on("onRemoteStreamStats",(function(e){D._networkQualityManager.updateDownlinkStats(e,D._findRemoteStreamByScreen(e.userId,e.isScreen)),D.emit(Pj.ON_REMOTE_STREAM_STATS,hN(e))})),null===(A=this._mediaServerClient)||void 0===A||A.on(Pj.RESUBSCRIBE,(function(e){D.emit(Pj.RESUBSCRIBE,e)})),null===(w=this._mediaServerClient)||void 0===w||w.on(Pj.RECONNECT_FAILED,(function(){D.emit(Pj.RECONNECT_FAILED)})),null===(C=this._mediaServerClient)||void 0===C||C.on("joinSuccess",this._onJoinSucc.bind(this)),null===(x=this._mediaServerClient)||void 0===x||x.on(Rj.ON_FORWARD_DST_ROOM_USER_KICK,this._forwardStreamManager.onForwardDstRoomUserKick.bind(this._forwardStreamManager)),null===(O=this._mediaServerClient)||void 0===O||O.on(Pj.ON_REJOIN_WITH_TCP,(function(){D.emit(Pj.ON_REJOIN_WITH_TCP)})),null===(N=this._mediaServerClient)||void 0===N||N.on(Pj.ON_ICE_CONNECT_WITH_TCP,(function(){D.emit(Pj.ON_ICE_CONNECT_WITH_TCP)}))}},{key:"_onLocalStreamStats",value:function(e){this._networkQualityManager.updateUplinkStats(e),this.emit(Pj.ON_LOCAL_STREAM_STATS,hN(e))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(C=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.connect();case 2:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"join",value:(w=Rm(km().mark((function e(t,r,n,i,o){var a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(a=this._monitor)||void 0===a||a.set({rtc_app_id:t,room_id:r,user_id:i.userId}),BG.info("join()"),this._mediaServerClient.setLiveControlMessage(o),this._roomInfo={appId:t,roomId:r,token:n,userInfo:i,roomProfile:this._roomConfig.roomProfileType},this.setSessionId(),e.prev=5,e.next=8,this._mediaServerClient.join(this._roomInfo);case 8:return c=e.sent,null!==(s=c.roomAttributes)&&void 0!==s&&s.multiChatMode&&this._handleFFAudioTrack(),this._initSubtitleTool(),e.abrupt("return",{users:c.clients,streams:c.streams});case 14:if(e.prev=14,e.t0=e.catch(5),e.t0.code===vA.OPERATION_CANCEL){e.next=18;break}throw e.t0;case 18:case"end":return e.stop()}}),e,this,[[5,14]])}))),function(e,t,r,n,i){return w.apply(this,arguments)})},{key:"publishScreen",value:(A=Rm(km().mark((function e(t,r,n,i,o){var a,s,c,u,d,l,h,v,_,p,f,m;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BG.info("publishScreen()"),this._localScreenStream||(this._localScreenStream=new AV(this._context),null!==(a=this._mediaServerClient)&&void 0!==a&&null!==(s=a.vendorConfig)&&void 0!==s&&s.enableMultiVendor&&(this._localScreenStream.pcSessionId=fw()),this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new kG(this._localScreenStream,this._mediaServerClient.handler))),c=!1,u=!1,d=!1,l=!1,!this._localScreenStream.videoTrack&&r?(r instanceof MU&&(u=!0),c=!0):this._localScreenStream.videoTrack&&!r&&(c=!1),!this._localScreenStream.audioTrack&&n?(n instanceof LU&&(l=!0),d=!0):this._localScreenStream.audioTrack&&!n&&(d=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(dN(i)&&(this._localScreenStream.pubAudio=o===Lj.PUB),lN(i)&&(this._localScreenStream.pubVideo=o===Lj.PUB),BG.info("publishScreen mediaType","pubAudio: %o, pubVideo: %o",this._localScreenStream.pubAudio,this._localScreenStream.pubVideo)),this._localScreenStream.pubAudio||this._localScreenStream.pubVideo){e.next=18;break}if(null===(h=this._localScreenStream)||void 0===h||!h.hasPublished){e.next=17;break}return e.abrupt("return",this.unpublishScreen());case 17:return e.abrupt("return");case 18:if(this._localScreenStream.hasPublished){e.next=24;break}return null===(v=this._localScreenStream.observer)||void 0===v||v.setPublish(!0),e.next=22,this._mediaServerClient.publish(this._localScreenStream);case 22:e.next=28;break;case 24:return u?null===(_=this._localScreenStream.observer)||void 0===_||_.setPushVideo(c):null===(p=this._localScreenStream.observer)||void 0===p||p.setEnableVideo(c),l?null===(f=this._localScreenStream.observer)||void 0===f||f.setPushAudio(d):null===(m=this._localScreenStream.observer)||void 0===m||m.setEnableAudio(d),e.next=28,this.updatePubScreenTrack();case 28:this._localScreenStream.pubAudio||this._localScreenStream.pubVideo?this._localScreenStream.startReport(this._onLocalStreamStats.bind(this),this._mediaServerClient.handler):this._localScreenStream.stopReport("unpublish screen");case 29:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return A.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(R=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BG.info("updatePubScreenTrack","Invoke updatePubScreenTrack"),!this._localScreenStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localScreenStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return R.apply(this,arguments)})},{key:"unpublishScreen",value:(I=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BG.info("unpublish","Invoke unpublishScreen"),!this._localScreenStream){e.next=8;break}return null===(t=this._localScreenStream.observer)||void 0===t||t.setPublish(!1),e.next=5,this._mediaServerClient.unpublish(this._localScreenStream);case 5:this._localScreenStream.stopReport("unpublish screen"),this._localScreenStream.clean(),this._localScreenStream=void 0;case 8:case"end":return e.stop()}}),e,this)}))),function(){return I.apply(this,arguments)})},{key:"liveControlMessage",value:(k=Rm(km().mark((function e(t){var r,n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BG.info("controlMessage","Invoke controlMessage"),null===(r=t.transcodeMeta)||void 0===r||r.layout.regions.forEach((function(e){n.roomInfo&&(e.roomID=n.roomInfo.roomId)})),e.next=4,this._mediaServerClient.controlMessage(t);case 4:this._mediaServerClient.setLiveControlMessage("stopped"===t.action?void 0:t);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(T=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"stopped"===t.action&&delete t.publicStreamMeta,e.next=3,this._mediaServerClient.controlMessage(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"subtitleControlMessage",value:(E=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.controlMessage(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"updateUserAttributes",value:(b=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BG.info("updateUserAttributes","Invoke updateUserAttributes"),t.role&&this._roomInfo&&(this._roomInfo.userInfo.role=t.role),e.next=4,this._mediaServerClient.updateUserAttributes(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"publish",value:(S=Rm(km().mark((function e(t,r,n,i,o,a){var s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=E.length>6&&void 0!==E[6]&&E[6],BG.info("publish","Invoke publish"),c=!1,this._localStream||(this._localStream=new AV(this._context),null!==(u=this._mediaServerClient)&&void 0!==u&&null!==(d=u.vendorConfig)&&void 0!==d&&d.enableMultiVendor&&(this._localStream.pcSessionId=fw()),this._mediaServerClient.handler&&(this._localStream.observer=new kG(this._localStream,this._mediaServerClient.handler)),c=!0,this._localStream.vendorCode=(null===(l=this._mediaServerClient.vendorConfig)||void 0===l?void 0:l.vendorCode)||0),this._localStream.videoTrack=n,this._localStream.audioTrack=i,this._localStream.videoEncodeConfig=t,this._localStream.enableSimulcast=r,o&&(dN(o)&&(this._localStream.pubAudio=a===Lj.PUB),lN(o)&&(this._localStream.pubVideo=a===Lj.PUB),BG.info("publish mediaType","pubAudio: %o, pubVideo: %o",this._localStream.pubAudio,this._localStream.pubVideo)),this._localStream.hasPublished){e.next=26;break}if(this._localStream.pubAudio||this._localStream.pubVideo){e.next=12;break}return e.abrupt("return");case 12:return e.prev=12,s?null===(h=this._localStream.observer)||void 0===h||h.setLogin(!0):c&&(v=!!this._localStream.videoTrack,_=!!this._localStream.audioTrack,p=this._localStream.videoTrack instanceof MU,f=this._localStream.audioTrack instanceof LU,this._roomConfig.isAutoPublish&&!this._hasPublished?(v&&(p?null===(m=this._localStream.observer)||void 0===m||m.setPushVideo(!0):null===(g=this._localStream.observer)||void 0===g||g.setEnableVideo(!0)),_&&(f?null===(y=this._localStream.observer)||void 0===y||y.setPushAudio(!0):null===(S=this._localStream.observer)||void 0===S||S.setEnableAudio(!0))):null===(b=this._localStream.observer)||void 0===b||b.setPublish(!0)),e.next=16,this._mediaServerClient.publish(this._localStream);case 16:this._hasPublished=!0,this.emit(Pj.ON_PUBLISH_RESULT,{isScreen:!1,state:ol.PUBLISH_SUCC}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(12),this.emit(Pj.ON_PUBLISH_RESULT,{isScreen:!1,state:ol.PUBLISH_FAIL}),e.t0;case 24:e.next=28;break;case 26:return e.next=28,this.updatePubTrack();case 28:this._localStream.pubAudio||this._localStream.pubVideo?this._localStream.startReport(this._onLocalStreamStats.bind(this),this._mediaServerClient.handler):this._localStream.stopReport("unpublish");case 29:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e,t,r,n,i,o){return S.apply(this,arguments)})},{key:"updatePubTrack",value:(y=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BG.info("updatePubTrack","Invoke updatePubTrack"),!this._localStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"unpublish",value:(g=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BG.info("unpublish","Invoke unpublish"),!this._localStream){e.next=7;break}return e.next=4,this._mediaServerClient.unpublish(this._localStream);case 4:this._localStream.stopReport("unpublish"),this._localStream.clean(),this._localStream=void 0;case 7:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"subscribe",value:(m=Rm(km().mark((function e(t,r,n){var i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BG.info("subscribe","remoteStream %o",t),i=void 0,n&&(i=this._getSubLayer(n,t)),e.next=5,this._mediaServerClient.subscribe(t,r,i);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return m.apply(this,arguments)})},{key:"updateSubTrack",value:(f=Rm(km().mark((function e(t,r,n,i){var o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BG.info("updateSubTrack","Invoke updateSubTrack"),!i){e.next=4;break}return e.next=4,null===(a=this._mediaServerClient)||void 0===a?void 0:a.updateSubTrackLayer(t,i);case 4:return e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrack(t,r,n));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return f.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(p=Rm(km().mark((function e(t,r){var n,i,o,a,s;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((a=this._findRemoteStreamByScreen(t,!1))&&a.hasSubscribed&&!((null==a||null===(n=a.attributes)||void 0===n||null===(i=n.videoDescriptions)||void 0===i?void 0:i.length)<=1)){e.next=3;break}return e.abrupt("return");case 3:return s=this._getSubLayer(r,a),a.originalStreamIndex=s.spatialLayer,e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrackLayer(a,s));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"_getSubLayer",value:function(e,t){for(var r,n,i,o,a,s=null==t?void 0:t.attributes,c=s.videoDescriptions,u=s.subVideoDescriptions,d=Array.isArray(u)?u:c,l=-1,h=e.width*e.height,v=0;v<(null==d?void 0:d.length);v++){var _,p;if(h>=(null===(_=d[v])||void 0===_?void 0:_.width)*(null===(p=d[v])||void 0===p?void 0:p.height)){l=v;break}}var f=d[0];if(-1===l)f=d[l=d.length-1];else if(0!==l){var m=d[l-1].width*d[l-1].height,g=(m-h)/(m-d[l].width*d[l].height);f=g<.1?d[l-1]:d[l],l=g<.1?l-1:l}return a=null!==(r=null===(n=f)||void 0===n?void 0:n.sub_index)&&void 0!==r?r:-1,{spatialLayer:null!==(i=null===(o=f)||void 0===o?void 0:o.video_index)&&void 0!==i?i:l,spatialSubLayer:a}}},{key:"unsubscribe",value:(_=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BG.info("unsubscribe","Invoke unsubscribe"),e.next=3,this._mediaServerClient.unsubscribe(t,r);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return _.apply(this,arguments)})},{key:"startSubtitle",value:(v=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subtitleTool){e.next=5;break}return e.next=3,this._subtitleTool.start(t);case 3:e.next=6;break;case 5:throw new mA(vA.INVOKED_BEFORE_JOIN_ROOM,"join first");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"stopSubtitle",value:(h=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(t=this._subtitleTool)||void 0===t||t.stop();case 1:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"startForwardStream2Rooms",value:(l=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.startForwardStream2Rooms(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(d=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.updateForwardStream2Rooms(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(u=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.stopForwardStream2Rooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"pauseForwardStream2AllRooms",value:(c=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.pauseForwardStream2AllRooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(s=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.resumeForwardStream2AllRooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"leave",value:(a=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=h.length>0&&void 0!==h[0]&&h[0],BG.info("leave","Invoke leave"),n=WO(),null===(t=this._subtitleTool)||void 0===t||t.destroy(),delete this._subtitleTool,e.prev=5,s=$k(oR(a=this._remoteStreams).call(a));try{for(s.s();!(c=s.n()).done;)u=c.value,Array.isArray(u)&&u.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setLogin(!1)}))}catch(v){s.e(v)}finally{s.f()}return this._localStream&&(null===(d=this._localStream.observer)||void 0===d||d.setLogin(!1)),e.next=11,this._mediaServerClient.leave().catch((function(){}));case 11:this.destroy(),null===(i=this._monitor)||void 0===i||i.report("rtc_leave_room",{error_code:0,message:"",elapse:WO()-n}),null===(o=this._monitor)||void 0===o||o.set({room_id:"",user_id:"",rtc_session_id:"",rtc_vid:""}),e.next=24;break;case 16:if(e.prev=16,e.t0=e.catch(5),!r){e.next=22;break}throw e.t0;case 22:this.destroy();case 23:e.t0 instanceof Error&&(null===(l=this._monitor)||void 0===l||l.report("rtc_leave_room",{error_code:-1,message:e.t0.message,elapse:WO()-n}));case 24:case"end":return e.stop()}}),e,this,[[5,16]])}))),function(){return a.apply(this,arguments)})},{key:"updateRemoteUserPriority",value:function(e){var t,r=this;null===(t=this.remoteStreams.get(e))||void 0===t||t.forEach((function(t){var n=(r._context||{}).userPriority;t.hasSubscribed&&n.has(e)&&r._mediaServerClient.updateSubPriority(t,n.get(e))}))}},{key:"destroy",value:function(){var e;BG.info("destroy","Invoke destroy"),jO(this.id,"room_destroy","".concat((new Error).stack)),null===(e=this._subtitleTool)||void 0===e||e.destroy(),delete this._subtitleTool,this._mediaServerClient.destroy(),this._removeHandlerEventHandler(),this._roomInfo=void 0,this._remoteUsers=new $S;var t,r,n,i=$k(this._remoteStreams);try{for(i.s();!(t=i.n()).done;){var o=eI(t.value,2)[1];Array.isArray(o)&&o.forEach((function(e){e&&e.destroy()}))}}catch(a){i.e(a)}finally{i.f()}(this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new $S,this._localStream)&&(null===(r=this._localStream)||void 0===r||r.clean(),this._localStream=void 0);this._localScreenStream&&(null===(n=this._localScreenStream)||void 0===n||n.clean(),this._localScreenStream=void 0);this._removeHandlerEventHandler(),clearTimeout(this._connectionLostTimer),this._userDuplicateLoginTimerMap.forEach((function(e){clearTimeout(e)})),this._userDuplicateLoginTimerMap.clear(),this._networkQualityManager.destroy(),this._videoSizeObserver.destroy(),this._csrcUserIdMap={},this._virtualStreams=[],this._remoteStreamStreamIdUserIdMap={},this._forwardStreamManager.clear()}},{key:"updateToken",value:(o=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BG.info("updateToken","Invoke updateToken"),this._roomInfo&&(this._roomInfo.token=t),e.prev=2,e.next=5,this._mediaServerClient.updateToken(t);case 5:e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(2),this.safeEmit(Pj.ON_ROOM_ERROR,{errorCode:vA.UPDATE_TOKEN_WITH_INVALID_TOKEN}),e.t0;case 11:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return o.apply(this,arguments)})},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._mediaServerClient)||void 0===r?void 0:r.sendUserMessage(e,t)}},{key:"setSessionId",value:function(){var e;this._sessionId=_w(),this._mediaServerClient._sessionId=this._sessionId,null===(e=this._monitor)||void 0===e||e.set({rtc_session_id:this._sessionId})}},{key:"sendRoomMessage",value:(i=Rm(km().mark((function e(t){var r,n,i,o,a,s=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=s.length>1&&void 0!==s[1]&&s[1],a={clientId:null===(r=this._roomInfo)||void 0===r?void 0:r.userInfo.userId,binary:o,message:"",roomId:null===(n=this._roomInfo)||void 0===n?void 0:n.roomId},!o){e.next=8;break}return e.next=5,YO.ab2b64str(t);case 5:a.message=e.sent,e.next=9;break;case 8:a.message=t;case 9:return e.abrupt("return",null===(i=this._mediaServerClient)||void 0===i?void 0:i.sendRoomMessage(a));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"_onJoinSucc",value:function(e){var t,r,n,i=this,o=e.joinRes,a=e.reconnect;BG.info("_onJoinSucc()","invoke. ".concat(a?"[reconnect]":"")),this._serverConfig=o.config,this._mediaServerClient.roomAttributes=o.roomAttributes;var s=[],c=[],u=[],d=[],l=[];null===(t=o.clientsDetail)||void 0===t||t.forEach((function(e){if(e.attributes&&(e.attributes.serverMuteVideo&&i.safeEmit(Pj.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&i.safeEmit(Pj.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio})),e.clientId!==o.clientId){var t=i._remoteUsers.get(e.clientId);t?t._stillExist=!0:s.push(e)}}));var h,v=$k(oR(r=this._remoteUsers).call(r));try{for(v.s();!(h=v.n()).done;){var _=h.value;_._stillExist||c.push({clientId:_.userId}),delete _._stillExist}}catch(g){v.e(g)}finally{v.f()}o.streams.forEach((function(e){var t=i._findRemoteStreamByScreen(e.clientId,e.screen);t?(t.stillExist=!0,t.streamId=e.streamId,l.push(e)):d.push(e)}));var p,f=$k(oR(n=this._remoteStreams).call(n));try{for(f.s();!(p=f.n()).done;){var m=p.value;Array.isArray(m)&&m.forEach((function(e){e.stillExist?delete e.stillExist:u.push({clientId:e.userId,streamId:e.streamId,message:kj.clientDisconnected})}))}}catch(g){f.e(g)}finally{f.f()}c.forEach((function(e){return i._onUserDisconnection(e)})),s.forEach((function(e){return i._onUserConnection(e)})),u.forEach((function(e){return i._onRemoveStream(e)})),d.forEach((function(e){return i._onAddStream(e,{fromSignal:!1})})),l.forEach((function(e){return i._onUpdateStreamAttributes(e)})),a&&this._handleSendOrRecvStreamAfterReconnect()}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e,t,r,n,i,o=this;this._localStream&&(this._localStream.clean(),this._localStream.vendorCode=(null===(r=this._mediaServerClient.vendorConfig)||void 0===r?void 0:r.vendorCode)||0,null===(n=this._localStream.observer)||void 0===n||n.setLogin(!0),this._mediaServerClient.publish(this._localStream).catch((function(e){})));this._localScreenStream&&(this._localScreenStream.clean(),null===(i=this._localScreenStream.observer)||void 0===i||i.setLogin(!0),this._mediaServerClient.publish(this._localScreenStream).catch((function(e){})));var a,s=$k(oR(t=this._remoteStreams).call(t));try{for(s.s();!(a=s.n()).done;){var c=a.value;Array.isArray(c)&&c.forEach(function(){var e=Rm(km().mark((function e(t){var r,n,i,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasSubscribed){e.next=17;break}return t.resetHasSubscribed(),e.prev=2,BG.info(Om(r="start resubscribe ".concat(t.userId," with ")).call(r,t.subMediaType)),lN(t.subMediaType)&&(null===(n=t.observer)||void 0===n||n.setSubscribeVideo(!0)),dN(t.subMediaType)&&(null===(i=t.observer)||void 0===i||i.setSubscribeAudio(!0)),e.next=8,o._mediaServerClient.subscribe(t,t.subMediaType);case 8:BG.info(Om(a="success resubscribe ".concat(t.userId," with ")).call(a,t.subMediaType)),o.safeEmit(Pj.RESUBSCRIBE,{stream:t}),e.next=17;break;case 12:e.prev=12,e.t0=e.catch(2),BG.error(Om(s=Om(c="failed resubscribe ".concat(t.userId," with ")).call(c,t.subMediaType,", error:")).call(s,e.t0)),t.clean(),null==t||t.resetHasSubscribed();case 17:case"end":return e.stop()}}),e,null,[[2,12]])})));return function(t){return e.apply(this,arguments)}}())}}catch(u){s.e(u)}finally{s.f()}null===(e=this._subtitleTool)||void 0===e||e.reconnect(),this._forwardStreamManager.resumeFromReconnect()}},{key:"_handleFFAudioTrack",value:function(){var e,t,r,n,i=null===(e=this._mediaServerClient)||void 0===e||null===(t=e.handler)||void 0===t?void 0:t.audioTrack4ff,o=null===(r=this._mediaServerClient)||void 0===r||null===(n=r.handler)||void 0===n?void 0:n.getTransceivers();if(i&&Array.isArray(o)){var a=yE(o).call(o,(function(e){var t;return(null==e||null===(t=e.receiver)||void 0===t?void 0:t.track)===i}));if(a){var s=new wV(this._context,"ff-stream","ff-stream",!1,!1,jG);s.virtual=!0,s.audioTransceiver=a,s.audioMid="0",s.audioTrack=QU(i),this._virtualStreams.push(s),this.safeEmit(Pj.SUBSCRIBE_PUSH_TRACK,{stream:s})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?yE(r).call(r,(function(e){return e.streamId===t})):null}},{key:"_findRemoteStreamByScreen",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?yE(r).call(r,(function(e){return e.isScreen===t})):null}},{key:"_onAddStream",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.needEmit,i=void 0===n||n,o=r.fromSignal,a=void 0===o||o,s=r.virtual,c=void 0!==s&&s;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var u=this._roomConfig,d=u.isAutoSubscribeAudio,l=u.isAutoSubscribeVideo,h=this._findRemoteStreamByScreen(e.clientId,e.screen);if(h&&h.streamId!==e.streamId){var v,_=null===(v=this._remoteStreams.get(e.clientId))||void 0===v?void 0:Gs(v).call(v,(function(e){return e.streamId!==h.streamId}));h.clean(),this._remoteStreams.set(e.clientId,_||[])}var p=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,p)p.attributes=e.attributes;else if((p=new wV(this._context,e.clientId,e.streamId,e.screen,!1,e.attributes)).virtual=c,this._initStreamListeners(p),!c){var f=this._remoteStreams.get(e.clientId);f?f.push(p):this._remoteStreams.set(e.clientId,[p])}if(this._mediaServerClient.handler&&(p.observer=new EG(p,this._mediaServerClient.handler)),!p.isScreen&&l){var m,g,y,S,b,E,T,k;if(a&&p.hasVideo)if(p.attributes.extvideo)null===(m=p.observer)||void 0===m||m.setExternalVideoSource(!0),null===(g=p.observer)||void 0===g||g.setPushVideo(!0);else null===(y=p.observer)||void 0===y||y.setExternalVideoSource(!1),null===(S=p.observer)||void 0===S||S.setPublishVideo(!0);if(a&&p.hasAudio&&d&&!this._mediaServerClient.roomAttributes.multiChatMode)if(p.attributes.extaudio)null===(b=p.observer)||void 0===b||b.setExternalAudioSource(!0),null===(E=p.observer)||void 0===E||E.setPushAudio(!0);else null===(T=p.observer)||void 0===T||T.setExternalAudioSource(!1),null===(k=p.observer)||void 0===k||k.setPublishAudio(!0);if(i&&!a){var I,R=this._roomConfig,A=R.isAutoSubscribeAudio,w=R.isAutoSubscribeVideo;null===(I=p.observer)||void 0===I||I.setLogin(!0,{audio:!!A&&!this.multiChatMode,video:!!w})}}return i&&this.safeEmit(Rj.ON_ADD_STREAM,{stream:p}),p}}},{key:"_onUserConnection",value:function(e){var t;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var r=this._userDuplicateLoginTimerMap.get(e.clientId);if("number"==typeof r)return this._userDuplicateLoginTimerMap.delete(e.clientId),void self.clearTimeout(r);var n={userId:e.clientId,extraInfo:e.attributes.extra_info};this._remoteUsers.set(e.clientId,Zd({},n)),this.safeEmit(Rj.USER_CONNECTION,{userInfo:n}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(Pj.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(Pj.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}}},{key:"_onUserDisconnection",value:function(e){var t,r=this,n=e.clientId,i=e.tag,o=e.code;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var a=null;i===Cj.kickedByAdmin?a=vA.KICKED_OUT:i===Cj.onUserTokenDidExpire?a=vA.TOKEN_EXPIRED:i===Cj.userDuplicateLogin&&(a=vA.DUPLICATE_LOGIN),o===xj.roomDismissByAdmin&&(a=vA.ROOM_DISMISS),a&&this.safeEmit(Pj.ON_ROOM_ERROR,{errorCode:a})}else{var s=tl.DROPPED;i===Cj.userLeave?s=tl.QUIT:i===Cj.kickedByAdmin?s=tl.KICKED_BY_ADMIN:i===Cj.roleChanged&&(s=tl.SWITCH_TO_INVISIBLE);var c=function(){var e;r._remoteUsers.delete(n),null===(e=r._remoteStreams.get(n))||void 0===e||e.forEach((function(e){r._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:kj.clientDisconnected})})),r._remoteStreams.delete(n),r.safeEmit(Pj.ON_USER_LEAVE,{userInfo:{userId:n},reason:s})};if(i===Cj.userDuplicateLogin){var u=this._userDuplicateLoginTimerMap.get(n);u&&self.clearTimeout(u);var d=self.setTimeout(c,5e3);this._userDuplicateLoginTimerMap.set(n,d)}else c()}}},{key:"_onRemoveStream",value:function(e){var t,r=this;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var n=this._remoteStreams.get(e.clientId);if(n){var i=yE(n).call(n,(function(t){return t.streamId===e.streamId}));if(i){var o,a,s;if(null===(o=this._mediaServerClient)||void 0===o||o.handleRemoveStream(i,e).then((function(){var t=r._remoteStreams.get(e.clientId);t&&(t=Gs(t).call(t,(function(t){return t.streamId!==e.streamId||(t.clean(),!1)})),r._remoteStreams.set(e.clientId,t))})).finally((function(){r.safeEmit(Rj.ON_REMOVE_STREAM,{stream:i,reason:e.message,callback:function(){return i.destroy()}})})),i.hasVideo)null===(a=i.observer)||void 0===a||a.setPublishVideo(!1);if(i.hasAudio&&!this._mediaServerClient.roomAttributes.multiChatMode)null===(s=i.observer)||void 0===s||s.setPublishAudio(!1)}}}}},{key:"_onUpdateUserAttributes",value:function(e){e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(Pj.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(Pj.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){var t;e.roomAttributes&&(this._mediaServerClient.roomAttributes=Zd(Zd({},this._mediaServerClient.roomAttributes),e.roomAttributes)),null!==(t=e.roomAttributes)&&void 0!==t&&t.multiChatMode&&this._handleFFAudioTrack()}},{key:"_onUpdateStreamAttributes",value:function(e){var t=this._roomConfig,r=t.isAutoSubscribeAudio,n=t.isAutoSubscribeVideo,i=e.clientId,o=e.streamId,a=e.attributes,s=this._findRemoteStream(i,o);if(s){var c,u,d=s.attributes,l=Zd(Zd({},d),a),h=!1,v=l.localaudio!==d.localaudio,_=!1,p=!1,f=l.localvideo!==d.localvideo,m=!1,g=cV.NONE,y=cV.NONE;if(l.audiostream!==d.audiostream&&(h=l.localaudio,_=!!l.audiostream,l.audiostream?g|=ul.AUDIO:y|=ul.AUDIO),l.videostream!==d.videostream&&(p=l.localvideo,m=!!l.videostream,l.videostream?g|=ul.VIDEO:y|=ul.VIDEO),g&&this.safeEmit(Pj.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:g,isScreen:s.isScreen,pubState:Lj.PUB,remoteStream:s}),y&&this.safeEmit(Pj.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:y,isScreen:s.isScreen,pubState:Lj.UNPUB,remoteStream:s}),s.attributes=l,l.localaudio!==d.localaudio)if(l.localaudio){var S,b,E,T;if(r&&l.audiostream)if(l.extaudio)null===(S=s.observer)||void 0===S||S.setExternalAudioSource(!0),null===(b=s.observer)||void 0===b||b.setPushAudio(!0);else null===(E=s.observer)||void 0===E||E.setExternalAudioSource(!1),null===(T=s.observer)||void 0===T||T.setEnableAudio(!0);this.safeEmit(Pj.ON_USER_START_AUDIO_CAPTURE,{userId:i},s)}else{var k,I,R,A;if(l.extaudio)null===(k=s.observer)||void 0===k||k.setExternalAudioSource(!0),null===(I=s.observer)||void 0===I||I.setPushAudio(!1);else null===(R=s.observer)||void 0===R||R.setExternalAudioSource(!1),null===(A=s.observer)||void 0===A||A.setEnableAudio(!1);!s.isScreen&&this.safeEmit(Pj.ON_USER_STOP_AUDIO_CAPTURE,{userId:i})}if(l.localvideo!==d.localvideo)if(l.localvideo){var w,C,x,O;if(n&&l.videostream)if(l.extvideo)null===(w=s.observer)||void 0===w||w.setExternalVideoSource(!0),null===(C=s.observer)||void 0===C||C.setPushVideo(!0);else null===(x=s.observer)||void 0===x||x.setExternalVideoSource(!1),null===(O=s.observer)||void 0===O||O.setEnableVideo(!0);this.safeEmit(Pj.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var N,D,P,M;if(l.extvideo)null===(N=s.observer)||void 0===N||N.setExternalVideoSource(!0),null===(D=s.observer)||void 0===D||D.setPushVideo(!1);else null===(P=s.observer)||void 0===P||P.setExternalVideoSource(!1),null===(M=s.observer)||void 0===M||M.setEnableVideo(!1);!s.isScreen&&this.safeEmit(Pj.ON_USER_STOP_VIDEO_CAPTURE,{userId:i})}if(h&&!v)null===(c=s.observer)||void 0===c||c.setRemoteUnmuteAudio(_);if(p&&!f)null===(u=s.observer)||void 0===u||u.setRemoteUnmuteVideo(m)}}},{key:"_onPushTrack",value:function(e){var t,r=this;if(null!==(t=e.streamId)&&void 0!==t&&hA(t).call(t,"audio_mux")){var n=this._onAddStream(Zd(Zd({},e),{},{attributes:jG}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._mediaServerClient.subscribe4pushTrack(n,e).then((function(){r.safeEmit(Pj.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){BG.error("subscribe","push track failed %o",e)}))}else{var i,o;null===(i=this._monitor)||void 0===i||i.report("rtc_error",{message:Om(o="onPushTrack, userId: ".concat(e.clientId,", ")).call(o,e.streamId),error_code:jj.TRACK_ERROR})}}},{key:"_onRemoveTrack",value:function(e){var t,r=e.clientId,n=e.streamId,i=e.message,o=e.trackType;BG.info("_onRemoveTrack","remove track: %o",r);var a=this._findRemoteStream(r,n);a&&(a.removeTrack=!0,null===(t=this._mediaServerClient)||void 0===t||t.unsubscribe4removeTrack(a,i,o),this.emit(Pj.REMOVE_PUSH_TRACK,{stream:a,mediaType:o+1}))}},{key:"_onMeetingSpeakerChange",value:function(e){if(Array.isArray(null==e?void 0:e.speakerCsrcInfo)){var t={};null==e||e.speakerCsrcInfo.forEach((function(e){var r=e.csrc,n=e.userId;e.isScreen||(t[r]=n)})),this._csrcUserIdMap=t}Array.isArray(e.muxStreamInUse)&&this._virtualStreams.forEach((function(t){var r;null!==(r=e.muxStreamInUse)&&void 0!==r&&mT(r).call(r,t.streamId)?t.virtualOccupy=!0:t.virtualOccupy=!1}))}},{key:"getActiveSpeakerInMultiChatMode",value:function(){var e=this,t=[];return this._virtualStreams.forEach((function(r){var n,i=null===(n=r.audioTransceiver)||void 0===n?void 0:n.receiver;if(i){var o=eI(i.getContributingSources()||[],1)[0];if(o){var a=o.audioLevel,s=o.source;e._csrcUserIdMap[s]&&t.push({userId:e._csrcUserIdMap[s],audioLevel:a})}}})),t.length&&GR(t).call(t,(function(e,t){return e.audioLevel-t.audioLevel})),t}},{key:"_onReconnecting",value:function(){var e,t,r,n,i,o,a,s=this;if(this._roomInfo){var c,u=$k(oR(a=this._remoteStreams).call(a));try{for(u.s();!(c=u.n()).done;){var d=c.value;Array.isArray(d)&&d.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setDisconnect(),e.clean()}))}}catch(l){u.e(l)}finally{u.f()}this._virtualStreams.forEach((function(e){var t;s.emit(Pj.REMOVE_PUSH_TRACK,{stream:e,mediaType:ul.AUDIO}),null===(t=e.observer)||void 0===t||t.setDisconnect(),e.clean()})),this._virtualStreams=[],null===(e=this.localStream)||void 0===e||null===(t=e.observer)||void 0===t||t.setDisconnect(),null===(r=this.localStream)||void 0===r||r.clean(),null===(n=this.localScreenStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setDisconnect(),null===(o=this.localScreenStream)||void 0===o||o.clean()}}},{key:"_onConnectionStateChange",value:function(e){var t,r=this;if(e.next===vG.DISCONNECTED)t=ll.CONNECTION_STATE_DISCONNECTED;else if(e.next===vG.CONNECTED)clearTimeout(this._connectionLostTimer),t=this._mediaServerClient.isReconnecting?ll.CONNECTION_STATE_RECONNECTED:ll.CONNECTION_STATE_CONNECTED;else{if(e.next!==vG.CONNECTING)return;this._mediaServerClient.isReconnecting?(t=ll.CONNECTION_STATE_RECONNECTING,this._onReconnecting()):t=ll.CONNECTION_STATE_CONNECTING}e.prev===vG.CONNECTED&&e.next===vG.DISCONNECTED&&(this._connectionLostTimer=window.setTimeout((function(){r.safeEmit(wj.ON_CONNECTION_STATE_CHANGE,{state:ll.CONNECTION_STATE_LOST})}),1e4)),this._networkQualityManager.setMSC(this._mediaServerClient),this.safeEmit(wj.ON_CONNECTION_STATE_CHANGE,{state:t})}},{key:"_initStreamListeners",value:function(e){var t=this;e.on("ontrack",(function(e){e.track})),e.on("onSEIMessage",(function(r){var n;t.emit(Pj.ON_SEI_MESSAGED_RECEIVED,{sei:r,remoteStreamKey:{userId:e.userId,roomId:null===(n=t._roomInfo)||void 0===n?void 0:n.roomId,streamIndex:e.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){this.safeEmit(Rj.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(Rj.USER_MESSAGE_RECEIVED,{userId:e.from,message:e.msg})}},{key:"_onUserBinaryMessageReceived",value:function(e){var t,r={userId:e.from,message:e.msg};null!==(t=this._subtitleTool)&&void 0!==t&&t.onMessageRecv(r)||this.safeEmit(Rj.USER_BINARY_MESSAGE_RECEIVED,r)}},{key:"_initSubtitleTool",value:function(){var e=this;this._subtitleTool=new NG(this),this._subtitleTool.onEvent=function(t){e.emit(Pj.ON_SUBTITLE_STATE_CHANGED,t)},this._subtitleTool.onMessage=function(t){e.emit(Pj.ON_SUBTITLE_MESSAGE_RECEIVED,t)}}},{key:"_onPostProcessingMessage",value:function(e){if(e.body)if("subtitleCallback"!==e.type){var t=e.body,r=t.error||0,n=Mj.START,i=["success","parameter error","subscription timeout","ffmpeg error","cdn error","publish error"];if("2.0"===t.protocol){switch(t.eventType){case"TranscodeStarted":0!==t.error&&(n=Mj.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?Mj.START_FAILED:Mj.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?Mj.STOP_FAILED:Mj.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?Mj.UPDATE_FAILED:Mj.UPDATE_SUCCESS}this.safeEmit(Rj.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(Rj.POST_PROCESSING_MESSAGE,{code:r,message:i[r],type:e.type})}else{var o;null===(o=this._subtitleTool)||void 0===o||o.onResult(e)}}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(Rj.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onStreamFailed",value:(n=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d,l;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("publish"!==t.type){e.next=11;break}if(s=void 0,(null===(r=this.localStream)||void 0===r?void 0:r.streamId)===t.streamId?s=this.localStream:(null===(n=this.localScreenStream)||void 0===n?void 0:n.streamId)===t.streamId&&(s=this.localScreenStream),s){e.next=5;break}return e.abrupt("return");case 5:return null===(i=s)||void 0===i||i.clean(),e.next=8,null===(o=this._mediaServerClient)||void 0===o?void 0:o.unpublish(s).catch((function(){}));case 8:null===(a=this._mediaServerClient)||void 0===a||a.publish(s).catch((function(){})),e.next=20;break;case 11:if("subscribe"!==t.type){e.next=20;break}if(c=this._remoteStreamStreamIdUserIdMap[t.streamId],!(u=this._findRemoteStream(c,t.streamId))){e.next=20;break}return e.next=17,null===(d=this._mediaServerClient)||void 0===d?void 0:d.unsubscribe(u,ul.AUDIO_AND_VIDEO);case 17:return e.next=19,null===(l=this._mediaServerClient)||void 0===l?void 0:l.subscribe(u,u.subMediaType,u.subLayer);case 19:this.safeEmit(Pj.RESUBSCRIBE,{stream:u});case 20:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_onStreamControlMessage",value:function(e){var t,r;e.type===Ij.PushLimitWarn&&(null!==(t=this._localStream)&&void 0!==t&&t.pubAudio||null!==(r=this._localStream)&&void 0!==r&&r.pubVideo||this.unpublish())}},{key:"_onPublishOnDemand",value:(r=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,v,_,p;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publishOnDemandItem&&!this._publishOnDemandBusy&&!1!==(null===(t=this._serverConfig)||void 0===t||null===(r=t.engine_VPM)||void 0===r||null===(n=r.ondemand)||void 0===n?void 0:n.enable)){e.next=2;break}return e.abrupt("return");case 2:if(null===(i=this._localStream)||void 0===i||!i.enableSimulcast||null===(o=this._localStream)||void 0===o||!o.videoTransceiver){e.next=16;break}return this._publishOnDemandBusy=!0,u=this._publishOnDemandItem,this._publishOnDemandItem=void 0,d=[],l=null===(s=this._localStream)||void 0===s?void 0:s.stream.id,h=null===(c=this._localStream)||void 0===c?void 0:c.videoTransceiver.sender,v=h.getParameters(),Array.isArray(v.encodings)&&Array.isArray(u)&&(p={},BG.info("_onPublishOnDemand exec","usedDescriptions: %o",u),u.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&mT(t).call(t,l)){var r=null==e?void 0:e.Metadata.VideoIndex;p[r]=!0}})),v.encodings=jm(_=v.encodings).call(_,(function(e){if(e.rid){p[e.rid]?e.active=!0:e.active=!1;var t=Number(e.rid);d[t]=e.active}return e})),this._context&&(this._context.activeSimStreams=d)),e.next=13,h.setParameters(v);case 13:this._publishOnDemandBusy=!1,e.next=18;break;case 16:if(null!==(a=this._localStream)&&void 0!==a&&a.videoTransceiver){e.next=18;break}return e.abrupt("return");case 18:this._onPublishOnDemand();case 19:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_onRTT",value:function(e){var t=e.StreamIds,r=e.Metadata;if(t.length&&r){var n,i=t[0];null!==(n=this._context)&&void 0!==n&&n.streamRTT&&(this._context.streamRTT[i]={audio:r.audio_rtt,video:r.video_rtt})}}},{key:"_onSSC",value:function(e){var t=e.StreamIds,r=e.Metadata,n=t[0],i=this._remoteStreamStreamIdUserIdMap[n],o=this._findRemoteStream(i,n),a={userId:i,isScreen:!!o&&o.isScreen,beforeVideoIndex:r.ssc_items[0].prev_layer_id,afterVideoIndex:r.ssc_items[0].cur_layer_id,beforeEnable:0!==r.ssc_items[0].prev_video_open,afterEnable:0!==r.ssc_items[0].cur_video_open,reason:r.ssc_items[0].change_reason};this.emit(Pj.ON_SIMULCAST_SUBSCRIBE_FALLBACK,a)}},{key:"_reportNetworkQuality",value:function(e,t){this.emit(Pj.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){var i;this.emit(Pj.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:null===(i=this.roomInfo)||void 0===i?void 0:i.roomId,userId:e,streamIndex:t?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN},{width:r,height:n})}},{key:"multiChatMode",get:function(){var e;return null===(e=this._mediaServerClient)||void 0===e?void 0:e.multiChatMode()}},{key:"setAudioEncodeMaxBitrate",value:(t=Rm(km().mark((function e(t,r){var n,i,o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(n=t===cl.STREAM_INDEX_MAIN?this.localStream:this.localScreenStream)||!n.pubAudio){e.next=7;break}if(null==(o=null===(i=n.audioTransceiver)||void 0===i?void 0:i.sender.getParameters())||!o.encodings.length){e.next=7;break}return o.encodings[0].maxBitrate=1e3*r,e.next=7,null===(a=n.audioTransceiver)||void 0===a?void 0:a.sender.setParameters(o);case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),O}(UD),HG=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=document.createElement(e);return t.id&&(r.id=t.id),t.classList&&t.classList.forEach((function(e){r.classList.add(e)})),t.style&&wb(r.style,t.style),t.attributes&&RA(t.attributes).forEach((function(e){var t=eI(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},zG=new Mw("Player",0),KG=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],XG={playsinline:"","webkit-playsinline":""},WG={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},qG=function(e){DI(n,e);var t,r=QI(n);function n(e,t){var i;Vl(this,n),Jd(tI(i=r.call(this)),"_containerDom",void 0),Jd(tI(i),"_videoDom",void 0),Jd(tI(i),"__cumulativeTime",void 0),Jd(tI(i),"userId",void 0),Jd(tI(i),"renderMode",void 0),Jd(tI(i),"mirrorType",hl.MIRROR_TYPE_NONE),Jd(tI(i),"isScreen",void 0),Jd(tI(i),"isLocal",void 0),Jd(tI(i),"played",!1),Jd(tI(i),"_needLoad",!1),Jd(tI(i),"_emitPlayFailed",!1),Jd(tI(i),"_videoContainer",void 0),Jd(tI(i),"_safari15VideoTimer",void 0),Jd(tI(i),"_monitor",void 0),Jd(tI(i),"_onLocalTrackMute",void 0),Jd(tI(i),"_onInterruptionEnd",void 0),Jd(tI(i),"_needResume",!1),Jd(tI(i),"emitVideoEvent",(function(e){var t,r,n={type:"video",rawEvent:e,readyState:(null===(t=i._videoDom)||void 0===t?void 0:t.readyState)||0,userId:i.userId,eventName:e.type,currentTime:(null===(r=i._videoDom)||void 0===r?void 0:r.currentTime)||0,isScreen:i.isScreen};switch(i.emit("playback_event",n),e.type){case"canplay":case"loadeddata":i._internalPlay();break;case"playing":zG.info("VideoPlayerPlaying","[userId-".concat(i.userId,"] video element playing"));break;case"pause":zG.info("VideoPlayerPause","[userId-".concat(i.userId,"] video element pause")),i._needResume&&(zG.info("VideoPlayerPause","[userId-".concat(i.userId,"] video element resume")),i._internalPlay(),i._needResume=!1)}})),Jd(tI(i),"_internalPlay",(function(){var e;if(null!==(e=i._videoDom)&&void 0!==e&&e.paused){var t=i._videoDom.play();null!=t&&t.then&&t.then((function(){var e;i.isLocal&&IN&&!i._needLoad&&(null===(e=i._videoDom)||void 0===e||e.load(),i._needLoad=!0)})).catch((function(e){var t,r,n,o,a,s;i._emitPlayFailed||("AbortError"!==e.name?(i._emitPlayFailed=!0,null===(t=i._monitor)||void 0===t||t.report("rtc_error",{message:Om(r="video autoplay failed, userId: ".concat(i.userId,", ")).call(r,e.name),error_code:jj.AUTOPLAY_FAILED}),i.emit("playback_event",{type:"video",rawEvent:e,readyState:(null===(n=i._videoDom)||void 0===n?void 0:n.readyState)||0,userId:i.userId,eventName:"autoplay-error",currentTime:(null===(o=i._videoDom)||void 0===o?void 0:o.currentTime)||0,isScreen:i.isScreen})):null===(a=i._monitor)||void 0===a||a.report("rtc_error",{message:Om(s="video autoplay failed, userId: ".concat(i.userId,", ")).call(s,e.name),error_code:jj.AUTOPLAY_FAILED}))}))}})),i.engineId=e;var o=t.renderDom;i._monitor=VO(e);var a=t.userId,s=t.isScreen?sl.RENDER_MODE_FIT:sl.RENDER_MODE_HIDDEN;i.renderMode=void 0!==t.renderMode?t.renderMode:s;var c="string"==typeof o?document.getElementById(o):o;if(!c)throw new mA(vA.CANT_FIND_DOM,"can't find dom");return i._videoContainer=document.createElement("div"),i._videoContainer.style.width="100%",i._videoContainer.style.height="100%",i._videoContainer.style.position="relative",i._videoContainer.style.overflow="hidden",i._containerDom=c,i.userId=a,i.isLocal=!!t.isLocal,i.isScreen=!!t.isScreen,i._initVideo(),i}return Ul(n,[{key:"_initVideo",value:function(){var e,t=this;this._videoDom||(this._videoDom=HG("video",{style:{width:"100%",height:"100%"},attributes:WG}),this._videoDom.id=Om(e="".concat(this.userId,"_")).call(e,XO()),this.setRenderMode(this.renderMode),this.mirror(this.mirrorType===hl.MIRROR_TYPE_RENDER));this._videoContainer.appendChild(this._videoDom),this._containerDom.appendChild(this._videoContainer),this._initListeners(),this._onLocalTrackMute=function(){t._needResume=!0},this._onInterruptionEnd=function(){zG.warn("resume player after iOS interruption"),t._internalPlay()},fU.on(_U.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),fU.on(_U.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),fU.on(_U.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd)}},{key:"_initListeners",value:function(){var e=this;this._videoDom&&KG.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.addEventListener(t,e.emitVideoEvent)}))}},{key:"_removeListeners",value:function(){var e=this;this._videoDom&&KG.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.removeEventListener(t,e.emitVideoEvent)}))}},{key:"_recordFrame",value:function(e){var t=this,r=e.isScreen?1.5:.55;if(TN){var n;if(null===(n=this._videoDom)||void 0===n||!n.requestVideoFrameCallback)return;this._videoDom.requestVideoFrameCallback((function n(i,o){var a=o.presentationTime;if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t.__cumulativeTime){var s,c=(a-t.__cumulativeTime)%2e3,u=c>1e3*r;null===(s=e.recordedVideoFrames)||void 0===s||s.push({playTime:a,isStall:u,stallCount:u?1:0,stallDuration:c})}t.__cumulativeTime=a,t._videoDom.requestVideoFrameCallback(n)}))}else this.on("playback_event",(function(n){var i;if("timeupdate"===n.eventName){if(0===(null===(i=t._videoDom)||void 0===i?void 0:i.currentTime))return;if(void 0===t.__cumulativeTime)return void(t.__cumulativeTime=t._videoDom.currentTime);if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t._videoDom.currentTime>t.__cumulativeTime){var o=Math.floor(1e3*(t._videoDom.currentTime-t.__cumulativeTime)),a=t._videoDom.currentTime-t.__cumulativeTime>r;e.recordedVideoFrames.push({playTime:t._videoDom.currentTime,isStall:a,stallCount:a?1:0,stallDuration:o%2e3})}t.__cumulativeTime=t._videoDom.currentTime}}))}},{key:"_recordPause",value:function(e){var t=this;void 0===e.statsReport.isPaused&&this.on("playback_event",(function(r){if("pause"===r.eventName)e.statsReport.isPaused=!0,e.statsReport.pauseStart=WO();else if("timeupdate"===r.eventName){var n;if((null===(n=t._videoDom)||void 0===n||!n.paused)&&e.statsReport.isPaused){e.statsReport.isPaused=!1;var i=WO()-(e.statsReport.pauseStart||0);i>500&&(e.statsReport.pauseDuration+=i)}}}))}},{key:"setRenderMode",value:function(e){this.renderMode=e,this._videoDom&&(this.renderMode===sl.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this.renderMode===sl.RENDER_MODE_FILL?this._videoDom.style.objectFit="fill":this._videoDom.style.objectFit="cover")}},{key:"playVideo",value:(t=Rm(km().mark((function e(t,r){var n,i,o,a,s=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=this._videoDom,zG.info("playVideo","play video track: ".concat(this.userId)),!(o&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(n=t.getTrack())||void 0===n?void 0:n.id))){e.next=5;break}try{jO(this.engineId,"playVideo","play video repeatedly",0,this.userId)}catch(uW){}return e.abrupt("return");case 5:o||(this._initVideo(),o=this._videoDom),zG.info("playVideo","play video by dom: ".concat(null===(i=o)||void 0===i?void 0:i.id)),(a=new MediaStream).addTrack(t.getTrack("preprocessing")),o.srcObject=a,o&&!this._containerDom.contains(this._videoContainer)&&this._containerDom.appendChild(this._videoContainer),o&&!this._videoContainer.contains(o)&&this._videoContainer.appendChild(o),setTimeout((function(){return s._internalPlay()})),r&&aD.VIDEO_STALL&&(this._recordFrame(r),this._recordPause(r),r.statsReport.player=this),this.played=!0;case 15:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"updateSrcObject",value:function(e){var t=e.getTrack();if(t&&this._videoDom){var r=new MediaStream;r.addTrack(t),this._videoDom.srcObject=r}}},{key:"removeTrack",value:function(){var e,t=null===(e=this._videoDom)||void 0===e?void 0:e.srcObject;if(t){var r=t.getVideoTracks();null!=r&&r.length&&r.forEach((function(e){t.removeTrack(e)}))}}},{key:"manuallyPlay",value:function(){if(zG.info("Invoke VideoPlayer.manuallyPlay",this.userId,this.isScreen),this._emitPlayFailed=!1,!this._videoDom)throw new mA(vA.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||NN?this._videoDom.play():Yf.resolve()}},{key:"mirror",value:function(e){var t;zG.info("mirror",Om(t="".concat(this.userId," set mirror: ")).call(t,e)),this.mirrorType=e?hl.MIRROR_TYPE_RENDER:hl.MIRROR_TYPE_NONE,this._videoDom&&(this._videoDom.style.transform=e?"rotateY(180deg)":"")}},{key:"stop",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=this._containerDom;(zG.info("stop","stop video track: ".concat(this.userId)),this._videoDom)&&(t||(this._videoDom.srcObject=null),null!=r&&r.contains(this._videoContainer)&&r.removeChild(this._videoContainer),null!==(e=this._videoContainer)&&void 0!==e&&e.contains(this._videoDom)&&this._videoContainer.removeChild(this._videoDom));this.__cumulativeTime=void 0,this.played=!1}},{key:"destroy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];zG.info("destroy","video player: ".concat(this.userId)),this.stop(e),OI(CI(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),fU.off(_U.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),fU.off(_U.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),fU.off(_U.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd),this._videoDom&&delete this._videoDom,this._safari15VideoTimer&&(window.clearInterval(this._safari15VideoTimer),this._safari15VideoTimer=void 0)}},{key:"domElement",get:function(){return this._videoDom}}]),n}(PD.exports.EventEmitter),YG=function(e){DI(i,e);var t,r,n=QI(i);function i(e,t){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{divId:void 0,muted:!1,isScreen:!1},a=o.divId,s=o.muted,c=o.isScreen;if(Vl(this,i),Jd(tI(r=n.call(this)),"_containerDom",void 0),Jd(tI(r),"_audioDom",void 0),Jd(tI(r),"_fakeAudioDom",void 0),Jd(tI(r),"userId",void 0),Jd(tI(r),"muted",!1),Jd(tI(r),"_emitPlayFailed",!1),Jd(tI(r),"played",!1),Jd(tI(r),"isScreen",void 0),Jd(tI(r),"_wechatTimer",void 0),Jd(tI(r),"_edgeTimer",void 0),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_pasued",!0),Jd(tI(r),"emitAudioEvent",(function(e){var t,n,i={type:"audio",rawEvent:e,readyState:(null===(t=r._audioDom)||void 0===t?void 0:t.readyState)||0,userId:r.userId,eventName:e.type,currentTime:(null===(n=r._audioDom)||void 0===n?void 0:n.currentTime)||0};"playing"===e.type&&zG.info("AudioPlayerPlaying","[userId-".concat(r.userId,"] audio element playing")),"pause"===e.type&&(zG.info("AudioPlayerPause","[userId-".concat(r.userId,"] audio element pause")),r._pasued||r._internalPlay()),MN&&NN&&("canplay"===e.type?(clearTimeout(r._wechatTimer),r._wechatTimer=window.setTimeout((function(){r._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(r._wechatTimer)),DN&&CN&&"error"===e.type&&(clearTimeout(r._edgeTimer),r._edgeTimer=window.setTimeout((function(){var e;0===(null===(e=r._audioDom)||void 0===e?void 0:e.currentTime)&&r._autoPlayError("edge")}),500)),r.emit("playback_event",i)})),Jd(tI(r),"_internalPlay",(function(){var e,t;if(jO(r.engineId,"_internalPlay",{paused:null===(e=r._audioDom)||void 0===e?void 0:e.paused}),null!==(t=r._audioDom)&&void 0!==t&&t.paused)try{var n,i=r._audioDom.play(),o=SU.getAudioContextInstance();if("suspended"===o.state){var a=o.resume(),s=setTimeout((function(){var e;"suspended"===o.state&&(r._autoPlayError("AudioContext cannot resume"),null===(e=r._monitor)||void 0===e||e.report("rtc_error",{message:"audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - timeout"),error_code:-1e3}));clearTimeout(s)}));a.catch((function(e){var t,n,i;r._autoPlayError("AudioContext cannot resume"),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:Om(n=Om(i="audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - rejected by: [")).call(i,null==e?void 0:e.name,"]")).call(n,null==e?void 0:e.message),error_code:-1e3})})).finally((function(){clearTimeout(s)}))}null!==(n=i)&&void 0!==n&&n.then&&(MN&&DN&&(i=i.then((function(){return new Yf((function(e){setTimeout(Rm(km().mark((function t(){var n;return km().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null===(n=r._audioDom)||void 0===n||n.pause(),r._audioDom.volume=1,t.next=4,r._audioDom.play();case 4:e();case 5:case"end":return t.stop()}}),t)}))),500)}))}))),i.then((function(){jO(r.engineId,"_internalPlay successfully",{userId:r.userId}),r._pasued=!1})).catch((function(e){var t,n,i;r._autoPlayError(e),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:Om(n=Om(i="audio autoplay failed, userId: ".concat(r.userId,": ")).call(i,e.message," ")).call(n,e.name),error_code:jj.AUTOPLAY_FAILED})})))}catch(l){var c,u,d;r._autoPlayError(l),null===(c=r._monitor)||void 0===c||c.report("rtc_error",{message:Om(u=Om(d="audio autoplay failed, userId: ".concat(r.userId,": ")).call(d,l.message," ")).call(u,l.name),error_code:jj.AUTOPLAY_FAILED})}})),r.engineId=e,a){var u=document.getElementById(a);if(!u)throw new mA(vA.CANT_FIND_DOM,"can't find dom");r._containerDom=u}else r._containerDom=document.body;return r.userId=t,r.muted=s,r.isScreen=c,r._monitor=VO(e),r._initAudio(),r}return Ul(i,[{key:"_initAudio",value:function(){var e;this._audioDom||(this._audioDom=HG("audio",{style:{display:"none"},attributes:XG}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id=Om(e="".concat(this.userId,"_")).call(e,XO()),this._containerDom.appendChild(this._audioDom));this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&KG.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.addEventListener(t,e.emitAudioEvent)}))}},{key:"_removeListeners",value:function(){var e=this;this._audioDom&&(KG.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.removeEventListener(t,e.emitAudioEvent)})),this._audioDom.removeEventListener("canplay",this._internalPlay),this._audioDom.removeEventListener("loadeddata",this._internalPlay))}},{key:"playAudio",value:(r=Rm(km().mark((function e(t){var r,n,i,o,a,s=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(zG.info("playAudio","play audio track: ".concat(this.userId)),!((o=this._audioDom)&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(r=t.getTrack())||void 0===r?void 0:r.id))){e.next=4;break}return e.abrupt("return");case 4:o||(this._initAudio(),o=this._audioDom),a=new MediaStream,t instanceof sV?(this._fakeAudioDom=new Audio,this._fakeAudioDom.muted=!0,this._fakeAudioDom.srcObject=new MediaStream([t.getOrgTrack()]),a.addTrack(t.getTrack())):a.addTrack(t.getTrack("preprocessing")),MN&&DN&&(this._audioDom.volume=0),o.srcObject=a,null===(n=o)||void 0===n||n.addEventListener("canplay",this._internalPlay),null===(i=o)||void 0===i||i.addEventListener("loadeddata",this._internalPlay),setTimeout((function(){return s._internalPlay()})),this.played=!0;case 13:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_autoPlayError",value:function(e){var t,r;this._emitPlayFailed||(this._emitPlayFailed=!0,this.emit("playback_event",{type:"audio",rawEvent:e,readyState:(null===(t=this._audioDom)||void 0===t?void 0:t.readyState)||0,userId:this.userId,eventName:"autoplay-error",currentTime:(null===(r=this._audioDom)||void 0===r?void 0:r.currentTime)||0}))}},{key:"pause",value:function(){if(!this._audioDom)throw new mA(vA.INVALID_PARAMS,"Player not found");this._pasued=!0,this._audioDom.pause()}},{key:"manuallyPlay",value:function(){var e,t=this;if(zG.info("Invoke AudioPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._audioDom)throw new mA(vA.INVALID_PARAMS,"Player not found");if(!this.played)return Yf.resolve();this._audioDom.volume=1,this._audioDom.muted=!1,null===(e=this._fakeAudioDom)||void 0===e||e.play();var r=[],n=this._audioDom.play();null!=n&&n.then&&r.push(n);var i=SU.getAudioContextInstance();if("suspended"===i.state){var o=i.resume();null!=o&&o.then&&r.push(o)}(r.length>0?Yf.all(r):Yf.resolve(n)).then((function(){t._pasued=!1}))}},{key:"setPlaybackDevice",value:(t=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return zG.info("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,hU.enumerateAudioPlaybackDevices();case 3:if(r=e.sent,n=jm(r).call(r,(function(e){return e.deviceId})),mT(n).call(n,t)&&this._audioDom&&this._audioDom.setSinkId){e.next=7;break}return e.abrupt("return");case 7:return e.next=9,this._audioDom.setSinkId(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"stop",value:function(){var e=this._containerDom;zG.info("stopAudio","stop audio track: ".concat(this.userId)),this._audioDom&&(this._audioDom.srcObject=null,null!=e&&e.contains(this._audioDom)&&e.removeChild(this._audioDom)),this._fakeAudioDom&&(this._fakeAudioDom.srcObject=null,this._fakeAudioDom=void 0),this.played=!1}},{key:"domElement",get:function(){return this._audioDom}},{key:"destroy",value:function(){zG.info("destroy","audio player: ".concat(this.userId)),this.stop(),OI(CI(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(this._audioDom.srcObject=null,delete this._audioDom),this._edgeTimer&&clearTimeout(this._edgeTimer)}}]),i}(PD.exports.EventEmitter);function JG(e,t,r,n){var i=function(){var e=Rm(km().mark((function e(t,i){var o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null==n?void 0:n.get(i),Array.isArray(o)&&(o=null===(a=o)||void 0===a?void 0:yE(a).call(a,(function(e){return e.isScreen===r}))),!t){e.next=9;break}if(!t.played){e.next=8;break}return e.next=6,t.manuallyPlay();case 6:e.next=9;break;case 8:o&&(t instanceof qG&&o.videoTrack&&t.playVideo(o.videoTrack,o),t instanceof YG&&o.audioTrack&&t.playAudio(o.audioTrack));case 9:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();if(t)return i(e.get(t),t);var o=[];return e.forEach((function(e,t){return o.push(i(e,t))})),Yf.all(o)}var QG=i,ZG=lt("iterator"),$G=!QG((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),!e.toJSON||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[ZG]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==r||"x"!==new URL("http://x",void 0).host})),eH=Jt,tH=E,rH=2147483647,nH=/[^\0-\u007E]/,iH=/[.\u3002\uFF0E\uFF61]/g,oH="Overflow: input needs wider integers to process",aH=RangeError,sH=tH(iH.exec),cH=Math.floor,uH=String.fromCharCode,dH=tH("".charCodeAt),lH=tH([].join),hH=tH([].push),vH=tH("".replace),_H=tH("".split),pH=tH("".toLowerCase),fH=function(e){return e+22+75*(e<26)},mH=function(e,t,r){var n=0;for(e=r?cH(e/700):e>>1,e+=cH(e/t);e>455;)e=cH(e/35),n+=36;return cH(n+36*e/(e+38))},gH=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=dH(e,r++);if(i>=55296&&i<=56319&&r<n){var o=dH(e,r++);56320==(64512&o)?hH(t,((1023&i)<<10)+(1023&o)+65536):(hH(t,i),r--)}else hH(t,i)}return t}(e);var r,n,i=e.length,o=128,a=0,s=72;for(r=0;r<e.length;r++)(n=e[r])<128&&hH(t,uH(n));var c=t.length,u=c;for(c&&hH(t,"-");u<i;){var d=rH;for(r=0;r<e.length;r++)(n=e[r])>=o&&n<d&&(d=n);var l=u+1;if(d-o>cH((rH-a)/l))throw aH(oH);for(a+=(d-o)*l,o=d,r=0;r<e.length;r++){if((n=e[r])<o&&++a>rH)throw aH(oH);if(n==o){for(var h=a,v=36;;){var _=v<=s?1:v>=s+26?26:v-s;if(h<_)break;var p=h-_,f=36-_;hH(t,uH(fH(_+p%f))),h=cH(p/f),v+=36}hH(t,uH(fH(h))),s=mH(a,l,u==c),a=0,u++}}a++,o++}return lH(t,"")},yH=Ar,SH=n,bH=O,EH=E,TH=w,kH=$G,IH=li,RH=Qg,AH=Mi,wH=Pc,CH=Zi,xH=mv,OH=R,NH=Ye,DH=Yt,PH=pn,MH=tr,LH=$,UH=gn,VH=Hn,FH=V,BH=yh,jH=hh,GH=wv,HH=lR,zH=lt("iterator"),KH="URLSearchParams",XH="URLSearchParamsIterator",WH=CH.set,qH=CH.getterFor(KH),YH=CH.getterFor(XH),JH=Object.getOwnPropertyDescriptor,QH=function(e){if(!TH)return SH[e];var t=JH(SH,e);return t&&t.value},ZH=QH("fetch"),$H=QH("Request"),ez=QH("Headers"),tz=$H&&$H.prototype,rz=ez&&ez.prototype,nz=SH.RegExp,iz=SH.TypeError,oz=SH.decodeURIComponent,az=SH.encodeURIComponent,sz=EH("".charAt),cz=EH([].join),uz=EH([].push),dz=EH("".replace),lz=EH([].shift),hz=EH([].splice),vz=EH("".split),_z=EH("".slice),pz=/\+/g,fz=Array(4),mz=function(e){return fz[e-1]||(fz[e-1]=nz("((?:%[\\da-f]{2}){"+e+"})","gi"))},gz=function(e){try{return oz(e)}catch(uW){return e}},yz=function(e){var t=dz(e,pz," "),r=4;try{return oz(t)}catch(uW){for(;r;)t=dz(t,mz(r--),gz);return t}},Sz=/[!'()~]|%20/g,bz={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},Ez=function(e){return bz[e]},Tz=function(e){return dz(az(e),Sz,Ez)},kz=wH((function(e,t){WH(this,{type:XH,iterator:BH(qH(e).entries),kind:t})}),"Iterator",(function(){var e=YH(this),t=e.kind,r=e.iterator.next(),n=r.value;return r.done||(r.value="keys"===t?n.key:"values"===t?n.value:[n.key,n.value]),r}),!0),Iz=function(e){this.entries=[],this.url=null,void 0!==e&&(LH(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===sz(e,0)?_z(e,1):e:UH(e)))};Iz.prototype={type:KH,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,c=jH(e);if(c)for(r=(t=BH(e,c)).next;!(n=bH(r,t)).done;){if(o=(i=BH(MH(n.value))).next,(a=bH(o,i)).done||(s=bH(o,i)).done||!bH(o,i).done)throw iz("Expected sequence with length 2");uz(this.entries,{key:UH(a.value),value:UH(s.value)})}else for(var u in e)NH(e,u)&&uz(this.entries,{key:u,value:UH(e[u])})},parseQuery:function(e){if(e)for(var t,r,n=vz(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=vz(t,"="),uz(this.entries,{key:yz(lz(r)),value:yz(cz(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],uz(r,Tz(e.key)+"="+Tz(e.value));return cz(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var Rz=function(){xH(this,Az);var e=arguments.length>0?arguments[0]:void 0;WH(this,new Iz(e))},Az=Rz.prototype;if(RH(Az,{append:function(e,t){GH(arguments.length,2);var r=qH(this);uz(r.entries,{key:UH(e),value:UH(t)}),r.updateURL()},delete:function(e){GH(arguments.length,1);for(var t=qH(this),r=t.entries,n=UH(e),i=0;i<r.length;)r[i].key===n?hz(r,i,1):i++;t.updateURL()},get:function(e){GH(arguments.length,1);for(var t=qH(this).entries,r=UH(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){GH(arguments.length,1);for(var t=qH(this).entries,r=UH(e),n=[],i=0;i<t.length;i++)t[i].key===r&&uz(n,t[i].value);return n},has:function(e){GH(arguments.length,1);for(var t=qH(this).entries,r=UH(e),n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){GH(arguments.length,1);for(var r,n=qH(this),i=n.entries,o=!1,a=UH(e),s=UH(t),c=0;c<i.length;c++)(r=i[c]).key===a&&(o?hz(i,c--,1):(o=!0,r.value=s));o||uz(i,{key:a,value:s}),n.updateURL()},sort:function(){var e=qH(this);HH(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=qH(this).entries,n=DH(e,arguments.length>1?arguments[1]:void 0),i=0;i<r.length;)n((t=r[i++]).value,t.key,this)},keys:function(){return new kz(this,"keys")},values:function(){return new kz(this,"values")},entries:function(){return new kz(this,"entries")}},{enumerable:!0}),IH(Az,zH,Az.entries,{name:"entries"}),IH(Az,"toString",(function(){return qH(this).serialize()}),{enumerable:!0}),AH(Rz,KH),yH({global:!0,constructor:!0,forced:!kH},{URLSearchParams:Rz}),!kH&&OH(ez)){var wz=EH(rz.has),Cz=EH(rz.set),xz=function(e){if(LH(e)){var t,r=e.body;if(PH(r)===KH)return t=e.headers?new ez(e.headers):new ez,wz(t,"content-type")||Cz(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),VH(e,{body:FH(0,UH(r)),headers:FH(0,t)})}return e};if(OH(ZH)&&yH({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return ZH(e,arguments.length>1?xz(arguments[1]):{})}}),OH($H)){var Oz=function(e){return xH(this,tz),new $H(e,arguments.length>1?xz(arguments[1]):{})};tz.constructor=Oz,Oz.prototype=tz,yH({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Oz})}}var Nz,Dz=Ar,Pz=w,Mz=$G,Lz=n,Uz=Yt,Vz=E,Fz=li,Bz=function(e,t,r){return eH.f(e,t,r)},jz=mv,Gz=Ye,Hz=Rb,zz=XT,Kz=ni,Xz=Ud.codeAt,Wz=function(e){var t,r,n=[],i=_H(vH(pH(e),iH,"."),".");for(t=0;t<i.length;t++)r=i[t],hH(n,sH(nH,r)?"xn--"+gH(r):r);return lH(n,".")},qz=gn,Yz=Mi,Jz=wv,Qz={URLSearchParams:Rz,getState:qH},Zz=Zi,$z=Zz.set,eK=Zz.getterFor("URL"),tK=Qz.URLSearchParams,rK=Qz.getState,nK=Lz.URL,iK=Lz.TypeError,oK=Lz.parseInt,aK=Math.floor,sK=Math.pow,cK=Vz("".charAt),uK=Vz(/./.exec),dK=Vz([].join),lK=Vz(1..toString),hK=Vz([].pop),vK=Vz([].push),_K=Vz("".replace),pK=Vz([].shift),fK=Vz("".split),mK=Vz("".slice),gK=Vz("".toLowerCase),yK=Vz([].unshift),SK="Invalid scheme",bK="Invalid host",EK="Invalid port",TK=/[a-z]/i,kK=/[\d+-.a-z]/i,IK=/\d/,RK=/^0x/i,AK=/^[0-7]+$/,wK=/^\d+$/,CK=/^[\da-f]+$/i,xK=/[\0\t\n\r #%/:<>?@[\\\]^|]/,OK=/[\0\t\n\r #/:<>?@[\\\]^|]/,NK=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,DK=/[\t\n\r]/g,PK=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)yK(t,e%256),e=aK(e/256);return dK(t,".")}if("object"==typeof e){for(t="",n=function(e){for(var t=null,r=1,n=null,i=0,o=0;o<8;o++)0!==e[o]?(i>r&&(t=n,r=i),n=null,i=0):(null===n&&(n=o),++i);return i>r&&(t=n,r=i),t}(e),r=0;r<8;r++)i&&0===e[r]||(i&&(i=!1),n===r?(t+=r?":":"::",i=!0):(t+=lK(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},MK={},LK=Hz({},MK,{" ":1,'"':1,"<":1,">":1,"`":1}),UK=Hz({},LK,{"#":1,"?":1,"{":1,"}":1}),VK=Hz({},UK,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),FK=function(e,t){var r=Xz(e,0);return r>32&&r<127&&!Gz(t,e)?e:encodeURIComponent(e)},BK={ftp:21,file:null,http:80,https:443,ws:80,wss:443},jK=function(e,t){var r;return 2==e.length&&uK(TK,cK(e,0))&&(":"==(r=cK(e,1))||!t&&"|"==r)},GK=function(e){var t;return e.length>1&&jK(mK(e,0,2))&&(2==e.length||"/"===(t=cK(e,2))||"\\"===t||"?"===t||"#"===t)},HK=function(e){return"."===e||"%2e"===gK(e)},zK={},KK={},XK={},WK={},qK={},YK={},JK={},QK={},ZK={},$K={},eX={},tX={},rX={},nX={},iX={},oX={},aX={},sX={},cX={},uX={},dX={},lX=function(e,t,r){var n,i,o,a=qz(e);if(t){if(i=this.parse(a))throw iK(i);this.searchParams=null}else{if(void 0!==r&&(n=new lX(r,!0)),i=this.parse(a,null,n))throw iK(i);(o=rK(new tK)).bindURL(this),this.searchParams=o}};lX.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,c=this,u=t||zK,d=0,l="",h=!1,v=!1,_=!1;for(e=qz(e),t||(c.scheme="",c.username="",c.password="",c.host=null,c.port=null,c.path=[],c.query=null,c.fragment=null,c.cannotBeABaseURL=!1,e=_K(e,NK,"")),e=_K(e,DK,""),n=zz(e);d<=n.length;){switch(i=n[d],u){case zK:if(!i||!uK(TK,i)){if(t)return SK;u=XK;continue}l+=gK(i),u=KK;break;case KK:if(i&&(uK(kK,i)||"+"==i||"-"==i||"."==i))l+=gK(i);else{if(":"!=i){if(t)return SK;l="",u=XK,d=0;continue}if(t&&(c.isSpecial()!=Gz(BK,l)||"file"==l&&(c.includesCredentials()||null!==c.port)||"file"==c.scheme&&!c.host))return;if(c.scheme=l,t)return void(c.isSpecial()&&BK[c.scheme]==c.port&&(c.port=null));l="","file"==c.scheme?u=nX:c.isSpecial()&&r&&r.scheme==c.scheme?u=WK:c.isSpecial()?u=QK:"/"==n[d+1]?(u=qK,d++):(c.cannotBeABaseURL=!0,vK(c.path,""),u=cX)}break;case XK:if(!r||r.cannotBeABaseURL&&"#"!=i)return SK;if(r.cannotBeABaseURL&&"#"==i){c.scheme=r.scheme,c.path=Kz(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,u=dX;break}u="file"==r.scheme?nX:YK;continue;case WK:if("/"!=i||"/"!=n[d+1]){u=YK;continue}u=ZK,d++;break;case qK:if("/"==i){u=$K;break}u=sX;continue;case YK:if(c.scheme=r.scheme,i==Nz)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=Kz(r.path),c.query=r.query;else if("/"==i||"\\"==i&&c.isSpecial())u=JK;else if("?"==i)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=Kz(r.path),c.query="",u=uX;else{if("#"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=Kz(r.path),c.path.length--,u=sX;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=Kz(r.path),c.query=r.query,c.fragment="",u=dX}break;case JK:if(!c.isSpecial()||"/"!=i&&"\\"!=i){if("/"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,u=sX;continue}u=$K}else u=ZK;break;case QK:if(u=ZK,"/"!=i||"/"!=cK(l,d+1))continue;d++;break;case ZK:if("/"!=i&&"\\"!=i){u=$K;continue}break;case $K:if("@"==i){h&&(l="%40"+l),h=!0,o=zz(l);for(var p=0;p<o.length;p++){var f=o[p];if(":"!=f||_){var m=FK(f,VK);_?c.password+=m:c.username+=m}else _=!0}l=""}else if(i==Nz||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(h&&""==l)return"Invalid authority";d-=zz(l).length+1,l="",u=eX}else l+=i;break;case eX:case tX:if(t&&"file"==c.scheme){u=oX;continue}if(":"!=i||v){if(i==Nz||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(c.isSpecial()&&""==l)return bK;if(t&&""==l&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(l))return a;if(l="",u=aX,t)return;continue}"["==i?v=!0:"]"==i&&(v=!1),l+=i}else{if(""==l)return bK;if(a=c.parseHost(l))return a;if(l="",u=rX,t==tX)return}break;case rX:if(!uK(IK,i)){if(i==Nz||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()||t){if(""!=l){var g=oK(l,10);if(g>65535)return EK;c.port=c.isSpecial()&&g===BK[c.scheme]?null:g,l=""}if(t)return;u=aX;continue}return EK}l+=i;break;case nX:if(c.scheme="file","/"==i||"\\"==i)u=iX;else{if(!r||"file"!=r.scheme){u=sX;continue}if(i==Nz)c.host=r.host,c.path=Kz(r.path),c.query=r.query;else if("?"==i)c.host=r.host,c.path=Kz(r.path),c.query="",u=uX;else{if("#"!=i){GK(dK(Kz(n,d),""))||(c.host=r.host,c.path=Kz(r.path),c.shortenPath()),u=sX;continue}c.host=r.host,c.path=Kz(r.path),c.query=r.query,c.fragment="",u=dX}}break;case iX:if("/"==i||"\\"==i){u=oX;break}r&&"file"==r.scheme&&!GK(dK(Kz(n,d),""))&&(jK(r.path[0],!0)?vK(c.path,r.path[0]):c.host=r.host),u=sX;continue;case oX:if(i==Nz||"/"==i||"\\"==i||"?"==i||"#"==i){if(!t&&jK(l))u=sX;else if(""==l){if(c.host="",t)return;u=aX}else{if(a=c.parseHost(l))return a;if("localhost"==c.host&&(c.host=""),t)return;l="",u=aX}continue}l+=i;break;case aX:if(c.isSpecial()){if(u=sX,"/"!=i&&"\\"!=i)continue}else if(t||"?"!=i)if(t||"#"!=i){if(i!=Nz&&(u=sX,"/"!=i))continue}else c.fragment="",u=dX;else c.query="",u=uX;break;case sX:if(i==Nz||"/"==i||"\\"==i&&c.isSpecial()||!t&&("?"==i||"#"==i)){if(".."===(s=gK(s=l))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"==i||"\\"==i&&c.isSpecial()||vK(c.path,"")):HK(l)?"/"==i||"\\"==i&&c.isSpecial()||vK(c.path,""):("file"==c.scheme&&!c.path.length&&jK(l)&&(c.host&&(c.host=""),l=cK(l,0)+":"),vK(c.path,l)),l="","file"==c.scheme&&(i==Nz||"?"==i||"#"==i))for(;c.path.length>1&&""===c.path[0];)pK(c.path);"?"==i?(c.query="",u=uX):"#"==i&&(c.fragment="",u=dX)}else l+=FK(i,UK);break;case cX:"?"==i?(c.query="",u=uX):"#"==i?(c.fragment="",u=dX):i!=Nz&&(c.path[0]+=FK(i,MK));break;case uX:t||"#"!=i?i!=Nz&&("'"==i&&c.isSpecial()?c.query+="%27":c.query+="#"==i?"%23":FK(i,MK)):(c.fragment="",u=dX);break;case dX:i!=Nz&&(c.fragment+=FK(i,LK))}d++}},parseHost:function(e){var t,r,n;if("["==cK(e,0)){if("]"!=cK(e,e.length-1))return bK;if(t=function(e){var t,r,n,i,o,a,s,c=[0,0,0,0,0,0,0,0],u=0,d=null,l=0,h=function(){return cK(e,l)};if(":"==h()){if(":"!=cK(e,1))return;l+=2,d=++u}for(;h();){if(8==u)return;if(":"!=h()){for(t=r=0;r<4&&uK(CK,h());)t=16*t+oK(h(),16),l++,r++;if("."==h()){if(0==r)return;if(l-=r,u>6)return;for(n=0;h();){if(i=null,n>0){if(!("."==h()&&n<4))return;l++}if(!uK(IK,h()))return;for(;uK(IK,h());){if(o=oK(h(),10),null===i)i=o;else{if(0==i)return;i=10*i+o}if(i>255)return;l++}c[u]=256*c[u]+i,2!=++n&&4!=n||u++}if(4!=n)return;break}if(":"==h()){if(l++,!h())return}else if(h())return;c[u++]=t}else{if(null!==d)return;l++,d=++u}}if(null!==d)for(a=u-d,u=7;0!=u&&a>0;)s=c[u],c[u--]=c[d+a-1],c[d+--a]=s;else if(8!=u)return;return c}(mK(e,1,-1)),!t)return bK;this.host=t}else if(this.isSpecial()){if(e=Wz(e),uK(xK,e))return bK;if(t=function(e){var t,r,n,i,o,a,s,c=fK(e,".");if(c.length&&""==c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(r=[],n=0;n<t;n++){if(""==(i=c[n]))return e;if(o=10,i.length>1&&"0"==cK(i,0)&&(o=uK(RK,i)?16:8,i=mK(i,8==o?1:2)),""===i)a=0;else{if(!uK(10==o?wK:8==o?AK:CK,i))return e;a=oK(i,o)}vK(r,a)}for(n=0;n<t;n++)if(a=r[n],n==t-1){if(a>=sK(256,5-t))return null}else if(a>255)return null;for(s=hK(r),n=0;n<r.length;n++)s+=r[n]*sK(256,3-n);return s}(e),null===t)return bK;this.host=t}else{if(uK(OK,e))return bK;for(t="",r=zz(e),n=0;n<r.length;n++)t+=FK(r[n],MK);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return Gz(BK,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&jK(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,n=e.password,i=e.host,o=e.port,a=e.path,s=e.query,c=e.fragment,u=t+":";return null!==i?(u+="//",e.includesCredentials()&&(u+=r+(n?":"+n:"")+"@"),u+=PK(i),null!==o&&(u+=":"+o)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+dK(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw iK(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new hX(e.path[0]).origin}catch(uW){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+PK(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(qz(e)+":",zK)},getUsername:function(){return this.username},setUsername:function(e){var t=zz(qz(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=FK(t[r],VK)}},getPassword:function(){return this.password},setPassword:function(e){var t=zz(qz(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=FK(t[r],VK)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?PK(e):PK(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,eX)},getHostname:function(){var e=this.host;return null===e?"":PK(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,tX)},getPort:function(){var e=this.port;return null===e?"":qz(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=qz(e))?this.port=null:this.parse(e,rX))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+dK(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,aX))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=qz(e))?this.query=null:("?"==cK(e,0)&&(e=mK(e,1)),this.query="",this.parse(e,uX)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=qz(e))?("#"==cK(e,0)&&(e=mK(e,1)),this.fragment="",this.parse(e,dX)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var hX=function(e){var t=jz(this,vX),r=Jz(arguments.length,1)>1?arguments[1]:void 0,n=$z(t,new lX(e,!1,r));Pz||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},vX=hX.prototype,_X=function(e,t){return{get:function(){return eK(this)[e]()},set:t&&function(e){return eK(this)[t](e)},configurable:!0,enumerable:!0}};if(Pz&&(Bz(vX,"href",_X("serialize","setHref")),Bz(vX,"origin",_X("getOrigin")),Bz(vX,"protocol",_X("getProtocol","setProtocol")),Bz(vX,"username",_X("getUsername","setUsername")),Bz(vX,"password",_X("getPassword","setPassword")),Bz(vX,"host",_X("getHost","setHost")),Bz(vX,"hostname",_X("getHostname","setHostname")),Bz(vX,"port",_X("getPort","setPort")),Bz(vX,"pathname",_X("getPathname","setPathname")),Bz(vX,"search",_X("getSearch","setSearch")),Bz(vX,"searchParams",_X("getSearchParams")),Bz(vX,"hash",_X("getHash","setHash"))),Fz(vX,"toJSON",(function(){return eK(this).serialize()}),{enumerable:!0}),Fz(vX,"toString",(function(){return eK(this).serialize()}),{enumerable:!0}),nK){var pX=nK.createObjectURL,fX=nK.revokeObjectURL;pX&&Fz(hX,"createObjectURL",Uz(pX,nK)),fX&&Fz(hX,"revokeObjectURL",Uz(fX,nK))}Yz(hX,"URL"),Dz({global:!0,constructor:!0,forced:!Mz,sham:!Pz},{URL:hX});var mX=ee.URL,gX=function(){var e=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(mX.createObjectURL(new Blob([t],r))),e.prev=1,n.muted=!0,e.next=5,n.play();case 5:return n.pause(),e.abrupt("return",!0);case 9:return e.prev=9,e.t0=e.catch(1),e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t,r){return e.apply(this,arguments)}}(),yX=ad,SX=tc,bX=function(e,t,r,n){for(var i,o=n>1?void 0:n?SX(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&yX(t,r,o),o},EX=function(){function e(t,r){Vl(this,e),Jd(this,"_sharedAudioContext",new AudioContext),Jd(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),Jd(this,"_localGainNode",this._sharedAudioContext.createGain()),Jd(this,"_bufferGainNode",this._sharedAudioContext.createGain()),Jd(this,"_audioBufferSource",void 0),Jd(this,"_localSource",void 0),Jd(this,"_context",void 0),Jd(this,"_failedAudioList",[]),Jd(this,"_startingIds",new $S),Jd(this,"_revokeURLs",new AM),Jd(this,"mixingMap",new $S),Jd(this,"resourcesCache",new $S),Jd(this,"volumeConfig",new $S),Jd(this,"cachedBuffer",[]),Jd(this,"id","AudioMixingManager"),this.engineId=r,this._context=t,this._localGainNode.gain.value=1}var t,r,n;return Ul(e,[{key:"mixMediaStream",value:function(e){this._localSource&&this._localSource.disconnect(this._localGainNode),this._localSource=this._sharedAudioContext.createMediaStreamSource(e),this._localSource.connect(this._localGainNode).connect(this._audioDestination)}},{key:"startAudioMixing",value:(n=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,v,_,p,f,m=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===this._startingIds.get(t)){e.next=3;break}return console.warn("AudioMixing task id: ".concat(t," is starting")),e.abrupt("return");case 3:if(this._startingIds.set(t,t),i=n.playCount,pD(o=n.type,"mixingType",pj(Nl)),a=this._context.getLocalAudioTrack()){e.next=9;break}return e.abrupt("return");case 9:if((s=a.getTrack("preprocessing"))&&this.mixMediaStream(new MediaStream([s])),null!=(c=this.mixingMap.get(t))&&c.audioNode){c.audioNode.pause(),this._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_STOPPED,error:_A.AUDIO_MIXING_ERROR_OK});try{c.gainNode.disconnect(this._audioDestination),c.audioSource.disconnect(c.gainNode)}catch(g){}}if(!(d=this.resourcesCache.get(t))||d.filePath!==r){e.next=18;break}u=d.getAudioNode(),e.next=31;break;case 18:return e.next=20,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw m._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_FAILED,error:_A.AUDIO_MIXING_ERROR_START_FAILED}),new mA(vA.LOAD_RESOURCES_FAILED,e.statusText)}));case 20:return l=e.sent,Qb(r).call(r,"mp3")?h={type:"audio/mpeg"}:Qb(r).call(r,"aac")&&(h={type:"audio/aac"}),e.next=24,gX(l,h);case 24:if(e.sent){e.next=28;break}throw this._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_FAILED,error:_A.AUDIO_MIXING_ERROR_START_FAILED}),new mA(vA.LOAD_RESOURCES_FAILED,"invalid audio resource");case 28:(u=new Audio).crossOrigin="anonymous",u.src=mX.createObjectURL(new Blob([l],h));case 31:return i<=0?u.loop=!0:i>0&&(v=i,u.onended=function(){--v>0?u.play():(m.mixingMap.delete(t),m._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_FINISHED,error:_A.AUDIO_MIXING_ERROR_OK}))}),e.prev=32,e.next=35,u.play();case 35:e.next=42;break;case 37:e.prev=37,e.t0=e.catch(32),console.error(e.t0),this._failedAudioList.push(u),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:cl.STREAM_INDEX_MAIN,mediaType:ul.AUDIO});case 42:if(this._startingIds.delete(t),_=this._sharedAudioContext.createMediaElementSource(u),p=this._sharedAudioContext.createGain(),f=this.volumeConfig.get(t),p.gain.value=f?f/100:1,_.connect(p).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:_,audioNode:u,gainNode:p,type:"file"}),o===Nl.PUBLISH)try{p.disconnect(this._sharedAudioContext.destination)}catch(g){}else p.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_PLAYING,error:_A.AUDIO_MIXING_ERROR_OK});case 52:case"end":return e.stop()}}),e,this,[[32,37]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"stopAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&"file"===t.type&&(this.mixingMap.delete(e),t.audioNode.pause(),t.audioSource.disconnect(t.gainNode),t.gainNode.disconnect(this._audioDestination),this._context.emitMessage({mixId:e,state:Dl.AUDIO_MIXING_STATE_STOPPED,error:_A.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Dl.AUDIO_MIXING_STATE_PAUSED,error:_A.AUDIO_MIXING_ERROR_OK}),t.audioNode.pause())}},{key:"resumeAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Dl.AUDIO_MIXING_STATE_PLAYING,error:_A.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=Rm(km().mark((function e(t,r){var n,i,o=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.stopAudioMixing(t),e.next=3,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw new mA(vA.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(o._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_FAILED,error:_A.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof mA)throw e;throw new mA(vA.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,Qb(r).call(r,"mp3")?i={type:"audio/mpeg"}:Qb(r).call(r,"aac")&&(i={type:"audio/aac"}),e.next=7,gX(n,i);case 7:if(e.sent){e.next=11;break}throw this._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_FAILED,error:_A.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new mA(vA.LOAD_RESOURCES_FAILED,"Load resources failed");case 11:return this._context.emitMessage({mixId:t,state:Dl.AUDIO_MIXING_STATE_PRELOADED,error:_A.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){var e=mX.createObjectURL(new Blob([n],i));return o._revokeURLs.add(e),new Audio(e)},filePath:r,duration:0}),e.next=15,new Yf((function(e){var r=mX.createObjectURL(new Blob([n],i)),a=new Audio(r);a.addEventListener("durationchange",(function(){var n=o.resourcesCache.get(t);n&&(n.duration=a.duration,o.resourcesCache.set(t,n)),mX.revokeObjectURL(r),e(null)}))}));case 15:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"unloadAudioMixing",value:function(e){this.resourcesCache.has(e)&&this.resourcesCache.delete(e)}},{key:"getAudioMixingVolume",value:function(e){var t=this.mixingMap.get(e);return t?100*t.gainNode.gain.value:0}},{key:"setAudioMixingVolume",value:function(e,t){t<0?t=0:t>400&&(t=400),this.volumeConfig.set(e,t);var r=this.mixingMap.get(e);r&&(r.gainNode.gain.value=Number(t)/100)}},{key:"getAudioMixingDuration",value:function(e){var t=this.mixingMap.get(e),r=this.resourcesCache.get(e);return t||r?t?1e3*t.audioNode.duration:r?1e3*r.duration:0:0}},{key:"getAudioMixingCurrentPosition",value:function(e){var t=this.mixingMap.get(e);return t?1e3*t.audioNode.currentTime:0}},{key:"setAudioMixingPosition",value:function(e,t){var r=this.mixingMap.get(e);r&&(r.audioNode.currentTime=t/1e3,r.audioNode.play())}},{key:"enableAudioMixingBuffer",value:function(e){pD(e,"type",pj(Nl));var t=this._context.getLocalAudioTrack();if(t){var r=t.getTrack("preprocessing");if(r&&this.mixMediaStream(new MediaStream([r])),e===Nl.PUBLISH)try{this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(n){}else this._bufferGainNode.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],e),this._bufferGainNode.connect(this._audioDestination),this._context.emitMessage({mixId:-1,state:Dl.AUDIO_MIXING_STATE_PCM_ENABLED,error:_A.AUDIO_MIXING_ERROR_OK})}}},{key:"disableAudioMixingBuffer",value:function(){if(this.cachedBuffer=[],this._audioBufferSource){try{this._audioBufferSource.disconnect(this._bufferGainNode),this._bufferGainNode.disconnect(this._audioDestination),this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(e){}finally{this._audioBufferSource=void 0}this._context.updateLocalAudioTrack(),this._context.emitMessage({mixId:-1,state:Dl.AUDIO_MIXING_STATE_PCM_DISABLED,error:_A.AUDIO_MIXING_ERROR_OK})}}},{key:"pushAudioMixingBuffer",value:function(e){var t=this;if(!(this._audioBufferSource&&(this.cachedBuffer.push(e),this.cachedBuffer.length>0))){this._audioBufferSource=this._sharedAudioContext.createBufferSource(),this._audioBufferSource.buffer=e,this._audioBufferSource.connect(this._bufferGainNode);try{this._audioBufferSource.start()}catch(r){this._failedAudioList.push(this._audioBufferSource)}this._audioBufferSource.onended=function(){var e;if(null===(e=t._audioBufferSource)||void 0===e||e.disconnect(t._bufferGainNode),t._audioBufferSource=void 0,t.cachedBuffer.length){var r=t.cachedBuffer.shift();r&&t.pushAudioMixingBuffer(r)}}}}},{key:"stopAll",value:function(){var e=this;if(this._localSource)try{this._localSource.disconnect(this._localGainNode),delete this._localSource}catch(t){}this.mixingMap.forEach((function(t,r){e.stopAudioMixing(r)}))}},{key:"mixTrack",get:function(){return this._audioDestination.stream.getAudioTracks()[0]}},{key:"sharedAudioContext",get:function(){return this._sharedAudioContext}},{key:"resumeLocalPlay",value:(t=Rm(km().mark((function e(){var t,r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=$k(this._failedAudioList),e.prev=2,r.s();case 4:if((n=r.n()).done){e.next=24;break}if(i=n.value,e.prev=6,!(i instanceof HTMLAudioElement)){e.next=13;break}return i.muted=!1,e.next=11,i.play();case 11:e.next=14;break;case 13:i.start();case 14:e.next=22;break;case 16:return e.prev=16,e.t0=e.catch(6),t.push(i),console.error(e.t0),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:cl.STREAM_INDEX_MAIN,mediaType:ul.AUDIO}),e.abrupt("break",24);case 22:e.next=4;break;case 24:e.next=29;break;case 26:e.prev=26,e.t1=e.catch(2),r.e(e.t1);case 29:return e.prev=29,r.f(),e.finish(29);case 32:this._failedAudioList=t;case 33:case"end":return e.stop()}}),e,this,[[2,26,29,32],[6,16]])}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e=this._sharedAudioContext;"closed"!==e.state&&"function"==typeof e.close&&e.close(),this.cachedBuffer=[],this.mixingMap.clear(),this.resourcesCache.clear(),this.volumeConfig.clear(),this._startingIds=new $S,this._revokeURLs.forEach((function(e){mX.revokeObjectURL(e)}))}}]),e}();bX([FO("id","filePath","options")],EX.prototype,"startAudioMixing",1),bX([FO("id")],EX.prototype,"stopAudioMixing",1),bX([FO("id")],EX.prototype,"pauseAudioMixing",1),bX([FO("id")],EX.prototype,"resumeAudioMixing",1),bX([FO("id")],EX.prototype,"preloadAudioMixing",1),bX([FO("id")],EX.prototype,"unloadAudioMixing",1),bX([FO("id")],EX.prototype,"getAudioMixingVolume",1),bX([FO("id","volume")],EX.prototype,"setAudioMixingVolume",1),bX([FO("id")],EX.prototype,"getAudioMixingDuration",1),bX([FO("id")],EX.prototype,"getAudioMixingCurrentPosition",1),bX([FO("id","position")],EX.prototype,"setAudioMixingPosition",1),bX([FO("type")],EX.prototype,"enableAudioMixingBuffer",1),bX([FO()],EX.prototype,"disableAudioMixingBuffer",1),bX([FO("buffer")],EX.prototype,"pushAudioMixingBuffer",1);var TX=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(TX||{}),kX=new Mw("RTMClient",1),IX=function(e){DI(c,e);var t,r,n,i,o,a,s=QI(c);function c(e){var t;return Vl(this,c),Jd(tI(t=s.call(this)),"_dataChannelSignal",void 0),Jd(tI(t),"_handler",void 0),Jd(tI(t),"_dataChannelSignalState",vG.DISCONNECTED),Jd(tI(t),"_loginSessionId",null),Jd(tI(t),"_userId",null),Jd(tI(t),"_token",null),Jd(tI(t),"_loginResolveCallback",void 0),Jd(tI(t),"_loginRejectCallback",void 0),Jd(tI(t),"_wait_login_token",!1),Jd(tI(t),"_serverParamsCache",void 0),Jd(tI(t),"id",void 0),Jd(tI(t),"_connectionManager",void 0),Jd(tI(t),"isReconnecting",!1),t._ctx=e,t.id=e.id,t._connectionManager=new sG(e),t._addConnectHandler(),t}return Ul(c,[{key:"login",value:function(e,t){var r=this;return new Yf((function(n,i){var o;if(kX.info("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new mA(vA.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new mA(vA.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,null===(o=VO(r.id))||void 0===o||o.set({rtm_user_id:t}),r._loginResolveCallback=n,r._loginRejectCallback=i,r._dataChannelSignal?r._login():r.connect().then((function(){r._login()}))}))}},{key:"logout",value:(a=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mA(vA.NOT_LOGIN,"login first");case 2:return e.next=4,null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("logout",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId},{functionType:iG.C2RTM}).catch((function(){}));case 4:this._clearState();case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"updateLoginToken",value:(o=Rm(km().mark((function e(t){var r=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new Yf((function(e,t){r._wait_login_token?(r._loginResolveCallback=e,r._loginRejectCallback=t,r._login()):e()})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(i=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mA(vA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.next=5,this._dataChannelSignal.sendSignaling("getPeerOnlineStatus",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,peerUserId:t},{functionType:iG.C2RTM});case 5:return r=e.sent,e.abrupt("return",null==r?void 0:r.status);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(n=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mA(vA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:t,room:"",msg:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"setServerParams",value:(r=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,_D(t,"signature"),_D(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new mA(vA.NOT_LOGIN,"login first");case 5:return this._checkDataChannelSignal(),e.next=8,this._dataChannelSignal.sendSignaling("setServerParams",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,signature:t,url:r},{functionType:iG.C2RTM}).catch((function(e){throw new mA(vA.UNEXPECTED_ERROR,e.msg)}));case 8:this._serverParamsCache={signature:t,url:r},this.emit("onServerParamsSetResult"),e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(0),this.emit("onServerParamsSetResult",e.t0),e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,12]])}))),function(e,t){return r.apply(this,arguments)})},{key:"sendServerMessage",value:(t=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mA(vA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:"",room:"",type:Zj.BUSINESS_SERVER,msg:t}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e;kX.info("destroy","invoke."),OI(CI(c.prototype),"removeAllListeners",this).call(this),this._loginResolveCallback&&this._loginRejectCallback&&(this._loginRejectCallback(new mA(vA.LOGIN_FAILED,"logout")),delete this._loginResolveCallback,delete this._loginRejectCallback),null===(e=this._dataChannelSignal)||void 0===e||e.destroy(),delete this._dataChannelSignal,this._clearState(),this._connectionManager.destroy(),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=XO();this._checkDataChannelSignal(),this._dataChannelSignal.sendSignaling("login",{Token:YO.token2auth(this._ctx.appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:aD.VERSION,deviceId:$N.getDeviceId(),appId:this._ctx.appId,userId:this._userId}},{functionType:iG.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,wO.setRtsSessionId(e.id,t),e._wait_login_token=!1,e._serverParamsCache&&e.setServerParams(e._serverParamsCache.signature,e._serverParamsCache.url)})).catch((function(t){var r,n,i=t||{},o=i.code,a=i.message;e._wait_login_token=!1,o>=700&&o<800?708===o?(r=vA.INVALID_PARAMS,n="Invalid userId"):(r=vA.INVALID_TOKEN,n="Invalid token",e._wait_login_token=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=vA.LOGIN_FAILED,n="login failed"),"function"==typeof e._loginRejectCallback&&e._loginRejectCallback(new mA(r,a||n))})).finally((function(){delete e._loginResolveCallback,delete e._loginRejectCallback}))}}},{key:"connect",value:function(){var e=this;return new Yf((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"_checkDataChannelSignal",value:function(){if(!this._dataChannelSignal||this._dataChannelSignalState!==vG.CONNECTED)throw new mA(vA.NOT_CONNECTED_YET,"datachannel not connect")}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n;e._dataChannelSignalState=vG.CONNECTED,kX.info("connectStateChange","connected"),null===(r=e._handler)||void 0===r||r.destroy(),null===(n=e._dataChannelSignal)||void 0===n||n.destroy(),e._handler=Tj(e._ctx,t.pc),e._dataChannelSignal=t.signaling,e._addSignalEventHandler(),e.isReconnecting&&e._login()})),this._connectionManager.on("disconnected",(function(t){e._dataChannelSignalState=vG.DISCONNECTED,kX.warn("connectStateChange","disconnected. %o",t),e.isReconnecting&&(e.emit("onUserDisconnection"),e._clearState())})),this._connectionManager.on("connecting",(function(){var t;e.isReconnecting=!1,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e._dataChannelSignalState=vG.CONNECTING,kX.info("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(){var t;e.isReconnecting=!0,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e._dataChannelSignalState=vG.CONNECTING,kX.warn("connectStateChange","reconnecting")}))}},{key:"_addSignalEventHandler",value:function(){var e,t,r,n=this;null===(e=this._dataChannelSignal)||void 0===e||e.on(Rj.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){n.emit("onUserMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),null===(t=this._dataChannelSignal)||void 0===t||t.on(Rj.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){n.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),null===(r=this._dataChannelSignal)||void 0===r||r.on(Rj.USER_DISCONNECTION,(function(){n.emit("onUserDisconnection"),n._clearState()}))}},{key:"_clearState",value:function(){this._userId=null,this._token=null,this._loginSessionId=null,wO.setRtsSessionId(this.id,"")}}]),c}(PD.exports.EventEmitter),RX=function(){function e(t){Vl(this,e),Jd(this,"_roomId",void 0),Jd(this,"_constraints",{}),Jd(this,"_profile",void 0),Jd(this,"_customMaxBitrate",0),this._appId=t}return Ul(e,[{key:"setRoomId",value:function(e){this._roomId=e}},{key:"setAudioProfile",value:function(e){this._profile=e,this._customMaxBitrate=0}},{key:"customMaxBitrate",get:function(){return this._customMaxBitrate}},{key:"setCustomMaxBitrate",value:function(e){var t=$N.getEngineWebConfig(this._appId,this._roomId||"").audio_encode;this._customMaxBitrate=null!=t&&t.bitrate?0:1e3*e}},{key:"getOpusConfigStr",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=$N.getEngineWebConfig(this._appId,this._roomId||""),n=r.audio_encode,i=this.getConstraints(),o=i.sampleRate,a=i.channelCount,s="number"==typeof o?o:null==o?void 0:o.exact,c="number"==typeof a?a:null==a?void 0:a.exact,u={};t.split(";").forEach((function(e){var t=eI(e.split("="),2),r=t[0],n=t[1];r&&n&&(u[r]=n)}));var d=(null==n?void 0:n.bitrate)||this._customMaxBitrate||this._getConfigByAudioProfile().bitrate;d&&(u.maxaveragebitrate=d);var l=(null==n?void 0:n.enc_sample_rate)||s;l&&(u["sprop-maxcapturerate"]=l);var h=(null==n?void 0:n.playback_rate)||s;return h&&(u.maxplaybackrate=h),(c&&c>1||null!=n&&n.stereo)&&(u["sprop-stereo"]=1,u.stereo=1),null!=n&&n.dtx&&(u.usedtx=1),jm(e=an(u)).call(e,(function(e){var t;return Om(t="".concat(e,"=")).call(t,u[e])})).join(";")}},{key:"updateConstraints",value:function(e){this._constraints=Zd(Zd({},this._constraints),e)}},{key:"getConstraints",value:function(){var e=Zd({},this._constraints),t=$N.getEngineWebConfig(this._appId,this._roomId||"").audio_capture;pN(null==t?void 0:t.sample_rate)||(e.sampleRate=t.sample_rate),pN(null==t?void 0:t.channel)||(e.channelCount=t.channel),pN(null==t?void 0:t.agc)||(e.autoGainControl=t.agc),pN(null==t?void 0:t.ans)||(e.noiseSuppression=t.ans),pN(null==t?void 0:t.aec)||(e.echoCancellation=t.aec);var r=this._getConfigByAudioProfile(),n=r.sampleRate,i=r.channel;return pN(e.sampleRate)&&!pN(n)&&(e.sampleRate=n),pN(e.channelCount)&&!pN(i)&&(e.channelCount=i),e}},{key:"_getConfigByAudioProfile",value:function(){var e={};switch(this._profile){case El.fluent:e.sampleRate=16e3,e.bitrate=24e3;break;case El.standard:e.sampleRate=48e3,e.bitrate=48e3;break;case El.hd:e.sampleRate=48e3,e.bitrate=128e3,e.channel=2;break;case El.standardStereo:e.sampleRate=48e3,e.bitrate=8e4,e.channel=2;break;case El.hdMono:e.sampleRate=48e3,e.bitrate=128e3}return e}}]),e}(),AX=function(e){DI(o,e);var t,r,n,i=QI(o);function o(e,t,r){var n,a=r.businessId;return Vl(this,o),Jd(tI(n=i.call(this)),"_mediaServerClient",void 0),Jd(tI(n),"_appId",void 0),Jd(tI(n),"remoteStreams",void 0),Jd(tI(n),"_businessId",void 0),Jd(tI(n),"_ctx",void 0),n.id=e,n._appId=t,n.remoteStreams=new $S,n._businessId=a,n._ctx={id:n.id,appId:n._appId,avSync:!0,audioProfileManager:new RX(n._appId),useCloudProxy:!1,userPriority:new $S,joinRoomConfig:new tD(n.id)},n}return Ul(o,[{key:"connect",value:(n=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._mediaServerClient=new pG(this._ctx),this._businessId&&(this._mediaServerClient.businessId=this._businessId),this._bindEvents(),e.next=5,this._mediaServerClient.connect();case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startPlayPublicStream",value:(r=Rm(km().mark((function e(t){var r,n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.remoteStreams.get(t)){e.next=2;break}throw new mA(vA.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new wV(this._ctx,t,t,!1,!0,{audiostream:!0,localaudio:!0,videostream:!0,localvideo:!0,extaudio:!1,extvideo:!1,videoDescriptions:[]})).on("onSEIMessage",(function(e){if(e instanceof Uint8Array)for(var t=vN(e),i=0;i<t.seiCount;i++)n.emit(Pj.ON_SEI_MESSAGED_RECEIVED,{sei:t.seis[i],publicStreamId:r.streamId})})),e.next=6,this._mediaServerClient.subscribePublicStream(r);case 6:return this.remoteStreams.set(t,r),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stopPlayPublicStream",value:function(e){var t=this.remoteStreams.get(e);if(t)return this.remoteStreams.delete(e),this._mediaServerClient.unsubscribePublicStream(t)}},{key:"destroy",value:function(){var e;this.remoteStreams.forEach((function(e){e.clean()})),this.remoteStreams=new $S,null===(e=this._mediaServerClient)||void 0===e||e.destroy(),this.removeAllListeners()}},{key:"_handleReconnected",value:(t=Rm(km().mark((function e(){var t,r,n,i=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=$k(this.remoteStreams);try{for(n=function(){var e=eI(r.value,1)[0];i.remoteStreams.delete(e),i.startPlayPublicStream(e).then((function(){var t=i.remoteStreams.get(e);i.safeEmit(Pj.RESUBSCRIBE,{stream:t})}))},t.s();!(r=t.n()).done;)n()}catch(o){t.e(o)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_bindEvents",value:function(){var e,t,r=this;null===(e=this._mediaServerClient)||void 0===e||e.on("joinSuccess",(function(e){e.reconnect&&r._handleReconnected()})),null===(t=this._mediaServerClient)||void 0===t||t.on("onRemoteStreamStats",(function(e){r.emit("onRemoteStreamStats",e)}))}}]),o}(UD),wX=new Mw("AudioDeviceManager",1),CX=function(e){DI(c,e);var t,r,n,i,o,a,s=QI(c);function c(e){var t;return Vl(this,c),Jd(tI(t=s.call(this)),"_audioLevelFetcher",void 0),Jd(tI(t),"_playbackDeviceTestTimer",void 0),Jd(tI(t),"_audioElement",void 0),Jd(tI(t),"_audioTrack",void 0),Jd(tI(t),"_mediaRecorder",void 0),Jd(tI(t),"_recoderTimer",void 0),Jd(tI(t),"_isAudioPlaybackDeviceTesting",!1),Jd(tI(t),"_isAudioDeviceRecordTesting",!1),Jd(tI(t),"_audioCaptureAndRecoderResolve",void 0),Jd(tI(t),"_onAutoplayFailed",void 0),Jd(tI(t),"_audioPlaybackDeviceId",void 0),t._extensionManager=e,t}return Ul(c,[{key:"audioTrack",get:function(){return this._audioTrack}},{key:"startAudioPlaybackDeviceTest",value:(a=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new mA(vA.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,wX.info("startAudioPlaybackDeviceTest()","Invoke"),e.prev=4,e.next=7,this._playAudioFile(t,{loop:!0});case 7:e.next=14;break;case 9:throw e.prev=9,e.t0=e.catch(4),wX.error("startAudioPlaybackDeviceTest()","error",e.t0),this.stopAudioPlaybackDeviceTest(),e.t0;case 14:this._startEmitAudioPlaybackDeviceTestVolume(r);case 15:case"end":return e.stop()}}),e,this,[[4,9]])}))),function(e,t){return a.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this._isAudioPlaybackDeviceTesting&&(wX.info("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(o=Rm(km().mark((function e(t,r,n){var i,o=this,a=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=a.length>3&&void 0!==a[3]?a[3]:3e4,window.MediaRecorder){e.next=3;break}throw new mA(vA.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 3:if(!this._isAudioDeviceRecordTesting&&!this._isAudioPlaybackDeviceTesting){e.next=5;break}throw new mA(vA.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 5:return this._isAudioDeviceRecordTesting=!0,wX.info("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){wX.info("startAudioDeviceRecordTest()","".concat(i,'ms automatic call method "stopAudioDeviceRecordAndPlayTest"')),o._stopAudioCaptureAndRecoder()}),i),e.prev=8,this._onAutoplayFailed=r,e.next=12,this._startAudioCaptureAndRecoder(t,null!=n?n:100);case 12:e.next=19;break;case 14:throw e.prev=14,e.t0=e.catch(8),this._isAudioDeviceRecordTesting=!1,delete this._onAutoplayFailed,e.t0;case 19:delete this._audioCaptureAndRecoderResolve;case 20:case"end":return e.stop()}}),e,this,[[8,14]])}))),function(e,t,r){return o.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){wX.info("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(wX.info("stopAudioDevicePlayTest()","Invoke"),this._isAudioDeviceRecordTesting=!1,this.stopAudioDeviceRecordAndPlayTest(),this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement()),delete this._onAutoplayFailed}},{key:"getRecordTrack",value:function(){return this._audioTrack}},{key:"setSinkId",value:(i=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(wX.info("setSinkId()","Invoke"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=3;break}throw new mA(vA.NOT_SUPPORTED,"setSinkId not supported by current browser");case 3:return e.next=5,hU.getDeviceById(t);case 5:if(r=e.sent){e.next=8;break}throw new mA(vA.INVALID_DEVICE_ID,"audio playback device id ".concat(t," is invalid"));case 8:return this._audioPlaybackDeviceId=t,this._setAudioCtxSinkId(),e.abrupt("return",r);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getSinkId",value:function(){return this._audioPlaybackDeviceId}},{key:"destroy",value:function(){wX.info("destroy()","Invoke"),OI(CI(c.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:(n=Rm(km().mark((function e(t,r){var n,i=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return wX.info("_playAudioFile()",Om(n="Invoke url=".concat(t,"; loop=")).call(n,r.loop)),e.abrupt("return",new Yf((function(e,n){var o=HG("audio",{attributes:{src:t,crossOrigin:"anonymous"}});i._audioElement=o,o.loop=r.loop,i._audioLevelFetcher=new yU(o),o.onplaying=function(){o.onplaying=null,wX.info("_playAudioFile()","onplaying"),e()},o.onerror=function(){var e=Rm(km().mark((function e(t){var r,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:wX.error("_playAudioFile()","onerror",t),i=t.message||(null==o||null===(r=o.error)||void 0===r?void 0:r.message),n(new mA(vA.LOAD_RESOURCES_FAILED,"Failed to play recorded audio".concat(i?", reason: ".concat(i):".")));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),i._setAudioCtxSinkId().then((function(){var e,t;return null===(e=o.play())||void 0===e||null===(t=e.catch)||void 0===t?void 0:t.call(e,(function(e){var t;wX.warn("_playAudioFile()","autoplay error",e);var r=Om(t="Failed to play recorded audio, ".concat(e.name,": ")).call(t,e.message);"NotAllowedError"===e.name&&i._onAutoplayFailed?i._onAutoplayFailed((function(){var e;return Yf.all([null===(e=i._audioLevelFetcher)||void 0===e?void 0:e.resume(),o.play()])})):n(new mA(vA.LOAD_RESOURCES_FAILED,r))}))}))})));case 2:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"_destroyAudioElement",value:function(){this._audioElement&&(wX.info("_destroyAudioElement()","Invoke"),this._audioElement.onplaying=null,this._audioElement.onerror=null,this._audioElement.src="",delete this._audioElement,"function"==typeof this._audioCaptureAndRecoderResolve&&this._audioCaptureAndRecoderResolve())}},{key:"_startEmitAudioPlaybackDeviceTestVolume",value:function(e){var t=this;e=Math.max(e,100),this._audioElement&&(wX.info("_startEmitAudioPlaybackDeviceTestVolume()","start timer(".concat(e,"ms)")),this._playbackDeviceTestTimer=self.setInterval((function(){t._audioLevelFetcher&&t.emit("onAudioPlaybackDeviceTestVolume",t._audioLevelFetcher.getAudioLevel())}),e))}},{key:"_stopEmitAudioPlaybackDeviceTestVolume",value:function(){var e;void 0!==this._playbackDeviceTestTimer&&(wX.info("_stopEmitAudioPlaybackDeviceTestVolume()","stop timer"),self.clearInterval(this._playbackDeviceTestTimer),delete this._playbackDeviceTestTimer),null===(e=this._audioLevelFetcher)||void 0===e||e.destroy(),delete this._audioLevelFetcher}},{key:"_startAudioCaptureAndRecoder",value:(r=Rm(km().mark((function e(t,r){var n,i=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,WU({},this._extensionManager);case 2:return this._audioTrack=e.sent,this._audioTrack.setVolume(r),n=new MediaStream([this._audioTrack.getTrack("preprocessing")]),wX.info("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new Yf((function(e,r){var o,a;"function"==typeof MediaRecorder.isTypeSupported&&(o=yE(a=["audio/webm","audio/mp4"]).call(a,(function(e){return MediaRecorder.isTypeSupported(e)})),wX.info("startAudioDeviceRecordTest()","use mimeType: ".concat(o))),i._mediaRecorder=new MediaRecorder(n,o?{mimeType:o}:void 0);var s=i._mediaRecorder.mimeType;i._mediaRecorder.ondataavailable=function(){var n=Rm(km().mark((function n(o){var a,c;return km().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!i._isAudioDeviceRecordTesting){n.next=16;break}return wX.info("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),c=new Blob([o.data],{type:s}),n.prev=3,n.next=6,i._playAudioFile(mX.createObjectURL(c),{loop:!1});case 6:n.next=11;break;case 8:return n.prev=8,n.t0=n.catch(3),n.abrupt("return",r(n.t0));case 11:i._startEmitAudioPlaybackDeviceTestVolume(t),null===(a=i._audioElement)||void 0===a||a.addEventListener("ended",(function(){i.stopAudioDevicePlayTest(),e()})),i._audioCaptureAndRecoderResolve=e,n.next=17;break;case 16:e();case 17:case"end":return n.stop()}}),n,null,[[3,8]])})));return function(e){return n.apply(this,arguments)}}(),i._mediaRecorder.onerror=function(e){r(new mA(vA.AUDIO_DEVICE_TEST_FAILED,e.message||"mediaRecorder error"))},i._audioCaptureAndRecoderResolve=e,i._mediaRecorder.start()})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_stopAudioCaptureAndRecoder",value:function(){var e;this._mediaRecorder&&("recording"===this._mediaRecorder.state&&this._mediaRecorder.stop(),delete this._mediaRecorder),null===(e=this._audioTrack)||void 0===e||e.close(),delete this._audioTrack}},{key:"_setAudioCtxSinkId",value:(t=Rm(km().mark((function e(){var t,r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._audioPlaybackDeviceId){"default"===t&&(t="");try{null===(r=SU.getAudioContextInstance())||void 0===r||null===(n=r.setSinkId)||void 0===n||n.call(r,t),wX.info("setSinkId","ctx.sinkId=".concat(t))}catch(o){wX.error("setSinkId",Om(i="failed, ".concat(o.name," - ")).call(i,o.message))}}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),c}(PD.exports.EventEmitter),xX=new Mw("VideoSnapshot",1),OX=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},NX=function(){var e=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d,l;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=document.createElement("canvas"),o=i.getContext("2d")){e.next=4;break}throw new Error("canvas.getContext error");case 4:if(a=function(e,t,n){return t=t||e.width,n=n||e.height,i.width=t,i.height=n,r?o.setTransform(-1,0,0,1,t,0):o.setTransform(1,0,0,1,0,0),o.drawImage(e,0,0,t,n),o.getImageData(0,0,t,n)},s=Date.now(),!(c=OX(n))){e.next=16;break}return xX.info("takeSnapshot","VideoPlayer already set."),e.next=11,a(c,c.videoWidth,c.videoHeight);case 11:return u=e.sent,xX.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",u);case 16:if(!window.ImageCapture){e.next=29;break}if("live"!==(d=new window.ImageCapture(t)).track.readyState||!d.track.enabled||d.track.muted){e.next=29;break}return xX.info("takeSnapshot","use ImageCapture"),e.t0=a,e.next=23,d.grabFrame();case 23:return e.t1=e.sent,e.next=26,(0,e.t0)(e.t1);case 26:return l=e.sent,xX.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",l);case 29:return xX.info("takeSnapshot","use temp video"),e.abrupt("return",new Yf((function(e,r){var n=new MediaStream([t]),i=document.createElement("video");i.setAttribute("playsinline",""),i.muted=!0,document.body.appendChild(i),i.onplaying=function(){var r=a(i,i.videoWidth,i.videoHeight);xX.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e(r),n.removeTrack(t),i.srcObject=null,i.load()},i.onerror=r,i.srcObject=n,i.play()})));case 31:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),DX=function(){return{url:"",video:{codec:Il.H264,width:640,height:360,fps:15,gop:2,kBitRate:PX(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:kl.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function PX(e,t,r){return e*t<=288e3?r<=15?800:1200:e*t<=864e3?r<=15?1200:1800:e*t<=1152e3?r<=15?1600:2400:e*t<=2592e3?r<=15?2500:3750:r<=15?3300:5e3}function MX(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new mA(vA.INVALID_PARAMS,"Invalid rtmp address")}function LX(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new mA(vA.INVALID_PARAMS,"regions should not be empty.");var t,r=$k(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new mA(vA.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if("boolean"!=typeof n.isScreenStream)throw new mA(vA.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(i){r.e(i)}finally{r.f()}}function UX(e,t){var r,n,i,o=function(e,r){var n=vb(e).call(e,(function(e,t){return null==e?void 0:e[t]}),t),i=vb(e).call(e,(function(e,t){return null==e?void 0:e[t]}),DX());return n&&r(n)?n:i},a=function(e){return e%2==0?e:e+1},s=a(o(["video","width"],(function(e){return e>=2&&e<=1920}))),c=a(o(["video","height"],(function(e){return e>=2&&e<=1920}))),u=o(["video","fps"],(function(e){return e>=1&&e<=60})),d=(null===(r=t.video)||void 0===r?void 0:r.kBitRate)||0,l=o(["audio","sampleRate"],(function(e){var t;return!!yE(t=[32e3,44100,48e3]).call(t,(function(t){return t===e||t/1e3===e}))}));return{type:"transcode",action:e,transcodeMeta:{transcode:{url:t.url},control:{protocol:"2.0"},audio:{codec:o(["audio","codec"],(function(e){return"AAC"===e})),bitRate:1e3*o(["audio","kBitRate"],(function(e){return e>=32&&e<=192})),sampleRate:l<100?1e3*l:l,channels:o(["audio","channels"],(function(e){var t;return mT(t=[1,2]).call(t,e)})),profile:o(["audio","AACProfile"],(function(e){var t;return mT(t=[kl.LC,kl.HEv1,kl.HEv2]).call(t,e)}))},video:{codec:o(["video","codec"],(function(e){var t;return mT(t=["H264","H265"]).call(t,e)})),fps:u,gop:o(["video","gop"],(function(e){return e>=1&&e<=5}))*u,bitRate:1e3*(d>=16&&d<=1e4?d:PX(s,c,u)),width:s,height:c},layout:{canvas:{bgnd:o(["layout","backgroundColor"],(function(e){return/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(e)}))},regions:(null===(n=t.layout)||void 0===n||null===(i=n.regions)||void 0===i?void 0:jm(i).call(i,(function(e){var t,r;return{alpha:!e.alpha||Number(e.alpha)>1||Number(e.alpha)<=0?1:Number(e.alpha),uid:e.userId,zorder:!e.zorder||Number(e.zorder)<0||Number(e.zorder)>100?0:Number(e.zorder),x:!e.x||Number(e.x)>=1||Number(e.x)<0?0:Number(e.x),y:!e.y||Number(e.y)>=1||Number(e.y)<0?0:Number(e.y),w:!e.w||Number(e.w)>1||Number(e.w)<=0?1:Number(e.w),h:!e.h||Number(e.h)>1||Number(e.h)<=0?1:Number(e.h),renderMode:e.renderMode&&mT(t=[1,2,3]).call(t,e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&mT(r=[0,1,2]).call(r,e.contentControl)?e.contentControl:0,screen:!!e.isScreenStream}})))||[],app_data:o(["layout","appData"],(function(e){return"string"==typeof e}))}}}}var VX,FX={getDefaultValue:DX,checkStartParams:function(e){var t;MX(e.url),LX(null===(t=e.layout)||void 0===t?void 0:t.regions)},checckUpdateParams:function(e){var t;e.url&&MX(e.url),LX(null===(t=e.layout)||void 0===t?void 0:t.regions)},getStartParams:function(e){return UX("started",e)},getUpdateParams:function(e){return UX("layoutChanged",e)}},BX=ad,jX=tc,GX=function(e,t,r,n){for(var i,o=n>1?void 0:n?jX(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&BX(t,r,o),o},HX=new Mw("Engine",0),zX=function(e){DI(Te,e);var t,r,n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k,I,R,A,w,C,x,O,N,D,P,M,L,U,V,F,B,j,G,H,z,K,X,W,q,Y,J,Q,Z,$,ee,te,re,ne,ie,oe,ae,se,ce,ue,de,le,he,ve,_e,pe,fe,me,ge,ye,Se,be,Ee=QI(Te);function Te(e,t,r){var n;return Vl(this,Te),Jd(tI(n=Ee.call(this)),"monitor",void 0),Jd(tI(n),"_room",void 0),Jd(tI(n),"_publicStreamManager",void 0),Jd(tI(n),"_appId",void 0),Jd(tI(n),"_businessId",void 0),Jd(tI(n),"_visibility",!0),Jd(tI(n),"_localVideoTrack",void 0),Jd(tI(n),"_localAudioTrack",void 0),Jd(tI(n),"_localImgVideoTrack",void 0),Jd(tI(n),"_localImgScreenTrack",void 0),Jd(tI(n),"_localScreenVideoTrack",void 0),Jd(tI(n),"_localScreenAudioTrack",void 0),Jd(tI(n),"_tempMixingAudioTrack",void 0),Jd(tI(n),"_localAudioVolume",100),Jd(tI(n),"_localScreenAudioVolume",100),Jd(tI(n),"_remoteAudioVolume",new $S),Jd(tI(n),"_remoteScreenAudioVolume",new $S),Jd(tI(n),"_publicAudioVolume",new $S),Jd(tI(n),"_videoPlayer",void 0),Jd(tI(n),"_screenPlayer",void 0),Jd(tI(n),"_remoteVideoPlayer",new $S),Jd(tI(n),"_remoteScreenPlayer",new $S),Jd(tI(n),"_remoteAudioPlayer",new $S),Jd(tI(n),"_remoteScreenAudioPlayer",new $S),Jd(tI(n),"_publicStreamAudioPlayer",new $S),Jd(tI(n),"_publicStreamVideoPlayer",new $S),Jd(tI(n),"_publicStreamIds",new $S),Jd(tI(n),"_roomConfig",void 0),Jd(tI(n),"_videoStreamConstraints",dD),Jd(tI(n),"_audioStreamConstraints",{}),Jd(tI(n),"_enableSimulcast",!1),Jd(tI(n),"_videoStreamEncodeConfig",[dD]),Jd(tI(n),"_screenStreamEncodeConfig",[lD]),Jd(tI(n),"_dummyMainImage",void 0),Jd(tI(n),"_dummyScreenImage",void 0),Jd(tI(n),"_trackSourceType",void 0),Jd(tI(n),"_liveTranscodeConfig",void 0),Jd(tI(n),"_startCloudProxyTimestamp",void 0),Jd(tI(n),"_localVideoDeviceId",void 0),Jd(tI(n),"_localAudioDeviceId",void 0),Jd(tI(n),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeStreamIds:{}}),Jd(tI(n),"_audioVolumeIndicationTimer",void 0),Jd(tI(n),"_dummyMainTimer",void 0),Jd(tI(n),"_dummyScreenTimer",void 0),Jd(tI(n),"_audioPropertiesReportTimer",null),Jd(tI(n),"_mirrorType",hl.MIRROR_TYPE_RENDER),Jd(tI(n),"_audioMixingManager",void 0),Jd(tI(n),"_pubLock",void 0),Jd(tI(n),"_rtmClient",void 0),Jd(tI(n),"_messageStatisticsObserver",void 0),Jd(tI(n),"_tempRoomInfo",void 0),Jd(tI(n),"_originIceConfigRequestUrls",void 0),Jd(tI(n),"_originConfigServerUrls",void 0),Jd(tI(n),"_originLogServerUrl",void 0),Jd(tI(n),"_extensionManager",void 0),Jd(tI(n),"_audioDeviceManager",void 0),Jd(tI(n),"_remoteVideoConfig",new $S),Jd(tI(n),"_cameraCapturing",!1),Jd(tI(n),"_interruptCameraCapture",!1),Jd(tI(n),"_micCapturing",!1),Jd(tI(n),"_interruptMicCapture",!1),Jd(tI(n),"_config",void 0),Jd(tI(n),"_needClosePreTrack",!1),Jd(tI(n),"_ctx",void 0),Jd(tI(n),"_updateMixAudioTrack",function(){var e=Rm(km().mark((function e(t){var r,i,o=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.length>1&&void 0!==o[1]?o[1]:Nl.PLAYOUT_AND_PUBLISH,HX.info("_updateMixAudioTrack()"),n._localAudioTrack){e.next=5;break}return t&&(n._tempMixingAudioTrack={track:t,type:i}),e.abrupt("return");case 5:if(t?(n._localAudioTrack.mixType=i,n._localAudioTrack.mixedAudioTrack=t):(delete n._localAudioTrack.mixType,delete n._localAudioTrack.mixedAudioTrack),null===(r=n._room)||void 0===r||!r.hasPublished){e.next=9;break}return e.next=9,n._updatePublish();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),Jd(tI(n),"_onAudioMixingMessage",(function(e){n.safeEmit(Ml.onAudioMixingStateChanged,e)})),Jd(tI(n),"_onAudioMixingAutoplayFailed",(function(e){n.safeEmit(Ml.onAutoplayFailed,e)})),n.id=t,n._appId=e,n._pubLock=new Dj("pubLock"),n._addDeviceEventHandler(),n._extensionManager=new EU(t),n._audioDeviceManager=new CX(n._extensionManager),n._audioMixingManager=new EX({getLocalAudioTrack:function(){return n._localAudioTrack},updateLocalAudioTrack:n._updateMixAudioTrack,emitMessage:n._onAudioMixingMessage,onAutoPlayFailed:n._onAudioMixingAutoplayFailed},t),n._ctx={id:t,appId:e,avSync:!0,streamRTT:{},useCloudProxy:!1,audioProfileManager:new RX(e),userPriority:new $S,expectedIDC:null==r?void 0:r.expectedIDC,joinRoomConfig:new tD(t)},window.__rtc_engine__=tI(n),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=tI(n),n._trackSourceType={video:$d.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:$d.VIDEO_SOURCE_TYPE_INTERNAL,audio:el.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:el.AUDIO_SOURCE_TYPE_INTERNAL},n._config=r,n._rtmClient=new IX(n._ctx),n._handleRTMClient(n._rtmClient),n._handleAudioDeviceManager(),n._messageStatisticsObserver=new CO(t),n.monitor=VO(t),wO.createRTSMsgReportor(n.id),n._getServerConfig(),n}return Ul(Te,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(be=Rm(km().mark((function e(t){var r,n,i,o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("updateToken()","token: %s",t),_D(t,"token"),!this.waitForNewToken||!this._tempRoomInfo){e.next=8;break}return n=this._tempRoomInfo,i=n.config,o=n.userInfo,a=n.roomId,delete this._tempRoomInfo,e.next=7,this.joinRoom(t,a,o,i);case 7:return e.abrupt("return",e.sent);case 8:if(this._room){e.next=10;break}throw new mA(vA.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 10:return e.next=12,null===(r=this._room)||void 0===r?void 0:r.updateToken(t);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return be.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(Se=Rm(km().mark((function e(t){var r,n,i,o=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("setVideoCaptureDevice()","deviceId: %s",t),_D(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:return r=dB({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete r.deviceId,r.facingMode=t):r.deviceId={exact:t},MN&&kN&&KN>=85&&KN<=91&&(null===(n=this._videoPlayer)||void 0===n||n.removeTrack()),this._needClosePreTrack=this._needClosePreTrack||MN&&kN,this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),delete this._localVideoTrack),HX.info("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=13,KU(r,this._extensionManager).catch((function(e){if(o._localVideoTrack&&!o._localVideoTrack.dummy)return HX.warn("setVideoCaptureDevice()","createCameraVideoTrack failed, stop pre VideoTrack."),o._removeLocalTrackEvents(o._localVideoTrack),o._localVideoTrack.close(),delete o._localVideoTrack,KU(r,o._extensionManager).then((function(e){return o._needClosePreTrack=!0,e})).catch(Rm(km().mark((function t(){var r;return km().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return HX.error("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,KU(o._videoStreamConstraints,o._extensionManager);case 3:throw r=t.sent,o._switchTrack(r),e;case 6:case"end":return t.stop()}}),t)}))));throw e}));case 13:return i=e.sent,HX.success("setVideoCaptureDevice()","createCameraVideoTrack success."),this._videoStreamConstraints=r,this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),e.next=19,this._switchTrack(i);case 19:case"end":return e.stop()}}),e,this)}))),function(e){return Se.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(ye=Rm(km().mark((function e(t){var r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("setAudioCaptureDevice()","deviceId: %s",t),_D(t,"deviceId"),this._localAudioDeviceId=t,this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._localAudioTrack.close(),this._removeLocalTrackEvents(this._localAudioTrack),e.prev=8,this._micCapturing=!0,e.next=12,WU(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 12:if(i=e.sent,!this._interruptMicCapture){e.next=18;break}return this._interruptMicCapture=!1,i.close(),this._localAudioTrack=void 0,e.abrupt("return");case 18:if(this._initLocalTrackEvents(i),this._localAudioTrack=i,this._localAudioTrack.setVolume(this._localAudioVolume),this._room){e.next=23;break}return e.abrupt("return");case 23:if(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n||!n.pubAudio){e.next=26;break}return e.next=26,this._updatePublish();case 26:return e.prev=26,this._micCapturing=!1,e.finish(26);case 29:case"end":return e.stop()}}),e,this,[[8,,26,29]])}))),function(e){return ye.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){hU.on(Ml.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),hU.on(Ml.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k,I,R,A,w,C,x,O,N,D,P,M=this;null===(e=this._room)||void 0===e||e.on(Rj.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(Rj.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(Rj.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(Pj.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(Pj.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(Pj.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(Rj.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(Rj.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(Rj.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(Rj.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(d=this._room)||void 0===d||d.on(Rj.POST_PROCESSING_MESSAGE,(function(e){"2.0"===e.protocol?M._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?M._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&M._onLiveTranscodingResult(e)})),null===(l=this._room)||void 0===l||l.on(wj.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(h=this._room)||void 0===h||h.on(wj.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return M.safeEmit(Ml.onVendorConnectionStateChanged,e)})),null===(v=this._room)||void 0===v||v.on(Pj.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(_=this._room)||void 0===_||_.on(Pj.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(p=this._room)||void 0===p||p.on(Pj.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(f=this._room)||void 0===f||f.on(Pj.ON_PUBLISH_RESULT,(function(e){var t;null!==(t=M._room)&&void 0!==t&&t._roomConfig.isAutoPublish&&M.safeEmit(Ml.onAutoPublishResult,e)})),null===(m=this._room)||void 0===m||m.on(Pj.ON_REMOTE_STREAM_STATS,(function(e){M.safeEmit(Ml.onRemoteStreamStats,e)})),null===(g=this._room)||void 0===g||g.on(Pj.ON_LOCAL_STREAM_STATS,(function(e){M.safeEmit(Ml.onLocalStreamStats,e)})),null===(y=this._room)||void 0===y||y.on(Pj.ON_SUBTITLE_STATE_CHANGED,(function(e){M.safeEmit(Ml.onSubtitleStateChanged,e)})),null===(S=this._room)||void 0===S||S.on(Pj.ON_SUBTITLE_MESSAGE_RECEIVED,(function(e){M.safeEmit(Ml.onSubtitleMessageReceived,e)})),null===(b=this._room)||void 0===b||b.on(Pj.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(E=this._room)||void 0===E||E.on(Pj.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;M._updateAudioPlayerState(t),M.safeEmit(Ml.onUserStartAudioCapture,{userId:r})})),null===(T=this._room)||void 0===T||T.on(Pj.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;M.safeEmit(Ml.onUserStopAudioCapture,{userId:t})})),null===(k=this._room)||void 0===k||k.on(Pj.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;M.safeEmit(Ml.onUserStartVideoCapture,{userId:t})})),null===(I=this._room)||void 0===I||I.on(Pj.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;M.safeEmit(Ml.onUserStopVideoCapture,{userId:t})})),null===(R=this._room)||void 0===R||R.on(Pj.ON_SEI_MESSAGED_RECEIVED,(function(e){M.safeEmit(Ml.onSEIMessageReceived,e)})),null===(A=this._room)||void 0===A||A.on(Pj.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){M.safeEmit(Ml.onRemoteVideoSizeChanged,e,t)})),null===(w=this._room)||void 0===w||w.on(Pj.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return M.safeEmit(Ml.onSimulcastSubscribeFallback,e)})),null===(C=this._room)||void 0===C||C.on(Pj.RECONNECT_FAILED,(function(){M.safeEmit(Ml.onError,{errorCode:vA.RECONNECT_FAILED})})),null===(x=this._room)||void 0===x||x.on(Pj.ON_VIDEO_STREAM_BANNED,(function(e){M.safeEmit(Ml.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(O=this._room)||void 0===O||O.on(Pj.ON_AUDIO_STREAM_BANNED,(function(e){M.safeEmit(Ml.onAudioStreamBanned,{uid:e.uid,banned:e.banned})})),null===(N=this._room)||void 0===N||N.on(Pj.ON_FORWARD_STREAM_ERROR,(function(e){M.safeEmit(Ml.onForwardStreamError,e)})),null===(D=this._room)||void 0===D||D.on(Pj.ON_REJOIN_WITH_TCP,(function(){M.safeEmit(Ml.onRejoinWithTcp)})),null===(P=this._room)||void 0===P||P.on(Pj.ON_ICE_CONNECT_WITH_TCP,(function(){M.safeEmit(Ml.onIceConnectWithTcp)}))}},{key:"safeEmit",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return CD(e)&&BO(this.id,e,i),(t=OI(CI(Te.prototype),"safeEmit",this)).call.apply(t,Om(r=[this,e]).call(r,i))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(ge=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._room){e.next=2;break}return e.abrupt("return",!1);case 2:return this._room=new GG({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:bl.communication},this._ctx),this._addHandlerEventHandler(),e.next=6,this._room.connect(this._appId);case 6:case"end":return e.stop()}}),e,this)}))),function(){return ge.apply(this,arguments)})},{key:"joinRoom",value:(me=Rm(km().mark((function e(t,r,n,i){var o,a,s,c,u,d;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("joinRoom()","token: %o roomId: %o, userInfo: %o, roomConfig: %o",t,r,n,i),bD(t)||_D(t,"token"),ED(r),ID(n),RD(i=dB({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:bl.communication},i)),(null===(o=this._room)||void 0===o?void 0:o.connectionState)!==vG.CONNECTED){e.next=8;break}throw new mA(vA.REPEAT_JOIN,"Already joined");case 8:return this._room||(this._room=new GG(i,this._ctx),this._addHandlerEventHandler()),this._room.roomConfig=i,a=this._liveTranscodeConfig&&FX.getStartParams(this._liveTranscodeConfig),s=Zd(Zd({},n),{},{businessId:this._businessId,role:this._visibility?TX.NORMAL_USER:TX.SILENT_USER}),e.prev=12,this._ctx.useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),OG(s),e.next=17,this._room.join(this._appId,r,t,s,a);case 17:return u=e.sent,this._roomConfig=i,this._ctx.audioProfileManager.setRoomId(r),this._tempRoomInfo&&delete this._tempRoomInfo,null!==(c=i)&&void 0!==c&&c.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:ul.AUDIO_AND_VIDEO}):this.safeEmit(Ml.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),wO.setRoomId(this.id,r),wO.setUserId(this.id,n.userId),e.abrupt("return",u);case 27:throw e.prev=27,e.t0=e.catch(12),e.t0.code===vA.INVALID_TOKEN&&(this._tempRoomInfo={config:i,roomId:r,userInfo:s}),null===(d=this._room)||void 0===d||d.destroy(),delete this._room,e.t0;case 33:case"end":return e.stop()}}),e,this,[[12,27]])}))),function(e,t,r,n){return me.apply(this,arguments)})},{key:"leaveRoom",value:(fe=Rm(km().mark((function e(){var t,r,n,i=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],HX.info("leaveRoom()"),!t){e.next=7;break}return e.next=5,null===(r=this._room)||void 0===r?void 0:r.leave(t);case 5:e.next=8;break;case 7:null===(n=this._room)||void 0===n||n.leave(t).catch();case 8:this._removeHandlerEventHandler(),this._ctx.audioProfileManager.setRoomId(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new $S,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new $S,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new $S,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new $S,this._roomConfig=void 0,this._publicStreamIds=new $S,wO.setRoomId(this.id,""),wO.setUserId(this.id,"");case 24:case"end":return e.stop()}}),e,this)}))),function(){return fe.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;HX.info("destroy()"),this.removeAllListeners(),this._removeHandlerEventHandler(),null===(e=this._room)||void 0===e||e.destroy(),this._room=void 0,null===(t=this._videoPlayer)||void 0===t||t.destroy(),this._videoPlayer=void 0,this._screenPlayer=void 0,this._videoStreamConstraints={},this._videoStreamEncodeConfig=[dD],this._screenStreamEncodeConfig=[lD],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeStreamIds:{}},this._messageStatisticsObserver.destroy(),this.monitor.destroy(),wO.destroyRTSMsgReportor(this.id),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyMainTimer),clearInterval(this._dummyScreenTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close(),this._localAudioTrack=void 0),this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localVideoTrack=void 0),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close(),this._localScreenAudioTrack=void 0),this._localScreenVideoTrack&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localScreenVideoTrack=void 0),this._localImgVideoTrack&&(this._localImgVideoTrack.stop(),this._localImgVideoTrack=void 0),this._localImgScreenTrack&&(this._localImgScreenTrack.stop(),this._localImgScreenTrack=void 0),this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new $S,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new $S,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new $S,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new $S,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new $S,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new $S,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._publicStreamManager)||void 0===r||r.destroy(),this._publicStreamIds=new $S,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new $S,this._ctx.userPriority.clear(),this._extensionManager.destroy(),this._cameraCapturing=!1,this._micCapturing=!1,this._interruptCameraCapture=!1,this._interruptMicCapture=!1,this._ctx.avSync=!0,this._localAudioVolume=100,this._localScreenAudioVolume=100,this._remoteAudioVolume.clear(),this._remoteScreenAudioVolume.clear(),this._publicAudioVolume.clear()}},{key:"publishStream",value:(pe=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!lN(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,jU(this._localImgVideoTrack,this._extensionManager);case 6:this._localVideoTrack=e.sent;case 7:return e.next=9,this._updatePublish({mediaType:t});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return pe.apply(this,arguments)})},{key:"unpublishStream",value:(_e=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("unpublishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!r){e.next=5;break}return e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.unpublish());case 5:return e.next=7,this._updatePublish({mediaType:t,pubState:Lj.UNPUB});case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return _e.apply(this,arguments)})},{key:"publishScreen",value:(ve=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("publishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.prev=3,!lN(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,HU(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:Lj.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof mA)){e.next=18;break}throw e.t0;case 18:throw new mA(vA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return ve.apply(this,arguments)})},{key:"unpublishScreen",value:(he=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HX.info("unpublishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.next=5,this._updateScreenPublish({mediaType:t,pubState:Lj.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return he.apply(this,arguments)})},{key:"subscribeStream",value:(le=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HX.info("subscribeStream()","userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!1,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return le.apply(this,arguments)})},{key:"_subscribe",value:(de=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._checkMediaType(n),this._assertNotInRoom(),n!==ul.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){e.next=5;break}return HX.warn("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 5:if(u=this._room.remoteStreams.get(r),d=null==u?void 0:yE(u).call(u,(function(e){return e.isScreen===t}))){e.next=9;break}throw new mA(vA.STREAM_NOT_EXIST,"stream not exist");case 9:return l=this._pauseAllSubscribeState.audio,h=this._pauseAllSubscribeState.video,this._pauseAllSubscribeState.audio&&(n-=n&ul.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&ul.VIDEO),HX.warn("subscribeStream()","due to pauseAll mediaType: %o",n),v=d.hasSubscribed,_=this._remoteVideoConfig.get(r)||(null===(o=this._roomConfig)||void 0===o?void 0:o.remoteVideoConfig),d.originalMediaType=n,e.next=19,this._room.subscribe(d,n,_);case 19:dN(n)&&this._updateAudioPlayerState(d),lN(n)&&this._updateVideoPlayerState(d),p=0,f=0,l!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?p|=ul.AUDIO:f|=ul.AUDIO),h!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?p|=ul.VIDEO:f|=ul.VIDEO),p&&this.pauseAllSubscribedStream(p),f&&this.resumeAllSubscribedStream(f),this._pauseAllSubscribeState.resumeStreamIds[d.streamId]=d.streamId,!t&&(null!==(a=this._roomConfig)&&void 0!==a&&a.isAutoSubscribeAudio||null!==(s=this._roomConfig)&&void 0!==s&&s.isAutoSubscribeVideo)&&(d.audioTrack||d.videoTrack)&&(m={userId:r,isScreen:!1,state:il.SUBSCRIBE_SUCC},this.safeEmit(Ml.onAutoSubscribeResult,m)),null!==(c=this._room)&&void 0!==c&&c.multiChatMode||v||!dN(n)||!d.hasAudio||null===(g=d.observer)||void 0===g||g.setSubscribeAudio(!0),!v&&lN(n)&&d.hasVideo&&(null===(y=d.observer)||void 0===y||y.setSubscribeVideo(!0));case 31:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return de.apply(this,arguments)})},{key:"unsubscribeStream",value:(ue=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:HX.info("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this._unsubscribe(!1,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ue.apply(this,arguments)})},{key:"subscribeScreen",value:(ce=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HX.info("subscribeScreen() userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!0,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ce.apply(this,arguments)})},{key:"unsubscribeScreen",value:(se=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:HX.info("unsubscribeScreen() userId: %o, mediaType: %o",t,r),this._unsubscribe(!0,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return se.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(this._checkMediaType(r),this._assertNotInRoom(),r!==ul.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){var a,s=this._room.remoteStreams.get(t),c=null==s?void 0:yE(s).call(s,(function(t){return t.isScreen===e}));if(null==c||!c.hasSubscribed)throw new mA(vA.STREAM_NOT_EXIST,"stream not exist");if(MN&&KN&&KN>=85&&KN<=91&&r!==ul.AUDIO)null===(a=e?this._remoteScreenPlayer.get(t):this._remoteVideoPlayer.get(t))||void 0===a||a.stop();return this._room.unsubscribe(c,r).then((function(){n||delete o._pauseAllSubscribeState.resumeStreamIds[c.streamId]}))}HX.warn("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(ae=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HX.info("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),TD(t),xD(r),this._remoteVideoConfig.set(t,r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.updateSubVideoConfig(t,r).then((function(){})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return ae.apply(this,arguments)})},{key:"startVideoCapture",value:(oe=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,v=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("startVideoCapture()","deviceId: %s",t),bD(t)||_D(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,this._trackSourceType.video!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mA(vA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(!(this._cameraCapturing||this._localVideoTrack&&!this._localVideoTrack.dummy)){e.next=8;break}throw new mA(vA.REPEAT_CAPTURE,"Has already capture");case 8:return a=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?a.facingMode=t:a.deviceId={exact:t},this._videoStreamConstraints=a),s={},e.prev=11,this._cameraCapturing=!0,e.next=15,KU(a,this._extensionManager);case 15:if(u=e.sent,!this._interruptCameraCapture){e.next=22;break}throw this._interruptCameraCapture=!1,this._removeLocalTrackEvents(u),this._localVideoTrack=void 0,u.close(),new mA(vA.INTERRUPT,"interrupt by stopVideoCapture");case 22:if(this._initLocalTrackEvents(u),this._localVideoTrack=u,null===(c=this._videoPlayer)||void 0===c||c.playVideo(u),(d=null==u?void 0:u.getTrack())&&(s=d.getSettings(),l={width:s.width,height:s.height},this._localVideoTrack.resolution=l,setTimeout((function(){return v.safeEmit(Ml.onLocalVideoSizeChanged,{streamIndex:cl.STREAM_INDEX_MAIN,info:l})}))),this._room){e.next=29;break}return e.abrupt("return",s);case 29:return e.prev=29,this._cameraCapturing=!1,e.finish(29);case 32:return h=this._room._roomConfig.isAutoPublish,(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localStream)&&void 0!==n&&n.pubVideo||h)&&(this._visibility?this._updatePublish():this.safeEmit(Ml.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),null===(i=this._room.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableVideo(!0),e.abrupt("return",s);case 36:case"end":return e.stop()}}),e,this,[[11,,29,32]])}))),function(e){return oe.apply(this,arguments)})},{key:"stopVideoCapture",value:(ie=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("stopVideoCapture()"),!this._cameraCapturing){e.next=5;break}return this._interruptCameraCapture=!0,HX.warn("stopVideoCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.video!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new mA(vA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 7:if(null===(t=this._videoPlayer)||void 0===t||t.stop(),this._localVideoTrack&&(this._localVideoTrack.dummy||((s=this._extensionManager.getPluginByName(bU.PRE_PROCESSING,"RTCBeautyExtension"))&&s.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localImgVideoTrack?(null===(c=this._localVideoTrack)||void 0===c||c.setTrack(this._localImgVideoTrack,this._extensionManager),this._localVideoTrack.dummy=!0):this._localVideoTrack=void 0)),this._room){e.next=11;break}return e.abrupt("return");case 11:if(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n||!n.pubVideo){e.next=14;break}return e.next=14,this._updatePublish();case 14:null===(i=this._room)||void 0===i||null===(o=i.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setEnableVideo(!1);case 15:case"end":return e.stop()}}),e,this)}))),function(){return ie.apply(this,arguments)})},{key:"startAudioCapture",value:(ne=Rm(km().mark((function e(t){var r,n,i,o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("startAudioCapture()","deviceId: $o",t),bD(t)||_D(t,"deviceId"),t=t||this._localAudioDeviceId,this._localAudioDeviceId=t,this._trackSourceType.audio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mA(vA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 6:if(!this._micCapturing&&!this._localAudioTrack){e.next=8;break}throw new mA(vA.REPEAT_CAPTURE,"Has already capture");case 8:return t&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),a={},e.prev=10,this._micCapturing=!0,e.next=14,WU(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 14:if(s=e.sent,!this._interruptMicCapture){e.next=21;break}throw this._interruptMicCapture=!1,this._removeLocalTrackEvents(s),s.close(),this._localAudioTrack=void 0,new mA(vA.INTERRUPT,"interrupt by stopAudioCapture");case 21:if(this._initLocalTrackEvents(s),this._localAudioTrack=s,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),s.getOrgTrack()&&(a=s.getOrgTrack().getSettings()),this._room){e.next=28;break}return e.abrupt("return",a);case 28:return e.prev=28,this._micCapturing=!1,e.finish(28);case 31:return c=this._room._roomConfig.isAutoPublish,(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localStream)&&void 0!==n&&n.pubAudio||c)&&(this._visibility?this._updatePublish():this.safeEmit(Ml.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),null===(i=this._room.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableAudio(!0),e.abrupt("return",a);case 35:case"end":return e.stop()}}),e,this,[[10,,28,31]])}))),function(e){return ne.apply(this,arguments)})},{key:"stopAudioCapture",value:(re=Rm(km().mark((function e(){var t,r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("stopAudioCapture()"),!this._micCapturing){e.next=5;break}return this._interruptMicCapture=!0,HX.warn("stopAudioCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.audio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new mA(vA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:if(this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,this._audioMixingManager.stopAll(),this._room){e.next=12;break}return e.abrupt("return");case 12:if(null===(t=this._room)||void 0===t||null===(r=t.localStream)||void 0===r||!r.pubAudio){e.next=15;break}return e.next=15,this._updatePublish();case 15:null===(n=this._room.localStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setEnableAudio(!1);case 16:case"end":return e.stop()}}),e,this)}))),function(){return re.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return HX.info("getAudioMixingManager()","invoke"),this._audioMixingManager}},{key:"startScreenCapture",value:(te=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,v,_,p,f,m=this,g=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=g.length>0&&void 0!==g[0]?g[0]:{},HX.info("startScreenCapture()","config: %o",c),u=c.enableAudio,d=void 0!==u&&u,this._trackSourceType.screenVideo!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new mA(vA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 5:if(this._trackSourceType.screenAudio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new mA(vA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:return e.next=9,YU(d,this._extensionManager,this._screenStreamEncodeConfig[0]);case 9:if(l=e.sent,h=eI(l,2),v=h[0],null==(_=h[1])||_.setVolume(this._localScreenAudioVolume),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(t=this._localScreenAudioTrack)||void 0===t||t.close(),delete this._localScreenAudioTrack,this._localScreenVideoTrack=v,null!==(r=this._screenStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&v.setContentHint(null===(p=this._screenStreamEncodeConfig[0])||void 0===p?void 0:p.contentHint),(f=null==v?void 0:v.getTrack())&&setTimeout((function(){var e=f.getSettings(),t={width:e.width,height:e.height};v.resolution=t,m.safeEmit(Ml.onLocalVideoSizeChanged,{streamIndex:cl.STREAM_INDEX_SCREEN,info:{width:e.width,height:e.height}})}),500),_&&(this._localScreenAudioTrack=_,this._initLocalTrackEvents(_)),null===(n=this._screenPlayer)||void 0===n||n.playVideo(this._localScreenVideoTrack),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),!(null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubAudio||null!==(a=this._room)&&void 0!==a&&null!==(s=a.localScreenStream)&&void 0!==s&&s.pubVideo)){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(){return te.apply(this,arguments)})},{key:"stopScreenCapture",value:(ee=Rm(km().mark((function e(){var t,r,n,i,o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("stopScreenCapture()"),null===(t=this._screenPlayer)||void 0===t||t.stop(),this._localScreenVideoTrack&&(this._localScreenVideoTrack.dummy||(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localImgScreenTrack&&(null===(a=this._localScreenVideoTrack)||void 0===a||a.setTrack(this._localImgScreenTrack,this._extensionManager),this._localScreenVideoTrack.dummy=!0))),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,!(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localScreenStream)&&void 0!==n&&n.pubAudio||null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubVideo)){e.next=8;break}return e.next=8,this._updateScreenPublish();case 8:case"end":return e.stop()}}),e,this)}))),function(){return ee.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){if(HX.info("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),pD(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),t&&t.renderDom){var r,n,i,o,a=Zd(Zd({userId:this._getUserId()},t),{},{isLocal:!0});if(AD(a),e===cl.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new qG(this.id,a),this._initPlayerEvents(this._videoPlayer,!1,e),this._videoPlayer.mirror(!!this._mirrorType),this._localVideoTrack&&!this._localVideoTrack.dummy&&(null===(r=this._config)||void 0===r?void 0:r.autoPlayPolicy)!==Tl.PLAY_MANUALLY&&this._videoPlayer.playVideo(this._localVideoTrack),(null===(n=this._room)||void 0===n?void 0:n.localStream)&&(this._room.localStream.videoDom=this._videoPlayer.domElement),this._videoPlayer.domElement;if(e===cl.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new qG(this.id,Zd(Zd({},a),{},{isScreen:!0,isLocal:!0})),this._initPlayerEvents(this._screenPlayer,!1,e),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy)!==Tl.PLAY_MANUALLY&&this._screenPlayer.playVideo(this._localScreenVideoTrack),(null===(o=this._room)||void 0===o?void 0:o.localScreenStream)&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),this._screenPlayer.domElement;if(t&&void 0!==t.renderMode){var s=e===cl.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer;null==s||s.setRenderMode(t.renderMode)}}else{var c,u;e===cl.STREAM_INDEX_MAIN?(null===(c=this._videoPlayer)||void 0===c||c.destroy(!0),delete this._videoPlayer):(null===(u=this._screenPlayer)||void 0===u||u.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:($=Rm(km().mark((function e(t){var r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("startLiveTranscoding()","transcode: %o",t),FX.checkStartParams(t),this._liveTranscodeConfig=t,!((n=null===(r=this._room)||void 0===r?void 0:r.roomInfo)&&n.roomId.length+n.userInfo.userId.length>126)){e.next=6;break}throw new mA(vA.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(Ml.onStreamMixingEvent,{event:Mj.START,error:0,message:""}),!this._room||this._room.connectionState!==vG.CONNECTED){e.next=11;break}return e.next=11,null===(i=this._room)||void 0===i?void 0:i.liveControlMessage(FX.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof mA)){e.next=19;break}throw e.t0;case 19:throw new mA(vA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return $.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(Z=Rm(km().mark((function e(t){var r,n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("updateLiveTranscoding()","transcode: %o",t),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete(i=dB({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,FX.checckUpdateParams(i),this._liveTranscodeConfig=dB(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(Ml.onStreamMixingEvent,{event:Mj.UPDATE,error:0,message:""}),e.next=13,null===(o=this._room)||void 0===o?void 0:o.liveControlMessage(FX.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(e.t0 instanceof mA)){e.next=21;break}throw e.t0;case 21:throw new mA(vA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return Z.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(Q=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("stopLiveTranscoding()"),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete this._liveTranscodeConfig,e.prev=4,this.safeEmit(Ml.onStreamMixingEvent,{event:Mj.STOP,error:0,message:""}),e.next=8,null===(t=this._room)||void 0===t?void 0:t.liveControlMessage({action:"stopped",type:"transcode"});case 8:e.next=17;break;case 10:if(e.prev=10,e.t0=e.catch(4),!(e.t0 instanceof mA)){e.next=16;break}throw e.t0;case 16:throw new mA(vA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return Q.apply(this,arguments)})},{key:"startSubtitle",value:(J=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HX.info("startSubtitle()","config: %o",t),this._assertNotInRoom(),e.next=4,null===(r=this._room)||void 0===r?void 0:r.startSubtitle(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return J.apply(this,arguments)})},{key:"stopSubtitle",value:function(){var e;HX.info("stopSubtitle()","invoke"),null===(e=this._room)||void 0===e||e.stopSubtitle()}},{key:"setBusinessId",value:function(e){return HX.info("setBusinessId()","businessId: %s",e),!function(e){return"string"!=typeof e}(e)&&!this._room&&(this.monitor.set({rtc_business_id:e}),this._businessId=e,!0)}},{key:"setUserVisibility",value:(Y=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("setUserVisibility()","enable: %o",t),t=!!t,this._visibility!==t){e.next=4;break}return e.abrupt("return");case 4:if(this._room){e.next=7;break}return this._visibility=t,e.abrupt("return");case 7:if(this._assertNotInRoom(),this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),e.t0=!t,!e.t0){e.next=13;break}return e.next=13,this._room.unpublish();case 13:return e.next=15,this._room.updateUserAttributes({role:t?TX.NORMAL_USER:TX.SILENT_USER});case 15:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:ul.AUDIO_AND_VIDEO});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return Y.apply(this,arguments)})},{key:"_initPlayerEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:cl.STREAM_INDEX_MAIN,i=n===cl.STREAM_INDEX_SCREEN;e.on("playback_event",(function(n){switch(n.eventName){case"timeupdate":return;case"loadeddata":if("audio"===n.type){var o,a,s=e.userId.replace("_screen",""),c=null===(o=t._room)||void 0===o||null===(a=o.remoteStreams.get(s))||void 0===a?void 0:yE(a).call(a,(function(e){return e.isScreen===i})),u=function(){r?t.safeEmit(Ml.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:s}):(t.safeEmit(Ml.onAudioFirstFrameDecoded,{userId:s,isScreen:i}),t.safeEmit(Ml.onRemoteAudioFirstFrame,{userId:s,isScreen:i})),t.monitor.report("first_remote_audio_render",{stream_id:"",stream_user_id:s||""},{isScreen:i})};c&&c.observer&&!c.observer.audioFirstFrameReceived?c.observer.once("recvAudioFirstFrame",u):u()}else{var d,l,h={userId:e.userId,height:(null===(d=e.domElement)||void 0===d?void 0:d.videoHeight)||0,width:(null===(l=e.domElement)||void 0===l?void 0:l.videoWidth)||0,isScreen:i};r?(h.publicStreamId=h.userId,delete h.userId,delete h.isScreen,t.safeEmit(Ml.onFirstPublicStreamVideoFrameRendered,h),t.safeEmit(Ml.onFirstPublicStreamVideoFrameDecoded,h)):e.isLocal||(t.safeEmit(Ml.onVideoFirstFrameRendered,h),t.safeEmit(Ml.onVideoFirstFrameDecoded,h),t.safeEmit(Ml.onRemoteVideoFirstFrame,h)),t.monitor.report("first_remote_video_render",{stream_id:"",stream_user_id:n.userId||""},{isScreen:i})}break;case"autoplay-error":return r&&(n.publicStreamId=n.userId),jO(t.id,"autoplay-error",e instanceof qG?"video":"audio",0,n.userId||""),void t.safeEmit(Ml.onAutoplayFailed,{userId:n.userId,kind:e instanceof qG?"video":"audio",mediaType:e instanceof qG?ul.VIDEO:ul.AUDIO,streamIndex:e.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN})}t.safeEmit(Ml.onPlayerEvent,n)}))}},{key:"_initLocalTrackEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];["track-ended","track-mute","track-unmute"].forEach((function(r){e.on(r,function(){var e=Rm(km().mark((function e(n){var i,o,a,s;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.monitor.report("rtc_error",{message:Om(i="track-".concat(r," mediaType: ")).call(i,n.getTrack().kind),error_code:jj.TRACK_ERROR,capture_session_id:n.captureSessionId,media_type:r,reason:r}),o=!1,n!==t._localScreenAudioTrack&&n!==t._localScreenVideoTrack||(o=!0),a=n.getTrack(),s=a.kind,t.safeEmit({"track-ended":Ml.onTrackEnded,"track-mute":Ml.onTrackMute,"track-unmute":Ml.onTrackUnmute}[r],{kind:s,isScreen:o}),!PN&&!xN){e.next=13;break}if("track-mute"!==r){e.next=12;break}if(fU.emit(_U.ON_IOS_LOCAL_TRACK_MUTE,s),"audio"!==s){e.next=12;break}return e.next=11,t.stopAudioCapture();case 11:t.startAudioCapture();case 12:"track-unmute"===r&&fU.emit(_U.ON_IOS_LOCAL_TRACK_UNMUTE,s);case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())})),e.on("resolution-change",(function(e){t._extensionManager.getPluginsByType(bU.PRE_PROCESSING).forEach((function(t){var r;null==t||null===(r=t.applyConstraints)||void 0===r||r.call(t,e)})),t.safeEmit(Ml.onLocalVideoSizeChanged,{streamIndex:r?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN,info:e})}))}},{key:"_removeLocalTrackEvents",value:function(e){e.removeAllListeners("track-ended"),e.removeAllListeners("track-mute"),e.removeAllListeners("track-unmute"),e.removeAllListeners("resolution-change")}},{key:"setRemoteVideoPlayer",value:function(e,t){HX.info("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),pD(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),AD(t);var r,n,i,o=t.userId;if(e===cl.STREAM_INDEX_MAIN){var a,s,c;if(null===(a=this._remoteVideoPlayer.get(o))||void 0===a||a.destroy(),!t.renderDom)return;var u=new qG(this.id,t);this._initPlayerEvents(u,!1,e),this._remoteVideoPlayer.set(o,u);var d=null===(s=this._room)||void 0===s||null===(c=s.remoteStreams.get(o))||void 0===c?void 0:yE(c).call(c,(function(e){return!e.isScreen}));return d&&(this._updateVideoPlayerState(d),d.videoDom=u.domElement),u.domElement}if(null===(r=this._remoteScreenPlayer.get(o))||void 0===r||r.destroy(),t.renderDom){var l=new qG(this.id,Zd(Zd({},t),{},{isScreen:!0}));this._remoteScreenPlayer.set(o,l),this._initPlayerEvents(l,!1,e);var h=null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(o))||void 0===i?void 0:yE(i).call(i,(function(e){return e.isScreen}));return h&&(this._updateVideoPlayerState(h),h.videoDom=l.domElement),l.domElement}}},{key:"setLocalVideoMirrorType",value:function(e){HX.info("setLocalVideoMirrorType()","mirrorType: %o",e),pD(e,"mirrorType",[hl.MIRROR_TYPE_NONE,hl.MIRROR_TYPE_RENDER]),this._mirrorType=e,this._videoPlayer&&this._videoPlayer.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(q=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HX.info("setAudioPlaybackDevice()","deviceId: %s",t),_D(t,"deviceId"),e.next=4,this._audioDeviceManager.setSinkId(t);case 4:r=e.sent,this._remoteAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this._remoteScreenAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this.safeEmit(Ml.onAudioPlaybackDeviceChanged,r),this.monitor.report("rtc_audio_device",{audio_event:"playout_device_switch",message:Mm(r),error_code:0});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return q.apply(this,arguments)})},{key:"play",value:(W=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=g.length>1&&void 0!==g[1]?g[1]:ul.AUDIO_AND_VIDEO,a=g.length>2?g[2]:void 0,HX.info("play()","userId: %s, mediaType: %s, streamIndex: %s",t,o,a),s=!t||t===this._getUserId()||"local_user"===t,c=void 0===a||a===cl.STREAM_INDEX_MAIN,u=void 0===a||a===cl.STREAM_INDEX_SCREEN,d=o!==ul.VIDEO,l=o!==ul.AUDIO,h=[],s&&l&&(c&&this._localVideoTrack&&(null===(v=this._videoPlayer)||void 0===v||v.mirror(!!this._mirrorType),h.push(null===(_=this._videoPlayer)||void 0===_?void 0:_.manuallyPlay())),u&&this._localScreenVideoTrack&&h.push(null===(p=this._screenPlayer)||void 0===p?void 0:p.manuallyPlay())),t===(null===(r=this._audioMixingManager)||void 0===r?void 0:r.id)&&h.push(this._audioMixingManager.resumeLocalPlay()),f=null===(n=this._room)||void 0===n?void 0:n.remoteStreams,l&&c&&h.push(JG(this._remoteVideoPlayer,t,!1,f)),l&&u&&h.push(JG(this._remoteScreenPlayer,t,!0,f)),d&&c&&h.push(JG(this._remoteAudioPlayer,t,!1,f)),l&&u&&h.push(JG(this._remoteScreenAudioPlayer,t,!0,f)),m=null===(i=this._publicStreamManager)||void 0===i?void 0:i.remoteStreams,d&&h.push(JG(this._publicStreamVideoPlayer,t,!1,m)),l&&h.push(JG(this._publicStreamAudioPlayer,t,!1,m)),e.abrupt("return",Yf.all(h).then((function(){})));case 20:case"end":return e.stop()}}),e,this)}))),function(e){return W.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(X=Rm(km().mark((function e(t){var r,n,i,o,a,s=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),dN(t)&&(s._pauseAllSubscribeState.audio=!0),lN(t)&&(s._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",Yf.resolve());case 6:n=[],i=$k(oR(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(e.hasSubscribed){s._pauseAllSubscribeState.resumeStreamIds[e.streamId]=e.streamId;var r=s._unsubscribe(e.isScreen,e.userId,t,!0);r&&n.push(r)}}))}catch(c){i.e(c)}finally{i.f()}return e.abrupt("return",Yf.all(n).then((function(){})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return X.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(K=Rm(km().mark((function e(t){var r,n,i,o,a,s=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.info("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),dN(t)&&(s._pauseAllSubscribeState.audio=!1),lN(t)&&(s._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",Yf.resolve());case 6:n=[],i=$k(oR(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(s._pauseAllSubscribeState.resumeStreamIds[e.streamId]){delete s._pauseAllSubscribeState.resumeStreamIds[e.streamId];var r=s._subscribe(e.isScreen,e.userId,t);r&&n.push(r)}}))}catch(c){i.e(c)}finally{i.f()}return e.abrupt("return",Yf.all(n).then((function(){var e,t;null===(e=s._room)||void 0===e||null===(t=e.remoteStreams)||void 0===t||t.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){s._updateAudioPlayerState(e),s._updateVideoPlayerState(e)}))}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return K.apply(this,arguments)})},{key:"sendUserMessage",value:(z=Rm(km().mark((function e(t,r){var n,i,o,a=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return TD(t),wD(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!1,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!1,o,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return z.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(H=Rm(km().mark((function e(t,r){var n,i,o,a=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return TD(t),gD(r,"message"),wD(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!0,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!0,o,e),e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return H.apply(this,arguments)})},{key:"sendRoomMessage",value:(G=Rm(km().mark((function e(t){var r,n,i,o=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return wD(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return G.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(j=Rm(km().mark((function e(t){var r,n,i,o=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return wD(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t,!0))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return j.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(B=Rm(km().mark((function e(){var t,r=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.length>0&&void 0!==r[0]?r[0]:{},HX.info("setAudioCaptureConfig()","config: %o",t),delete t.deviceId,yD(t),this._shouldUpdateAudioConf("setAudioCaptureConfig")&&this._ctx.audioProfileManager.updateConstraints(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return B.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(F=Rm(km().mark((function e(){var t,r=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},HX.info("setVideoCaptureConfig()","config: %o",t),e.abrupt("return",this._setVideoCaptureConfig(t));case 3:case"end":return e.stop()}}),e,this)}))),function(){return F.apply(this,arguments)})},{key:"_setVideoCaptureConfig",value:(V=Rm(km().mark((function e(){var t,r,n,i=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(delete(r=i.length>0&&void 0!==i[0]?i[0]:{}).deviceId,yD(r),n=Zd(Zd({},r),{},{deviceId:this._videoStreamConstraints.deviceId}),!this._localVideoTrack){e.next=7;break}return e.next=7,this._localVideoTrack.updateVideoCaptureConfig(n);case 7:return this._videoStreamConstraints=n,e.abrupt("return",(null===(t=this._localVideoTrack)||void 0===t?void 0:t.getTrack().getSettings())||{});case 9:case"end":return e.stop()}}),e,this)}))),function(){return V.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){var t;return HX.info("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,14!==(null==GN?void 0:GN[0])&&(null!==(t=this._room)&&void 0!==t&&t.hasPublished&&mN("You must call this API before publishing the video streams"),!0)}},{key:"setVideoEncoderConfig",value:(U=Rm(km().mark((function e(t){var r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(HX.info("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),ND(t=Gs(t).call(t,(function(e){return!!e}))),t.length>3&&(mN("setVideoEncoderConfig: You can set parameters for up to 3 streams"),t=Tm(t).call(t,0,3)),n=1;n<t.length;n++)i=gN(t[0].width)/gN(t[n].width)||1,Math.floor(i)!==i&&mN("setVideoEncoderConfig: The resolution setting needs to be an integer multiple");GR(t).call(t,(function(e,t){return t.maxKbps-e.maxKbps})),this._setVideoCaptureConfig(Zd({},t[0])),this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(cl.STREAM_INDEX_MAIN),null!==(r=this._room)&&void 0!==r&&r.hasPublished&&this._updatePublish();case 11:case"end":return e.stop()}}),e,this)}))),function(e){return U.apply(this,arguments)})},{key:"setScreenEncoderConfig",value:(L=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:HX.info("setScreenEncoderConfig()","description: %o",t),this._screenStreamEncodeConfig=[t],this._localScreenVideoTrack&&(this._localScreenVideoTrack.updateVideoCaptureConfig(t),t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint)),this._updateDummyCaptureImage(cl.STREAM_INDEX_SCREEN),null!==(r=this._room)&&void 0!==r&&r.hasScreenPublished&&this._updateScreenPublish();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return L.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(HX.info("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!GM())throw new mA(vA.NOT_SUPPORTED,"Browser does not support sending SEI");pD(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),vD(r,"repeatCount",0,30);var n="string"==typeof t?new Uint8Array(YO.str2ab(t)):t;if(t.length){var i;if(e===cl.STREAM_INDEX_MAIN){var o,a,s;if(null===(o=this._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.hasPublished)return;i=null===(s=this._room)||void 0===s?void 0:s.localStream}else{var c,u,d;if(null===(c=this._room)||void 0===c||null===(u=c.localScreenStream)||void 0===u||!u.hasPublished)return;i=null===(d=this._room)||void 0===d?void 0:d.localScreenStream}if(n.byteLength>4096)HX.warn("sei size must not bigger than 4KB");else{var l=XO();i.seiList.push({content:n,uuid:l,repeatCount:r}),setTimeout((function(){var e;if(i){var t,r=QR(e=i.seiList).call(e,(function(e){return e.uuid===l}));if(r)rT(t=i.seiList).call(t,r,1)}}),2e3)}}else HX.warn("sei message must not be empty")}},{key:"setAudioVolumeIndicationInterval",value:function(e){var t=this;HX.info("setAudioVolumeIndicationInterval()","interval %o: ",e),("number"!=typeof e||e<200)&&(e=200);var r=[];this._audioVolumeIndicationTimer&&clearInterval(this._audioVolumeIndicationTimer),this._audioVolumeIndicationTimer=setInterval((function(){var e,n;r=[],null===(e=t._room)||void 0===e||e.remoteStreams.forEach((function(e,t){var n;if(0!==e.length){var i=yE(e).call(e,(function(e){return!e.isScreen})),o=null==i||null===(n=i.audioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t,volume:o||0})}}));var i=null===(n=t._localAudioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t._getUserId(),volume:i||0}),t.safeEmit(Ml.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n=e[0],i=vb(t).call(t,(function(e,t){return e&&e.audioPropertiesInfo.nonlinearVolume>t.audioPropertiesInfo.nonlinearVolume?e:t}),void 0);if((r=n?i?n.audioPropertiesInfo.nonlinearVolume>i.audioPropertiesInfo.nonlinearVolume?n:i:n:i)&&r.audioPropertiesInfo.nonlinearVolume>-35){var o,a;if(r.streamKey)o=this._room.remoteUsers.get(r.streamKey.userId);else o=null===(a=this._room._roomInfo)||void 0===a?void 0:a.userInfo;o&&this.safeEmit(Ml.onActiveSpeaker,{userId:o.userId,extraInfo:o.extraInfo})}}}},{key:"enableAudioPropertiesReport",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};HX.info("enableAudioPropertiesReport()","config %o: ",t);var r=t.enableInBackground,n=void 0===r||r,i=t.interval,o=void 0===i?100:i;this._stopAudioPropertiesReport(),o<=0||(o=Math.max(100,o),this._audioPropertiesReportTimer=self.setInterval((function(){if(n||"hidden"!==document.visibilityState){var t=[],r=e._audioDeviceManager.getRecordTrack()||e._localAudioTrack;if(r){var i=r.getAudioLevel();t.push({streamIndex:cl.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:i,nonlinearVolume:uN(i)}})}if(e._localScreenAudioTrack){var o=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:cl.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:o,nonlinearVolume:uN(o)}})}if(e.safeEmit(Ml.onLocalAudioPropertiesReport,t),e._room){var a,s=[];if(null!==(a=e._room)&&void 0!==a&&a.multiChatMode)e._room.getActiveSpeakerInMultiChatMode().forEach((function(t){var r,n,i=255*t.audioLevel;s.push({streamKey:{userId:t.userId,streamIndex:cl.STREAM_INDEX_MAIN,roomId:null===(r=e._room)||void 0===r||null===(n=r._roomInfo)||void 0===n?void 0:n.roomId},audioPropertiesInfo:{linearVolume:i,nonlinearVolume:uN(i)}})}));else e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o=t.audioTrack.getAudioLevel();s.push({streamKey:{userId:r,streamIndex:t.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN,roomId:null===(n=e._room)||void 0===n||null===(i=n.roomInfo)||void 0===i?void 0:i.roomId},audioPropertiesInfo:{linearVolume:o,nonlinearVolume:uN(o)}})}}))}));e.safeEmit(Ml.onRemoteAudioPropertiesReport,s),e._sendActiveSpeaker(t,Gs(s).call(s,(function(e){return e.streamKey.streamIndex!==cl.STREAM_INDEX_SCREEN})))}}}),o))}},{key:"setVideoSourceType",value:(M=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k,I,R,A;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),pD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),pD(r,"VideoSourceType",[$d.VIDEO_SOURCE_TYPE_EXTERNAL,$d.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===cl.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,HX.print("setVideoSourceType",Om(i="set ".concat(n," source type to ")).call(i,r)),!this._localVideoTrack||t!==cl.STREAM_INDEX_MAIN){e.next=17;break}if(u=!1,r===$d.VIDEO_SOURCE_TYPE_EXTERNAL&&(u=!0,(d=this._extensionManager.getPluginByName(bU.PRE_PROCESSING,"RTCBeautyExtension"))&&d.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null===(o=this._videoPlayer)||void 0===o||o.stop(),this._localVideoTrack=void 0,l=null===(a=this._room)||void 0===a?void 0:a._roomConfig.isAutoPublish,u?null===(h=this._room)||void 0===h||null===(v=h.localStream)||void 0===v||null===(_=v.observer)||void 0===_||_.setEnableVideo(!1):null===(p=this._room)||void 0===p||null===(f=p.localStream)||void 0===f||null===(m=f.observer)||void 0===m||m.setPushVideo(!1),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubVideo||l)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(!this._localScreenVideoTrack||t!==cl.STREAM_INDEX_SCREEN){e.next=26;break}if(b=!1,r===$d.VIDEO_SOURCE_TYPE_EXTERNAL&&(b=!0,this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(g=this._screenPlayer)||void 0===g||g.stop(),this._localScreenVideoTrack=void 0,b?null===(E=this._room)||void 0===E||null===(T=E.localScreenStream)||void 0===T||null===(k=T.observer)||void 0===k||k.setEnableVideo(!1):null===(I=this._room)||void 0===I||null===(R=I.localScreenStream)||void 0===R||null===(A=R.observer)||void 0===A||A.setPushVideo(!1),null===(y=this._room)||void 0===y||null===(S=y.localScreenStream)||void 0===S||!S.pubVideo){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return M.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(P=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.print("setExternalVideoTrack()","index: %o, track: %o",t,r),pD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),fD(r),t!==cl.STREAM_INDEX_MAIN){e.next=15;break}if(this._trackSourceType.video===$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mA(vA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,ZU(r,this._extensionManager);case 8:if(this._localVideoTrack=e.sent,this._initLocalTrackEvents(this._localVideoTrack),null===(n=this._videoPlayer)||void 0===n||n.playVideo(this._localVideoTrack),s=null===(i=this._room)||void 0===i?void 0:i._roomConfig.isAutoPublish,!(null!==(o=this._room)&&void 0!==o&&null!==(a=o.localStream)&&void 0!==a&&a.pubVideo||s)){e.next=15;break}return e.next=15,this._updatePublish();case 15:if(t!==cl.STREAM_INDEX_SCREEN){e.next=27;break}if(this._trackSourceType.screenVideo===$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=18;break}throw new mA(vA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 18:return e.next=20,rV(r,this._extensionManager);case 20:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(c=this._screenPlayer)||void 0===c||c.playVideo(this._localScreenVideoTrack),null===(u=this._room)||void 0===u||null===(d=u.localScreenStream)||void 0===d||null===(l=d.observer)||void 0===l||l.setPushVideo(!0),null===(h=this._room)||void 0===h||null===(v=h.localScreenStream)||void 0===v||!v.pubVideo){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(e,t){return P.apply(this,arguments)})},{key:"setAudioSourceType",value:(D=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,_,p,f,m,g,y,S,b,E,T,k;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),pD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),pD(r,"audioSourceType",[el.AUDIO_SOURCE_TYPE_EXTERNAL,el.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===cl.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,HX.print("setVideoSourceType",Om(i="set ".concat(n," source type to ")).call(i,r)),!this._localAudioTrack||t!==cl.STREAM_INDEX_MAIN){e.next=16;break}if(c=!1,this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL&&(c=!0,this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,u=null===(o=this._room)||void 0===o?void 0:o._roomConfig.isAutoPublish,c?null===(d=this._room)||void 0===d||null===(l=d.localStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setEnableAudio(!1):null===(v=this._room)||void 0===v||null===(_=v.localStream)||void 0===_||null===(p=_.observer)||void 0===p||p.setPushAudio(!1),!(null!==(a=this._room)&&void 0!==a&&null!==(s=a.localStream)&&void 0!==s&&s.pubAudio||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(!this._localScreenAudioTrack||t!==cl.STREAM_INDEX_SCREEN){e.next=24;break}if(g=!1,this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL&&(g=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,g?null===(y=this._room)||void 0===y||null===(S=y.localScreenStream)||void 0===S||null===(b=S.observer)||void 0===b||b.setEnableAudio(!1):null===(E=this._room)||void 0===E||null===(T=E.localScreenStream)||void 0===T||null===(k=T.observer)||void 0===k||k.setPushAudio(!1),null===(f=this._room)||void 0===f||null===(m=f.localScreenStream)||void 0===m||!m.pubAudio){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return D.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(N=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,v,_;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.print("setExternalAudioTrack()","index: %o, track: %o",t,r),pD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),fD(r),t!==cl.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mA(vA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,eV(r,this._extensionManager);case 8:if(this._localAudioTrack=e.sent,this._localAudioTrack.setVolume(this._localAudioVolume),this._initLocalTrackEvents(this._localAudioTrack),u=null===(n=this._room)||void 0===n?void 0:n._roomConfig.isAutoPublish,null===(i=this._room)||void 0===i||null===(o=i.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setPushAudio(!0),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubAudio||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(t!==cl.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenAudio===el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new mA(vA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 19:return e.next=21,iV(r,this._extensionManager);case 21:if(this._localScreenAudioTrack=e.sent,this._localScreenAudioTrack.setVolume(this._localScreenAudioVolume),this._initLocalTrackEvents(this._localScreenAudioTrack),null===(d=this._room)||void 0===d||null===(l=d.localScreenStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setPushAudio(!0),null===(v=this._room)||void 0===v||null===(_=v.localScreenStream)||void 0===_||!_.pubAudio){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return N.apply(this,arguments)})},{key:"login",value:(O=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HX.info("login()","token: %o, userInfo: %o",t,r),bD(t)||_D(t,"token"),TD(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return O.apply(this,arguments)})},{key:"logout",value:(x=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HX.info("logout()"),e.abrupt("return",this._rtmClient.logout());case 2:case"end":return e.stop()}}),e,this)}))),function(){return x.apply(this,arguments)})},{key:"updateLoginToken",value:(C=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HX.info("updateLoginToken()","token: %o",t),bD(t)||_D(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(w=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HX.info("getPeerOnlineStatus()","userId: %o",t),TD(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(A=Rm(km().mark((function e(t,r){var n,i=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return TD(t),wD(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!1,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!1,n,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return A.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(R=Rm(km().mark((function e(t,r){var n,i=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return TD(t),gD(r,"message"),wD(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!0,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!0,n,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"setServerParams",value:(I=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HX.info("setServerParams()","signature: %o, url: %0",t,r),e.abrupt("return",this._rtmClient.setServerParams(t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return I.apply(this,arguments)})},{key:"sendServerMessage",value:(k=Rm(km().mark((function e(t){var r,n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return _D(t,"message"),wD(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!1,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!1,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(T=Rm(km().mark((function e(t){var r,n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return gD(t,"message"),wD(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!0,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!0,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new mA(vA.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");HX.info("startCloudProxy()",e),_D(e.logProxy,"logProxy"),_D(e.accessProxy,"accessProxy"),_D(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=cD("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=cD("LOG_SERVER_URL"),this._originConfigServerUrls=cD("CONFIG_REQUEST_DOMAINS"),sD("ICE_CONFIG_REQUEST_URLS",e.accessProxy),sD("LOG_SERVER_URL",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://".concat(e)),"".concat(e,"/video/v1/webrtc_log/")}(e.logProxy)),sD("CONFIG_REQUEST_DOMAINS",[e.configProxy]),$N.clearAccessNode(this._appId),$N.clearAccessUrls(),this._ctx.useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){var e;if(this._room)throw new mA(vA.STOP_CLOUD_PROXY_BEFORE_LEAVE,"[stopCloudProxy] should be invoke after leave room ");HX.info("stopCloudProxy()"),sD("ICE_CONFIG_REQUEST_URLS",null===(e=this._originIceConfigRequestUrls)||void 0===e?void 0:jm(e).call(e,(function(e){return e.replace("https://","").replace("/dispatch/v1/AccessInfo?Action=GetAccessInfo","")}))),sD("LOG_SERVER_URL",this._originLogServerUrl),sD("CONFIG_REQUEST_DOMAINS",this._originConfigServerUrls),$N.clearAccessNode(this._appId),$N.clearAccessUrls(),this._ctx.useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(E=Rm(km().mark((function e(t,r){var n,i,o,a=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),kD(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new mA(vA.REPEAT_PUSH,"repeat push public media stream");case 5:return o=uD(t,"started",r),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.publicStreamControlMessage(o))||void 0===i?void 0:i.then((function(){a._publicStreamIds.set(t,t)})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return E.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(b=Rm(km().mark((function e(t,r){var n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HX.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),kD(t),this._assertNotInRoom(),i=uD(t,"layoutChanged",r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.publicStreamControlMessage(i));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return b.apply(this,arguments)})},{key:"stopPushPublicStream",value:(S=Rm(km().mark((function e(t){var r,n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HX.print("startPushPublicStream()","publicStreamId: %o",t),kD(t),this._assertNotInRoom(),e.abrupt("return",null===(r=this._room)||void 0===r?void 0:r.publicStreamControlMessage({type:"publicstream",action:"stopped",publicStreamID:t}).then((function(){n._publicStreamIds.delete(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"startPlayPublicStream",value:(y=Rm(km().mark((function e(t){var r,n,i,o,a,s,c=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(kD(t),this._publicStreamManager){e.next=8;break}return this._publicStreamManager=new AX(this.id,this._appId,{businessId:this._businessId}),this._publicStreamManager.on(Pj.RESUBSCRIBE,(function(e){var t=e.stream;if(t){var r,n=c._publicStreamAudioPlayer.get(t.streamId);n&&t.audioTrack&&(n.stop(),n.playAudio(null===(r=e.stream)||void 0===r?void 0:r.audioTrack));var i,o=c._publicStreamVideoPlayer.get(t.streamId);o&&t.videoTrack&&o.playVideo(null===(i=e.stream)||void 0===i?void 0:i.videoTrack)}})),null===(r=this._publicStreamManager)||void 0===r||r.on("onRemoteStreamStats",(function(e){e.publicStreamId=e.userId,delete e.userId,delete e.isScreen,c.safeEmit(Ml.onPublicStreamStats,e)})),null===(n=this._publicStreamManager)||void 0===n||n.on(Pj.ON_SEI_MESSAGED_RECEIVED,(function(e){c.safeEmit(Ml.onPublicStreamSEIMessageReceived,e)})),e.next=8,this._publicStreamManager.connect();case 8:return e.next=10,this._publicStreamManager.startPlayPublicStream(t);case 10:i=e.sent,(o=this._publicStreamVideoPlayer.get(t))&&null!=i&&i.videoTrack&&o.playVideo(i.videoTrack,i),!(a=this._publicStreamAudioPlayer.get(t))&&null!=i&&i.audioTrack&&(a=new YG(this.id,t,{muted:(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)===Tl.VIDEO_ONLY,isScreen:!1}),this._initPlayerEvents(a,!0),a.playAudio(i.audioTrack),this._publicStreamAudioPlayer.set(t,a));case 15:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(g=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publicStreamManager){e.next=2;break}return e.abrupt("return");case 2:this._publicStreamManager.stopPlayPublicStream(t),(r=this._publicStreamAudioPlayer.get(t))&&(r.destroy(),this._publicStreamAudioPlayer.delete(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"setAudioProfile",value:(m=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:HX.info("setAudioProfile()","profile: %o",t),this._shouldUpdateAudioConf("setAudioProfile")&&this._ctx.audioProfileManager.setAudioProfile(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"setAudioEncodeMaxBitrate",value:(f=Rm(km().mark((function e(t){var r,n,i,o,a,s;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.print("setAudioEncodeMaxBitrate()",t),vD(t,"maxBitrate",6,256),this._ctx.audioProfileManager.setCustomMaxBitrate(t),!this._ctx.audioProfileManager.customMaxBitrate){e.next=10;break}if(!EN||!(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localStream)&&void 0!==n&&n.pubAudio||null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubAudio)){e.next=6;break}throw new mA(vA.NOT_SUPPORTED,"Your browser does not support set audio encode maxBitrate dynamically.");case 6:return e.next=8,null===(a=this._room)||void 0===a?void 0:a.setAudioEncodeMaxBitrate(cl.STREAM_INDEX_MAIN,t);case 8:return e.next=10,null===(s=this._room)||void 0===s?void 0:s.setAudioEncodeMaxBitrate(cl.STREAM_INDEX_SCREEN,t);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,i,o;HX.print("setPublicStreamVideoPlayer()","publicStreamId: %o, videoPlayerOption: %o",e,t);var a=this._publicStreamVideoPlayer.get(e);if(null===(r=a)||void 0===r||r.destroy(),null!=t&&t.renderDom){a=new qG(this.id,Zd(Zd({},t),{},{userId:e})),this._initPlayerEvents(a,!0),this._publicStreamVideoPlayer.set(e,a);var s=null===(n=this._publicStreamManager)||void 0===n||null===(i=n.remoteStreams)||void 0===i?void 0:i.get(e);null!=s&&s.videoTrack&&(null===(o=this._config)||void 0===o?void 0:o.autoPlayPolicy)!==Tl.PLAY_MANUALLY&&a.playVideo(s.videoTrack,s)}else this._publicStreamVideoPlayer.delete(e)}},{key:"setDummyCaptureImagePath",value:(p=Rm(km().mark((function e(t,r){var n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Yf((function(e,i){_D(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){t===cl.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),e()}catch(r){i(new mA(vA.UNEXPECTED_ERROR,r.message))}},o.onerror=function(){i(new mA(vA.UNEXPECTED_ERROR,"Load image error"))}})));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return p.apply(this,arguments)})},{key:"_updateDummyCaptureImage",value:function(e){var t,r;if(e===cl.STREAM_INDEX_MAIN?(t=this._dummyMainImage,r=this._videoStreamEncodeConfig[0]):(t=this._dummyScreenImage,r=this._screenStreamEncodeConfig[0]),t){var n,i,o=document.createElement("canvas"),a=o.getContext("2d"),s=gN(r.width),c=gN(r.height);if(!a)throw new mA(vA.UNEXPECTED_ERROR,"Not support canvas");!s||!c||t.width<=s&&t.height<=c?(n=t.width,i=t.height):(n=Math.min(s,t.width*c/t.height),i=Math.min(c,t.height*s/t.width)),o.width=n,o.height=i,a.drawImage(t,0,0,t.width,t.height,0,0,n,i);var u=window.setInterval((function(){t&&a.drawImage(t,0,0,t.width,t.height,0,0,n,i)}),200);e===cl.STREAM_INDEX_MAIN?(clearInterval(this._dummyMainTimer),this._dummyMainTimer=u):(clearInterval(this._dummyScreenTimer),this._dummyScreenTimer=u);var d,l,h,v,_=o.captureStream(5).getVideoTracks()[0];if(e===cl.STREAM_INDEX_MAIN){if(this._localImgVideoTrack=_,null!==(d=this._localVideoTrack)&&void 0!==d&&d.dummy)null===(l=this._localVideoTrack)||void 0===l||l.setTrack(this._localImgVideoTrack,this._extensionManager)}else if(this._localImgScreenTrack=_,null!==(h=this._localScreenVideoTrack)&&void 0!==h&&h.dummy)null===(v=this._localScreenVideoTrack)||void 0===v||v.setTrack(this._localImgScreenTrack,this._extensionManager)}}},{key:"_addListenExtensionEvent",value:function(e){var t=this;e.on("re-capture-audio",(function(){t._localAudioTrack&&t.stopAudioCapture().then((function(){t.startAudioCapture()}))})),e.on("re-capture-video",(function(){t._localVideoTrack&&!t._localVideoTrack.dummy&&t.stopVideoCapture().then((function(){t.startVideoCapture()}))})),e.on("reset-video-effect",function(){var e=Rm(km().mark((function e(r,n){var i,o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t._localVideoTrack||t._localVideoTrack.dummy){e.next=17;break}return t._localVideoTrack&&t._removeLocalTrackEvents(t._localVideoTrack),e.prev=2,e.next=5,t._localVideoTrack.generatePreProcessingTrack(t._extensionManager);case 5:e.next=10;break;case 7:e.prev=7,e.t0=e.catch(2),n(e.t0);case 10:if(t._initLocalTrackEvents(t._localVideoTrack),null!==(i=t._videoPlayer)&&void 0!==i&&i.played&&(t._videoPlayer.stop(),t._videoPlayer.playVideo(t._localVideoTrack),t._videoPlayer.mirror(!!t._mirrorType)),t.safeEmit(Ml.onLocalStreamTrackChangedByExtension,{streamIndex:cl.STREAM_INDEX_MAIN,type:"video"}),r(),null===(o=t._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.pubVideo){e.next=17;break}return e.next=17,t._updatePublish();case 17:r();case 18:case"end":return e.stop()}}),e,null,[[2,7]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"registerExtension",value:(_=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.monitor=this.monitor,e.prev=1,e.next=4,t.isSupported();case 4:if(e.sent){e.next=7;break}throw new Error("This extension is not supported.");case 7:e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(1),new Error("This extension is not supported.");case 12:return e.next=14,t.init({videoCaptureConfig:this._videoStreamConstraints});case 14:this._extensionManager.register(t),this._addListenExtensionEvent(t);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return _.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(Mm(FX.getDefaultValue()))}},{key:"_updatePublish",value:(v=Rm(km().mark((function e(){var t,r,n,i=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},HX.info("_updatePublish()","config: %o",t),r={mediaType:void 0,invokeByJoinRoom:!1,pubState:Lj.PUB},t=Zd(Zd({},r),t),this._visibility){e.next=6;break}throw new mA(vA.NO_PUBLISH_PERMISSION,"no publish permission");case 6:return e.next=8,this._pubLock.lock();case 8:if(n=e.sent,this._room&&this._room.connectionState===vG.CONNECTED){e.next=12;break}return n(),e.abrupt("return");case 12:return e.prev=12,e.next=15,this._room.publish(this._videoStreamEncodeConfig,this._enableSimulcast,this._localVideoTrack,this._localAudioTrack,t.mediaType,t.pubState,t.invokeByJoinRoom);case 15:this._videoPlayer&&this._room.localStream&&(this._room.localStream.videoDom=this._videoPlayer.domElement),e.next=25;break;case 18:if(e.prev=18,e.t0=e.catch(12),!(e.t0 instanceof mA)){e.next=24;break}throw e.t0;case 24:throw new mA(vA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 25:return e.prev=25,n(),e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[12,18,25,28]])}))),function(){return v.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(h=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HX.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),_D(t,"filePath"),vD(r,"indicationInterval"),e.next=5,this._audioDeviceManager.startAudioPlaybackDeviceTest(t,r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){HX.info("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(l=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HX.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),vD(t,"indicationInterval"),e.next=4,this._audioDeviceManager.startAudioDeviceRecordTest(t,r,this._localAudioVolume);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){HX.info("stopAudioDeviceRecordAndPlayTest()"),this._audioDeviceManager.stopAudioDeviceRecordAndPlayTest()}},{key:"stopAudioDevicePlayTest",value:function(){HX.info("stopAudioDevicePlayTest()"),this._audioDeviceManager.stopAudioDevicePlayTest()}},{key:"setRemoteUserPriority",value:function(e,t){var r;HX.print("setRemoteUserPriority()","userId: %o, priority: %o",e,t);try{TD(e),pD(t,"priority",[gl.HIGH,gl.MEDIUM,gl.LOW])}catch(n){return console.warn(n),!1}return this._ctx.userPriority.set(e,t),null===(r=this._room)||void 0===r||r.updateRemoteUserPriority(e),!0}},{key:"takeLocalSnapshot",value:(d=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.print("takeLocalSnapshot()","streamIndex: %o",t),pD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),r=t===cl.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new mA(vA.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return n=t===cl.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer,e.abrupt("return",NX(r.getTrack("preprocessing"),(null==n?void 0:n.mirrorType)===hl.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(u=Rm(km().mark((function e(t,r){var n,i,o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HX.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),_D(t,"id"),pD(r,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),c=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=yE(i).call(i,(function(e){return e.isScreen===(r===cl.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.videoTrack)||(null===(a=this._publicStreamManager)||void 0===a||null===(s=a.remoteStreams.get(t))||void 0===s?void 0:s.videoTrack)){e.next=6;break}throw new mA(vA.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",NX(c.getTrack(),!1,r===cl.STREAM_INDEX_MAIN?this._remoteVideoPlayer.get(t):this._remoteScreenPlayer.get(t)));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){HX.info("setSubscribeFallbackOption()","option: %o",e);try{pD(e,"option",[ml.DISABLE,ml.VIDEO_STREAM_LOW,ml.AUDIO_ONLY])}catch(t){return console.warn(t),!1}return!this._room&&(this._ctx.subscribeFallbackOption=e,!0)}},{key:"getLocalStreamTrack",value:function(e,t){var r,n,i,o=this;if(e===cl.STREAM_INDEX_MAIN?(n="video"===t?this.localVideoTrack:this.localAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localStream}):(n="video"===t?this.localScreenVideoTrack:this.localScreenAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localScreenStream}),n){var a=n instanceof aV&&n.mixedAudioTrack?n.mixedAudioTrack:n.getTrack("preprocessing");if(a){var s=i();return this._reportMsTrackEvent(a,(null==s||null===(r=s.stream)||void 0===r?void 0:r.id)||"local"),a}}}},{key:"getRemoteStreamTrack",value:function(e,t,r){var n,i,o=(null===(n=this._room)||void 0===n?void 0:n.remoteStreams.get(e))||[];if(o&&o.length){var a,s,c,u,d;if(t===cl.STREAM_INDEX_MAIN)a=yE(o).call(o,(function(e){return!e.isScreen})),i="video"===r?null===(s=a)||void 0===s?void 0:s.videoTrack:null===(c=a)||void 0===c?void 0:c.audioTrack;else a=yE(o).call(o,(function(e){return e.isScreen})),i="video"===r?null===(u=a)||void 0===u?void 0:u.videoTrack:null===(d=a)||void 0===d?void 0:d.audioTrack;if(i){var l=i.getTrack();if(l&&a){var h=a.streamId;return this._reportMsTrackEvent(l,h),l}}}}},{key:"getPublicStreamTrack",value:function(e,t){if(this._publicStreamManager&&this._publicStreamManager.remoteStreams){var r=this._publicStreamManager.remoteStreams.get(e);if(r){var n="video"===t?r.videoTrack:r.audioTrack;if(n){var i=n.getTrack();if(i){var o=r.streamId;return this._reportMsTrackEvent(i,o),i}}}}}},{key:"setRemoteStreamRenderSync",value:function(e){return!this._room&&(this._ctx.avSync=!!e,!0)}},{key:"setCaptureVolume",value:function(e,t){var r,n,i;(pD(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),t=DD(t,"volume",0,400),e===cl.STREAM_INDEX_SCREEN)?(null===(r=this._localScreenAudioTrack)||void 0===r||r.setVolume(t),this._localScreenAudioVolume=t):(null===(n=this._localAudioTrack)||void 0===n||n.setVolume(t),null===(i=this._audioDeviceManager.audioTrack)||void 0===i||i.setVolume(t),this._localAudioVolume=t)}},{key:"setPlaybackVolume",value:function(e,t,r){var n,i,o;if(TD(e),pD(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),r=DD(r,"volume",0,400),null!==(n=this._room)&&void 0!==n&&n.multiChatMode)mN("setPlaybackVolume is not supported in Conference mode");else{var a=t===cl.STREAM_INDEX_SCREEN;a?this._remoteScreenAudioVolume.set(e,r):this._remoteAudioVolume.set(e,r),null===(i=this._room)||void 0===i||null===(o=i.remoteStreams.get(e))||void 0===o||o.forEach((function(e){var t;e.isScreen===a&&(null===(t=e.audioTrack)||void 0===t||t.setVolume(r))}))}}},{key:"setPublicStreamVolume",value:function(e,t){var r,n,i;_D(e,"publicStreamId"),t=DD(t,"volume",0,400),this._publicAudioVolume.set(e,t),null===(r=this._publicStreamManager)||void 0===r||null===(n=r.remoteStreams.get(e))||void 0===n||null===(i=n.audioTrack)||void 0===i||i.setVolume(t)}},{key:"startForwardStreamToRooms",value:(c=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){ED(e.roomId)})),this._assertNotInRoom(),e.next=4,this._room.startForwardStream2Rooms(t);case 4:return r=e.sent,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"updateForwardStreamToRooms",value:(s=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){ED(e.roomId)})),this._assertNotInRoom(),e.next=4,this._room.updateForwardStream2Rooms(t);case 4:return r=e.sent,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"stopForwardStreamToRooms",value:(a=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.stopForwardStream2Rooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"pauseForwardStreamToAllRooms",value:(o=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.pauseForwardStream2AllRooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"resumeForwardStreamToAllRooms",value:(i=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.resumeForwardStream2AllRooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_reportMsTrackEvent",value:function(e,t){var r=this;if(!e.hookStop){e.hookStop=!0;var n=e.stop;e.stop=function(){jO(r.id,"stop",t,0,t),n.call(e)}}}},{key:"_updateScreenPublish",value:(n=Rm(km().mark((function e(){var t,r,n,i=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:{},HX.info("_updateScreenPublish()"),r={mediaType:void 0,pubState:Lj.PUB},t=Zd(Zd({},r),t),e.next=6,this._pubLock.lock();case 6:if(n=e.sent,this._room&&this._room.connectionState===vG.CONNECTED){e.next=10;break}return n(),e.abrupt("return");case 10:return e.prev=10,e.next=13,this._room.publishScreen(this._screenStreamEncodeConfig,this._localScreenVideoTrack,this._localScreenAudioTrack,t.mediaType,t.pubState);case 13:this._screenPlayer&&this._room.localScreenStream&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),e.next=23;break;case 16:if(e.prev=16,e.t0=e.catch(10),!(e.t0 instanceof mA)){e.next=22;break}throw e.t0;case 22:throw new mA(vA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 23:return e.prev=23,n(),e.finish(23);case 26:case"end":return e.stop()}}),e,this,[[10,16,23,26]])}))),function(){return n.apply(this,arguments)})},{key:"_updateAudioPlayerState",value:function(e){HX.info("_updateAudioPlayerState()");var t,r=e.userId,n=e.isScreen,i=n?this._remoteScreenAudioPlayer:this._remoteAudioPlayer,o=i.get(r);if(e.audioTrack&&e.attributes.audiostream&&e.subAudio){var a,s,c,u=n?null!==(a=this._remoteScreenAudioVolume.get(r))&&void 0!==a?a:100:null!==(s=this._remoteAudioVolume.get(r))&&void 0!==s?s:100;if(e.audioTrack.setVolume(u),!o){var d;o=new YG(this.id,r,{muted:(null===(d=this._config)||void 0===d?void 0:d.autoPlayPolicy)===Tl.VIDEO_ONLY,isScreen:n}),this._initPlayerEvents(o,!1,n?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN),i.set(r,o);var l=this._audioDeviceManager.getSinkId();l&&o.setPlaybackDevice(l)}(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)!==Tl.PLAY_MANUALLY&&o.playAudio(e.audioTrack),TN&&xN&&(t=this._remoteAudioPlayer,VX&&clearTimeout(VX),VX=setTimeout((function(){var e,r=$k(t);try{for(r.s();!(e=r.n()).done;){var n=eI(e.value,2),i=n[0],o=n[1];null!=i&&hA(i).call(i,"mux")&&o.pause()}}catch(l){r.e(l)}finally{r.f()}var a,s=$k(t);try{for(s.s();!(a=s.n()).done;){var c=eI(a.value,2),u=c[0],d=c[1];null!=u&&hA(u).call(u,"mux")&&d.manuallyPlay()}}catch(l){s.e(l)}finally{s.f()}}),2e3))}else{var h;null===(h=o)||void 0===h||h.stop()}}},{key:"_updateVideoPlayerState",value:function(e){var t;HX.info("_updateVideoPlayerState()");var r,n,i=e.userId;if(r=e.isScreen?this._remoteScreenPlayer.get(i):this._remoteVideoPlayer.get(i),e.videoTrack)r&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==Tl.PLAY_MANUALLY&&r.playVideo(e.videoTrack,e);else if(null!==(t=r)&&void 0!==t&&t.played){var o;null===(o=r)||void 0===o||o.stop()}}},{key:"_onAddStream",value:(r=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=t.stream).videoDom=null===(r=this._remoteVideoPlayer.get(n.userId))||void 0===r?void 0:r.domElement,i=null==n?void 0:n.attributes,o=i.localaudio,a=i.audiostream,s=i.localvideo,c=i.videostream,u=cV.NONE,a&&(u|=ul.AUDIO),c&&(u|=ul.VIDEO),!u){e.next=12;break}return e.next=9,new Yf((function(e){return setTimeout(e)}));case 9:null!=n&&n.isScreen?this.safeEmit(Ml.onUserPublishScreen,{userId:n.userId,mediaType:u}):(this.safeEmit(Ml.onUserPublishStream,{userId:n.userId,mediaType:u,videoStreamDescriptions:null==n||null===(d=n.attributes)||void 0===d?void 0:d.videoDescriptions}),this._handleAutoSubscribe(n,!0)),this.safeEmit("onAddStream",{userId:n.userId,mediaType:u,isScreen:!(null==n||!n.isScreen)}),null!=n&&n.isScreen||(o&&this.safeEmit(Ml.onUserStartAudioCapture,{userId:n.userId}),s&&this.safeEmit(Ml.onUserStartVideoCapture,{userId:n.userId}));case 12:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_handleAutoSubscribe",value:function(e,t){var r,n,i=cV.NONE;if(null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoSubscribeAudio&&(i|=ul.AUDIO),null!==(n=this._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo&&(i|=ul.VIDEO),i){var o,a;if(t&&dN(i))null===(o=e.observer)||void 0===o||o.setAutoSubscribeAudio(!0);if(t&&lN(i))null===(a=e.observer)||void 0===a||a.setAutoSubscribeVideo(!0);this._subscribe(!1,e.userId,i)}}},{key:"_onRemoveStream",value:function(e){var t,r=this,n=e.stream,i=null!==(t=XX[e.reason])&&void 0!==t?t:dl.STREAM_REMOVE_REASON_OTHER,o=n.isScreen?Ml.onUserUnpublishScreen:Ml.onUserUnpublishStream,a=cV.NONE;n.attributes.audiostream&&(a|=ul.AUDIO),n.attributes.videostream&&(a|=ul.VIDEO),a!==cV.NONE&&(this.safeEmit(o,{userId:n.userId,mediaType:a,reason:i}),this.safeEmit("onRemoveStream",{userId:n.userId,isScreen:n.isScreen})),"function"==typeof e.callback&&e.callback(),this._getRemotePlayer(n.userId,n.isScreen).forEach((function(e){n.isScreen?(r._remoteScreenPlayer.delete(n.userId),r._remoteScreenAudioPlayer.delete(n.userId)):(r._remoteAudioPlayer.delete(n.userId),r._remoteVideoPlayer.delete(n.userId)),null==e||e.destroy()}))}},{key:"_onUserConnection",value:function(e){var t=this;setTimeout((function(){return t.safeEmit(Ml.onUserJoined,e)}))}},{key:"_onUserLeave",value:function(e){var t=this,r=e.userInfo;this._getRemotePlayer(r.userId,!0).forEach((function(e){t._remoteScreenAudioPlayer.delete(r.userId),t._remoteScreenPlayer.delete(r.userId),null==e||e.destroy()})),this._getRemotePlayer(r.userId,!1).forEach((function(e){t._remoteAudioPlayer.delete(r.userId),t._remoteVideoPlayer.delete(r.userId),null==e||e.destroy()})),this.safeEmit(Ml.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(Ml.onError,e),null===(t=this._room)||void 0===t||t.destroy(),this._room=void 0}},{key:"_onNetworkQuality",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this.safeEmit.apply(this,Om(e=[Ml.onNetworkQuality]).call(e,r))}},{key:"_onConnectionStateChange",value:function(e){if(void 0!==this._startCloudProxyTimestamp&&this._ctx.useCloudProxy&&e.state===ll.CONNECTION_STATE_CONNECTED&&this.safeEmit(Ml.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),this.safeEmit(Ml.onConnectionStateChanged,e),e.state===ll.CONNECTION_STATE_RECONNECTING){var t,r=$k(this._remoteAudioPlayer);try{for(r.s();!(t=r.n()).done;){var n=eI(t.value,2),i=n[0],o=n[1];null!=i&&hA(i).call(i,"mux")&&o.stop()}}catch(a){r.e(a)}finally{r.f()}}}},{key:"_getRemotePlayer",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ul.AUDIO_AND_VIDEO,n=(t?this._remoteScreenAudioPlayer:this._remoteAudioPlayer).get(e),i=(t?this._remoteScreenPlayer:this._remoteVideoPlayer).get(e),o=[];return r&ul.AUDIO&&o.push(n),r&ul.VIDEO&&o.push(i),o}},{key:"_stopAudioPropertiesReport",value:function(){null!==this._audioPropertiesReportTimer&&(clearInterval(this._audioPropertiesReportTimer),this._audioPropertiesReportTimer=null)}},{key:"_onResubscribe",value:function(e){e.stream&&(this._getRemotePlayer(e.stream.userId,e.stream.isScreen).forEach((function(e){return null==e?void 0:e.stop()})),this._updateAudioPlayerState(e.stream),this._updateVideoPlayerState(e.stream))}},{key:"_onSubscribePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onRemovePushTrack",value:function(e){var t=this;if(e.stream){this._updateAudioPlayerState(e.stream);var r=e.stream;this._getRemotePlayer(r.userId,r.isScreen,e.mediaType).forEach((function(n){e.mediaType&ul.AUDIO&&(r.isScreen?t._remoteScreenAudioPlayer.delete(r.userId):t._remoteAudioPlayer.delete(r.userId)),r.isScreen?e.mediaType&ul.VIDEO&&t._remoteScreenPlayer.delete(r.userId):e.mediaType&ul.VIDEO&&t._remoteVideoPlayer.delete(r.userId),null==n||n.destroy()}))}}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(Ml.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(Ml.onAudioDeviceStateChanged,e)}},{key:"_onUserPublishStateChange",value:function(e){var t,r=this,n=e.userId,i=e.isScreen,o=e.mediaType,a=e.pubState,s=e.remoteStream,c={userId:n,mediaType:o};(o&ul.AUDIO&&setTimeout((function(){r._updateAudioPlayerState(s)})),i)?a===Lj.PUB?this.safeEmit(Ml.onUserPublishScreen,c):this.safeEmit(Ml.onUserUnpublishScreen,Zd(Zd({},c),{},{reason:dl.STREAM_REMOVE_REASON_UNPUBLISH})):a===Lj.PUB?(c.videoStreamDescriptions=null==s||null===(t=s.attributes)||void 0===t?void 0:t.videoDescriptions,this.safeEmit(Ml.onUserPublishStream,c),this._handleAutoSubscribe(s,!0)):this.safeEmit(Ml.onUserUnpublishStream,Zd(Zd({},c),{},{reason:dl.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(Ml.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(Ml.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Ml.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Ml.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(Ml.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(Ml.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(Ml.onTokenWillExpire)}},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(Ml.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Ml.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Ml.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(Ml.onError,{errorCode:vA.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(Ml.onError,{errorCode:vA.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(Ml.onServerParamsSetResult,null==e?void 0:e.code)}))}},{key:"waitForNewToken",get:function(){return!!this._tempRoomInfo}},{key:"localAudioTrack",get:function(){return this._localAudioTrack}},{key:"localVideoTrack",get:function(){return this._localVideoTrack}},{key:"localScreenAudioTrack",get:function(){return this._localScreenAudioTrack}},{key:"localScreenVideoTrack",get:function(){return this._localScreenVideoTrack}},{key:"remoteStreams",get:function(){var e,t,r=[];null!==(e=this._room)&&void 0!==e&&e.remoteStreams&&(null===(t=this._room)||void 0===t||t.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){r.push({userId:e.userId,isScreen:e.isScreen,hasVideo:e.hasVideo,hasAudio:e.hasAudio,videoStreamDescriptions:e.attributes.videoDescriptions})}))})));return r}},{key:"iceState",get:function(){var e,t,r,n;return null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient)||void 0===t||null===(r=t.handler)||void 0===r||null===(n=r._peerConnection)||void 0===n?void 0:n.iceConnectionState}},{key:"remoteUsers",get:function(){var e,t,r=[];null!==(e=this._room)&&void 0!==e&&e.remoteUsers&&(null===(t=this._room)||void 0===t||t.remoteUsers.forEach((function(e){r.push({userId:e.userId})})));return r}},{key:"multiChatMode",get:function(){var e,t;return!(null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient)||void 0===t||!t.roomAttributes.multiChatMode)}},{key:"_handleAudioDeviceManager",value:function(){var e=this;this._audioDeviceManager.on("onAudioPlaybackDeviceTestVolume",(function(t){e.safeEmit(Ml.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||this._room.connectionState!==vG.CONNECTED)throw new mA(vA.NOT_CONNECTED_YET,"server not connected")}},{key:"_checkMediaType",value:function(e){pD(e,"mediaType",[ul.AUDIO,ul.VIDEO,ul.AUDIO_AND_VIDEO])}},{key:"_getUserId",value:function(){var e,t;return(null===(e=this._room)||void 0===e||null===(t=e.roomInfo)||void 0===t?void 0:t.userInfo.userId)||"local_user"}},{key:"_switchTrack",value:(t=Rm(km().mark((function e(t){var r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._initLocalTrackEvents(t),this._localVideoTrack=t,null!==(r=this._videoPlayer)&&void 0!==r&&r.played&&(this._videoPlayer.stop(),this._videoPlayer.playVideo(t),this._videoPlayer.mirror(!!this._mirrorType)),null===(n=this._room)||void 0===n||null===(i=n.localStream)||void 0===i||!i.pubVideo){e.next=6;break}return e.next=6,this._updatePublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_shouldUpdateAudioConf",value:function(e){var t,r,n,i=(null===(t=this._room)||void 0===t?void 0:t.hasPublished)||(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n?void 0:n.pubAudio)||this._localAudioTrack&&this._localAudioTrack.sourceType===TU.INTERNAL;if(i){var o="engine.".concat(e," should be called before publishing or capturing.");console.warn("[RTC WebSDK]: ".concat(o)),jO(this.id,e,o)}return!i}},{key:"_getServerConfig",value:function(){var e=this;HO({engineId:this.id,appId:this.appId,sdkVersion:cD("VERSION"),requestDomains:cD("CONFIG_REQUEST_DOMAINS"),keys:["rts_report","web_join_room"]}).then((function(t){t.rts_report&&wO.setConfig(t.rts_report),e._ctx.joinRoomConfig.setServerConfig(t.web_join_room)}))}}]),Te}(UD);GX([FO()],zX.prototype,"updateToken",1),GX([FO()],zX.prototype,"setVideoCaptureDevice",1),GX([FO()],zX.prototype,"setAudioCaptureDevice",1),GX([function(e,t,r){if("function"==typeof r.value){var n=r.value;r.value=function(){for(var e,t=VO(this.id),r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return null==t||t.set({room_id:i[1],user_id:null===(e=i[2])||void 0===e?void 0:e.userId}),n.apply(this,i)}}},FO()],zX.prototype,"connect",1),GX([FO()],zX.prototype,"joinRoom",1),GX([FO()],zX.prototype,"leaveRoom",1),GX([FO()],zX.prototype,"destroy",1),GX([FO()],zX.prototype,"publishStream",1),GX([FO()],zX.prototype,"unpublishStream",1),GX([FO()],zX.prototype,"publishScreen",1),GX([FO()],zX.prototype,"unpublishScreen",1),GX([FO()],zX.prototype,"subscribeStream",1),GX([FO()],zX.prototype,"unsubscribeStream",1),GX([FO()],zX.prototype,"subscribeScreen",1),GX([FO()],zX.prototype,"unsubscribeScreen",1),GX([FO()],zX.prototype,"setRemoteVideoConfig",1),GX([FO()],zX.prototype,"startVideoCapture",1),GX([FO()],zX.prototype,"stopVideoCapture",1),GX([FO()],zX.prototype,"startAudioCapture",1),GX([FO()],zX.prototype,"stopAudioCapture",1),GX([FO()],zX.prototype,"getAudioMixingManager",1),GX([FO()],zX.prototype,"startScreenCapture",1),GX([FO()],zX.prototype,"stopScreenCapture",1),GX([FO()],zX.prototype,"setLocalVideoPlayer",1),GX([FO()],zX.prototype,"startLiveTranscoding",1),GX([FO()],zX.prototype,"updateLiveTranscoding",1),GX([FO()],zX.prototype,"stopLiveTranscoding",1),GX([FO()],zX.prototype,"startSubtitle",1),GX([FO()],zX.prototype,"stopSubtitle",1),GX([FO()],zX.prototype,"setBusinessId",1),GX([FO()],zX.prototype,"setUserVisibility",1),GX([FO()],zX.prototype,"setRemoteVideoPlayer",1),GX([FO()],zX.prototype,"setLocalVideoMirrorType",1),GX([FO()],zX.prototype,"setAudioPlaybackDevice",1),GX([FO()],zX.prototype,"play",1),GX([FO()],zX.prototype,"pauseAllSubscribedStream",1),GX([FO()],zX.prototype,"resumeAllSubscribedStream",1),GX([FO()],zX.prototype,"sendUserMessage",1),GX([FO()],zX.prototype,"sendUserBinaryMessage",1),GX([FO()],zX.prototype,"sendRoomMessage",1),GX([FO()],zX.prototype,"sendRoomBinaryMessage",1),GX([FO()],zX.prototype,"setAudioCaptureConfig",1),GX([fN("4.51"),FO()],zX.prototype,"setVideoCaptureConfig",1),GX([FO()],zX.prototype,"enableSimulcastMode",1),GX([FO()],zX.prototype,"setVideoEncoderConfig",1),GX([FO()],zX.prototype,"setScreenEncoderConfig",1),GX([FO()],zX.prototype,"sendSEIMessage",1),GX([fN("4.42"),FO()],zX.prototype,"setAudioVolumeIndicationInterval",1),GX([FO()],zX.prototype,"enableAudioPropertiesReport",1),GX([FO()],zX.prototype,"setVideoSourceType",1),GX([FO()],zX.prototype,"setExternalVideoTrack",1),GX([FO()],zX.prototype,"setAudioSourceType",1),GX([FO()],zX.prototype,"setExternalAudioTrack",1),GX([FO()],zX.prototype,"login",1),GX([FO()],zX.prototype,"logout",1),GX([FO()],zX.prototype,"updateLoginToken",1),GX([FO()],zX.prototype,"getPeerOnlineStatus",1),GX([FO()],zX.prototype,"sendUserMessageOutsideRoom",1),GX([FO()],zX.prototype,"sendUserBinaryMessageOutsideRoom",1),GX([FO()],zX.prototype,"setServerParams",1),GX([FO()],zX.prototype,"sendServerMessage",1),GX([FO()],zX.prototype,"sendServerBinaryMessage",1),GX([FO()],zX.prototype,"startCloudProxy",1),GX([FO()],zX.prototype,"stopCloudProxy",1),GX([FO()],zX.prototype,"startPushPublicStream",1),GX([FO()],zX.prototype,"updatePublicStreamParam",1),GX([FO()],zX.prototype,"stopPushPublicStream",1),GX([FO("streamId")],zX.prototype,"startPlayPublicStream",1),GX([FO("streamId")],zX.prototype,"stopPlayPublicStream",1),GX([FO()],zX.prototype,"setAudioProfile",1),GX([FO()],zX.prototype,"setAudioEncodeMaxBitrate",1),GX([FO()],zX.prototype,"setPublicStreamVideoPlayer",1),GX([FO()],zX.prototype,"setDummyCaptureImagePath",1),GX([FO()],zX.prototype,"registerExtension",1),GX([FO()],zX.prototype,"startAudioPlaybackDeviceTest",1),GX([FO()],zX.prototype,"stopAudioPlaybackDeviceTest",1),GX([FO()],zX.prototype,"startAudioDeviceRecordTest",1),GX([FO()],zX.prototype,"stopAudioDeviceRecordAndPlayTest",1),GX([FO()],zX.prototype,"stopAudioDevicePlayTest",1),GX([FO()],zX.prototype,"setRemoteUserPriority",1),GX([FO()],zX.prototype,"takeLocalSnapshot",1),GX([FO()],zX.prototype,"takeRemoteSnapshot",1),GX([FO()],zX.prototype,"setSubscribeFallbackOption",1),GX([FO()],zX.prototype,"getLocalStreamTrack",1),GX([FO()],zX.prototype,"getRemoteStreamTrack",1),GX([FO()],zX.prototype,"getPublicStreamTrack",1),GX([FO()],zX.prototype,"setRemoteStreamRenderSync",1),GX([FO()],zX.prototype,"startForwardStreamToRooms",1),GX([FO()],zX.prototype,"updateForwardStreamToRooms",1),GX([FO()],zX.prototype,"stopForwardStreamToRooms",1),GX([FO()],zX.prototype,"pauseForwardStreamToAllRooms",1),GX([FO()],zX.prototype,"resumeForwardStreamToAllRooms",1);var KX,XX={"client unpublished":dl.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":dl.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":dl.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":dl.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":dl.STREAM_REMOVE_REASON_REPUBLISH},WX=new Mw("VERTC",0);Ew.storeKey=Om(KX="".concat(Date.now(),"-")).call(KX,$N.getDeviceId()),xO({rtc_sdk_version:aD.VERSION,device_id:$N.getDeviceId(),log_cache_key:Ew.storeKey}),OO(aD.LOG_SERVER_URL);var qX=1,YX=function(e,t){WX.info("createEngine","Invoke VERTC.createEngine"),_D(e,"appId");var r=(qX++).toString();return function(e,t){var r=new kO(e);r.set(Zd(Zd({},t),{},{engine_session_id:fw()})),r.report("sdk_init_engine",{start:Date.now(),type:"begin"}),UO.set(e,r)}(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new zX(e,r,t)},JX=function(e){if(WX.info("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof zX))throw new mA(vA.INVALID_ENGINE,"Invalid engine object");var t;e.destroy(),(t=e.monitor).report("sdk_init_engine",{start:Date.now(),type:"end"}),UO.delete(t.id)},QX=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",hU.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ZX=function(){var e=Rm(km().mark((function e(){var t,r,n,i,o,a,s=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:{video:!0,audio:!0},r=t.video,n=t.audio,i={video:!1,audio:!1},!r){e.next=14;break}return e.prev=4,e.next=7,hU.getPermissions({video:!0,force:!0});case 7:o=e.sent,i.video=o.video,o.video||(i.videoExceptionError=o.reason),e.next=14;break;case 12:e.prev=12,e.t0=e.catch(4);case 14:if(!n){e.next=25;break}return e.prev=15,e.next=18,hU.getPermissions({audio:!0,force:!0});case 18:a=e.sent,i.audio=a.audio,a.audio||(i.audioExceptionError=a.reason),e.next=25;break;case 23:e.prev=23,e.t1=e.catch(15);case 25:return e.abrupt("return",i);case 26:case"end":return e.stop()}}),e,null,[[4,12],[15,23]])})));return function(){return e.apply(this,arguments)}}(),$X=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",hU.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),eW=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",hU.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),tW=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",hU.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),rW=function(){return aD.VERSION},nW=function(){return DO("isSupported",0,""),wM()},iW=function(){return DO("getSupportedCodecs",0,""),OM()},oW=function(e){var t=e.logLevel,r=e.LogfileSize;t&&(Ew.logLevel=t),r&&(Ew.LogfileSize=r)},aW=function(e){Ew.download(e)};function sW(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Mm(jm(t).call(t,(function(e){return e instanceof zX?"[ENGINE]":e})))}function cW(e,t){return function(){DO(t,0,sW.apply(void 0,arguments));var r=e.apply(void 0,arguments);return"function"==typeof(null==r?void 0:r.then)?r.then((function(e){return PO(t,0,sW(e)),e})).catch((function(e){throw PO(t,e.code,e.message),e})):(PO(t,0,sW(r)),r)}}return Zd(Zd(Zd(Zd({},new(Ul((function e(){Vl(this,e),Jd(this,"getSdkVersion",cW(rW,"getSdkVersion")),Jd(this,"createEngine",cW(YX,"createEngine")),Jd(this,"destroyEngine",cW(JX,"destroyEngine")),Jd(this,"enumerateDevices",cW(QX,"enumerateDevices")),Jd(this,"enableDevices",cW(ZX,"enableDevices")),Jd(this,"enumerateAudioCaptureDevices",cW($X,"enumerateAudioCaptureDevices")),Jd(this,"enumerateVideoCaptureDevices",cW(eW,"enumerateVideoCaptureDevices")),Jd(this,"enumerateAudioPlaybackDevices",cW(tW,"enumerateAudioPlaybackDevices")),Jd(this,"getParameter",cD),Jd(this,"setParameter",sD),Jd(this,"isSupported",cW(nW,"isSupported")),Jd(this,"getSupportedCodecs",cW(iW,"getSupportedCodecs")),Jd(this,"events",Ml),Jd(this,"ErrorCode",vA),Jd(this,"platform","BytePlus"),Jd(this,"commitInfo","release_455<39e3dc8*>"),Jd(this,"downloadLog",cW(aW,"downloadLog")),Jd(this,"setLogConfig",cW(oW,"setLogConfig"))})))),xl),Pl),{},{events:Ml})}));
|
|
6
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).BytePlusRTC=t()}(this,(function(){"use strict";function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e){return e&&e.Math==Math&&e},n=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof t&&t)||function(){return this}()||Function("return this")(),i=function(e){try{return!!e()}catch(t){return!0}},o=!i((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),a=o,s=Function.prototype,c=s.apply,u=s.call,d="object"==typeof Reflect&&Reflect.apply||(a?u.bind(c):function(){return u.apply(c,arguments)}),l=o,h=Function.prototype,p=h.call,v=l&&h.bind.bind(p,p),f=l?v:function(e){return function(){return p.apply(e,arguments)}},_=f,m=_({}.toString),y=_("".slice),g=function(e){return y(m(e),8,-1)},S=g,b=f,E=function(e){if("Function"===S(e))return b(e)},k="object"==typeof document&&document.all,T={all:k,IS_HTMLDDA:void 0===k&&void 0!==k},I=T.all,R=T.IS_HTMLDDA?function(e){return"function"==typeof e||e===I}:function(e){return"function"==typeof e},A={},w=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),C=o,x=Function.prototype.call,O=C?x.bind(x):function(){return x.apply(x,arguments)},D={},N={}.propertyIsEnumerable,M=Object.getOwnPropertyDescriptor,P=M&&!N.call({1:2},1);D.f=P?function(e){var t=M(this,e);return!!t&&t.enumerable}:N;var L,U,V=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},F=i,B=g,j=Object,G=E("".split),H=F((function(){return!j("z").propertyIsEnumerable(0)}))?function(e){return"String"==B(e)?G(e,""):j(e)}:j,z=function(e){return null==e},K=z,X=TypeError,W=function(e){if(K(e))throw X("Can't call method on "+e);return e},q=H,Y=W,J=function(e){return q(Y(e))},Q=R,Z=T.all,$=T.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:Q(e)||e===Z}:function(e){return"object"==typeof e?null!==e:Q(e)},ee={},te=ee,re=n,ne=R,ie=function(e){return ne(e)?e:void 0},oe=function(e,t){return arguments.length<2?ie(te[e])||ie(re[e]):te[e]&&te[e][t]||re[e]&&re[e][t]},ae=E({}.isPrototypeOf),se=oe("navigator","userAgent")||"",ce=n,ue=se,de=ce.process,le=ce.Deno,he=de&&de.versions||le&&le.version,pe=he&&he.v8;pe&&(U=(L=pe.split("."))[0]>0&&L[0]<4?1:+(L[0]+L[1])),!U&&ue&&(!(L=ue.match(/Edge\/(\d+)/))||L[1]>=74)&&(L=ue.match(/Chrome\/(\d+)/))&&(U=+L[1]);var ve=U,fe=ve,_e=i,me=!!Object.getOwnPropertySymbols&&!_e((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&fe&&fe<41})),ye=me&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ge=oe,Se=R,be=ae,Ee=Object,ke=ye?function(e){return"symbol"==typeof e}:function(e){var t=ge("Symbol");return Se(t)&&be(t.prototype,Ee(e))},Te=String,Ie=function(e){try{return Te(e)}catch(t){return"Object"}},Re=R,Ae=Ie,we=TypeError,Ce=function(e){if(Re(e))return e;throw we(Ae(e)+" is not a function")},xe=Ce,Oe=z,De=function(e,t){var r=e[t];return Oe(r)?void 0:xe(r)},Ne=O,Me=R,Pe=$,Le=TypeError,Ue={exports:{}},Ve=n,Fe=Object.defineProperty,Be=function(e,t){try{Fe(Ve,e,{value:t,configurable:!0,writable:!0})}catch(r){Ve[e]=t}return t},je="__core-js_shared__",Ge=n[je]||Be(je,{}),He=Ge;(Ue.exports=function(e,t){return He[e]||(He[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.0",mode:"pure",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.0/LICENSE",source:"https://github.com/zloirock/core-js"});var ze=W,Ke=Object,Xe=function(e){return Ke(ze(e))},We=Xe,qe=E({}.hasOwnProperty),Ye=Object.hasOwn||function(e,t){return qe(We(e),t)},Je=E,Qe=0,Ze=Math.random(),$e=Je(1..toString),et=function(e){return"Symbol("+(void 0===e?"":e)+")_"+$e(++Qe+Ze,36)},tt=n,rt=Ue.exports,nt=Ye,it=et,ot=me,at=ye,st=rt("wks"),ct=tt.Symbol,ut=ct&&ct.for,dt=at?ct:ct&&ct.withoutSetter||it,lt=function(e){if(!nt(st,e)||!ot&&"string"!=typeof st[e]){var t="Symbol."+e;ot&&nt(ct,e)?st[e]=ct[e]:st[e]=at&&ut?ut(t):dt(t)}return st[e]},ht=O,pt=$,vt=ke,ft=De,_t=function(e,t){var r,n;if("string"===t&&Me(r=e.toString)&&!Pe(n=Ne(r,e)))return n;if(Me(r=e.valueOf)&&!Pe(n=Ne(r,e)))return n;if("string"!==t&&Me(r=e.toString)&&!Pe(n=Ne(r,e)))return n;throw Le("Can't convert object to primitive value")},mt=TypeError,yt=lt("toPrimitive"),gt=function(e,t){if(!pt(e)||vt(e))return e;var r,n=ft(e,yt);if(n){if(void 0===t&&(t="default"),r=ht(n,e,t),!pt(r)||vt(r))return r;throw mt("Can't convert object to primitive value")}return void 0===t&&(t="number"),_t(e,t)},St=ke,bt=function(e){var t=gt(e,"string");return St(t)?t:t+""},Et=$,kt=n.document,Tt=Et(kt)&&Et(kt.createElement),It=function(e){return Tt?kt.createElement(e):{}},Rt=It,At=!w&&!i((function(){return 7!=Object.defineProperty(Rt("div"),"a",{get:function(){return 7}}).a})),wt=w,Ct=O,xt=D,Ot=V,Dt=J,Nt=bt,Mt=Ye,Pt=At,Lt=Object.getOwnPropertyDescriptor;A.f=wt?Lt:function(e,t){if(e=Dt(e),t=Nt(t),Pt)try{return Lt(e,t)}catch(r){}if(Mt(e,t))return Ot(!Ct(xt.f,e,t),e[t])};var Ut=i,Vt=R,Ft=/#|\.prototype\./,Bt=function(e,t){var r=Gt[jt(e)];return r==zt||r!=Ht&&(Vt(t)?Ut(t):!!t)},jt=Bt.normalize=function(e){return String(e).replace(Ft,".").toLowerCase()},Gt=Bt.data={},Ht=Bt.NATIVE="N",zt=Bt.POLYFILL="P",Kt=Bt,Xt=Ce,Wt=o,qt=E(E.bind),Yt=function(e,t){return Xt(e),void 0===t?e:Wt?qt(e,t):function(){return e.apply(t,arguments)}},Jt={},Qt=w&&i((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Zt=$,$t=String,er=TypeError,tr=function(e){if(Zt(e))return e;throw er($t(e)+" is not an object")},rr=w,nr=At,ir=Qt,or=tr,ar=bt,sr=TypeError,cr=Object.defineProperty,ur=Object.getOwnPropertyDescriptor,dr="enumerable",lr="configurable",hr="writable";Jt.f=rr?ir?function(e,t,r){if(or(e),t=ar(t),or(r),"function"==typeof e&&"prototype"===t&&"value"in r&&hr in r&&!r.writable){var n=ur(e,t);n&&n.writable&&(e[t]=r.value,r={configurable:lr in r?r.configurable:n.configurable,enumerable:dr in r?r.enumerable:n.enumerable,writable:!1})}return cr(e,t,r)}:cr:function(e,t,r){if(or(e),t=ar(t),or(r),nr)try{return cr(e,t,r)}catch(n){}if("get"in r||"set"in r)throw sr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var pr=Jt,vr=V,fr=w?function(e,t,r){return pr.f(e,t,vr(1,r))}:function(e,t,r){return e[t]=r,e},_r=n,mr=d,yr=E,gr=R,Sr=A.f,br=Kt,Er=ee,kr=Yt,Tr=fr,Ir=Ye,Rr=function(e){var t=function(r,n,i){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,i)}return mr(e,this,arguments)};return t.prototype=e.prototype,t},Ar=function(e,t){var r,n,i,o,a,s,c,u,d=e.target,l=e.global,h=e.stat,p=e.proto,v=l?_r:h?_r[d]:(_r[d]||{}).prototype,f=l?Er:Er[d]||Tr(Er,d,{})[d],_=f.prototype;for(i in t)r=!br(l?i:d+(h?".":"#")+i,e.forced)&&v&&Ir(v,i),a=f[i],r&&(s=e.dontCallGetSet?(u=Sr(v,i))&&u.value:v[i]),o=r&&s?s:t[i],r&&typeof a==typeof o||(c=e.bind&&r?kr(o,_r):e.wrap&&r?Rr(o):p&&gr(o)?yr(o):o,(e.sham||o&&o.sham||a&&a.sham)&&Tr(c,"sham",!0),Tr(f,i,c),p&&(Ir(Er,n=d+"Prototype")||Tr(Er,n,{}),Tr(Er[n],i,o),e.real&&_&&!_[i]&&Tr(_,i,o)))},wr=Math.ceil,Cr=Math.floor,xr=Math.trunc||function(e){var t=+e;return(t>0?Cr:wr)(t)},Or=function(e){var t=+e;return t!=t||0===t?0:xr(t)},Dr=Or,Nr=Math.max,Mr=Math.min,Pr=function(e,t){var r=Dr(e);return r<0?Nr(r+t,0):Mr(r,t)},Lr=Or,Ur=Math.min,Vr=function(e){return e>0?Ur(Lr(e),9007199254740991):0},Fr=Vr,Br=function(e){return Fr(e.length)},jr=J,Gr=Pr,Hr=Br,zr=function(e){return function(t,r,n){var i,o=jr(t),a=Hr(o),s=Gr(n,a);if(e&&r!=r){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},Kr={includes:zr(!0),indexOf:zr(!1)},Xr={},Wr=Ye,qr=J,Yr=Kr.indexOf,Jr=Xr,Qr=E([].push),Zr=function(e,t){var r,n=qr(e),i=0,o=[];for(r in n)!Wr(Jr,r)&&Wr(n,r)&&Qr(o,r);for(;t.length>i;)Wr(n,r=t[i++])&&(~Yr(o,r)||Qr(o,r));return o},$r=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],en=Zr,tn=$r,rn=Object.keys||function(e){return en(e,tn)},nn=Xe,on=rn;Ar({target:"Object",stat:!0,forced:i((function(){on(1)}))},{keys:function(e){return on(nn(e))}});var an=ee.Object.keys,sn={};sn[lt("toStringTag")]="z";var cn="[object z]"===String(sn),un=cn,dn=R,ln=g,hn=lt("toStringTag"),pn=Object,vn="Arguments"==ln(function(){return arguments}()),fn=un?ln:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=pn(e),hn))?r:vn?ln(t):"Object"==(n=ln(t))&&dn(t.callee)?"Arguments":n},_n=fn,mn=String,yn=function(e){if("Symbol"===_n(e))throw TypeError("Cannot convert a Symbol value to a string");return mn(e)},gn={},Sn=w,bn=Qt,En=Jt,kn=tr,Tn=J,In=rn;gn.f=Sn&&!bn?Object.defineProperties:function(e,t){kn(e);for(var r,n=Tn(t),i=In(t),o=i.length,a=0;o>a;)En.f(e,r=i[a++],n[r]);return e};var Rn,An=oe("document","documentElement"),wn=Ue.exports,Cn=et,xn=wn("keys"),On=function(e){return xn[e]||(xn[e]=Cn(e))},Dn=tr,Nn=gn,Mn=$r,Pn=Xr,Ln=An,Un=It,Vn=On("IE_PROTO"),Fn=function(){},Bn=function(e){return"<script>"+e+"</"+"script>"},jn=function(e){e.write(Bn("")),e.close();var t=e.parentWindow.Object;return e=null,t},Gn=function(){try{Rn=new ActiveXObject("htmlfile")}catch(n){}var e,t;Gn="undefined"!=typeof document?document.domain&&Rn?jn(Rn):((t=Un("iframe")).style.display="none",Ln.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(Bn("document.F=Object")),e.close(),e.F):jn(Rn);for(var r=Mn.length;r--;)delete Gn.prototype[Mn[r]];return Gn()};Pn[Vn]=!0;var Hn=Object.create||function(e,t){var r;return null!==e?(Fn.prototype=Dn(e),r=new Fn,Fn.prototype=null,r[Vn]=e):r=Gn(),void 0===t?r:Nn.f(r,t)},zn={},Kn=Zr,Xn=$r.concat("length","prototype");zn.f=Object.getOwnPropertyNames||function(e){return Kn(e,Xn)};var Wn={},qn=bt,Yn=Jt,Jn=V,Qn=function(e,t,r){var n=qn(t);n in e?Yn.f(e,n,Jn(0,r)):e[n]=r},Zn=Pr,$n=Br,ei=Qn,ti=Array,ri=Math.max,ni=function(e,t,r){for(var n=$n(e),i=Zn(t,n),o=Zn(void 0===r?n:r,n),a=ti(ri(o-i,0)),s=0;i<o;i++,s++)ei(a,s,e[i]);return a.length=s,a},ii=g,oi=J,ai=zn.f,si=ni,ci="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Wn.f=function(e){return ci&&"Window"==ii(e)?function(e){try{return ai(e)}catch(t){return si(ci)}}(e):ai(oi(e))};var ui={};ui.f=Object.getOwnPropertySymbols;var di=fr,li=function(e,t,r,n){return n&&n.enumerable?e[t]=r:di(e,t,r),e},hi={},pi=lt;hi.f=pi;var vi,fi,_i,mi=ee,yi=Ye,gi=hi,Si=Jt.f,bi=function(e){var t=mi.Symbol||(mi.Symbol={});yi(t,e)||Si(t,e,{value:gi.f(e)})},Ei=O,ki=oe,Ti=lt,Ii=li,Ri=function(){var e=ki("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=Ti("toPrimitive");t&&!t[n]&&Ii(t,n,(function(e){return Ei(r,this)}),{arity:1})},Ai=fn,wi=cn?{}.toString:function(){return"[object "+Ai(this)+"]"},Ci=cn,xi=Jt.f,Oi=fr,Di=Ye,Ni=wi,Mi=lt("toStringTag"),Pi=function(e,t,r,n){if(e){var i=r?e:e.prototype;Di(i,Mi)||xi(i,Mi,{configurable:!0,value:t}),n&&!Ci&&Oi(i,"toString",Ni)}},Li=R,Ui=n.WeakMap,Vi=Li(Ui)&&/native code/.test(String(Ui)),Fi=Vi,Bi=n,ji=$,Gi=fr,Hi=Ye,zi=Ge,Ki=On,Xi=Xr,Wi="Object already initialized",qi=Bi.TypeError,Yi=Bi.WeakMap;if(Fi||zi.state){var Ji=zi.state||(zi.state=new Yi);Ji.get=Ji.get,Ji.has=Ji.has,Ji.set=Ji.set,vi=function(e,t){if(Ji.has(e))throw qi(Wi);return t.facade=e,Ji.set(e,t),t},fi=function(e){return Ji.get(e)||{}},_i=function(e){return Ji.has(e)}}else{var Qi=Ki("state");Xi[Qi]=!0,vi=function(e,t){if(Hi(e,Qi))throw qi(Wi);return t.facade=e,Gi(e,Qi,t),t},fi=function(e){return Hi(e,Qi)?e[Qi]:{}},_i=function(e){return Hi(e,Qi)}}var Zi={set:vi,get:fi,has:_i,enforce:function(e){return _i(e)?fi(e):vi(e,{})},getterFor:function(e){return function(t){var r;if(!ji(t)||(r=fi(t)).type!==e)throw qi("Incompatible receiver, "+e+" required");return r}}},$i=g,eo=Array.isArray||function(e){return"Array"==$i(e)},to=R,ro=Ge,no=E(Function.toString);to(ro.inspectSource)||(ro.inspectSource=function(e){return no(e)});var io=ro.inspectSource,oo=E,ao=i,so=R,co=fn,uo=io,lo=function(){},ho=[],po=oe("Reflect","construct"),vo=/^\s*(?:class|function)\b/,fo=oo(vo.exec),_o=!vo.exec(lo),mo=function(e){if(!so(e))return!1;try{return po(lo,ho,e),!0}catch(t){return!1}},yo=function(e){if(!so(e))return!1;switch(co(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return _o||!!fo(vo,uo(e))}catch(t){return!0}};yo.sham=!0;var go=!po||ao((function(){var e;return mo(mo.call)||!mo(Object)||!mo((function(){e=!0}))||e}))?yo:mo,So=eo,bo=go,Eo=$,ko=lt("species"),To=Array,Io=function(e){var t;return So(e)&&(t=e.constructor,(bo(t)&&(t===To||So(t.prototype))||Eo(t)&&null===(t=t[ko]))&&(t=void 0)),void 0===t?To:t},Ro=function(e,t){return new(Io(e))(0===t?0:t)},Ao=Yt,wo=H,Co=Xe,xo=Br,Oo=Ro,Do=E([].push),No=function(e){var t=1==e,r=2==e,n=3==e,i=4==e,o=6==e,a=7==e,s=5==e||o;return function(c,u,d,l){for(var h,p,v=Co(c),f=wo(v),_=Ao(u,d),m=xo(f),y=0,g=l||Oo,S=t?g(c,m):r||a?g(c,0):void 0;m>y;y++)if((s||y in f)&&(p=_(h=f[y],y,v),e))if(t)S[y]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return y;case 2:Do(S,h)}else switch(e){case 4:return!1;case 7:Do(S,h)}return o?-1:n||i?i:S}},Mo={forEach:No(0),map:No(1),filter:No(2),some:No(3),every:No(4),find:No(5),findIndex:No(6),filterReject:No(7)},Po=Ar,Lo=n,Uo=O,Vo=E,Fo=w,Bo=me,jo=i,Go=Ye,Ho=ae,zo=tr,Ko=J,Xo=bt,Wo=yn,qo=V,Yo=Hn,Jo=rn,Qo=zn,Zo=Wn,$o=ui,ea=A,ta=Jt,ra=gn,na=D,ia=li,oa=Ue.exports,aa=Xr,sa=et,ca=lt,ua=hi,da=bi,la=Ri,ha=Pi,pa=Zi,va=Mo.forEach,fa=On("hidden"),_a="Symbol",ma=pa.set,ya=pa.getterFor(_a),ga=Object.prototype,Sa=Lo.Symbol,ba=Sa&&Sa.prototype,Ea=Lo.TypeError,ka=Lo.QObject,Ta=ea.f,Ia=ta.f,Ra=Zo.f,Aa=na.f,wa=Vo([].push),Ca=oa("symbols"),xa=oa("op-symbols"),Oa=oa("wks"),Da=!ka||!ka.prototype||!ka.prototype.findChild,Na=Fo&&jo((function(){return 7!=Yo(Ia({},"a",{get:function(){return Ia(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=Ta(ga,t);n&&delete ga[t],Ia(e,t,r),n&&e!==ga&&Ia(ga,t,n)}:Ia,Ma=function(e,t){var r=Ca[e]=Yo(ba);return ma(r,{type:_a,tag:e,description:t}),Fo||(r.description=t),r},Pa=function(e,t,r){e===ga&&Pa(xa,t,r),zo(e);var n=Xo(t);return zo(r),Go(Ca,n)?(r.enumerable?(Go(e,fa)&&e[fa][n]&&(e[fa][n]=!1),r=Yo(r,{enumerable:qo(0,!1)})):(Go(e,fa)||Ia(e,fa,qo(1,{})),e[fa][n]=!0),Na(e,n,r)):Ia(e,n,r)},La=function(e,t){zo(e);var r=Ko(t),n=Jo(r).concat(Ba(r));return va(n,(function(t){Fo&&!Uo(Ua,r,t)||Pa(e,t,r[t])})),e},Ua=function(e){var t=Xo(e),r=Uo(Aa,this,t);return!(this===ga&&Go(Ca,t)&&!Go(xa,t))&&(!(r||!Go(this,t)||!Go(Ca,t)||Go(this,fa)&&this[fa][t])||r)},Va=function(e,t){var r=Ko(e),n=Xo(t);if(r!==ga||!Go(Ca,n)||Go(xa,n)){var i=Ta(r,n);return!i||!Go(Ca,n)||Go(r,fa)&&r[fa][n]||(i.enumerable=!0),i}},Fa=function(e){var t=Ra(Ko(e)),r=[];return va(t,(function(e){Go(Ca,e)||Go(aa,e)||wa(r,e)})),r},Ba=function(e){var t=e===ga,r=Ra(t?xa:Ko(e)),n=[];return va(r,(function(e){!Go(Ca,e)||t&&!Go(ga,e)||wa(n,Ca[e])})),n};Bo||(Sa=function(){if(Ho(ba,this))throw Ea("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Wo(arguments[0]):void 0,t=sa(e),r=function(e){this===ga&&Uo(r,xa,e),Go(this,fa)&&Go(this[fa],t)&&(this[fa][t]=!1),Na(this,t,qo(1,e))};return Fo&&Da&&Na(ga,t,{configurable:!0,set:r}),Ma(t,e)},ia(ba=Sa.prototype,"toString",(function(){return ya(this).tag})),ia(Sa,"withoutSetter",(function(e){return Ma(sa(e),e)})),na.f=Ua,ta.f=Pa,ra.f=La,ea.f=Va,Qo.f=Zo.f=Fa,$o.f=Ba,ua.f=function(e){return Ma(ca(e),e)},Fo&&Ia(ba,"description",{configurable:!0,get:function(){return ya(this).description}})),Po({global:!0,constructor:!0,wrap:!0,forced:!Bo,sham:!Bo},{Symbol:Sa}),va(Jo(Oa),(function(e){da(e)})),Po({target:_a,stat:!0,forced:!Bo},{useSetter:function(){Da=!0},useSimple:function(){Da=!1}}),Po({target:"Object",stat:!0,forced:!Bo,sham:!Fo},{create:function(e,t){return void 0===t?Yo(e):La(Yo(e),t)},defineProperty:Pa,defineProperties:La,getOwnPropertyDescriptor:Va}),Po({target:"Object",stat:!0,forced:!Bo},{getOwnPropertyNames:Fa}),la(),ha(Sa,_a),aa[fa]=!0;var ja=me&&!!Symbol.for&&!!Symbol.keyFor,Ga=Ar,Ha=oe,za=Ye,Ka=yn,Xa=Ue.exports,Wa=ja,qa=Xa("string-to-symbol-registry"),Ya=Xa("symbol-to-string-registry");Ga({target:"Symbol",stat:!0,forced:!Wa},{for:function(e){var t=Ka(e);if(za(qa,t))return qa[t];var r=Ha("Symbol")(t);return qa[t]=r,Ya[r]=t,r}});var Ja=Ar,Qa=Ye,Za=ke,$a=Ie,es=ja,ts=(0,Ue.exports)("symbol-to-string-registry");Ja({target:"Symbol",stat:!0,forced:!es},{keyFor:function(e){if(!Za(e))throw TypeError($a(e)+" is not a symbol");if(Qa(ts,e))return ts[e]}});var rs=E([].slice),ns=Ar,is=oe,os=d,as=O,ss=E,cs=i,us=eo,ds=R,ls=$,hs=ke,ps=rs,vs=me,fs=is("JSON","stringify"),_s=ss(/./.exec),ms=ss("".charAt),ys=ss("".charCodeAt),gs=ss("".replace),Ss=ss(1..toString),bs=/[\uD800-\uDFFF]/g,Es=/^[\uD800-\uDBFF]$/,ks=/^[\uDC00-\uDFFF]$/,Ts=!vs||cs((function(){var e=is("Symbol")();return"[null]"!=fs([e])||"{}"!=fs({a:e})||"{}"!=fs(Object(e))})),Is=cs((function(){return'"\\udf06\\ud834"'!==fs("\udf06\ud834")||'"\\udead"'!==fs("\udead")})),Rs=function(e,t){var r=ps(arguments),n=t;if((ls(t)||void 0!==e)&&!hs(e))return us(t)||(t=function(e,t){if(ds(n)&&(t=as(n,this,e,t)),!hs(t))return t}),r[1]=t,os(fs,null,r)},As=function(e,t,r){var n=ms(r,t-1),i=ms(r,t+1);return _s(Es,e)&&!_s(ks,i)||_s(ks,e)&&!_s(Es,n)?"\\u"+Ss(ys(e,0),16):e};fs&&ns({target:"JSON",stat:!0,arity:3,forced:Ts||Is},{stringify:function(e,t,r){var n=ps(arguments),i=os(Ts?Rs:fs,null,n);return Is&&"string"==typeof i?gs(i,bs,As):i}});var ws=ui,Cs=Xe;Ar({target:"Object",stat:!0,forced:!me||i((function(){ws.f(1)}))},{getOwnPropertySymbols:function(e){var t=ws.f;return t?t(Cs(e)):[]}});var xs=ee.Object.getOwnPropertySymbols,Os=i,Ds=ve,Ns=lt("species"),Ms=function(e){return Ds>=51||!Os((function(){var t=[];return(t.constructor={})[Ns]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Ps=Mo.filter;Ar({target:"Array",proto:!0,forced:!Ms("filter")},{filter:function(e){return Ps(this,e,arguments.length>1?arguments[1]:void 0)}});var Ls=ee,Us=function(e){return Ls[e+"Prototype"]},Vs=Us("Array").filter,Fs=ae,Bs=Vs,js=Array.prototype,Gs=function(e){var t=e.filter;return e===js||Fs(js,e)&&t===js.filter?Bs:t},Hs={exports:{}},zs=Ar,Ks=i,Xs=J,Ws=A.f,qs=w,Ys=Ks((function(){Ws(1)}));zs({target:"Object",stat:!0,forced:!qs||Ys,sham:!qs},{getOwnPropertyDescriptor:function(e,t){return Ws(Xs(e),t)}});var Js=ee.Object,Qs=Hs.exports=function(e,t){return Js.getOwnPropertyDescriptor(e,t)};Js.getOwnPropertyDescriptor.sham&&(Qs.sham=!0);var Zs,$s,ec,tc=Hs.exports,rc={},nc=w,ic=Ye,oc=Function.prototype,ac=nc&&Object.getOwnPropertyDescriptor,sc=ic(oc,"name"),cc={EXISTS:sc,PROPER:sc&&"something"===function(){}.name,CONFIGURABLE:sc&&(!nc||nc&&ac(oc,"name").configurable)},uc=!i((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),dc=Ye,lc=R,hc=Xe,pc=uc,vc=On("IE_PROTO"),fc=Object,_c=fc.prototype,mc=pc?fc.getPrototypeOf:function(e){var t=hc(e);if(dc(t,vc))return t[vc];var r=t.constructor;return lc(r)&&t instanceof r?r.prototype:t instanceof fc?_c:null},yc=i,gc=R,Sc=$,bc=Hn,Ec=mc,kc=li,Tc=lt("iterator"),Ic=!1;[].keys&&("next"in(ec=[].keys())?($s=Ec(Ec(ec)))!==Object.prototype&&(Zs=$s):Ic=!0);var Rc=!Sc(Zs)||yc((function(){var e={};return Zs[Tc].call(e)!==e}));gc((Zs=Rc?{}:bc(Zs))[Tc])||kc(Zs,Tc,(function(){return this}));var Ac={IteratorPrototype:Zs,BUGGY_SAFARI_ITERATORS:Ic},wc=Ac.IteratorPrototype,Cc=Hn,xc=V,Oc=Pi,Dc=rc,Nc=function(){return this},Mc=function(e,t,r,n){var i=t+" Iterator";return e.prototype=Cc(wc,{next:xc(+!n,r)}),Oc(e,i,!1,!0),Dc[i]=Nc,e},Pc=R,Lc=String,Uc=TypeError,Vc=E,Fc=tr,Bc=function(e){if("object"==typeof e||Pc(e))return e;throw Uc("Can't set "+Lc(e)+" as a prototype")},jc=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=Vc(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),t=r instanceof Array}catch(n){}return function(r,n){return Fc(r),Bc(n),t?e(r,n):r.__proto__=n,r}}():void 0),Gc=Ar,Hc=O,zc=cc,Kc=Mc,Xc=mc,Wc=Pi,qc=li,Yc=rc,Jc=Ac,Qc=zc.PROPER,Zc=Jc.BUGGY_SAFARI_ITERATORS,$c=lt("iterator"),eu="keys",tu="values",ru="entries",nu=function(){return this},iu=function(e,t,r,n,i,o,a){Kc(r,t,n);var s,c,u,d=function(e){if(e===i&&f)return f;if(!Zc&&e in p)return p[e];switch(e){case eu:case tu:case ru:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,p=e.prototype,v=p[$c]||p["@@iterator"]||i&&p[i],f=!Zc&&v||d(i),_="Array"==t&&p.entries||v;if(_&&(s=Xc(_.call(new e)))!==Object.prototype&&s.next&&(Wc(s,l,!0,!0),Yc[l]=nu),Qc&&i==tu&&v&&v.name!==tu&&(h=!0,f=function(){return Hc(v,this)}),i)if(c={values:d(tu),keys:o?f:d(eu),entries:d(ru)},a)for(u in c)(Zc||h||!(u in p))&&qc(p,u,c[u]);else Gc({target:t,proto:!0,forced:Zc||h},c);return a&&p[$c]!==f&&qc(p,$c,f,{name:i}),Yc[t]=f,c},ou=function(e,t){return{value:e,done:t}},au=J,su=function(){},cu=rc,uu=Zi,du=(Jt.f,iu),lu=ou,hu="Array Iterator",pu=uu.set,vu=uu.getterFor(hu);du(Array,"Array",(function(e,t){pu(this,{type:hu,target:au(e),index:0,kind:t})}),(function(){var e=vu(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,lu(void 0,!0)):lu("keys"==r?n:"values"==r?t[n]:[n,t[n]],!1)}),"values");cu.Arguments=cu.Array;su(),su(),su();var fu={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},_u=n,mu=fn,yu=fr,gu=rc,Su=lt("toStringTag");for(var bu in fu){var Eu=_u[bu],ku=Eu&&Eu.prototype;ku&&mu(ku)!==Su&&yu(ku,Su,bu),gu[bu]=gu.Array}var Tu=i,Iu=function(e,t){var r=[][e];return!!r&&Tu((function(){r.call(null,t||function(){return 1},1)}))},Ru=Mo.forEach,Au=Iu("forEach")?[].forEach:function(e){return Ru(this,e,arguments.length>1?arguments[1]:void 0)};Ar({target:"Array",proto:!0,forced:[].forEach!=Au},{forEach:Au});var wu=Us("Array").forEach,Cu=fn,xu=Ye,Ou=ae,Du=wu,Nu=Array.prototype,Mu={DOMTokenList:!0,NodeList:!0},Pu=function(e){var t=e.forEach;return e===Nu||Ou(Nu,e)&&t===Nu.forEach||xu(Mu,Cu(e))?Du:t},Lu=oe,Uu=zn,Vu=ui,Fu=tr,Bu=E([].concat),ju=Lu("Reflect","ownKeys")||function(e){var t=Uu.f(Fu(e)),r=Vu.f;return r?Bu(t,r(e)):t},Gu=ju,Hu=J,zu=A,Ku=Qn;Ar({target:"Object",stat:!0,sham:!w},{getOwnPropertyDescriptors:function(e){for(var t,r,n=Hu(e),i=zu.f,o=Gu(n),a={},s=0;o.length>s;)void 0!==(r=i(n,t=o[s++]))&&Ku(a,t,r);return a}});var Xu=ee.Object.getOwnPropertyDescriptors,Wu={exports:{}},qu=Ar,Yu=w,Ju=gn.f;qu({target:"Object",stat:!0,forced:Object.defineProperties!==Ju,sham:!Yu},{defineProperties:Ju});var Qu=ee.Object,Zu=Wu.exports=function(e,t){return Qu.defineProperties(e,t)};Qu.defineProperties.sham&&(Zu.sham=!0);var $u=Wu.exports,ed={exports:{}},td=Ar,rd=w,nd=Jt.f;td({target:"Object",stat:!0,forced:Object.defineProperty!==nd,sham:!rd},{defineProperty:nd});var id=ee.Object,od=ed.exports=function(e,t,r){return id.defineProperty(e,t,r)};id.defineProperty.sham&&(od.sham=!0);var ad=ed.exports,sd=TypeError,cd=function(e){if(e>9007199254740991)throw sd("Maximum allowed index exceeded");return e},ud=Ar,dd=i,ld=eo,hd=$,pd=Xe,vd=Br,fd=cd,_d=Qn,md=Ro,yd=Ms,gd=ve,Sd=lt("isConcatSpreadable"),bd=gd>=51||!dd((function(){var e=[];return e[Sd]=!1,e.concat()[0]!==e})),Ed=yd("concat"),kd=function(e){if(!hd(e))return!1;var t=e[Sd];return void 0!==t?!!t:ld(e)};ud({target:"Array",proto:!0,arity:1,forced:!bd||!Ed},{concat:function(e){var t,r,n,i,o,a=pd(this),s=md(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(kd(o=-1===t?a:arguments[t]))for(i=vd(o),fd(c+i),r=0;r<i;r++,c++)r in o&&_d(s,c,o[r]);else fd(c+1),_d(s,c++,o);return s.length=c,s}}),bi("asyncIterator"),bi("hasInstance"),bi("isConcatSpreadable"),bi("iterator"),bi("match"),bi("matchAll"),bi("replace"),bi("search"),bi("species"),bi("split");var Td=Ri;bi("toPrimitive"),Td();var Id=oe,Rd=Pi;bi("toStringTag"),Rd(Id("Symbol"),"Symbol"),bi("unscopables"),Pi(n.JSON,"JSON",!0);var Ad=ee.Symbol;bi("asyncDispose"),bi("dispose"),bi("matcher"),bi("metadataKey"),bi("observable"),bi("metadata"),bi("patternMatch"),bi("replaceAll");var wd=Ad,Cd=E,xd=Or,Od=yn,Dd=W,Nd=Cd("".charAt),Md=Cd("".charCodeAt),Pd=Cd("".slice),Ld=function(e){return function(t,r){var n,i,o=Od(Dd(t)),a=xd(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=Md(o,a))<55296||n>56319||a+1===s||(i=Md(o,a+1))<56320||i>57343?e?Nd(o,a):n:e?Pd(o,a,a+2):i-56320+(n-55296<<10)+65536}},Ud={codeAt:Ld(!1),charAt:Ld(!0)},Vd=Ud.charAt,Fd=yn,Bd=Zi,jd=iu,Gd=ou,Hd="String Iterator",zd=Bd.set,Kd=Bd.getterFor(Hd);jd(String,"String",(function(e){zd(this,{type:Hd,string:Fd(e),index:0})}),(function(){var e,t=Kd(this),r=t.string,n=t.index;return n>=r.length?Gd(void 0,!0):(e=Vd(r,n),t.index+=e.length,Gd(e,!1))}));var Xd=hi.f("iterator");function Wd(e){return(Wd="function"==typeof wd&&"symbol"==typeof Xd?function(e){return typeof e}:function(e){return e&&"function"==typeof wd&&e.constructor===wd&&e!==wd.prototype?"symbol":typeof e})(e)}var qd=hi.f("toPrimitive");function Yd(e){var t=function(e,t){if("object"!==Wd(e)||null===e)return e;var r=e[qd];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==Wd(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Wd(t)?t:String(t)}function Jd(e,t,r){return(t=Yd(t))in e?ad(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Qd(e,t){var r=an(e);if(xs){var n=xs(e);t&&(n=Gs(n).call(n,(function(t){return tc(e,t).enumerable}))),r.push.apply(r,n)}return r}function Zd(e){for(var t=1;t<arguments.length;t++){var r,n,i=null!=arguments[t]?arguments[t]:{};t%2?Pu(r=Qd(Object(i),!0)).call(r,(function(t){Jd(e,t,i[t])})):Xu?$u(e,Xu(i)):Pu(n=Qd(Object(i))).call(n,(function(t){ad(e,t,tc(i,t))}))}return e}var $d=function(e){return e[e.VIDEO_SOURCE_TYPE_EXTERNAL=0]="VIDEO_SOURCE_TYPE_EXTERNAL",e[e.VIDEO_SOURCE_TYPE_INTERNAL=1]="VIDEO_SOURCE_TYPE_INTERNAL",e}($d||{}),el=function(e){return e[e.AUDIO_SOURCE_TYPE_EXTERNAL=0]="AUDIO_SOURCE_TYPE_EXTERNAL",e[e.AUDIO_SOURCE_TYPE_INTERNAL=1]="AUDIO_SOURCE_TYPE_INTERNAL",e}(el||{}),tl=function(e){return e[e.QUIT=0]="QUIT",e[e.DROPPED=1]="DROPPED",e[e.SWITCH_TO_INVISIBLE=2]="SWITCH_TO_INVISIBLE",e[e.KICKED_BY_ADMIN=3]="KICKED_BY_ADMIN",e}(tl||{}),rl=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(rl||{}),nl=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(nl||{}),il=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(il||{}),ol=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(ol||{}),al=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(al||{}),sl=function(e){return e[e.RENDER_MODE_HIDDEN=0]="RENDER_MODE_HIDDEN",e[e.RENDER_MODE_FIT=1]="RENDER_MODE_FIT",e[e.RENDER_MODE_FILL=2]="RENDER_MODE_FILL",e}(sl||{}),cl=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(cl||{}),ul=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(ul||{}),dl=function(e){return e[e.STREAM_REMOVE_REASON_UNPUBLISH=0]="STREAM_REMOVE_REASON_UNPUBLISH",e[e.STREAM_REMOVE_REASON_PUBLISH_FAILED=1]="STREAM_REMOVE_REASON_PUBLISH_FAILED",e[e.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED=2]="STREAM_REMOVE_REASON_KEEP_LIVE_FAILED",e[e.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED=3]="STREAM_REMOVE_REASON_CLIENT_DISCONNECTED",e[e.STREAM_REMOVE_REASON_REPUBLISH=4]="STREAM_REMOVE_REASON_REPUBLISH",e[e.STREAM_REMOVE_REASON_OTHER=5]="STREAM_REMOVE_REASON_OTHER",e}(dl||{}),ll=function(e){return e[e.CONNECTION_START=0]="CONNECTION_START",e[e.CONNECTION_STATE_DISCONNECTED=1]="CONNECTION_STATE_DISCONNECTED",e[e.CONNECTION_STATE_CONNECTING=2]="CONNECTION_STATE_CONNECTING",e[e.CONNECTION_STATE_CONNECTED=3]="CONNECTION_STATE_CONNECTED",e[e.CONNECTION_STATE_RECONNECTING=4]="CONNECTION_STATE_RECONNECTING",e[e.CONNECTION_STATE_RECONNECTED=5]="CONNECTION_STATE_RECONNECTED",e[e.CONNECTION_STATE_LOST=6]="CONNECTION_STATE_LOST",e}(ll||{}),hl=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(hl||{}),pl=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(pl||{}),vl=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(vl||{}),fl=function(e){return e[e.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",e[e.AUDIO_ONLY=1]="AUDIO_ONLY",e[e.VIDEO_ONLY=2]="VIDEO_ONLY",e}(fl||{}),_l=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(_l||{}),ml=function(e){return e[e.DISABLE=0]="DISABLE",e[e.VIDEO_STREAM_LOW=1]="VIDEO_STREAM_LOW",e[e.AUDIO_ONLY=2]="AUDIO_ONLY",e}(ml||{}),yl=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(yl||{}),gl=function(e){return e[e.UNKNOWN=0]="UNKNOWN",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.POOR=3]="POOR",e[e.BAD=4]="BAD",e[e.VBAD=5]="VBAD",e[e.DOWN=6]="DOWN",e}(gl||{}),Sl=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(Sl||{}),bl=function(e){return e[e.communication=0]="communication",e[e.chat=5]="chat",e[e.chatRoom=6]="chatRoom",e[e.coHost=9]="coHost",e[e.meeting=16]="meeting",e[e.classRoom=18]="classRoom",e}(bl||{}),El=function(e){return e[e.default=0]="default",e[e.fluent=1]="fluent",e[e.standard=2]="standard",e[e.hd=3]="hd",e[e.standardStereo=4]="standardStereo",e[e.hdMono=5]="hdMono",e}(El||{}),kl=function(e){return e[e.AUTO_PLAY=0]="AUTO_PLAY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.PLAY_MANUALLY=2]="PLAY_MANUALLY",e}(kl||{}),Tl=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(Tl||{}),Il=function(e){return e.H264="H264",e.H265="H265",e}(Il||{}),Rl=function(e){return e[e.ASR_ONLY=0]="ASR_ONLY",e[e.ASR_AND_TRANSLATION=1]="ASR_AND_TRANSLATION",e}(Rl||{}),Al=function(e){return e[e.STARTED=0]="STARTED",e[e.STOPPED=1]="STOPPED",e[e.ERROR=2]="ERROR",e}(Al||{}),wl=function(e){return e[e.FORWARD_STREAM_STATE_SUCCESS=0]="FORWARD_STREAM_STATE_SUCCESS",e[e.FORWARD_STREAM_STATE_FAILURE=1]="FORWARD_STREAM_STATE_FAILURE",e}(wl||{}),Cl=function(e){return e[e.FORWARD_STREAM_ERROR_OK=0]="FORWARD_STREAM_ERROR_OK",e[e.FORWARD_STREAM_ERROR_INVALID_TOKEN=1202]="FORWARD_STREAM_ERROR_INVALID_TOKEN",e[e.FORWARD_STREAM_ERROR_RESPONSE=1203]="FORWARD_STREAM_ERROR_RESPONSE",e[e.FORWARD_STREAM_ERROR_REMOTE_KICKED=1204]="FORWARD_STREAM_ERROR_REMOTE_KICKED",e[e.FORWARD_STREAM_ERROR_NOT_SUPPORT=1205]="FORWARD_STREAM_ERROR_NOT_SUPPORT",e}(Cl||{}),xl=Object.freeze(Object.defineProperty({__proto__:null,VideoSourceType:$d,AudioSourceType:el,UserOfflineReason:tl,ChannelProfile:rl,SubscribeMode:nl,SubscribeState:il,PublishState:ol,MirrorMode:al,VideoRenderMode:sl,StreamIndex:cl,MediaType:ul,StreamRemoveReason:dl,ConnectionState:ll,MirrorType:hl,LogChannel:pl,USER_ONLINE_STATUS:vl,PublicStreamType:fl,PublicInterpolationMode:_l,SubscribeFallbackOption:ml,RemoteUserPriority:yl,NetworkQuality:gl,FallbackOrRecoverReason:Sl,RoomProfileType:bl,AudioProfileType:El,RTCAutoPlayPolicy:kl,AAC_PROFILE:Tl,TRANSCODING_VIDEO_CODEC:Il,SUBTITLE_MODE:Rl,SubtitleEventType:Al,ForwardStreamState:wl,ForwardStreamError:Cl},Symbol.toStringTag,{value:"Module"})),Ol=function(e){return e[e.AUTO=0]="AUTO",e[e.MODE_L=1]="MODE_L",e[e.MODE_R=2]="MODE_R",e[e.MODE_MIX=3]="MODE_MIX",e}(Ol||{}),Dl=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(Dl||{}),Nl=function(e){return e[e.AUDIO_MIXING_STATE_PRELOADED=0]="AUDIO_MIXING_STATE_PRELOADED",e[e.AUDIO_MIXING_STATE_PLAYING=1]="AUDIO_MIXING_STATE_PLAYING",e[e.AUDIO_MIXING_STATE_PAUSED=2]="AUDIO_MIXING_STATE_PAUSED",e[e.AUDIO_MIXING_STATE_STOPPED=3]="AUDIO_MIXING_STATE_STOPPED",e[e.AUDIO_MIXING_STATE_FAILED=4]="AUDIO_MIXING_STATE_FAILED",e[e.AUDIO_MIXING_STATE_FINISHED=5]="AUDIO_MIXING_STATE_FINISHED",e[e.AUDIO_MIXING_STATE_PCM_ENABLED=6]="AUDIO_MIXING_STATE_PCM_ENABLED",e[e.AUDIO_MIXING_STATE_PCM_DISABLED=7]="AUDIO_MIXING_STATE_PCM_DISABLED",e}(Nl||{}),Ml=Object.freeze(Object.defineProperty({__proto__:null,AudioMixingDualMonoMode:Ol,AudioMixingType:Dl,AudioMixingState:Nl},Symbol.toStringTag,{value:"Module"})),Pl=function(e){return e.onTrackEnded="onTrackEnded",e.onTrackMute="onTrackMute",e.onTrackUnmute="onTrackUnmute",e.onPlayerEvent="onPlayerEvent",e.onAutoplayFailed="onAutoplayFailed",e.onUserJoined="onUserJoined",e.onUserLeave="onUserLeave",e.onConnectionStateChanged="onConnectionStateChanged",e.onUserPublishStream="onUserPublishStream",e.onUserUnpublishStream="onUserUnpublishStream",e.onUserPublishScreen="onUserPublishScreen",e.onUserUnpublishScreen="onUserUnpublishScreen",e.onRoomMessageReceived="onRoomMessageReceived",e.onRoomBinaryMessageReceived="onRoomBinaryMessageReceived",e.onUserMessageReceived="onUserMessageReceived",e.onUserBinaryMessageReceived="onUserBinaryMessageReceived",e.onVideoFirstFrameRendered="onVideoFirstFrameRendered",e.onVideoFirstFrameDecoded="onVideoFirstFrameDecoded",e.onRemoteVideoFirstFrame="onRemoteVideoFirstFrame",e.onAudioFirstFrameDecoded="onAudioFirstFrameDecoded",e.onRemoteAudioFirstFrame="onRemoteAudioFirstFrame",e.onFirstPublicStreamVideoFrameRendered="onFirstPublicStreamVideoFrameRendered",e.onFirstPublicStreamVideoFrameDecoded="onFirstPublicStreamVideoFrameDecoded",e.onFirstPublicStreamAudioFrameDecoded="onFirstPublicStreamAudioFrameDecoded",e.onVideoDeviceStateChanged="onVideoDeviceStateChanged",e.onAudioDeviceStateChanged="onAudioDeviceStateChanged",e.onRemoteStreamStats="onRemoteStreamStats",e.onPublicStreamStats="onPublicStreamStats",e.onLocalStreamStats="onLocalStreamStats",e.onAudioVolumeIndication="onAudioVolumeIndication",e.onLocalAudioPropertiesReport="onLocalAudioPropertiesReport",e.onRemoteAudioPropertiesReport="onRemoteAudioPropertiesReport",e.onActiveSpeaker="onActiveSpeaker",e.onAudioPlaybackDeviceChanged="onAudioPlaybackDeviceChanged",e.onUserStartVideoCapture="onUserStartVideoCapture",e.onUserStopVideoCapture="onUserStopVideoCapture",e.onUserStartAudioCapture="onUserStartAudioCapture",e.onUserStopAudioCapture="onUserStopAudioCapture",e.onAutoPublishResult="onAutoPublishResult",e.onAutoSubscribeResult="onAutoSubscribeResult",e.onLiveTranscodingResult="onLiveTranscodingResult",e.onStreamMixingEvent="onStreamMixingEvent",e.onAudioPlaybackDeviceTestVolume="onAudioPlaybackDeviceTestVolume",e.onSEIMessageReceived="onSEIMessageReceived",e.onError="onError",e.onAudioMixingStateChanged="onAudioMixingStateChanged",e.onUserMessageReceivedOutsideRoom="onUserMessageReceivedOutsideRoom",e.onUserBinaryMessageReceivedOutsideRoom="onUserBinaryMessageReceivedOutsideRoom",e.onTokenWillExpire="onTokenWillExpire",e.onCloudProxyConnected="onCloudProxyConnected",e.onPushPublicStreamResult="onPushPublicStreamResult",e.onPublicStreamSEIMessageReceived="onPublicStreamSEIMessageReceived",e.onNetworkQuality="onNetworkQuality",e.onSimulcastSubscribeFallback="onSimulcastSubscribeFallback",e.onRemoteVideoSizeChanged="onRemoteVideoSizeChanged",e.onVideoStreamBanned="onVideoStreamBanned",e.onAudioStreamBanned="onAudioStreamBanned",e.onLocalVideoSizeChanged="onLocalVideoSizeChanged",e.onSubtitleStateChanged="onSubtitleStateChanged",e.onSubtitleMessageReceived="onSubtitleMessageReceived",e.onServerParamsSetResult="onServerParamsSetResult",e.onLocalStreamTrackChangedByExtension="onLocalStreamTrackChangedByExtension",e.onVendorConnectionStateChanged="onVendorConnectionStateChanged",e.onForwardStreamError="onForwardStreamError",e.onRejoinWithTcp="onRejoinWithTcp",e.onIceConnectWithTcp="onIceConnectWithTcp",e}(Pl||{});function Ll(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),ad(e,Yd(n.key),n)}}function Ul(e,t,r){return t&&Ll(e.prototype,t),r&&Ll(e,r),ad(e,"prototype",{writable:!1}),e}function Vl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Ar({target:"Object",stat:!0,sham:!w},{create:Hn});var Fl=ee.Object,Bl=function(e,t){return Fl.create(e,t)},jl=Xe,Gl=mc,Hl=uc;Ar({target:"Object",stat:!0,forced:i((function(){Gl(1)})),sham:!Hl},{getPrototypeOf:function(e){return Gl(jl(e))}});var zl=ee.Object.getPrototypeOf;Ar({target:"Object",stat:!0},{setPrototypeOf:jc});var Kl=ee.Object.setPrototypeOf,Xl=Ye,Wl=ju,ql=A,Yl=Jt,Jl=Error,Ql=E("".replace),Zl=String(Jl("zxcasd").stack),$l=/\n\s*at [^:]*:[^\n]*/,eh=$l.test(Zl),th=$,rh=fr,nh=rc,ih=lt("iterator"),oh=Array.prototype,ah=function(e){return void 0!==e&&(nh.Array===e||oh[ih]===e)},sh=fn,ch=De,uh=z,dh=rc,lh=lt("iterator"),hh=function(e){if(!uh(e))return ch(e,lh)||ch(e,"@@iterator")||dh[sh(e)]},ph=O,vh=Ce,fh=tr,_h=Ie,mh=hh,yh=TypeError,gh=function(e,t){var r=arguments.length<2?mh(e):t;if(vh(r))return fh(ph(r,e));throw yh(_h(e)+" is not iterable")},Sh=O,bh=tr,Eh=De,kh=function(e,t,r){var n,i;bh(e);try{if(!(n=Eh(e,"return"))){if("throw"===t)throw r;return r}n=Sh(n,e)}catch(o){i=!0,n=o}if("throw"===t)throw r;if(i)throw n;return bh(n),r},Th=Yt,Ih=O,Rh=tr,Ah=Ie,wh=ah,Ch=Br,xh=ae,Oh=gh,Dh=hh,Nh=kh,Mh=TypeError,Ph=function(e,t){this.stopped=e,this.result=t},Lh=Ph.prototype,Uh=function(e,t,r){var n,i,o,a,s,c,u,d=r&&r.that,l=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),p=!(!r||!r.IS_ITERATOR),v=!(!r||!r.INTERRUPTED),f=Th(t,d),_=function(e){return n&&Nh(n,"normal",e),new Ph(!0,e)},m=function(e){return l?(Rh(e),v?f(e[0],e[1],_):f(e[0],e[1])):v?f(e,_):f(e)};if(h)n=e.iterator;else if(p)n=e;else{if(!(i=Dh(e)))throw Mh(Ah(e)+" is not iterable");if(wh(i)){for(o=0,a=Ch(e);a>o;o++)if((s=m(e[o]))&&xh(Lh,s))return s;return new Ph(!1)}n=Oh(e,i)}for(c=h?e.next:n.next;!(u=Ih(c,n)).done;){try{s=m(u.value)}catch(y){Nh(n,"throw",y)}if("object"==typeof s&&s&&xh(Lh,s))return s}return new Ph(!1)},Vh=yn,Fh=V,Bh=!i((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",Fh(1,7)),7!==e.stack)})),jh=Ar,Gh=ae,Hh=mc,zh=jc,Kh=function(e,t,r){for(var n=Wl(t),i=Yl.f,o=ql.f,a=0;a<n.length;a++){var s=n[a];Xl(e,s)||r&&Xl(r,s)||i(e,s,o(t,s))}},Xh=Hn,Wh=fr,qh=V,Yh=function(e,t){if(eh&&"string"==typeof e&&!Jl.prepareStackTrace)for(;t--;)e=Ql(e,$l,"");return e},Jh=function(e,t){th(t)&&"cause"in t&&rh(e,"cause",t.cause)},Qh=Uh,Zh=function(e,t){return void 0===e?arguments.length<2?"":t:Vh(e)},$h=Bh,ep=lt("toStringTag"),tp=Error,rp=[].push,np=function(e,t){var r,n=arguments.length>2?arguments[2]:void 0,i=Gh(ip,this);zh?r=zh(tp(),i?Hh(this):ip):(r=i?this:Xh(ip),Wh(r,ep,"Error")),void 0!==t&&Wh(r,"message",Zh(t)),$h&&Wh(r,"stack",Yh(r.stack,1)),Jh(r,n);var o=[];return Qh(e,rp,{that:o}),Wh(r,"errors",o),r};zh?zh(np,tp):Kh(np,tp,{name:!0});var ip=np.prototype=Xh(tp.prototype,{constructor:qh(1,np),message:qh(1,""),name:qh(1,"AggregateError")});jh({global:!0,constructor:!0,arity:2},{AggregateError:np});var op,ap,sp,cp,up="process"==g(n.process),dp=oe,lp=Jt,hp=w,pp=lt("species"),vp=function(e){var t=dp(e),r=lp.f;hp&&t&&!t[pp]&&r(t,pp,{configurable:!0,get:function(){return this}})},fp=ae,_p=TypeError,mp=function(e,t){if(fp(t,e))return e;throw _p("Incorrect invocation")},yp=go,gp=Ie,Sp=TypeError,bp=function(e){if(yp(e))return e;throw Sp(gp(e)+" is not a constructor")},Ep=tr,kp=bp,Tp=z,Ip=lt("species"),Rp=function(e,t){var r,n=Ep(e).constructor;return void 0===n||Tp(r=Ep(n)[Ip])?t:kp(r)},Ap=TypeError,wp=function(e,t){if(e<t)throw Ap("Not enough arguments");return e},Cp=/(?:ipad|iphone|ipod).*applewebkit/i.test(se),xp=n,Op=d,Dp=Yt,Np=R,Mp=Ye,Pp=i,Lp=An,Up=rs,Vp=It,Fp=wp,Bp=Cp,jp=up,Gp=xp.setImmediate,Hp=xp.clearImmediate,zp=xp.process,Kp=xp.Dispatch,Xp=xp.Function,Wp=xp.MessageChannel,qp=xp.String,Yp=0,Jp={},Qp="onreadystatechange";try{op=xp.location}catch(XW){}var Zp=function(e){if(Mp(Jp,e)){var t=Jp[e];delete Jp[e],t()}},$p=function(e){return function(){Zp(e)}},ev=function(e){Zp(e.data)},tv=function(e){xp.postMessage(qp(e),op.protocol+"//"+op.host)};Gp&&Hp||(Gp=function(e){Fp(arguments.length,1);var t=Np(e)?e:Xp(e),r=Up(arguments,1);return Jp[++Yp]=function(){Op(t,void 0,r)},ap(Yp),Yp},Hp=function(e){delete Jp[e]},jp?ap=function(e){zp.nextTick($p(e))}:Kp&&Kp.now?ap=function(e){Kp.now($p(e))}:Wp&&!Bp?(cp=(sp=new Wp).port2,sp.port1.onmessage=ev,ap=Dp(cp.postMessage,cp)):xp.addEventListener&&Np(xp.postMessage)&&!xp.importScripts&&op&&"file:"!==op.protocol&&!Pp(tv)?(ap=tv,xp.addEventListener("message",ev,!1)):ap=Qp in Vp("script")?function(e){Lp.appendChild(Vp("script")).onreadystatechange=function(){Lp.removeChild(this),Zp(e)}}:function(e){setTimeout($p(e),0)});var rv,nv,iv,ov,av,sv,cv,uv,dv={set:Gp,clear:Hp},lv=n,hv=/ipad|iphone|ipod/i.test(se)&&void 0!==lv.Pebble,pv=/web0s(?!.*chrome)/i.test(se),vv=n,fv=Yt,_v=A.f,mv=dv.set,yv=Cp,gv=hv,Sv=pv,bv=up,Ev=vv.MutationObserver||vv.WebKitMutationObserver,kv=vv.document,Tv=vv.process,Iv=vv.Promise,Rv=_v(vv,"queueMicrotask"),Av=Rv&&Rv.value;Av||(rv=function(){var e,t;for(bv&&(e=Tv.domain)&&e.exit();nv;){t=nv.fn,nv=nv.next;try{t()}catch(XW){throw nv?ov():iv=void 0,XW}}iv=void 0,e&&e.enter()},yv||bv||Sv||!Ev||!kv?!gv&&Iv&&Iv.resolve?((cv=Iv.resolve(void 0)).constructor=Iv,uv=fv(cv.then,cv),ov=function(){uv(rv)}):bv?ov=function(){Tv.nextTick(rv)}:(mv=fv(mv,vv),ov=function(){mv(rv)}):(av=!0,sv=kv.createTextNode(""),new Ev(rv).observe(sv,{characterData:!0}),ov=function(){sv.data=av=!av}));var wv=Av||function(e){var t={fn:e,next:void 0};iv&&(iv.next=t),nv||(nv=t,ov()),iv=t},Cv=n,xv=function(e){try{return{error:!1,value:e()}}catch(XW){return{error:!0,value:XW}}},Ov=function(){this.head=null,this.tail=null};Ov.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var Dv=Ov,Nv=n.Promise,Mv="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Pv=!Mv&&!up&&"object"==typeof window&&"object"==typeof document,Lv=n,Uv=Nv,Vv=R,Fv=Kt,Bv=io,jv=lt,Gv=Pv,Hv=Mv,zv=ve,Kv=Uv&&Uv.prototype,Xv=jv("species"),Wv=!1,qv=Vv(Lv.PromiseRejectionEvent),Yv={CONSTRUCTOR:Fv("Promise",(function(){var e=Bv(Uv),t=e!==String(Uv);if(!t&&66===zv)return!0;if(!Kv.catch||!Kv.finally)return!0;if(!zv||zv<51||!/native code/.test(e)){var r=new Uv((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[Xv]=n,!(Wv=r.then((function(){}))instanceof n))return!0}return!t&&(Gv||Hv)&&!qv})),REJECTION_EVENT:qv,SUBCLASSING:Wv},Jv={},Qv=Ce,Zv=TypeError,$v=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw Zv("Bad Promise constructor");t=e,r=n})),this.resolve=Qv(t),this.reject=Qv(r)};Jv.f=function(e){return new $v(e)};var ef,tf,rf=Ar,nf=up,of=n,af=O,sf=li,cf=Pi,uf=vp,df=Ce,lf=R,hf=$,pf=mp,vf=Rp,ff=dv.set,_f=wv,mf=function(e,t){var r=Cv.console;r&&r.error&&(1==arguments.length?r.error(e):r.error(e,t))},yf=xv,gf=Dv,Sf=Zi,bf=Nv,Ef=Yv,kf=Jv,Tf="Promise",If=Ef.CONSTRUCTOR,Rf=Ef.REJECTION_EVENT,Af=Sf.getterFor(Tf),wf=Sf.set,Cf=bf&&bf.prototype,xf=bf,Of=Cf,Df=of.TypeError,Nf=of.document,Mf=of.process,Pf=kf.f,Lf=Pf,Uf=!!(Nf&&Nf.createEvent&&of.dispatchEvent),Vf="unhandledrejection",Ff=function(e){var t;return!(!hf(e)||!lf(t=e.then))&&t},Bf=function(e,t){var r,n,i,o=t.value,a=1==t.state,s=a?e.ok:e.fail,c=e.resolve,u=e.reject,d=e.domain;try{s?(a||(2===t.rejection&&Kf(t),t.rejection=1),!0===s?r=o:(d&&d.enter(),r=s(o),d&&(d.exit(),i=!0)),r===e.promise?u(Df("Promise-chain cycle")):(n=Ff(r))?af(n,r,c,u):c(r)):u(o)}catch(XW){d&&!i&&d.exit(),u(XW)}},jf=function(e,t){e.notified||(e.notified=!0,_f((function(){for(var r,n=e.reactions;r=n.get();)Bf(r,e);e.notified=!1,t&&!e.rejection&&Hf(e)})))},Gf=function(e,t,r){var n,i;Uf?((n=Nf.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),of.dispatchEvent(n)):n={promise:t,reason:r},!Rf&&(i=of["on"+e])?i(n):e===Vf&&mf("Unhandled promise rejection",r)},Hf=function(e){af(ff,of,(function(){var t,r=e.facade,n=e.value;if(zf(e)&&(t=yf((function(){nf?Mf.emit("unhandledRejection",n,r):Gf(Vf,r,n)})),e.rejection=nf||zf(e)?2:1,t.error))throw t.value}))},zf=function(e){return 1!==e.rejection&&!e.parent},Kf=function(e){af(ff,of,(function(){var t=e.facade;nf?Mf.emit("rejectionHandled",t):Gf("rejectionhandled",t,e.value)}))},Xf=function(e,t,r){return function(n){e(t,n,r)}},Wf=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,jf(e,!0))},qf=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw Df("Promise can't be resolved itself");var n=Ff(t);n?_f((function(){var r={done:!1};try{af(n,t,Xf(qf,r,e),Xf(Wf,r,e))}catch(XW){Wf(r,XW,e)}})):(e.value=t,e.state=1,jf(e,!1))}catch(XW){Wf({done:!1},XW,e)}}};If&&(Of=(xf=function(e){pf(this,Of),df(e),af(ef,this);var t=Af(this);try{e(Xf(qf,t),Xf(Wf,t))}catch(XW){Wf(t,XW)}}).prototype,(ef=function(e){wf(this,{type:Tf,done:!1,notified:!1,parent:!1,reactions:new gf,rejection:!1,state:0,value:void 0})}).prototype=sf(Of,"then",(function(e,t){var r=Af(this),n=Pf(vf(this,xf));return r.parent=!0,n.ok=!lf(e)||e,n.fail=lf(t)&&t,n.domain=nf?Mf.domain:void 0,0==r.state?r.reactions.add(n):_f((function(){Bf(n,r)})),n.promise})),tf=function(){var e=new ef,t=Af(e);this.promise=e,this.resolve=Xf(qf,t),this.reject=Xf(Wf,t)},kf.f=Pf=function(e){return e===xf||undefined===e?new tf(e):Lf(e)}),rf({global:!0,constructor:!0,wrap:!0,forced:If},{Promise:xf}),cf(xf,Tf,!1,!0),uf(Tf);var Yf=lt("iterator"),Jf=!1;try{var Qf=0,Zf={next:function(){return{done:!!Qf++}},return:function(){Jf=!0}};Zf[Yf]=function(){return this},Array.from(Zf,(function(){throw 2}))}catch(XW){}var $f=function(e,t){if(!t&&!Jf)return!1;var r=!1;try{var n={};n[Yf]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(XW){}return r},e_=Nv,t_=Yv.CONSTRUCTOR||!$f((function(e){e_.all(e).then(void 0,(function(){}))})),r_=O,n_=Ce,i_=Jv,o_=xv,a_=Uh;Ar({target:"Promise",stat:!0,forced:t_},{all:function(e){var t=this,r=i_.f(t),n=r.resolve,i=r.reject,o=o_((function(){var r=n_(t.resolve),o=[],a=0,s=1;a_(e,(function(e){var c=a++,u=!1;s++,r_(r,t,e).then((function(e){u||(u=!0,o[c]=e,--s||n(o))}),i)})),--s||n(o)}));return o.error&&i(o.value),r.promise}});var s_=Ar,c_=Yv.CONSTRUCTOR;Nv&&Nv.prototype,s_({target:"Promise",proto:!0,forced:c_,real:!0},{catch:function(e){return this.then(void 0,e)}});var u_=O,d_=Ce,l_=Jv,h_=xv,p_=Uh;Ar({target:"Promise",stat:!0,forced:t_},{race:function(e){var t=this,r=l_.f(t),n=r.reject,i=h_((function(){var i=d_(t.resolve);p_(e,(function(e){u_(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var v_=O,f_=Jv;Ar({target:"Promise",stat:!0,forced:Yv.CONSTRUCTOR},{reject:function(e){var t=f_.f(this);return v_(t.reject,void 0,e),t.promise}});var __=tr,m_=$,y_=Jv,g_=function(e,t){if(__(e),m_(t)&&t.constructor===e)return t;var r=y_.f(e);return(0,r.resolve)(t),r.promise},S_=Ar,b_=Nv,E_=Yv.CONSTRUCTOR,k_=g_,T_=oe("Promise"),I_=!E_;S_({target:"Promise",stat:!0,forced:true},{resolve:function(e){return k_(I_&&this===T_?b_:this,e)}});var R_=O,A_=Ce,w_=Jv,C_=xv,x_=Uh;Ar({target:"Promise",stat:!0},{allSettled:function(e){var t=this,r=w_.f(t),n=r.resolve,i=r.reject,o=C_((function(){var r=A_(t.resolve),i=[],o=0,a=1;x_(e,(function(e){var s=o++,c=!1;a++,R_(r,t,e).then((function(e){c||(c=!0,i[s]={status:"fulfilled",value:e},--a||n(i))}),(function(e){c||(c=!0,i[s]={status:"rejected",reason:e},--a||n(i))}))})),--a||n(i)}));return o.error&&i(o.value),r.promise}});var O_=O,D_=Ce,N_=oe,M_=Jv,P_=xv,L_=Uh,U_="No one promise resolved";Ar({target:"Promise",stat:!0},{any:function(e){var t=this,r=N_("AggregateError"),n=M_.f(t),i=n.resolve,o=n.reject,a=P_((function(){var n=D_(t.resolve),a=[],s=0,c=1,u=!1;L_(e,(function(e){var d=s++,l=!1;c++,O_(n,t,e).then((function(e){l||u||(u=!0,i(e))}),(function(e){l||u||(l=!0,a[d]=e,--c||o(new r(a,U_)))}))})),--c||o(new r(a,U_))}));return a.error&&o(a.value),n.promise}});var V_=Ar,F_=Nv,B_=i,j_=oe,G_=R,H_=Rp,z_=g_,K_=F_&&F_.prototype;V_({target:"Promise",proto:!0,real:!0,forced:!!F_&&B_((function(){K_.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=H_(this,j_("Promise")),r=G_(e);return this.then(r?function(r){return z_(t,e()).then((function(){return r}))}:e,r?function(r){return z_(t,e()).then((function(){throw r}))}:e)}});var X_=ee.Promise,W_=Jv,q_=xv;Ar({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=W_.f(this),r=q_(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var Y_=X_,J_=Ar,Q_=eo,Z_=E([].reverse),$_=[1,2];J_({target:"Array",proto:!0,forced:String($_)===String($_.reverse())},{reverse:function(){return Q_(this)&&(this.length=this.length),Z_(this)}});var em=Us("Array").reverse,tm=ae,rm=em,nm=Array.prototype,im=function(e){var t=e.reverse;return e===nm||tm(nm,e)&&t===nm.reverse?rm:t},om=Ar,am=eo,sm=go,cm=$,um=Pr,dm=Br,lm=J,hm=Qn,pm=lt,vm=rs,fm=Ms("slice"),_m=pm("species"),mm=Array,ym=Math.max;om({target:"Array",proto:!0,forced:!fm},{slice:function(e,t){var r,n,i,o=lm(this),a=dm(o),s=um(e,a),c=um(void 0===t?a:t,a);if(am(o)&&(r=o.constructor,(sm(r)&&(r===mm||am(r.prototype))||cm(r)&&null===(r=r[_m]))&&(r=void 0),r===mm||void 0===r))return vm(o,s,c);for(n=new(void 0===r?mm:r)(ym(c-s,0)),i=0;s<c;s++,i++)s in o&&hm(n,i,o[s]);return n.length=i,n}});var gm=Us("Array").slice,Sm=ae,bm=gm,Em=Array.prototype,km=function(e){var t=e.slice;return e===Em||Sm(Em,e)&&t===Em.slice?bm:t};function Tm(){Tm=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=ad||function(e,t,r){e[t]=r.value},i="function"==typeof wd?wd:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(e,t,r){return ad(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(A){c=function(e,t,r){return e[t]=r}}function u(e,t,r,i){var o=t&&t.prototype instanceof h?t:h,a=Bl(o.prototype),s=new T(i||[]);return n(a,"_invoke",{value:S(e,r,s)}),a}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(A){return{type:"throw",arg:A}}}e.wrap=u;var l={};function h(){}function p(){}function v(){}var f={};c(f,o,(function(){return this}));var _=zl&&zl(zl(I([])));_&&_!==t&&r.call(_,o)&&(f=_);var m=v.prototype=h.prototype=Bl(f);function y(e){var t;Pu(t=["next","throw","return"]).call(t,(function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){function i(n,o,a,s){var c=d(e[n],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==Wd(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return i("throw",e,a,s)}))}s(c.arg)}var o;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}})}function S(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=b(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=d(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function b(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),l;var i=d(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,l;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],Pu(e).call(e,E,this),this.reset(!0)}function I(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:R}}function R(){return{value:void 0,done:!0}}return p.prototype=v,n(m,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:p,configurable:!0}),p.displayName=c(v,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Kl?Kl(e,v):(e.__proto__=v,c(e,s,"GeneratorFunction")),e.prototype=Bl(m),e},e.awrap=function(e){return{__await:e}},y(g.prototype),c(g.prototype,a,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,i,o){void 0===o&&(o=Y_);var a=new g(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},y(m),c(m,s,"Generator"),c(m,o,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return im(r).call(r),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=I,T.prototype={constructor:T,reset:function(e){var t;if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,Pu(t=this.tryEntries).call(t,k),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+km(n).call(n,1))&&(this[n]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),k(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;k(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function Im(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(XW){return void r(XW)}s.done?t(c):Y_.resolve(c).then(n,i)}function Rm(e){return function(){var t=this,r=arguments;return new Y_((function(n,i){var o=e.apply(t,r);function a(e){Im(o,n,i,a,s,"next",e)}function s(e){Im(o,n,i,a,s,"throw",e)}a(void 0)}))}}var Am=Us("Array").concat,wm=ae,Cm=Am,xm=Array.prototype,Om=function(e){var t=e.concat;return e===xm||wm(xm,e)&&t===xm.concat?Cm:t},Dm=ee,Nm=d;Dm.JSON||(Dm.JSON={stringify:JSON.stringify});var Mm=function(e,t,r){return Nm(Dm.JSON.stringify,null,arguments)},Pm=Mm,Lm=Mo.map;Ar({target:"Array",proto:!0,forced:!Ms("map")},{map:function(e){return Lm(this,e,arguments.length>1?arguments[1]:void 0)}});var Um=Us("Array").map,Vm=ae,Fm=Um,Bm=Array.prototype,jm=function(e){var t=e.map;return e===Bm||Vm(Bm,e)&&t===Bm.map?Fm:t},Gm="\t\n\v\f\r \u2028\u2029\ufeff",Hm=W,zm=yn,Km=E("".replace),Xm="[\t\n\v\f\r \u2028\u2029\ufeff]",Wm=RegExp("^"+Xm+Xm+"*"),qm=RegExp(Xm+Xm+"*$"),Ym=function(e){return function(t){var r=zm(Hm(t));return 1&e&&(r=Km(r,Wm,"")),2&e&&(r=Km(r,qm,"")),r}},Jm={start:Ym(1),end:Ym(2),trim:Ym(3)},Qm=n,Zm=i,$m=E,ey=yn,ty=Jm.trim,ry=Gm,ny=Qm.parseInt,iy=Qm.Symbol,oy=iy&&iy.iterator,ay=/^[+-]?0x/i,sy=$m(ay.exec),cy=8!==ny(ry+"08")||22!==ny(ry+"0x16")||oy&&!Zm((function(){ny(Object(oy))}))?function(e,t){var r=ty(ey(e));return ny(r,t>>>0||(sy(ay,r)?16:10))}:ny;Ar({global:!0,forced:parseInt!=cy},{parseInt:cy});var uy=ee.parseInt,dy={exports:{}},ly=i((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),hy=i,py=$,vy=g,fy=ly,_y=Object.isExtensible,my=hy((function(){_y(1)}))||fy?function(e){return!!py(e)&&((!fy||"ArrayBuffer"!=vy(e))&&(!_y||_y(e)))}:_y,yy=!i((function(){return Object.isExtensible(Object.preventExtensions({}))})),gy=Ar,Sy=E,by=Xr,Ey=$,ky=Ye,Ty=Jt.f,Iy=zn,Ry=Wn,Ay=my,wy=yy,Cy=!1,xy=et("meta"),Oy=0,Dy=function(e){Ty(e,xy,{value:{objectID:"O"+Oy++,weakData:{}}})},Ny=dy.exports={enable:function(){Ny.enable=function(){},Cy=!0;var e=Iy.f,t=Sy([].splice),r={};r[xy]=1,e(r).length&&(Iy.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===xy){t(n,i,1);break}return n},gy({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Ry.f}))},fastKey:function(e,t){if(!Ey(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!ky(e,xy)){if(!Ay(e))return"F";if(!t)return"E";Dy(e)}return e[xy].objectID},getWeakData:function(e,t){if(!ky(e,xy)){if(!Ay(e))return!0;if(!t)return!1;Dy(e)}return e[xy].weakData},onFreeze:function(e){return wy&&Cy&&Ay(e)&&!ky(e,xy)&&Dy(e),e}};by[xy]=!0;var My=Ar,Py=n,Ly=dy.exports,Uy=i,Vy=fr,Fy=Uh,By=mp,jy=R,Gy=$,Hy=Pi,zy=Jt.f,Ky=Mo.forEach,Xy=w,Wy=Zi.set,qy=Zi.getterFor,Yy=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=Py[e],c=s&&s.prototype,u={};if(Xy&&jy(s)&&(o||c.forEach&&!Uy((function(){(new s).entries().next()})))){var d=(n=t((function(t,r){Wy(By(t,d),{type:e,collection:new s}),null!=r&&Fy(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,l=qy(e);Ky(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in c)||o&&"clear"==e||Vy(d,e,(function(r,n){var i=l(this).collection;if(!t&&o&&!Gy(r))return"get"==e&&void 0;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||zy(d,"size",{configurable:!0,get:function(){return l(this).collection.size}})}else n=r.getConstructor(t,e,i,a),Ly.enable();return Hy(n,e,!1,!0),u[e]=n,My({global:!0,forced:!0},u),o||r.setStrong(n,e,i),n},Jy=li,Qy=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:Jy(e,n,t[n],r);return e},Zy=Jt.f,$y=Hn,eg=Qy,tg=Yt,rg=mp,ng=z,ig=Uh,og=iu,ag=ou,sg=vp,cg=w,ug=dy.exports.fastKey,dg=Zi.set,lg=Zi.getterFor,hg={getConstructor:function(e,t,r,n){var i=e((function(e,i){rg(e,o),dg(e,{type:t,index:$y(null),first:void 0,last:void 0,size:0}),cg||(e.size=0),ng(i)||ig(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=lg(t),s=function(e,t,r){var n,i,o=a(e),s=c(e,t);return s?s.value=r:(o.last=s={index:i=ug(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),cg?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var r,n=a(e),i=ug(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key==t)return r};return eg(o,{clear:function(){for(var e=a(this),t=e.index,r=e.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=void 0),delete t[r.index],r=r.next;e.first=e.last=void 0,cg?e.size=0:this.size=0},delete:function(e){var t=this,r=a(t),n=c(t,e);if(n){var i=n.next,o=n.previous;delete r.index[n.index],n.removed=!0,o&&(o.next=i),i&&(i.previous=o),r.first==n&&(r.first=i),r.last==n&&(r.last=o),cg?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=tg(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:r.first;)for(n(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!c(this,e)}}),eg(o,r?{get:function(e){var t=c(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),cg&&Zy(o,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=lg(t),o=lg(n);og(e,t,(function(e,t){dg(this,{type:n,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=o(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;return e.target&&(e.last=r=r?r.next:e.state.first)?ag("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,ag(void 0,!0))}),r?"entries":"values",!r,!0),sg(t)}};Yy("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),hg);var pg=ee.Map,vg=Yt,fg=O,_g=Ce,mg=bp,yg=z,gg=Uh,Sg=[].push,bg=function(e){var t,r,n,i,o=arguments.length,a=o>1?arguments[1]:void 0;return mg(this),(t=void 0!==a)&&_g(a),yg(e)?new this:(r=[],t?(n=0,i=vg(a,o>2?arguments[2]:void 0),gg(e,(function(e){fg(Sg,r,i(e,n++))}))):gg(e,Sg,{that:r}),new this(r))};Ar({target:"Map",stat:!0,forced:!0},{from:bg});var Eg=rs,kg=function(){return new this(Eg(arguments))};Ar({target:"Map",stat:!0,forced:!0},{of:kg});var Tg=O,Ig=Ce,Rg=tr,Ag=function(){for(var e,t=Rg(this),r=Ig(t.delete),n=!0,i=0,o=arguments.length;i<o;i++)e=Tg(r,t,arguments[i]),n=n&&e;return!!n};Ar({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:Ag});var wg=O,Cg=Ce,xg=tr,Og=function(e,t){var r,n,i=xg(this),o=Cg(i.get),a=Cg(i.has),s=Cg(i.set);return wg(a,i,e)?(r=wg(o,i,e),"update"in t&&(r=t.update(r,e,i),wg(s,i,e,r)),r):(n=t.insert(e,i),wg(s,i,e,n),n)};Ar({target:"Map",proto:!0,real:!0,forced:!0},{emplace:Og});var Dg=gh,Ng=tr,Mg=Yt,Pg=Dg,Lg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=Ng(this),r=Pg(t),n=Mg(e,arguments.length>1?arguments[1]:void 0);return!Lg(r,(function(e,r,i){if(!n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var Ug=oe,Vg=Yt,Fg=O,Bg=Ce,jg=tr,Gg=Rp,Hg=Dg,zg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=jg(this),r=Hg(t),n=Vg(e,arguments.length>1?arguments[1]:void 0),i=new(Gg(t,Ug("Map"))),o=Bg(i.set);return zg(r,(function(e,r){n(r,e,t)&&Fg(o,i,e,r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var Kg=tr,Xg=Yt,Wg=Dg,qg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=Kg(this),r=Wg(t),n=Xg(e,arguments.length>1?arguments[1]:void 0);return qg(r,(function(e,r,i){if(n(r,e,t))return i(r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var Yg=tr,Jg=Yt,Qg=Dg,Zg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=Yg(this),r=Qg(t),n=Jg(e,arguments.length>1?arguments[1]:void 0);return Zg(r,(function(e,r,i){if(n(r,e,t))return i(e)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var $g=Ar,eS=O,tS=Ce,rS=gh,nS=Uh,iS=E([].push);$g({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){tS(t);var r=rS(e),n=new this,i=tS(n.has),o=tS(n.get),a=tS(n.set);return nS(r,(function(e){var r=t(e);eS(i,n,r)?iS(eS(o,n,r),e):eS(a,n,r,[e])}),{IS_ITERATOR:!0}),n}});var oS=tr,aS=Dg,sS=function(e,t){return e===t||e!=e&&t!=t},cS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return cS(aS(oS(this)),(function(t,r,n){if(sS(r,e))return n()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var uS=O,dS=Uh,lS=Ce;Ar({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new this;lS(t);var n=lS(r.set);return dS(e,(function(e){uS(n,r,t(e),e)})),r}});var hS=tr,pS=Dg,vS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){return vS(pS(hS(this)),(function(t,r,n){if(r===e)return n(t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var fS=oe,_S=Yt,mS=O,yS=Ce,gS=tr,SS=Rp,bS=Dg,ES=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=gS(this),r=bS(t),n=_S(e,arguments.length>1?arguments[1]:void 0),i=new(SS(t,fS("Map"))),o=yS(i.set);return ES(r,(function(e,r){mS(o,i,n(r,e,t),r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var kS=oe,TS=Yt,IS=O,RS=Ce,AS=tr,wS=Rp,CS=Dg,xS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=AS(this),r=CS(t),n=TS(e,arguments.length>1?arguments[1]:void 0),i=new(wS(t,kS("Map"))),o=RS(i.set);return xS(r,(function(e,r){IS(o,i,e,n(r,e,t))}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var OS=Ce,DS=tr,NS=Uh;Ar({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=DS(this),r=OS(t.set),n=arguments.length,i=0;i<n;)NS(arguments[i++],r,{that:t,AS_ENTRIES:!0});return t}});var MS=tr,PS=Ce,LS=Dg,US=Uh,VS=TypeError;Ar({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=MS(this),r=LS(t),n=arguments.length<2,i=n?void 0:arguments[1];if(PS(e),US(r,(function(r,o){n?(n=!1,i=o):i=e(i,o,r,t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),n)throw VS("Reduce of empty map with no initial value");return i}});var FS=tr,BS=Yt,jS=Dg,GS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=FS(this),r=jS(t),n=BS(e,arguments.length>1?arguments[1]:void 0);return GS(r,(function(e,r,i){if(n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var HS=O,zS=tr,KS=Ce,XS=TypeError;Ar({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=zS(this),n=KS(r.get),i=KS(r.has),o=KS(r.set),a=arguments.length;KS(t);var s=HS(i,r,e);if(!s&&a<3)throw XS("Updating absent value");var c=s?HS(n,r,e):KS(a>2?arguments[2]:void 0)(e,r);return HS(o,r,e,t(c,e,r)),r}});var WS=O,qS=Ce,YS=R,JS=tr,QS=TypeError,ZS=function(e,t){var r,n=JS(this),i=qS(n.get),o=qS(n.has),a=qS(n.set),s=arguments.length>2?arguments[2]:void 0;if(!YS(t)&&!YS(s))throw QS("At least one callback required");return WS(o,n,e)?(r=WS(i,n,e),YS(t)&&(r=t(r),WS(a,n,e,r))):YS(s)&&(r=s(),WS(a,n,e,r)),r};Ar({target:"Map",proto:!0,real:!0,forced:!0},{upsert:ZS}),Ar({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:ZS});var $S=pg,eb=Ce,tb=Xe,rb=H,nb=Br,ib=TypeError,ob=function(e){return function(t,r,n,i){eb(r);var o=tb(t),a=rb(o),s=nb(o),c=e?s-1:0,u=e?-1:1;if(n<2)for(;;){if(c in a){i=a[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw ib("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=u)c in a&&(i=r(i,a[c],c,o));return i}},ab={left:ob(!1),right:ob(!0)}.left,sb=ve,cb=up;Ar({target:"Array",proto:!0,forced:!Iu("reduce")||!cb&&sb>79&&sb<83},{reduce:function(e){var t=arguments.length;return ab(this,e,t,t>1?arguments[1]:void 0)}});var ub=Us("Array").reduce,db=ae,lb=ub,hb=Array.prototype,pb=function(e){var t=e.reduce;return e===hb||db(hb,e)&&t===hb.reduce?lb:t},vb=w,fb=E,_b=O,mb=i,yb=rn,gb=ui,Sb=D,bb=Xe,Eb=H,kb=Object.assign,Tb=Object.defineProperty,Ib=fb([].concat),Rb=!kb||mb((function(){if(vb&&1!==kb({b:1},kb(Tb({},"a",{enumerable:!0,get:function(){Tb(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!=kb({},e)[r]||yb(kb({},t)).join("")!=n}))?function(e,t){for(var r=bb(e),n=arguments.length,i=1,o=gb.f,a=Sb.f;n>i;)for(var s,c=Eb(arguments[i++]),u=o?Ib(yb(c),o(c)):yb(c),d=u.length,l=0;d>l;)s=u[l++],vb&&!_b(a,c,s)||(r[s]=c[s]);return r}:kb,Ab=Rb;Ar({target:"Object",stat:!0,arity:2,forced:Object.assign!==Ab},{assign:Ab});var wb=ee.Object.assign,Cb=$,xb=g,Ob=lt("match"),Db=function(e){var t;return Cb(e)&&(void 0!==(t=e[Ob])?!!t:"RegExp"==xb(e))},Nb=TypeError,Mb=function(e){if(Db(e))throw Nb("The method doesn't accept regular expressions");return e},Pb=lt("match"),Lb=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[Pb]=!1,"/./"[e](t)}catch(n){}}return!1},Ub=Ar,Vb=E;A.f;var Fb=Vr,Bb=yn,jb=Mb,Gb=W,Hb=Lb,zb=Vb("".endsWith),Kb=Vb("".slice),Xb=Math.min;Ub({target:"String",proto:!0,forced:!Hb("endsWith")},{endsWith:function(e){var t=Bb(Gb(this));jb(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:Xb(Fb(r),n),o=Bb(e);return zb?zb(t,o,i):Kb(t,i-o.length,i)===o}});var Wb=Us("String").endsWith,qb=ae,Yb=Wb,Jb=String.prototype,Qb=function(e){var t=e.endsWith;return"string"==typeof e||e===Jb||qb(Jb,e)&&t===Jb.endsWith?Yb:t},Zb=!0,$b=!0;function eE(e,t,r){var n=e.match(t);return n&&n.length>=r&&uy(n[r],10)}function tE(e,t,r){if(e.RTCPeerConnection){var n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return i.apply(this,arguments);var o=function(e){var t=r(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new $S),this._eventMap[t].set(n,o),i.apply(this,[e,o])};var o=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(r))return o.apply(this,arguments);var n=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===an(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},ad(n,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}}function rE(e){return"boolean"!=typeof e?new Error("Argument type: "+Wd(e)+". Please use a boolean."):(Zb=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function nE(e){return"boolean"!=typeof e?new Error("Argument type: "+Wd(e)+". Please use a boolean."):($b=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function iE(){if("object"===("undefined"==typeof window?"undefined":Wd(window))){if(Zb)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function oE(e,t){$b&&console.warn(e+" is deprecated, please use "+t+" instead.")}function aE(e){var t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;var r=e.navigator;if(r.mozGetUserMedia)t.browser="firefox",t.version=eE(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=eE(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=eE(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}function sE(e){return"[object Object]"===Object.prototype.toString.call(e)}function cE(e){var t;return sE(e)?pb(t=an(e)).call(t,(function(t,r){var n=sE(e[r]),i=n?cE(e[r]):e[r],o=n&&!an(i).length;return void 0===i||o?t:wb(t,Jd({},r,i))}),{}):e}function uE(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),an(t).forEach((function(n){Qb(n).call(n,"Id")?uE(e,e.get(t[n]),r):Qb(n).call(n,"Ids")&&t[n].forEach((function(t){uE(e,e.get(t),r)}))})))}function dE(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new $S;if(null===t)return i;var o=[];return e.forEach((function(e){"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((function(t){e.forEach((function(r){r.type===n&&r.trackId===t.id&&uE(e,r,i)}))})),i}var lE=Ar,hE=Mo.find,pE="find",vE=!0;pE in[]&&Array(1).find((function(){vE=!1})),lE({target:"Array",proto:!0,forced:vE},{find:function(e){return hE(this,e,arguments.length>1?arguments[1]:void 0)}});var fE=Us("Array").find,_E=ae,mE=fE,yE=Array.prototype,gE=function(e){var t=e.find;return e===yE||_E(yE,e)&&t===yE.find?mE:t},SE=Ar,bE=Kr.indexOf,EE=Iu,kE=E([].indexOf),TE=!!kE&&1/kE([1],1,-0)<0,IE=EE("indexOf");SE({target:"Array",proto:!0,forced:TE||!IE},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return TE?kE(this,e,t)||0:bE(this,e,t)}});var RE=Us("Array").indexOf,AE=ae,wE=RE,CE=Array.prototype,xE=function(e){var t=e.indexOf;return e===CE||AE(CE,e)&&t===CE.indexOf?wE:t},OE=w,DE=eo,NE=TypeError,ME=Object.getOwnPropertyDescriptor,PE=OE&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(XW){return XW instanceof TypeError}}(),LE=Ie,UE=TypeError,VE=function(e,t){if(!delete e[t])throw UE("Cannot delete property "+LE(t)+" of "+LE(e))},FE=Ar,BE=Xe,jE=Pr,GE=Or,HE=Br,zE=PE?function(e,t){if(DE(e)&&!ME(e,"length").writable)throw NE("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},KE=cd,XE=Ro,WE=Qn,qE=VE,YE=Ms("splice"),JE=Math.max,QE=Math.min;FE({target:"Array",proto:!0,forced:!YE},{splice:function(e,t){var r,n,i,o,a,s,c=BE(this),u=HE(c),d=jE(e,u),l=arguments.length;for(0===l?r=n=0:1===l?(r=0,n=u-d):(r=l-2,n=QE(JE(GE(t),0),u-d)),KE(u+r-n),i=XE(c,n),o=0;o<n;o++)(a=d+o)in c&&WE(i,o,c[a]);if(i.length=n,r<n){for(o=d;o<u-n;o++)s=o+r,(a=o+n)in c?c[s]=c[a]:qE(c,s);for(o=u;o>u-n+r;o--)qE(c,o-1)}else if(r>n)for(o=u-n;o>d;o--)s=o+r-1,(a=o+n-1)in c?c[s]=c[a]:qE(c,s);for(o=0;o<r;o++)c[o+d]=arguments[o+2];return zE(c,u-n+r),i}});var ZE=Us("Array").splice,$E=ae,ek=ZE,tk=Array.prototype,rk=function(e){var t=e.splice;return e===tk||$E(tk,e)&&t===tk.splice?ek:t},nk=Kr.includes;Ar({target:"Array",proto:!0,forced:i((function(){return!Array(1).includes()}))},{includes:function(e){return nk(this,e,arguments.length>1?arguments[1]:void 0)}});var ik=Us("Array").includes,ok=Ar,ak=Mb,sk=W,ck=yn,uk=Lb,dk=E("".indexOf);ok({target:"String",proto:!0,forced:!uk("includes")},{includes:function(e){return!!~dk(ck(sk(this)),ck(ak(e)),arguments.length>1?arguments[1]:void 0)}});var lk=Us("String").includes,hk=ae,pk=ik,vk=lk,fk=Array.prototype,_k=String.prototype,mk=function(e){var t=e.includes;return e===fk||hk(fk,e)&&t===fk.includes?pk:"string"==typeof e||e===_k||hk(_k,e)&&t===_k.includes?vk:t},yk=iE;function gk(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==Wd(e)||e.mandatory||e.optional)return e;var t,r={};(an(e).forEach((function(t){if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var n="object"===Wd(e[t])?e[t]:{ideal:e[t]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+km(t).call(t,1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){r.optional=r.optional||[];var o={};"number"==typeof n.ideal?(o[i("min",t)]=n.ideal,r.optional.push(o),(o={})[i("max",t)]=n.ideal,r.optional.push(o)):(o[i("",t)]=n.ideal,r.optional.push(o))}void 0!==n.exact&&"number"!=typeof n.exact?(r.mandatory=r.mandatory||{},r.mandatory[i("",t)]=n.exact):["min","max"].forEach((function(e){void 0!==n[e]&&(r.mandatory=r.mandatory||{},r.mandatory[i(e,t)]=n[e])}))}})),e.advanced)&&(r.optional=Om(t=r.optional||[]).call(t,e.advanced));return r},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(Pm(e)))&&"object"===Wd(e.audio)){var o=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};o((e=JSON.parse(Pm(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===Wd(e.video)){var a=e.video.facingMode;a=a&&("object"===Wd(a)?a:{ideal:a});var s,c=t.version<66;if(a&&("user"===a.exact||"environment"===a.exact||"user"===a.ideal||"environment"===a.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||c))if(delete e.video.facingMode,"environment"===a.exact||"environment"===a.ideal?s=["back","rear"]:"user"!==a.exact&&"user"!==a.ideal||(s=["front"]),s)return r.mediaDevices.enumerateDevices().then((function(t){t=Gs(t).call(t,(function(e){return"videoinput"===e.kind}));var r=gE(t).call(t,(function(e){return s.some((function(t){var r;return mk(r=e.label.toLowerCase()).call(r,t)}))}));return!r&&t.length&&mk(s).call(s,"back")&&(r=t[t.length-1]),r&&(e.video.deviceId=a.exact?{exact:r.deviceId}:{ideal:r.deviceId}),e.video=n(e.video),yk("chrome: "+Pm(e)),i(e)}));e.video=n(e.video)}return yk("chrome: "+Pm(e)),i(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};if(r.getUserMedia=function(e,t,n){i(e,(function(e){r.webkitGetUserMedia(e,t,(function(e){n&&n(o(e))}))}))}.bind(r),r.mediaDevices.getUserMedia){var a=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(e){return i(e,(function(e){return a(e).then((function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach((function(e){e.stop()})),new DOMException("","NotFoundError");return t}),(function(e){return Y_.reject(o(e))}))}))}}}}function Sk(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function bk(e){if("object"===Wd(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){ad(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var r=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",(function(n){var i,o;e.RTCPeerConnection.prototype.getReceivers?i=gE(o=r.getReceivers()).call(o,(function(e){return e.track&&e.track.id===n.track.id})):i={track:n.track};var a=new Event("track");a.track=n.track,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)})),t.stream.getTracks().forEach((function(n){var i,o;e.RTCPeerConnection.prototype.getReceivers?i=gE(o=r.getReceivers()).call(o,(function(e){return e.track&&e.track.id===n.id})):i={track:n};var a=new Event("track");a.track=n,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else tE(e,"track",(function(e){return e.transceiver||ad(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function Ek(e){if("object"===Wd(e)&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){var e;return this._senders=this._senders||[],km(e=this._senders).call(e)};var r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){var i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t;n.apply(this,arguments);var r,i=xE(t=this._senders).call(t,e);-1!==i&&rk(r=this._senders).call(r,i,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((function(e){r._senders.push(t(r,e))}))};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach((function(e){var r,n,i,o=gE(r=t._senders).call(r,(function(t){return t.track===e}));o&&rk(n=t._senders).call(n,xE(i=t._senders).call(i,o),1)}))}}else if("object"===Wd(e)&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var a=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=a.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t},ad(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function kk(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=km(Array.prototype).call(arguments),n=r[0],i=r[1],o=r[2];if(arguments.length>0&&"function"==typeof n)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof n))return t.apply(this,[]);var a=function(e){var t={};return e.result().forEach((function(e){var r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((function(t){r[t]=e.stat(t)})),t[r.id]=r})),t},s=function(e){var t;return new $S(jm(t=an(e)).call(t,(function(t){return[t,e[t]]})))};if(arguments.length>=2){var c=function(e){i(s(a(e)))};return t.apply(this,[c,n])}return new Y_((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function Tk(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return dE(t,e.track,!0)}))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var n=e.RTCPeerConnection.prototype.getReceivers;n&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=n.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t}),tE(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return dE(t,e.track,!1)}))}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t,r,n,o=arguments[0];return this.getSenders().forEach((function(e){e.track===o&&(t?n=!0:t=e)})),this.getReceivers().forEach((function(e){return e.track===o&&(r?n=!0:r=e),e.track===o})),n||t&&r?Y_.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Y_.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function Ik(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e,t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},jm(e=an(this._shimmedLocalStreams)).call(e,(function(e){return t._shimmedLocalStreams[e][0]}))};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var n;if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var i=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===xE(n=this._shimmedLocalStreams[r.id]).call(n,i)&&this._shimmedLocalStreams[r.id].push(i):this._shimmedLocalStreams[r.id]=[r,i],i};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t,n,i=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((function(e){var t;if(gE(t=i.getSenders()).call(t,(function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")}));var o=this.getSenders();r.apply(this,arguments);var a=Gs(t=this.getSenders()).call(t,(function(e){return-1===xE(o).call(o,e)}));this._shimmedLocalStreams[e.id]=Om(n=[e]).call(n,a)};var n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&an(this._shimmedLocalStreams).forEach((function(r){var n,i,o=xE(n=t._shimmedLocalStreams[r]).call(n,e);-1!==o&&rk(i=t._shimmedLocalStreams[r]).call(i,o,1);1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function Rk(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Ik(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},jm(t).call(t,(function(t){return e._reverseStreams[t.id]}))};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((function(e){var t;if(gE(t=r.getSenders()).call(t,(function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,r){var n,i,o,a=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var s=km([]).call(arguments,1);if(1!==s.length||!gE(n=s[0].getTracks()).call(n,(function(e){return e===t})))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var c=gE(i=this.getSenders()).call(i,(function(e){return e.track===t}));if(c)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var u=this._streams[r.id];if(u)u.addTrack(t),Y_.resolve().then((function(){a.dispatchEvent(new Event("negotiationneeded"))}));else{var d=new e.MediaStream([t]);this._streams[r.id]=d,this._reverseStreams[d.id]=r,this.addStream(d)}return gE(o=this.getSenders()).call(o,(function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){var e=this,t=arguments,n=arguments.length&&"function"==typeof arguments[0];return n?r.apply(this,[function(r){var n=s(e,r);t[0].apply(null,[n])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):r.apply(this,arguments).then((function(t){return s(e,t)}))}));e.RTCPeerConnection.prototype[t]=n[t]}));var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=c(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};var a=tc(e.RTCPeerConnection.prototype,"localDescription");ad(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=a.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t,r=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{},an(this._streams).forEach((function(n){var i;gE(i=r._streams[n].getTracks()).call(i,(function(t){return e.track===t}))&&(t=r._streams[n])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function s(e,t){var r=t.sdp;return an(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:r})}function c(e,t){var r=t.sdp;return an(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:r})}}function Ak(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}))}function wk(e,t){tE(e,"negotiationneeded",(function(e){var r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e}))}var Ck=Object.freeze(Object.defineProperty({__proto__:null,shimMediaStream:Sk,shimOnTrack:bk,shimGetSendersWithDtmf:Ek,shimGetStats:kk,shimSenderReceiverGetStats:Tk,shimAddTrackRemoveTrackWithNative:Ik,shimAddTrackRemoveTrack:Rk,shimPeerConnection:Ak,fixNegotiationNeeded:wk,shimGetUserMedia:gk,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then((function(t){var n=r.video&&r.video.width,i=r.video&&r.video.height,o=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}},Symbol.toStringTag,{value:"Module"}));Ar({target:"Array",stat:!0},{isArray:eo});var xk=ee.Array.isArray;function Ok(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Dk=hh,Nk=tr,Mk=kh,Pk=Yt,Lk=O,Uk=Xe,Vk=function(e,t,r,n){try{return n?t(Nk(r)[0],r[1]):t(r)}catch(XW){Mk(e,"throw",XW)}},Fk=ah,Bk=go,jk=Br,Gk=Qn,Hk=gh,zk=hh,Kk=Array,Xk=function(e){var t=Uk(e),r=Bk(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=Pk(i,n>2?arguments[2]:void 0));var a,s,c,u,d,l,h=zk(t),p=0;if(!h||this===Kk&&Fk(h))for(a=jk(t),s=r?new this(a):Kk(a);a>p;p++)l=o?i(t[p],p):t[p],Gk(s,p,l);else for(d=(u=Hk(t,h)).next,s=r?new this:[];!(c=Lk(d,u)).done;p++)l=o?Vk(u,i,[c.value,p],!0):c.value,Gk(s,p,l);return s.length=p,s},Wk=Xk;Ar({target:"Array",stat:!0,forced:!$f((function(e){Array.from(e)}))},{from:Wk});var qk=ee.Array.from;function Yk(e,t){var r;if(e){if("string"==typeof e)return Ok(e,t);var n=km(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?qk(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ok(e,t):void 0}}function Jk(e){return function(e){if(xk(e))return Ok(e)}(e)||function(e){if(void 0!==wd&&null!=Dk(e)||null!=e["@@iterator"])return qk(e)}(e)||Yk(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var Qk=n,Zk=i,$k=yn,eT=Jm.trim,tT=E("".charAt),rT=Qk.parseFloat,nT=Qk.Symbol,iT=nT&&nT.iterator,oT=1/rT("\t\n\v\f\r \u2028\u2029\ufeff-0")!=-1/0||iT&&!Zk((function(){rT(Object(iT))}))?function(e){var t=eT($k(e)),r=rT(t);return 0===r&&"-"==tT(t,0)?-0:r}:rT;Ar({global:!0,forced:parseFloat!=oT},{parseFloat:oT});var aT=ee.parseFloat;function sT(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){oE("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var i=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},o=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(e){return"object"===Wd(e)&&"object"===Wd(e.audio)&&(e=JSON.parse(Pm(e)),i(e.audio,"autoGainControl","mozAutoGainControl"),i(e.audio,"noiseSuppression","mozNoiseSuppression")),o(e)},n&&n.prototype.getSettings){var a=n.prototype.getSettings;n.prototype.getSettings=function(){var e=a.apply(this,arguments);return i(e,"mozAutoGainControl","autoGainControl"),i(e,"mozNoiseSuppression","noiseSuppression"),e}}if(n&&n.prototype.applyConstraints){var s=n.prototype.applyConstraints;n.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===Wd(e)&&(e=JSON.parse(Pm(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function cT(e){"object"===Wd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&ad(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function uT(e,t){if("object"===Wd(e)&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}));var r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=km(Array.prototype).call(arguments),i=e[0],o=e[1],a=e[2];return n.apply(this,[i||null]).then((function(e){if(t.version<53&&!o)try{e.forEach((function(e){e.type=r[e.type]||e.type}))}catch(n){if("TypeError"!==n.name)throw n;e.forEach((function(t,n){e.set(n,wb({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function dT(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpSender.prototype))){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Y_.resolve(new $S)}}}function lT(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpReceiver.prototype))){var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r}),tE(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function hT(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;oE("removeStream","removeTrack"),this.getSenders().forEach((function(r){var n;r.track&&mk(n=e.getTracks()).call(n,r.track)&&t.removeTrack(r)}))})}function pT(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function vT(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]);var r=(e=Jk(e)).length>0;r&&e.forEach((function(e){if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(aT(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(aT(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));var n=t.apply(this,arguments);if(r){var i=n.sender,o=i.getParameters();(!("encodings"in o)||1===o.encodings.length&&0===an(o.encodings[0]).length)&&(o.encodings=e,i.sendEncodings=e,this.setParametersPromises.push(i.setParameters(o).then((function(){delete i.sendEncodings})).catch((function(){delete i.sendEncodings}))))}return n})}}function fT(e){if("object"===Wd(e)&&e.RTCRtpSender){var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e,r=t.apply(this,arguments);"encodings"in r||(r.encodings=Om(e=[]).call(e,this.sendEncodings||[{}]));return r})}}function _T(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Y_.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function mT(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Y_.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var yT=Object.freeze(Object.defineProperty({__proto__:null,shimOnTrack:cT,shimPeerConnection:uT,shimSenderGetStats:dT,shimReceiverGetStats:lT,shimRemoveStream:hT,shimRTCDataChannel:pT,shimAddTransceiver:vT,shimGetParameters:fT,shimCreateOffer:_T,shimCreateAnswer:mT,shimGetUserMedia:sT,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){var n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Y_.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}},Symbol.toStringTag,{value:"Module"}));function gT(e){if("object"===Wd(e)&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var r,n=this;this._localStreams||(this._localStreams=[]),mk(r=this._localStreams).call(r,e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(r){return t.call(n,r,e)})),e.getVideoTracks().forEach((function(r){return t.call(n,r,e)}))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var r=this,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return i&&i.forEach((function(e){var t;r._localStreams?mk(t=r._localStreams).call(t,e)||r._localStreams.push(e):r._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t,r,n=this;this._localStreams||(this._localStreams=[]);var i=xE(t=this._localStreams).call(t,e);if(-1!==i){rk(r=this._localStreams).call(r,i,1);var o=e.getTracks();this.getSenders().forEach((function(e){mk(o).call(o,e.track)&&n.removeTrack(e)}))}})}}function ST(e){if("object"===Wd(e)&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){ad(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){var t=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach((function(e){var r;if(t._remoteStreams||(t._remoteStreams=[]),!mk(r=t._remoteStreams).call(r,e)){t._remoteStreams.push(e);var n=new Event("addstream");n.stream=e,t.dispatchEvent(n)}}))})}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((function(t){var r;if(e._remoteStreams||(e._remoteStreams=[]),!(xE(r=e._remoteStreams).call(r,t)>=0)){e._remoteStreams.push(t);var n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}}))}),t.apply(e,arguments)}}}function bT(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Y_.resolve()):i},t.createAnswer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Y_.resolve()):i};var s=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),Y_.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Y_.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),Y_.resolve()):n},t.addIceCandidate=s}}function ET(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices,n=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(e){return n(kT(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function kT(e){return e&&void 0!==e.video?wb({},e,{video:cE(e.video)}):e}function TT(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){for(var n=[],i=0;i<e.iceServers.length;i++){var o=e.iceServers[i];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(oE("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(Pm(o))).urls=o.url,delete o.url,n.push(o)):n.push(e.iceServers[i])}e.iceServers=n}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&ad(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function IT(e){"object"===Wd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&ad(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function RT(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){var r,n;void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var i=gE(r=this.getTransceivers()).call(r,(function(e){return"audio"===e.receiver.track.kind}));!1===e.offerToReceiveAudio&&i?"sendrecv"===i.direction?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":"recvonly"===i.direction&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):!0!==e.offerToReceiveAudio||i||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var o=gE(n=this.getTransceivers()).call(n,(function(e){return"video"===e.receiver.track.kind}));!1===e.offerToReceiveVideo&&o?"sendrecv"===o.direction?o.setDirection?o.setDirection("sendonly"):o.direction="sendonly":"recvonly"===o.direction&&(o.setDirection?o.setDirection("inactive"):o.direction="inactive"):!0!==e.offerToReceiveVideo||o||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function AT(e){"object"!==Wd(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var wT=Object.freeze(Object.defineProperty({__proto__:null,shimLocalStreamsAPI:gT,shimRemoteStreamsAPI:ST,shimCallbacksAPI:bT,shimGetUserMedia:ET,shimConstraints:kT,shimRTCIceServerUrls:TT,shimTrackEventTransceiver:IT,shimCreateOfferLegacy:RT,shimAudioContext:AT},Symbol.toStringTag,{value:"Module"})),CT=cc.PROPER,xT=i,OT=Gm,DT=Jm.trim;Ar({target:"String",proto:!0,forced:function(e){return xT((function(){return!!OT[e]()||"
"!=="
"[e]()||CT&&OT[e].name!==e}))}("trim")},{trim:function(){return DT(this)}});var NT,MT,PT=Us("String").trim,LT=ae,UT=PT,VT=String.prototype,FT=function(e){var t=e.trim;return"string"==typeof e||e===VT||LT(VT,e)&&t===VT.trim?UT:t},BT={exports:{}};NT=BT,(MT={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}}).localCName=MT.generateIdentifier(),MT.splitLines=function(e){var t;return jm(t=FT(e).call(e).split("\n")).call(t,(function(e){return FT(e).call(e)}))},MT.splitSections=function(e){var t=e.split("\nm=");return jm(t).call(t,(function(e,t){var r;return FT(r=t>0?"m="+e:e).call(r)+"\r\n"}))},MT.getDescription=function(e){var t=MT.splitSections(e);return t&&t[0]},MT.getMediaSections=function(e){var t=MT.splitSections(e);return t.shift(),t},MT.matchPrefix=function(e,t){var r;return Gs(r=MT.splitLines(e)).call(r,(function(e){return 0===xE(e).call(e,t)}))},MT.parseCandidate=function(e){for(var t,r={foundation:(t=0===xE(e).call(e,"a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:uy(t[3],10),ip:t[4],address:t[4],port:uy(t[5],10),type:t[7]},n=8;n<t.length;n+=2)switch(t[n]){case"raddr":r.relatedAddress=t[n+1];break;case"rport":r.relatedPort=uy(t[n+1],10);break;case"tcptype":r.tcpType=t[n+1];break;case"ufrag":r.ufrag=t[n+1],r.usernameFragment=t[n+1];break;default:void 0===r[t[n]]&&(r[t[n]]=t[n+1])}return r},MT.writeCandidate=function(e){var t=[];t.push(e.foundation);var r=e.component;"rtp"===r?t.push(1):"rtcp"===r?t.push(2):t.push(r),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},MT.parseIceOptions=function(e){return e.substr(14).split(" ")},MT.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:uy(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=uy(t[1],10),r.channels=3===t.length?uy(t[2],10):1,r.numChannels=r.channels,r},MT.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==r?"/"+r:"")+"\r\n"},MT.parseExtmap=function(e){var t,r=e.substr(9).split(" ");return{id:uy(r[0],10),direction:xE(t=r[0]).call(t,"/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},MT.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},MT.parseFmtp=function(e){for(var t,r={},n=e.substr(xE(e).call(e," ")+1).split(";"),i=0;i<n.length;i++){var o,a;t=FT(o=n[i]).call(o).split("="),r[FT(a=t[0]).call(a)]=t[1]}return r},MT.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&an(e.parameters).length){var n=[];an(e.parameters).forEach((function(t){void 0!==e.parameters[t]?n.push(t+"="+e.parameters[t]):n.push(t)})),t+="a=fmtp:"+r+" "+n.join(";")+"\r\n"}return t},MT.parseRtcpFb=function(e){var t=e.substr(xE(e).call(e," ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},MT.writeRtcpFb=function(e){var t="",r=e.payloadType;return void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+r+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},MT.parseSsrcMedia=function(e){var t=xE(e).call(e," "),r={ssrc:uy(e.substr(7,t-7),10)},n=xE(e).call(e,":",t);return n>-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},MT.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:jm(t).call(t,(function(e){return uy(e,10)}))}},MT.getMid=function(e){var t=MT.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},MT.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},MT.getDtlsParameters=function(e,t){var r=MT.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:jm(r).call(r,MT.parseFingerprint)}},MT.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),r},MT.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:uy(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:km(t).call(t,3)}},MT.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===Wd(e.keyParams)?MT.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},MT.parseCryptoKeyParams=function(e){if(0!==xE(e).call(e,"inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},MT.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},MT.getCryptoParameters=function(e,t){var r=MT.matchPrefix(e+t,"a=crypto:");return jm(r).call(r,MT.parseCryptoLine)},MT.getIceParameters=function(e,t){var r=MT.matchPrefix(e+t,"a=ice-ufrag:")[0],n=MT.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},MT.writeIceParameters=function(e){var t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},MT.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=MT.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],o=MT.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(o){var a,s=MT.parseRtpMap(o),c=MT.matchPrefix(e,"a=fmtp:"+i+" ");switch(s.parameters=c.length?MT.parseFmtp(c[0]):{},s.rtcpFeedback=jm(a=MT.matchPrefix(e,"a=rtcp-fb:"+i+" ")).call(a,MT.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return MT.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(MT.parseExtmap(e))})),t},MT.writeRtpDescription=function(e,t){var r,n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=jm(r=t.codecs).call(r,(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach((function(e){n+=MT.writeRtpMap(e),n+=MT.writeFmtp(e),n+=MT.writeRtcpFb(e)}));var i=0;return t.codecs.forEach((function(e){e.maxptime>i&&(i=e.maxptime)})),i>0&&(n+="a=maxptime:"+i+"\r\n"),t.headerExtensions&&t.headerExtensions.forEach((function(e){n+=MT.writeExtmap(e)})),n},MT.parseRtpEncodingParameters=function(e){var t,r,n,i,o,a,s=[],c=MT.parseRtpParameters(e),u=-1!==xE(t=c.fecMechanisms).call(t,"RED"),d=-1!==xE(r=c.fecMechanisms).call(r,"ULPFEC"),l=Gs(n=jm(i=MT.matchPrefix(e,"a=ssrc:")).call(i,(function(e){return MT.parseSsrcMedia(e)}))).call(n,(function(e){return"cname"===e.attribute})),h=l.length>0&&l[0].ssrc,p=jm(o=MT.matchPrefix(e,"a=ssrc-group:FID")).call(o,(function(e){var t=e.substr(17).split(" ");return jm(t).call(t,(function(e){return uy(e,10)}))}));p.length>0&&p[0].length>1&&p[0][0]===h&&(a=p[0][1]),c.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:h,codecPayloadType:uy(e.parameters.apt,10)};h&&a&&(t.rtx={ssrc:a}),s.push(t),u&&((t=JSON.parse(Pm(t))).fec={ssrc:h,mechanism:d?"red+ulpfec":"red"},s.push(t))}})),0===s.length&&h&&s.push({ssrc:h});var v,f,_=MT.matchPrefix(e,"b=");return _.length&&(_=0===xE(v=_[0]).call(v,"b=TIAS:")?uy(_[0].substr(7),10):0===xE(f=_[0]).call(f,"b=AS:")?1e3*uy(_[0].substr(5),10)*.95-16e3:void 0,s.forEach((function(e){e.maxBitrate=_}))),s},MT.parseRtcpParameters=function(e){var t,r,n={},i=Gs(t=jm(r=MT.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return MT.parseSsrcMedia(e)}))).call(t,(function(e){return"cname"===e.attribute}))[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);var o=MT.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=o.length>0,n.compound=0===o.length;var a=MT.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},MT.writeRtcpParameters=function(e){var t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},MT.parseMsid=function(e){var t,r,n,i=MT.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(n=i[0].substr(7).split(" "))[0],track:n[1]};var o=Gs(t=jm(r=MT.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return MT.parseSsrcMedia(e)}))).call(t,(function(e){return"msid"===e.attribute}));return o.length>0?{stream:(n=o[0].value.split(" "))[0],track:n[1]}:void 0},MT.parseSctpDescription=function(e){var t,r=MT.parseMLine(e),n=MT.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=uy(n[0].substr(19),10)),isNaN(t)&&(t=65536);var i=MT.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:uy(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};var o=MT.matchPrefix(e,"a=sctpmap:");if(o.length>0){var a=o[0].substr(10).split(" ");return{port:uy(a[0],10),protocol:a[1],maxMessageSize:t}}},MT.writeSctpDescription=function(e,t){var r=[];return r="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},MT.generateSessionId=function(){return Math.random().toString().substr(2,21)},MT.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||MT.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},MT.getDirection=function(e,t){for(var r=MT.splitLines(e),n=0;n<r.length;n++)switch(r[n]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[n].substr(2)}return t?MT.getDirection(t):"sendrecv"},MT.getKind=function(e){return MT.splitLines(e)[0].split(" ")[0].substr(2)},MT.isRejected=function(e){return"0"===e.split(" ",2)[1]},MT.parseMLine=function(e){var t=MT.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:uy(t[1],10),protocol:t[2],fmt:km(t).call(t,3).join(" ")}},MT.parseOLine=function(e){var t=MT.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:uy(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},MT.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=MT.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},NT.exports=MT;var jT=BT.exports,GT=e({__proto__:null,default:jT},[BT.exports]);function HT(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){var r;if("object"===Wd(e)&&e.candidate&&0===xE(r=e.candidate).call(r,"a=")&&((e=JSON.parse(Pm(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=jT.parseCandidate(e.candidate),o=wb(n,i);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,tE(e,"icecandidate",(function(t){return t.candidate&&ad(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function zT(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||tE(e,"icecandidate",(function(e){if(e.candidate){var t=jT.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function KT(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||ad(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var r=function(e){if(!e||!e.sdp)return!1;var t=jT.splitSections(e.sdp);return t.shift(),t.some((function(e){var t,r=jT.parseMLine(e);return r&&"application"===r.kind&&-1!==xE(t=r.protocol).call(t,"SCTP")}))},n=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=uy(t[1],10);return r!=r?-1:r},i=function(e){var r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r},o=function(e,r){var n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);var i=jT.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=uy(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){var e=this.getConfiguration(),s=e.sdpSemantics;"plan-b"===s&&ad(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){var c,u=n(arguments[0]),d=i(u),l=o(arguments[0],u);c=0===d&&0===l?Number.POSITIVE_INFINITY:0===d||0===l?Math.max(d,l):Math.min(d,l);var h={};ad(h,"maxMessageSize",{get:function(){return c}}),this._sctp=h}return a.apply(this,arguments)}}}function XT(e){if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=t.apply(this,arguments);return r(e),e},tE(e,"datachannel",(function(e){return r(e.channel,e.target),e}))}function r(e,t){var r=e.send;e.send=function(){return r.apply(e,arguments)}}}function WT(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;ad(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),ad(t,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((function(e){var r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}}))}}function qT(e,t){if(e.RTCPeerConnection&&!("chrome"===t.browser&&t.version>=71||"safari"===t.browser&&t.version>=605)){var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){var n;if(t&&t.sdp&&-1!==xE(n=t.sdp).call(n,"\na=extmap-allow-mixed")){var i,o=Gs(i=t.sdp.split("\n")).call(i,(function(e){return"a=extmap-allow-mixed"!==FT(e).call(e)})).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:o}):t.sdp=o}return r.apply(this,arguments)}}}function YT(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.addIceCandidate;r&&0!==r.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Y_.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Y_.resolve())})}}function JT(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.setLocalDescription;r&&0!==r.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this,t=arguments[0]||{};if("object"!==Wd(t)||t.type&&t.sdp)return r.apply(this,arguments);if(!(t={type:t.type,sdp:t.sdp}).type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":t.type="offer";break;default:t.type="answer"}if(t.sdp||"offer"!==t.type&&"answer"!==t.type)return r.apply(this,[t]);var n="offer"===t.type?this.createOffer:this.createAnswer;return n.apply(this).then((function(t){return r.apply(e,[t])}))})}}var QT=Object.freeze(Object.defineProperty({__proto__:null,shimRTCIceCandidate:HT,shimRTCIceCandidateRelayProtocol:zT,shimMaxMessageSize:KT,shimSendThrowTypeError:XT,shimConnectionState:WT,removeExtmapAllowMixed:qT,shimAddIceCandidateNullOrEmpty:YT,shimParameterlessSetLocalDescription:JT},Symbol.toStringTag,{value:"Module"}));if(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.window,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},n=iE,i=aE(t),o={browserDetails:i,commonShim:QT,extractVersion:eE,disableLog:rE,disableWarnings:nE,sdp:GT};switch(i.browser){case"chrome":if(!Ck||!Ak||!r.shimChrome)return n("Chrome shim is not included in this adapter release."),o;if(null===i.version)return n("Chrome shim can not determine version, not shimming."),o;n("adapter.js shimming chrome."),o.browserShim=Ck,YT(t,i),JT(t),gk(t,i),Sk(t),Ak(t,i),bk(t),Rk(t,i),Ek(t),kk(t),Tk(t),wk(t,i),HT(t),zT(t),WT(t),KT(t,i),XT(t),qT(t,i);break;case"firefox":if(!yT||!uT||!r.shimFirefox)return n("Firefox shim is not included in this adapter release."),o;n("adapter.js shimming firefox."),o.browserShim=yT,YT(t,i),JT(t),sT(t,i),uT(t,i),cT(t),hT(t),dT(t),lT(t),pT(t),vT(t),fT(t),_T(t),mT(t),HT(t),WT(t),KT(t,i),XT(t);break;case"safari":if(!wT||!r.shimSafari)return n("Safari shim is not included in this adapter release."),o;n("adapter.js shimming safari."),o.browserShim=wT,YT(t,i),JT(t),TT(t),RT(t),bT(t),gT(t),ST(t),IT(t),ET(t),AT(t),HT(t),zT(t),KT(t,i),XT(t),qT(t,i);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window}),"undefined"!=typeof MediaStreamTrack){var ZT=MediaStreamTrack.prototype.getSettings;MediaStreamTrack.prototype.getSettings=function(){var e=ZT.call(this);return e.width&&(e.width=Math.floor(e.width)),e.height&&(e.height=Math.floor(e.height)),e.frameRate&&(e.frameRate=Math.floor(e.frameRate)),e}}function $T(e,t){var r=void 0!==wd&&Dk(e)||e["@@iterator"];if(!r){if(xk(e)||(r=Yk(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function eI(e,t){return function(e){if(xk(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==wd&&Dk(e)||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],c=!0,u=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(d){u=!0,i=d}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||Yk(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tI(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var rI=Ye,nI=function(e){return void 0!==e&&(rI(e,"value")||rI(e,"writable"))},iI=O,oI=$,aI=tr,sI=nI,cI=A,uI=mc;Ar({target:"Reflect",stat:!0},{get:function e(t,r){var n,i,o=arguments.length<3?t:arguments[2];return aI(t)===o?t[r]:(n=cI.f(t,r))?sI(n)?n.value:void 0===n.get?void 0:iI(n.get,o):oI(i=uI(t))?e(i,r,o):void 0}});var dI=ee.Reflect.get,lI=E,hI=Ce,pI=$,vI=Ye,fI=rs,_I=o,mI=Function,yI=lI([].concat),gI=lI([].join),SI={},bI=function(e,t,r){if(!vI(SI,t)){for(var n=[],i=0;i<t;i++)n[i]="a["+i+"]";SI[t]=mI("C,a","return new C("+gI(n,",")+")")}return SI[t](e,r)},EI=_I?mI.bind:function(e){var t=hI(this),r=t.prototype,n=fI(arguments,1),i=function(){var r=yI(n,fI(arguments));return this instanceof i?bI(t,r.length,r):t.apply(e,r)};return pI(r)&&(i.prototype=r),i},kI=EI;Ar({target:"Function",proto:!0,forced:Function.bind!==kI},{bind:kI});var TI=Us("Function").bind,II=ae,RI=TI,AI=Function.prototype,wI=function(e){var t=e.bind;return e===AI||II(AI,e)&&t===AI.bind?RI:t};function CI(e){var t;return(CI=Kl?wI(t=zl).call(t):function(e){return e.__proto__||zl(e)})(e)}function xI(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=CI(e)););return e}function OI(){var e;"undefined"!=typeof Reflect&&dI?OI=wI(e=dI).call(e):OI=function(e,t,r){var n=xI(e,t);if(n){var i=tc(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}};return OI.apply(this,arguments)}function DI(e,t){var r;return(DI=Kl?wI(r=Kl).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function NI(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Bl(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),ad(e,"prototype",{writable:!1}),t&&DI(e,t)}var MI=Ar,PI=d,LI=EI,UI=bp,VI=tr,FI=$,BI=Hn,jI=i,GI=oe("Reflect","construct"),HI=Object.prototype,zI=[].push,KI=jI((function(){function e(){}return!(GI((function(){}),[],e)instanceof e)})),XI=!jI((function(){GI((function(){}))})),WI=KI||XI;MI({target:"Reflect",stat:!0,forced:WI,sham:WI},{construct:function(e,t){UI(e),VI(t);var r=arguments.length<3?e:UI(arguments[2]);if(XI&&!KI)return GI(e,t,r);if(e==r){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var n=[null];return PI(zI,n,t),new(PI(LI,e,n))}var i=r.prototype,o=BI(FI(i)?i:HI),a=PI(e,o,t);return FI(a)?a:o}});var qI=ee.Reflect.construct;function YI(){if("undefined"==typeof Reflect||!qI)return!1;if(qI.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(qI(Boolean,[],(function(){}))),!0}catch(e){return!1}}function JI(e,t){if(t&&("object"===Wd(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return tI(e)}function QI(e){var t=YI();return function(){var r,n=CI(e);if(t){var i=CI(this).constructor;r=qI(n,arguments,i)}else r=n.apply(this,arguments);return JI(this,r)}}var ZI=Us("Array").values,$I=fn,eR=Ye,tR=ae,rR=ZI,nR=Array.prototype,iR={DOMTokenList:!0,NodeList:!0},oR=function(e){var t=e.values;return e===nR||tR(nR,e)&&t===nR.values||eR(iR,$I(e))?rR:t},aR=ni,sR=Math.floor,cR=function(e,t){var r=e.length,n=sR(r/2);return r<8?uR(e,t):dR(e,cR(aR(e,0,n),t),cR(aR(e,n),t),t)},uR=function(e,t){for(var r,n,i=e.length,o=1;o<i;){for(n=o,r=e[o];n&&t(e[n-1],r)>0;)e[n]=e[--n];n!==o++&&(e[n]=r)}return e},dR=function(e,t,r,n){for(var i=t.length,o=r.length,a=0,s=0;a<i||s<o;)e[a+s]=a<i&&s<o?n(t[a],r[s])<=0?t[a++]:r[s++]:a<i?t[a++]:r[s++];return e},lR=cR,hR=se.match(/firefox\/(\d+)/i),pR=!!hR&&+hR[1],vR=/MSIE|Trident/.test(se),fR=se.match(/AppleWebKit\/(\d+)\./),_R=!!fR&&+fR[1],mR=Ar,yR=E,gR=Ce,SR=Xe,bR=Br,ER=VE,kR=yn,TR=i,IR=lR,RR=Iu,AR=pR,wR=vR,CR=ve,xR=_R,OR=[],DR=yR(OR.sort),NR=yR(OR.push),MR=TR((function(){OR.sort(void 0)})),PR=TR((function(){OR.sort(null)})),LR=RR("sort"),UR=!TR((function(){if(CR)return CR<70;if(!(AR&&AR>3)){if(wR)return!0;if(xR)return xR<603;var e,t,r,n,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(n=0;n<47;n++)OR.push({k:t+n,v:r})}for(OR.sort((function(e,t){return t.v-e.v})),n=0;n<OR.length;n++)t=OR[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));mR({target:"Array",proto:!0,forced:MR||!PR||!LR||!UR},{sort:function(e){void 0!==e&&gR(e);var t=SR(this);if(UR)return void 0===e?DR(t):DR(t,e);var r,n,i=[],o=bR(t);for(n=0;n<o;n++)n in t&&NR(i,t[n]);for(IR(i,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:kR(t)>kR(r)?1:-1}}(e)),r=bR(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)ER(t,n++);return t}});var VR=Us("Array").sort,FR=ae,BR=VR,jR=Array.prototype,GR=function(e){var t=e.sort;return e===jR||FR(jR,e)&&t===jR.sort?BR:t},HR=Ar,zR=Mo.findIndex,KR="findIndex",XR=!0;KR in[]&&Array(1).findIndex((function(){XR=!1})),HR({target:"Array",proto:!0,forced:XR},{findIndex:function(e){return zR(this,e,arguments.length>1?arguments[1]:void 0)}});var WR=Us("Array").findIndex,qR=ae,YR=WR,JR=Array.prototype,QR=function(e){var t=e.findIndex;return e===JR||qR(JR,e)&&t===JR.findIndex?YR:t},ZR=Ar,$R=E;A.f;var eA=Vr,tA=yn,rA=Mb,nA=W,iA=Lb,oA=$R("".startsWith),aA=$R("".slice),sA=Math.min;ZR({target:"String",proto:!0,forced:!iA("startsWith")},{startsWith:function(e){var t=tA(nA(this));rA(e);var r=eA(sA(arguments.length>1?arguments[1]:void 0,t.length)),n=tA(e);return oA?oA(t,n,r):aA(t,r,r+n.length)===n}});var cA=Us("String").startsWith,uA=ae,dA=cA,lA=String.prototype,hA=function(e){var t=e.startsWith;return"string"==typeof e||e===lA||uA(lA,e)&&t===lA.startsWith?dA:t},pA=function(e){return e.INVALID_ENGINE="INVALID_ENGINE",e.INVALID_PARAMS="INVALID_PARAMS",e.INVOKED_BEFORE_JOIN_ROOM="INVOKED_BEFORE_JOIN_ROOM",e.INVALID_TOKEN="INVALID_TOKEN",e.EXPIRED_TOKEN="EXPIRED_TOKEN",e.JOIN_ROOM_FAILED="JOIN_ROOM_FAILED",e.UPDATE_TOKEN_WITH_INVALID_TOKEN="UPDATE_TOKEN_WITH_INVALID_TOKEN",e.UPDATE_TOKEN_BEFORE_JOIN="UPDATE_TOKEN_BEFORE_JOIN",e.REPEAT_JOIN="REPEAT_JOIN",e.REPEAT_PUBLISH="REPEAT_PUBLISH",e.REPEAT_PUSH="REPEAT_PUSH",e.REPEAT_PLAY="REPEAT_PLAY",e.PUBLISH_BEFORE_JOIN="PUBLISH_BEFORE_JOIN",e.UNPUBLISH_BEFORE_JOIN="UNPUBLISH_BEFORE_JOIN",e.SUBSCRIBE_BEFORE_JOIN="SUBSCRIBE_BEFORE_JOIN",e.UNSUBSCRIBE_BEFORE_JOIN="UNSUBSCRIBE_BEFORE_JOIN",e.NO_PUBLISH_PERMISSION="NO_PUBLISH_PERMISSION",e.STREAM_NOT_EXIST="STREAM_NOT_EXIST",e.EMPTY_STREAM="EMPTY_STREAM",e.NOT_CONNECTED_YET="NOT_CONNECTED_YET",e.IM_BEFORE_JOIN="IM_BEFORE_JOIN",e.USER_NOT_EXIST="USER_NOT_EXIST",e.ALREADY_IN_ROOM="ALREADY_IN_ROOM",e.KICKED_OUT="KICKED_OUT",e.ROOM_DISMISS="ROOM_DISMISS",e.TOKEN_EXPIRED="TOKEN_EXPIRED",e.DUPLICATE_LOGIN="DUPLICATE_LOGIN",e.INVOKED_BEFORE_CAPTURE="INVOKED_BEFORE_CAPTURE",e.REPEAT_CAPTURE="REPEAT_CAPTURE",e.GET_VIDEO_TRACK_FAILED="GET_VIDEO_TRACK_FAILED",e.GET_AUDIO_TRACK_FAILED="GET_AUDIO_TRACK_FAILED",e.GET_SCREEN_TRACK_FAILED="GET_SCREEN_TRACK_FAILED",e.STREAM_TYPE_NOT_MATCH="STREAM_TYPE_NOT_MATCH",e.CANT_FIND_DOM="CANT_FIND_DOM",e.INVALID_DEVICE_ID="INVALID_DEVICE_ID",e.NO_PERMISSION="NO_PERMISSION",e.NOT_SUPPORTED="NOT_SUPPORTED",e.INTERRUPT="INTERRUPT",e.ICE_SERVER_WRONG="ICE_SERVER_WRONG",e.ESTABLISH_DATACHANNEL_FAILED="ESTABLISH_DATACHANNEL_FAILED",e.LOAD_RESOURCES_FAILED="LOAD_RESOURCES_FAILED",e.SIGNALING_CHANNEL_NOT_OPEN="SIGNALING_CHANNEL_NOT_OPEN",e.TIME_OUT="TIME_OUT",e.REFUSE_OPERATION_IN_DISCONNECT="REFUSE_OPERATION_IN_DISCONNECT",e.ADD_TRANSCEIVER_FAILED="ADD_TRANSCEIVER_FAILED",e.UPDATE_TRACK_FAILED="UPDATE_TRACK_FAILED",e.PUBLISH_FAILED="PUBLISH_FAILED",e.UNPUBLISH_FAILED="UNPUBLISH_FAILED",e.SUBSCRIBE_FAILED="SUBSCRIBE_FAILED",e.UNSUBSCRIBE_FAILED="UNSUBSCRIBE_FAILED",e.OPERATION_CANCEL="OPERATION_CANCEL",e.START_CLOUD_PROXY_AFTER_JOIN="START_CLOUD_PROXY_AFTER_JOIN",e.STOP_CLOUD_PROXY_BEFORE_LEAVE="STOP_CLOUD_PROXY_BEFORE_LEAVE",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.REPEAT_DEVICE_TEST="REPEAT_DEVICE_TEST",e.AUDIO_DEVICE_TEST_FAILED="AUDIO_DEVICE_RECORD_FAILED",e.ALREADY_LOGIN="ALREADY_LOGIN",e.LOGIN_FAILED="LOGIN_FAILED",e.NOT_LOGIN="NOT_LOGIN",e.RTM_DUPLICATE_LOGIN="RTM_DUPLICATE_LOGIN",e.RTM_TOKEN_ERROR="RTM_TOKEN_ERROR",e.USER_MESSAGE_TIMEOUT="USER_MESSAGE_TIMEOUT",e.USER_MESSAGE_BROKEN="USER_MESSAGE_BROKEN",e.USER_MESSAGE_NO_RECEIVER="USER_MESSAGE_NO_RECEIVER",e.USER_MESSAGE_NO_RELAYPATH="USER_MESSAGE_NO_RELAYPATH",e.USER_MESSAGE_EXCEED_QPS="USER_MESSAGE_EXCEED_QPS",e.USER_MESSAGE_SEND_TO_SERVER_ERROR="USER_MESSAGE_SEND_TO_SERVER_ERROR",e.USER_MESSAGE_SERVER_RESPONSE_ERROR="USER_MESSAGE_SERVER_RESPONSE_ERROR",e.USER_MESSAGE_NOT_JOIN="USER_MESSAGE_NOT_JOIN",e.USER_MESSAGE_INIT="USER_MESSAGE_INIT",e.USER_MESSAGE_NO_CONNECTION="USER_MESSAGE_NO_CONNECTION",e.USER_MESSAGE_NOT_LOGIN="USER_MESSAGE_NOT_LOGIN",e.USER_MESSAGE_SERVER_PARAMS_NOTSET="USER_MESSAGE_SERVER_PARAMS_NOTSET",e.USER_MESSAGE_UNKNOWN="USER_MESSAGE_UNKNOWN",e.START_PUBLIC_STREAM_BEFORE_JOIN="START_PUBLIC_STREAM_BEFORE_JOIN",e.RECONNECT_FAILED="RECONNECT_FAILED",e.SUBTITLE_ALREADY_ON="SUBTITLE_ALREADY_ON",e.SUBTITLE_NOT_TURNED_ON="SUBTITLE_NOT_TURNED_ON",e.SUBTITLE_ERR_POSTPROCESS="SUBTITLE_ERR_POSTPROCESS",e.SUBTITLE_ERR_CONNECTION_ERROR="SUBTITLE_ERR_CONNECTION_ERROR",e.SUBTITLE_ERR_PROCESS_ERROR="SUBTITLE_ERR_PROCESS_ERROR",e.SUBTITLE_ERR_UNKNOWN="SUBTITLE_ERR_UNKNOWN",e.UNEXPECTED_INVOKE_FORWARD_STREAM="UNEXPECTED_INVOKE_FORWARD_STREAM",e}(pA||{}),vA=function(e){return e[e.AUDIO_MIXING_ERROR_OK=0]="AUDIO_MIXING_ERROR_OK",e[e.AUDIO_MIXING_ERROR_PRELOAD_FAILED=1]="AUDIO_MIXING_ERROR_PRELOAD_FAILED",e[e.AUDIO_MIXING_ERROR_START_FAILED=2]="AUDIO_MIXING_ERROR_START_FAILED",e[e.AUDIO_MIXING_ERROR_ID_NOT_FOUND=3]="AUDIO_MIXING_ERROR_ID_NOT_FOUND",e[e.AUDIO_MIXING_ERROR_SET_POSITION_FAILED=4]="AUDIO_MIXING_ERROR_SET_POSITION_FAILED",e[e.AUDIO_MIXING_ERROR_INVALID_VOLUME=5]="AUDIO_MIXING_ERROR_INVALID_VOLUME",e[e.AUDIO_MIXING_ERROR_LOAD_CONFLICT=6]="AUDIO_MIXING_ERROR_LOAD_CONFLICT",e[e.AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH=7]="AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH",e[e.AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH=8]="AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH",e[e.AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK=9]="AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK",e}(vA||{});function fA(e,t,r){var n;YI()?fA=wI(n=qI).call(n):fA=function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(wI(Function).apply(e,n));return r&&DI(i,r.prototype),i};return fA.apply(null,arguments)}function _A(e){var t="function"==typeof $S?new $S:void 0;return _A=function(e){if(null===e||(r=e,-1===xE(n=Function.toString.call(r)).call(n,"[native code]")))return e;var r,n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return fA(e,arguments,CI(this).constructor)}return i.prototype=Bl(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),DI(i,e)},_A(e)}var mA=function(e){NI(r,e);var t=QI(r);function r(e,n,i){var o;return Vl(this,r),Jd(tI(o=t.call(this,n)),"code",void 0),Jd(tI(o),"message",void 0),Jd(tI(o),"error",void 0),o.code=e,o.message=n,o.error=i,Kl(tI(o),r.prototype),o}return Ul(r,[{key:"toString",value:function(){var e;return Om(e="SDKError: ".concat(this.code," ")).call(e,this.message)}}]),r}(_A(Error)),yA=w,gA=E,SA=rn,bA=J,EA=gA(D.f),kA=gA([].push),TA=function(e){return function(t){for(var r,n=bA(t),i=SA(n),o=i.length,a=0,s=[];o>a;)r=i[a++],yA&&!EA(n,r)||kA(s,e?[r,n[r]]:n[r]);return s}},IA={entries:TA(!0),values:TA(!1)}.entries;Ar({target:"Object",stat:!0},{entries:function(e){return IA(e)}});var RA=ee.Object.entries,AA=Or,wA=yn,CA=W,xA=RangeError,OA=E,DA=Vr,NA=yn,MA=function(e){var t=wA(CA(this)),r="",n=AA(e);if(n<0||n==1/0)throw xA("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},PA=W,LA=OA(MA),UA=OA("".slice),VA=Math.ceil,FA=function(e){return function(t,r,n){var i,o,a=NA(PA(t)),s=DA(r),c=a.length,u=void 0===n?" ":NA(n);return s<=c||""==u?a:((o=LA(u,VA((i=s-c)/u.length))).length>i&&(o=UA(o,0,i)),e?a+o:o+a)}},BA={start:FA(!1),end:FA(!0)},jA=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(se),GA=BA.end;Ar({target:"String",proto:!0,forced:jA},{padEnd:function(e){return GA(this,e,arguments.length>1?arguments[1]:void 0)}});var HA=Us("String").padEnd,zA=ae,KA=HA,XA=String.prototype,WA=function(e){var t=e.padEnd;return"string"==typeof e||e===XA||zA(XA,e)&&t===XA.padEnd?KA:t},qA=cy;Ar({target:"Number",stat:!0,forced:Number.parseInt!=qA},{parseInt:qA});var YA=ee.Number.parseInt,JA=Math.log,QA=Math.LOG10E;Ar({target:"Math",stat:!0},{log10:Math.log10||function(e){return JA(e)*QA}});var ZA,$A=ee.Math.log10,ew=Us("Array").keys,tw=fn,rw=Ye,nw=ae,iw=ew,ow=Array.prototype,aw={DOMTokenList:!0,NodeList:!0},sw=function(e){var t=e.keys;return e===ow||nw(ow,e)&&t===ow.keys||rw(aw,tw(e))?iw:t},cw=new Uint8Array(16);function uw(){if(!ZA&&!(ZA="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ZA(cw)}var dw=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function lw(e){return"string"==typeof e&&dw.test(e)}for(var hw=[],pw=0;pw<256;++pw)hw.push((pw+256).toString(16).substr(1));function vw(e,t,r){var n=(e=e||{}).random||(e.rng||uw)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=n[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(hw[e[t+0]]+hw[e[t+1]]+hw[e[t+2]]+hw[e[t+3]]+"-"+hw[e[t+4]]+hw[e[t+5]]+"-"+hw[e[t+6]]+hw[e[t+7]]+"-"+hw[e[t+8]]+hw[e[t+9]]+"-"+hw[e[t+10]]+hw[e[t+11]]+hw[e[t+12]]+hw[e[t+13]]+hw[e[t+14]]+hw[e[t+15]]).toLowerCase();if(!lw(r))throw TypeError("Stringified UUID is invalid");return r}(n)}var fw=function(){return"undefined"==typeof window},_w=function(){return vw()},mw=function(e){return"number"==typeof e},yw=function(e){var t;return mk(t=Function.prototype.toString.call(e)).call(t,"[native code]")},gw="@byted/ve-rtc",Sw="@byted/ve-rtc-cache-size",bw=function(){function e(){Vl(this,e),Jd(this,"storeKey",void 0),Jd(this,"logLevel",void 0),Jd(this,"LogfileSize",void 0),Jd(this,"db",void 0),Jd(this,"logId",void 0),Jd(this,"cacheLog",void 0),Jd(this,"cachedSize",void 0),Jd(this,"preCacheTime",void 0),Jd(this,"timer",void 0),Jd(this,"_getSize",(function(e){return new Blob(e).size/1048576})),this.storeKey="",this.logId=1,this.cacheLog="",this.logLevel="none",this.LogfileSize=100,this._createStore()}return Ul(e,[{key:"_createStore",value:function(){var e=this;if(!fw()&&window.indexedDB){var t=indexedDB.open("@byted/ve-rtc");t.onupgradeneeded=function(){t.result.createObjectStore(gw);try{localStorage.removeItem(Sw)}catch(XW){}},t.onerror=function(e){},t.onsuccess=function(){e.db=t.result,e._getCachedSize()}}}},{key:"_getCachedSize",value:function(){var e=this;try{var t=localStorage.getItem(Sw);if(t)this.cachedSize=Number(t);else oR(this).call(this).then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(XW){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(Sw,"".concat(this.cachedSize))}catch(XW){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(gw,e).objectStore(gw)}},{key:"set",value:function(e){var t=this;return new Y_((function(r,n){if("none"===t.logLevel)return r();var i;if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+=Om(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,t.timer||(t.timer=setTimeout((function(){t.set("")}),1e3-(t.preCacheTime-Date.now()))),r();clearTimeout(t.timer),t.timer=null;var o=t._getStore("readwrite");if(!o)return n("get store fail");t.cachedSize&&t.cachedSize>t.LogfileSize&&t.keyEarliest().then((function(e){t.get(e).then((function(r){t.del(e).then((function(){t.cachedSize=t.cachedSize-t._getSize(["".concat(r)]),t._setCachedSize()}))}))}));var a=o.get(t.storeKey);a.onsuccess=function(){try{var i,s,c,u,d,l=Om(i="".concat(a.result||"")).call(i,t.cacheLog),h=e?Om(s=Om(c="".concat(l?"\n\n":"")).call(c,t.logId,": ")).call(s,e):"";o.put(Om(u="".concat(l)).call(u,h),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize([Om(d="".concat(t.cacheLog)).call(d,h)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(v){var p;if(!e)return n(v);t.cacheLog+=Om(p="\n\n".concat(t.logId,": ")).call(p,e),t.logId++,n(v)}},a.onerror=function(r){var i;if(!e)return n(r);t.cacheLog+=Om(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new Y_((function(r,n){var i=t._getStore("readonly");if(!i)return n();var o=i.get(e);o.onsuccess=function(){r(o.result)},o.onerror=function(e){n(e)}}))}},{key:"del",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.storeKey;return new Y_((function(r,n){var i=e._getStore("readwrite");if(!i)return n();var o=i.delete(t);o.onsuccess=function(){return r(o.result)},o.onerror=function(e){return n(e)}}))}},{key:"keyEarliest",value:function(){return sw(this).call(this).then((function(e){var t,r=Date.now();return e.forEach((function(e){if(e&&e.length){var n=e.split("-")[0];Number(n)<r&&(r=Number(n),t=e)}})),t}))}},{key:"keys",value:function(){var e=this;return new Y_((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAllKeys){var i=n.getAllKeys();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.key),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"values",value:function(){var e=this;return new Y_((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAll){var i=n.getAll();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.value),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"download",value:function(e){e=e||this.storeKey,this.get(e).then((function(t){var r=document.createElement("a");r.download="".concat(e,".txt"),r.href="data:text/paint;utf-8,".concat(t||""),r.click()}))}}]),e}(),Ew=new bw,kw=BA.start;Ar({target:"String",proto:!0,forced:jA},{padStart:function(e){return kw(this,e,arguments.length>1?arguments[1]:void 0)}});var Tw,Iw,Rw=Us("String").padStart,Aw=ae,ww=Rw,Cw=String.prototype,xw=function(e){var t=e.padStart;return"string"==typeof e||e===Cw||Aw(Cw,e)&&t===Cw.padStart?ww:t},Ow="[VERTC]",Dw="#0050b3",Nw=(Jd(Tw={},"DEBUG","rgba(0, 0, 0, 0)"),Jd(Tw," INFO","rgba(93, 173, 226, 0)"),Jd(Tw," WARN","rgba(255, 119, 0, 0.3)"),Jd(Tw,"ERROR","rgba(255, 0, 0, 0.3)"),Jd(Tw," SUCC","rgba(0, 119, 0, 0.3)"),Tw),Mw="undefined"!=typeof window&&mk(Iw=window.location.search).call(Iw,"_rtc_debug_"),Pw=function(){function e(t,r){Vl(this,e),Jd(this,"indent",void 0),Jd(this,"module",void 0),this.module=t,this.indent=r}return Ul(e,[{key:"log",value:function(e,t){for(var r,n,i,o,a,s,c,u,d=arguments.length,l=new Array(d>2?d-2:0),h=2;h<d;h++)l[h-2]=arguments[h];var p=l.shift();try{var v,f,_,m,y=Om(v=[]).call(v,l),g="".concat(p).replace(/%o/gi,(function(){var e=y.shift();return Pm(e)}));Ew.set(Om(f=Om(_=Om(m="".concat(Ow,"[").concat(this.module,".")).call(m,t,"] ")).call(_,g," ")).call(f,jm(y).call(y,(function(e){return Pm(e)})).join(", ")))}catch(XW){}if(Mw){for(var S="",b=0;b<this.indent;b++)S+=" ";(r=console).log.apply(r,Om(n=[Om(i=Om(o=Om(a=Om(s=Om(c=Om(u="%c".concat(Lw(),"-")).call(u,Ow,"%c[")).call(c,e,"]%c")).call(s,S,"[")).call(a,this.module,".")).call(o,t,"] ")).call(i,p),"color:".concat(Dw,";"),"background-color:".concat(Nw[e],";"),"color:".concat(Dw,";")]).call(n,l))}}},{key:"print",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=[" INFO",e]).call(t,n))}},{key:"debug",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=["DEBUG",e]).call(t,n))}},{key:"info",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=[" INFO",e]).call(t,n))}},{key:"warn",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=[" WARN",e]).call(t,n))}},{key:"error",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=["ERROR",e]).call(t,n))}},{key:"success",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];this.log.apply(this,Om(t=[" SUCC",e]).call(t,n))}}]),e}(),Lw=function(){var e,t,r=new Date;return Om(e="".concat(r.toTimeString().split(" ")[0],":")).call(e,xw(t=r.getMilliseconds().toString()).call(t,3,"0"))},Uw={};!function(e){var t="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.assign=function(e){for(var t=km(Array.prototype).call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==Wd(n))throw new TypeError(n+"must be non-object");for(var i in n)r(n,i)&&(e[i]=n[i])}}return e},e.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){var t,r,n,i,o,a;for(n=0,t=0,r=e.length;t<r;t++)n+=e[t].length;for(a=new Uint8Array(n),i=0,t=0,r=e.length;t<r;t++)o=e[t],a.set(o,i),i+=o.length;return a}},i={arraySet:function(e,t,r,n,i){for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){return Om([]).apply([],e)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,n)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,i))},e.setTyped(t)}(Uw);var Vw={},Fw={},Bw={},jw=Uw;function Gw(e){for(var t=e.length;--t>=0;)e[t]=0}var Hw=256,zw=286,Kw=30,Xw=15,Ww=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],qw=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Yw=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Jw=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Qw=new Array(576);Gw(Qw);var Zw=new Array(60);Gw(Zw);var $w=new Array(512);Gw($w);var eC=new Array(256);Gw(eC);var tC=new Array(29);Gw(tC);var rC,nC,iC,oC=new Array(Kw);function aC(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function sC(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function cC(e){return e<256?$w[e]:$w[256+(e>>>7)]}function uC(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function dC(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,uC(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function lC(e,t,r){dC(e,r[2*t],r[2*t+1])}function hC(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function pC(e,t,r){var n,i,o=new Array(16),a=0;for(n=1;n<=Xw;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=hC(o[s]++,s))}}function vC(e){var t;for(t=0;t<zw;t++)e.dyn_ltree[2*t]=0;for(t=0;t<Kw;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function fC(e){e.bi_valid>8?uC(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function _C(e,t,r,n){var i=2*t,o=2*r;return e[i]<e[o]||e[i]===e[o]&&n[t]<=n[r]}function mC(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&_C(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!_C(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function yC(e,t,r){var n,i,o,a,s=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],i=e.pending_buf[e.l_buf+s],s++,0===n?lC(e,i,t):(lC(e,(o=eC[i])+Hw+1,t),0!==(a=Ww[o])&&dC(e,i-=tC[o],a),lC(e,o=cC(--n),r),0!==(a=qw[o])&&dC(e,n-=oC[o],a))}while(s<e.last_lit);lC(e,256,t)}function gC(e,t){var r,n,i,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,c=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=573,r=0;r<c;r++)0!==o[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=a[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;r>=1;r--)mC(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],mC(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,o[2*i]=o[2*r]+o[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,o[2*r+1]=o[2*n+1]=i,e.heap[1]=i++,mC(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,o,a,s,c=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,l=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,v=t.stat_desc.max_length,f=0;for(o=0;o<=Xw;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>v&&(o=v,f++),c[2*n+1]=o,n>u||(e.bl_count[o]++,a=0,n>=p&&(a=h[n-p]),s=c[2*n],e.opt_len+=s*(o+a),l&&(e.static_len+=s*(d[2*n+1]+a)));if(0!==f){do{for(o=v-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[v]--,f-=2}while(f>0);for(o=v;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),n--)}}(e,t),pC(o,u,e.bl_count)}function SC(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++s<c&&i===a||(s<u?e.bl_tree[2*i]+=s:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))}function bC(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++s<c&&i===a)){if(s<u)do{lC(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(lC(e,i,e.bl_tree),s--),lC(e,16,e.bl_tree),dC(e,s-3,2)):s<=10?(lC(e,17,e.bl_tree),dC(e,s-3,3)):(lC(e,18,e.bl_tree),dC(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}}Gw(oC);var EC=!1;function kC(e,t,r,n){dC(e,0+(n?1:0),3),function(e,t,r,n){fC(e),n&&(uC(e,r),uC(e,~r)),jw.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}Bw._tr_init=function(e){EC||(!function(){var e,t,r,n,i,o=new Array(16);for(r=0,n=0;n<28;n++)for(tC[n]=r,e=0;e<1<<Ww[n];e++)eC[r++]=n;for(eC[r-1]=n,i=0,n=0;n<16;n++)for(oC[n]=i,e=0;e<1<<qw[n];e++)$w[i++]=n;for(i>>=7;n<Kw;n++)for(oC[n]=i<<7,e=0;e<1<<qw[n]-7;e++)$w[256+i++]=n;for(t=0;t<=Xw;t++)o[t]=0;for(e=0;e<=143;)Qw[2*e+1]=8,e++,o[8]++;for(;e<=255;)Qw[2*e+1]=9,e++,o[9]++;for(;e<=279;)Qw[2*e+1]=7,e++,o[7]++;for(;e<=287;)Qw[2*e+1]=8,e++,o[8]++;for(pC(Qw,287,o),e=0;e<Kw;e++)Zw[2*e+1]=5,Zw[2*e]=hC(e,5);rC=new aC(Qw,Ww,257,zw,Xw),nC=new aC(Zw,qw,0,Kw,Xw),iC=new aC(new Array(0),Yw,0,19,7)}(),EC=!0),e.l_desc=new sC(e.dyn_ltree,rC),e.d_desc=new sC(e.dyn_dtree,nC),e.bl_desc=new sC(e.bl_tree,iC),e.bi_buf=0,e.bi_valid=0,vC(e)},Bw._tr_stored_block=kC,Bw._tr_flush_block=function(e,t,r,n){var i,o,a=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<Hw;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),gC(e,e.l_desc),gC(e,e.d_desc),a=function(e){var t;for(SC(e,e.dyn_ltree,e.l_desc.max_code),SC(e,e.dyn_dtree,e.d_desc.max_code),gC(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Jw[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==t?kC(e,t,r,n):4===e.strategy||o===i?(dC(e,2+(n?1:0),3),yC(e,Qw,Zw)):(dC(e,4+(n?1:0),3),function(e,t,r,n){var i;for(dC(e,t-257,5),dC(e,r-1,5),dC(e,n-4,4),i=0;i<n;i++)dC(e,e.bl_tree[2*Jw[i]+1],3);bC(e,e.dyn_ltree,t-1),bC(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),yC(e,e.dyn_ltree,e.dyn_dtree)),vC(e),n&&fC(e)},Bw._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(eC[r]+Hw+1)]++,e.dyn_dtree[2*cC(t)]++),e.last_lit===e.lit_bufsize-1},Bw._tr_align=function(e){dC(e,2,3),lC(e,256,Qw),function(e){16===e.bi_valid?(uC(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)};var TC=function(e,t,r,n){for(var i=65535&e|0,o=e>>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+t[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16|0};var IC=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();var RC,AC=function(e,t,r,n){var i=IC,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},wC={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},CC=Uw,xC=Bw,OC=TC,DC=AC,NC=wC,MC=-2,PC=258,LC=262,UC=103,VC=113,FC=666;function BC(e,t){return e.msg=NC[t],t}function jC(e){return(e<<1)-(e>4?9:0)}function GC(e){for(var t=e.length;--t>=0;)e[t]=0}function HC(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(CC.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function zC(e,t){xC._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,HC(e.strm)}function KC(e,t){e.pending_buf[e.pending++]=t}function XC(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function WC(e,t){var r,n,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-LC?e.strstart-(e.w_size-LC):0,u=e.window,d=e.w_mask,l=e.prev,h=e.strstart+PC,p=u[o+a-1],v=u[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(r=t)+a]===v&&u[r+a-1]===p&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&o<h);if(n=PC-(h-o),o=h-PC,n>a){if(e.match_start=t,a=n,n>=s)break;p=u[o+a-1],v=u[o+a]}}}while((t=l[t&d])>c&&0!=--i);return a<=e.lookahead?a:e.lookahead}function qC(e){var t,r,n,i,o,a,s,c,u,d,l=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=l+(l-LC)){CC.arraySet(e.window,e.window,l,l,0),e.match_start-=l,e.strstart-=l,e.block_start-=l,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=l?n-l:0}while(--r);t=r=l;do{n=e.prev[--t],e.prev[t]=n>=l?n-l:0}while(--r);i+=l}if(0===e.strm.avail_in)break;if(a=e.strm,s=e.window,c=e.strstart+e.lookahead,u=i,d=void 0,(d=a.avail_in)>u&&(d=u),r=0===d?0:(a.avail_in-=d,CC.arraySet(s,a.input,a.next_in,d,c),1===a.state.wrap?a.adler=OC(a.adler,s,d,c):2===a.state.wrap&&(a.adler=DC(a.adler,s,d,c)),a.next_in+=d,a.total_in+=d,d),e.lookahead+=r,e.lookahead+e.insert>=3)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+3-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<LC&&0!==e.strm.avail_in)}function YC(e,t){for(var r,n;;){if(e.lookahead<LC){if(qC(e),e.lookahead<LC&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-LC&&(e.match_length=WC(e,r)),e.match_length>=3)if(n=xC._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=xC._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(zC(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(zC(e,!1),0===e.strm.avail_out)?1:2}function JC(e,t){for(var r,n,i;;){if(e.lookahead<LC){if(qC(e),e.lookahead<LC&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-LC&&(e.match_length=WC(e,r),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=xC._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(zC(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=xC._tr_tally(e,0,e.window[e.strstart-1]))&&zC(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=xC._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(zC(e,!1),0===e.strm.avail_out)?1:2}function QC(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function ZC(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new CC.Buf16(1146),this.dyn_dtree=new CC.Buf16(122),this.bl_tree=new CC.Buf16(78),GC(this.dyn_ltree),GC(this.dyn_dtree),GC(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new CC.Buf16(16),this.heap=new CC.Buf16(573),GC(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new CC.Buf16(573),GC(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function $C(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:VC,e.adler=2===t.wrap?0:1,t.last_flush=0,xC._tr_init(t),0):BC(e,MC)}function ex(e){var t,r=$C(e);return 0===r&&((t=e.state).window_size=2*t.w_size,GC(t.head),t.max_lazy_match=RC[t.level].max_lazy,t.good_match=RC[t.level].good_length,t.nice_match=RC[t.level].nice_length,t.max_chain_length=RC[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),r}function tx(e,t,r,n,i,o){if(!e)return MC;var a=1;if(-1===t&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>9||8!==r||n<8||n>15||t<0||t>9||o<0||o>4)return BC(e,MC);8===n&&(n=9);var s=new ZC;return e.state=s,s.strm=e,s.wrap=a,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+3-1)/3),s.window=new CC.Buf8(2*s.w_size),s.head=new CC.Buf16(s.hash_size),s.prev=new CC.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new CC.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=o,s.method=r,ex(e)}RC=[new QC(0,0,0,0,(function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(qC(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,zC(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-LC&&(zC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(zC(e,!1),e.strm.avail_out),1)})),new QC(4,4,8,4,YC),new QC(4,5,16,8,YC),new QC(4,6,32,32,YC),new QC(4,4,16,16,JC),new QC(8,16,32,32,JC),new QC(8,16,128,128,JC),new QC(8,32,128,256,JC),new QC(32,128,258,1024,JC),new QC(32,258,258,4096,JC)],Fw.deflateInit=function(e,t){return tx(e,t,8,15,8,0)},Fw.deflateInit2=tx,Fw.deflateReset=ex,Fw.deflateResetKeep=$C,Fw.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?MC:(e.state.gzhead=t,0):MC},Fw.deflate=function(e,t){var r,n,i,o;if(!e||!e.state||t>5||t<0)return e?BC(e,MC):MC;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===FC&&4!==t)return BC(e,0===e.avail_out?-5:MC);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,KC(n,31),KC(n,139),KC(n,8),n.gzhead?(KC(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),KC(n,255&n.gzhead.time),KC(n,n.gzhead.time>>8&255),KC(n,n.gzhead.time>>16&255),KC(n,n.gzhead.time>>24&255),KC(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),KC(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(KC(n,255&n.gzhead.extra.length),KC(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=DC(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(KC(n,0),KC(n,0),KC(n,0),KC(n,0),KC(n,0),KC(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),KC(n,3),n.status=VC);else{var a=8+(n.w_bits-8<<4)<<8;a|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=32),a+=31-a%31,n.status=VC,XC(n,a),0!==n.strstart&&(XC(n,e.adler>>>16),XC(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=DC(e.adler,n.pending_buf,n.pending-i,i)),HC(e),i=n.pending,n.pending!==n.pending_buf_size));)KC(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=DC(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=DC(e.adler,n.pending_buf,n.pending-i,i)),HC(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,KC(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=DC(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=DC(e.adler,n.pending_buf,n.pending-i,i)),HC(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,KC(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=DC(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=UC)}else n.status=UC;if(n.status===UC&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&HC(e),n.pending+2<=n.pending_buf_size&&(KC(n,255&e.adler),KC(n,e.adler>>8&255),e.adler=0,n.status=VC)):n.status=VC),0!==n.pending){if(HC(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&jC(t)<=jC(r)&&4!==t)return BC(e,-5);if(n.status===FC&&0!==e.avail_in)return BC(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&n.status!==FC){var s=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(qC(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=xC._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(zC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(zC(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=PC){if(qC(e),e.lookahead<=PC&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){o=e.strstart+PC;do{}while(n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&i<o);e.match_length=PC-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=xC._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=xC._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(zC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(zC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(zC(e,!1),0===e.strm.avail_out)?1:2}(n,t):RC[n.level].func(n,t);if(3!==s&&4!==s||(n.status=FC),1===s||3===s)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===s&&(1===t?xC._tr_align(n):5!==t&&(xC._tr_stored_block(n,0,0,!1),3===t&&(GC(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),HC(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(KC(n,255&e.adler),KC(n,e.adler>>8&255),KC(n,e.adler>>16&255),KC(n,e.adler>>24&255),KC(n,255&e.total_in),KC(n,e.total_in>>8&255),KC(n,e.total_in>>16&255),KC(n,e.total_in>>24&255)):(XC(n,e.adler>>>16),XC(n,65535&e.adler)),HC(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)},Fw.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==UC&&t!==VC&&t!==FC?BC(e,MC):(e.state=null,t===VC?BC(e,-3):0):MC},Fw.deflateSetDictionary=function(e,t){var r,n,i,o,a,s,c,u,d=t.length;if(!e||!e.state)return MC;if(2===(o=(r=e.state).wrap)||1===o&&42!==r.status||r.lookahead)return MC;for(1===o&&(e.adler=OC(e.adler,t,d,0)),r.wrap=0,d>=r.w_size&&(0===o&&(GC(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new CC.Buf8(r.w_size),CC.arraySet(u,t,d-r.w_size,r.w_size,0),t=u,d=r.w_size),a=e.avail_in,s=e.next_in,c=e.input,e.avail_in=d,e.next_in=0,e.input=t,qC(r);r.lookahead>=3;){n=r.strstart,i=r.lookahead-2;do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+3-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--i);r.strstart=n,r.lookahead=2,qC(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=s,e.input=c,e.avail_in=a,r.wrap=o,0},Fw.deflateInfo="pako deflate (from Nodeca project)";var rx={},nx=Uw,ix=!0,ox=!0;try{String.fromCharCode.apply(null,[0])}catch(WW){ix=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(WW){ox=!1}for(var ax=new nx.Buf8(256),sx=0;sx<256;sx++)ax[sx]=sx>=252?6:sx>=248?5:sx>=240?4:sx>=224?3:sx>=192?2:1;function cx(e,t){if(t<65534&&(e.subarray&&ox||!e.subarray&&ix))return String.fromCharCode.apply(null,nx.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}ax[254]=ax[254]=1,rx.string2buf=function(e){var t,r,n,i,o,a=e.length,s=0;for(i=0;i<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),s+=r<128?1:r<2048?2:r<65536?3:4;for(t=new nx.Buf8(s),o=0,i=0;o<s;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[o++]=r:r<2048?(t[o++]=192|r>>>6,t[o++]=128|63&r):r<65536?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|63&r):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|63&r);return t},rx.buf2binstring=function(e){return cx(e,e.length)},rx.binstring2buf=function(e){for(var t=new nx.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},rx.buf2string=function(e,t){var r,n,i,o,a=t||e.length,s=new Array(2*a);for(n=0,r=0;r<a;)if((i=e[r++])<128)s[n++]=i;else if((o=ax[i])>4)s[n++]=65533,r+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&r<a;)i=i<<6|63&e[r++],o--;o>1?s[n++]=65533:i<65536?s[n++]=i:(i-=65536,s[n++]=55296|i>>10&1023,s[n++]=56320|1023&i)}return cx(s,n)},rx.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+ax[e[r]]>t?r:t};var ux=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},dx=Fw,lx=Uw,hx=rx,px=wC,vx=ux,fx=Object.prototype.toString;function _x(e){if(!(this instanceof _x))return new _x(e);this.options=lx.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new vx,this.strm.avail_out=0;var r=dx.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==r)throw new Error(px[r]);if(t.header&&dx.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?hx.string2buf(t.dictionary):"[object ArrayBuffer]"===fx.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(r=dx.deflateSetDictionary(this.strm,n)))throw new Error(px[r]);this._dict_set=!0}}function mx(e,t){var r=new _x(t);if(r.push(e,!0),r.err)throw r.msg||px[r.err];return r.result}_x.prototype.push=function(e,t){var r,n,i=this.strm,o=this.options.chunkSize;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?i.input=hx.string2buf(e):"[object ArrayBuffer]"===fx.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new lx.Buf8(o),i.next_out=0,i.avail_out=o),1!==(r=dx.deflate(i,n))&&0!==r)return this.onEnd(r),this.ended=!0,!1;0!==i.avail_out&&(0!==i.avail_in||4!==n&&2!==n)||("string"===this.options.to?this.onData(hx.buf2binstring(lx.shrinkBuf(i.output,i.next_out))):this.onData(lx.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=dx.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==n||(this.onEnd(0),i.avail_out=0,!0)},_x.prototype.onData=function(e){this.chunks.push(e)},_x.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=lx.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},Vw.Deflate=_x,Vw.deflate=mx,Vw.deflateRaw=function(e,t){return(t=t||{}).raw=!0,mx(e,t)},Vw.gzip=function(e,t){return(t=t||{}).gzip=!0,mx(e,t)};var yx={},gx=tr,Sx=O,bx=Ye,Ex=ae,kx=function(){var e=gx(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Tx=RegExp.prototype,Ix=ae,Rx=function(e){var t=e.flags;return void 0!==t||"flags"in Tx||bx(e,"flags")||!Ex(Tx,e)?t:Sx(kx,e)},Ax=RegExp.prototype,wx=function(e){return e===Ax||Ix(Ax,e)?Rx(e):e.flags},Cx={},xx=Uw,Ox=15,Dx=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Nx=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],Mx=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],Px=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],Lx=Uw,Ux=TC,Vx=AC,Fx=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R;r=e.state,n=e.next_in,I=e.input,i=n+(e.avail_in-5),o=e.next_out,R=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),c=r.dmax,u=r.wsize,d=r.whave,l=r.wnext,h=r.window,p=r.hold,v=r.bits,f=r.lencode,_=r.distcode,m=(1<<r.lenbits)-1,y=(1<<r.distbits)-1;e:do{v<15&&(p+=I[n++]<<v,v+=8,p+=I[n++]<<v,v+=8),g=f[p&m];t:for(;;){if(p>>>=S=g>>>24,v-=S,0===(S=g>>>16&255))R[o++]=65535&g;else{if(!(16&S)){if(0==(64&S)){g=f[(65535&g)+(p&(1<<S)-1)];continue t}if(32&S){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}b=65535&g,(S&=15)&&(v<S&&(p+=I[n++]<<v,v+=8),b+=p&(1<<S)-1,p>>>=S,v-=S),v<15&&(p+=I[n++]<<v,v+=8,p+=I[n++]<<v,v+=8),g=_[p&y];r:for(;;){if(p>>>=S=g>>>24,v-=S,!(16&(S=g>>>16&255))){if(0==(64&S)){g=_[(65535&g)+(p&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(E=65535&g,v<(S&=15)&&(p+=I[n++]<<v,(v+=8)<S&&(p+=I[n++]<<v,v+=8)),(E+=p&(1<<S)-1)>c){e.msg="invalid distance too far back",r.mode=30;break e}if(p>>>=S,v-=S,E>(S=o-a)){if((S=E-S)>d&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(k=0,T=h,0===l){if(k+=u-S,S<b){b-=S;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}}else if(l<S){if(k+=u+l-S,(S-=l)<b){b-=S;do{R[o++]=h[k++]}while(--S);if(k=0,l<b){b-=S=l;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}}}else if(k+=l-S,S<b){b-=S;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}for(;b>2;)R[o++]=T[k++],R[o++]=T[k++],R[o++]=T[k++],b-=3;b&&(R[o++]=T[k++],b>1&&(R[o++]=T[k++]))}else{k=o-E;do{R[o++]=R[k++],R[o++]=R[k++],R[o++]=R[k++],b-=3}while(b>2);b&&(R[o++]=R[k++],b>1&&(R[o++]=R[k++]))}break}}break}}while(n<i&&o<s);n-=b=v>>3,p&=(1<<(v-=b<<3))-1,e.next_in=n,e.next_out=o,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=o<s?s-o+257:257-(o-s),r.hold=p,r.bits=v},Bx=function(e,t,r,n,i,o,a,s){var c,u,d,l,h,p,v,f,_,m=s.bits,y=0,g=0,S=0,b=0,E=0,k=0,T=0,I=0,R=0,A=0,w=null,C=0,x=new xx.Buf16(16),O=new xx.Buf16(16),D=null,N=0;for(y=0;y<=Ox;y++)x[y]=0;for(g=0;g<n;g++)x[t[r+g]]++;for(E=m,b=Ox;b>=1&&0===x[b];b--);if(E>b&&(E=b),0===b)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(S=1;S<b&&0===x[S];S++);for(E<S&&(E=S),I=1,y=1;y<=Ox;y++)if(I<<=1,(I-=x[y])<0)return-1;if(I>0&&(0===e||1!==b))return-1;for(O[1]=0,y=1;y<Ox;y++)O[y+1]=O[y]+x[y];for(g=0;g<n;g++)0!==t[r+g]&&(a[O[t[r+g]]++]=g);if(0===e?(w=D=a,p=19):1===e?(w=Dx,C-=257,D=Nx,N-=257,p=256):(w=Mx,D=Px,p=-1),A=0,g=0,y=S,h=o,k=E,T=0,d=-1,l=(R=1<<E)-1,1===e&&R>852||2===e&&R>592)return 1;for(;;){v=y-T,a[g]<p?(f=0,_=a[g]):a[g]>p?(f=D[N+a[g]],_=w[C+a[g]]):(f=96,_=0),c=1<<y-T,S=u=1<<k;do{i[h+(A>>T)+(u-=c)]=v<<24|f<<16|_|0}while(0!==u);for(c=1<<y-1;A&c;)c>>=1;if(0!==c?(A&=c-1,A+=c):A=0,g++,0==--x[y]){if(y===b)break;y=t[r+a[g]]}if(y>E&&(A&l)!==d){for(0===T&&(T=E),h+=S,I=1<<(k=y-T);k+T<b&&!((I-=x[k+T])<=0);)k++,I<<=1;if(R+=1<<k,1===e&&R>852||2===e&&R>592)return 1;i[d=A&l]=E<<24|k<<16|h-o|0}}return 0!==A&&(i[h+A]=y-T<<24|64<<16|0),s.bits=E,0},jx=-2,Gx=12,Hx=30;function zx(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function Kx(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Lx.Buf16(320),this.work=new Lx.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Xx(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Lx.Buf32(852),t.distcode=t.distdyn=new Lx.Buf32(592),t.sane=1,t.back=-1,0):jx}function Wx(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,Xx(e)):jx}function qx(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?jx:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,Wx(e))):jx}function Yx(e,t){var r,n;return e?(n=new Kx,e.state=n,n.window=null,0!==(r=qx(e,t))&&(e.state=null),r):jx}var Jx,Qx,Zx=!0;function $x(e){if(Zx){var t;for(Jx=new Lx.Buf32(512),Qx=new Lx.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Bx(1,e.lens,0,288,Jx,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Bx(2,e.lens,0,32,Qx,0,e.work,{bits:5}),Zx=!1}e.lencode=Jx,e.lenbits=9,e.distcode=Qx,e.distbits=5}function eO(e,t,r,n){var i,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Lx.Buf8(o.wsize)),n>=o.wsize?(Lx.arraySet(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((i=o.wsize-o.wnext)>n&&(i=n),Lx.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?(Lx.arraySet(o.window,t,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0}Cx.inflateReset=Wx,Cx.inflateReset2=qx,Cx.inflateResetKeep=Xx,Cx.inflateInit=function(e){return Yx(e,15)},Cx.inflateInit2=Yx,Cx.inflate=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R=0,A=new Lx.Buf8(4),w=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return jx;(r=e.state).mode===Gx&&(r.mode=13),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,l=s,h=c,k=0;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(2&r.wrap&&35615===u){r.check=0,A[0]=255&u,A[1]=u>>>8&255,r.check=Vx(r.check,A,2,0),u=0,d=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=Hx;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=Hx;break}if(d-=4,E=8+(15&(u>>>=4)),0===r.wbits)r.wbits=E;else if(E>r.wbits){e.msg="invalid window size",r.mode=Hx;break}r.dmax=1<<E,e.adler=r.check=1,r.mode=512&u?10:Gx,u=0,d=0;break;case 2:for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(r.flags=u,8!=(255&wx(r))){e.msg="unknown compression method",r.mode=Hx;break}if(57344&wx(r)){e.msg="unknown header flags set",r.mode=Hx;break}r.head&&(r.head.text=u>>8&1),512&wx(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=Vx(r.check,A,2,0)),u=0,d=0,r.mode=3;case 3:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.head&&(r.head.time=u),512&wx(r)&&(A[0]=255&u,A[1]=u>>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,r.check=Vx(r.check,A,4,0)),u=0,d=0,r.mode=4;case 4:for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&wx(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=Vx(r.check,A,2,0)),u=0,d=0,r.mode=5;case 5:if(1024&wx(r)){for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length=u,r.head&&(r.head.extra_len=u),512&wx(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=Vx(r.check,A,2,0)),u=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&wx(r)&&((p=r.length)>s&&(p=s),p&&(r.head&&(E=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),Lx.arraySet(r.head.extra,n,o,p,E)),512&wx(r)&&(r.check=Vx(r.check,n,p,o)),s-=p,o+=p,r.length-=p),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&wx(r)){if(0===s)break e;p=0;do{E=n[o+p++],r.head&&E&&r.length<65536&&(r.head.name+=String.fromCharCode(E))}while(E&&p<s);if(512&wx(r)&&(r.check=Vx(r.check,n,p,o)),s-=p,o+=p,E)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&wx(r)){if(0===s)break e;p=0;do{E=n[o+p++],r.head&&E&&r.length<65536&&(r.head.comment+=String.fromCharCode(E))}while(E&&p<s);if(512&wx(r)&&(r.check=Vx(r.check,n,p,o)),s-=p,o+=p,E)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&wx(r)){for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=Hx;break}u=0,d=0}r.head&&(r.head.hcrc=wx(r)>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=Gx;break;case 10:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}e.adler=r.check=zx(u),u=0,d=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,2;e.adler=r.check=1,r.mode=Gx;case Gx:if(5===t||6===t)break e;case 13:if(r.last){u>>>=7&d,d-=7&d,r.mode=27;break}for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}switch(r.last=1&u,d-=1,3&(u>>>=1)){case 0:r.mode=14;break;case 1:if($x(r),r.mode=20,6===t){u>>>=2,d-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=Hx}u>>>=2,d-=2;break;case 14:for(u>>>=7&d,d-=7&d;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=Hx;break}if(r.length=65535&u,u=0,d=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(p=r.length){if(p>s&&(p=s),p>c&&(p=c),0===p)break e;Lx.arraySet(i,n,o,p,a),s-=p,o+=p,c-=p,a+=p,r.length-=p;break}r.mode=Gx;break;case 17:for(;d<14;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(r.nlen=257+(31&u),u>>>=5,d-=5,r.ndist=1+(31&u),u>>>=5,d-=5,r.ncode=4+(15&u),u>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Hx;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.lens[w[r.have++]]=7&u,u>>>=3,d-=3}for(;r.have<19;)r.lens[w[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,T={bits:r.lenbits},k=Bx(0,r.lens,0,19,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid code lengths set",r.mode=Hx;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,y=65535&R,!((_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(y<16)u>>>=_,d-=_,r.lens[r.have++]=y;else{if(16===y){for(I=_+2;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u>>>=_,d-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=Hx;break}E=r.lens[r.have-1],p=3+(3&u),u>>>=2,d-=2}else if(17===y){for(I=_+3;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=_,E=0,p=3+(7&(u>>>=_)),u>>>=3,d-=3}else{for(I=_+7;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=_,E=0,p=11+(127&(u>>>=_)),u>>>=7,d-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Hx;break}for(;p--;)r.lens[r.have++]=E}}if(r.mode===Hx)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=Hx;break}if(r.lenbits=9,T={bits:r.lenbits},k=Bx(1,r.lens,0,r.nlen,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid literal/lengths set",r.mode=Hx;break}if(r.distbits=6,r.distcode=r.distdyn,T={bits:r.distbits},k=Bx(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,T),r.distbits=T.bits,k){e.msg="invalid distances set",r.mode=Hx;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,Fx(e,h),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,r.mode===Gx&&(r.back=-1);break}for(r.back=0;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,y=65535&R,!((_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(m&&0==(240&m)){for(g=_,S=m,b=y;m=(R=r.lencode[b+((u&(1<<g+S)-1)>>g)])>>>16&255,y=65535&R,!(g+(_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=g,d-=g,r.back+=g}if(u>>>=_,d-=_,r.back+=_,r.length=y,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=Gx;break}if(64&m){e.msg="invalid literal/length code",r.mode=Hx;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=(R=r.distcode[u&(1<<r.distbits)-1])>>>16&255,y=65535&R,!((_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(0==(240&m)){for(g=_,S=m,b=y;m=(R=r.distcode[b+((u&(1<<g+S)-1)>>g)])>>>16&255,y=65535&R,!(g+(_=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=g,d-=g,r.back+=g}if(u>>>=_,d-=_,r.back+=_,64&m){e.msg="invalid distance code",r.mode=Hx;break}r.offset=y,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Hx;break}r.mode=25;case 25:if(0===c)break e;if(p=h-c,r.offset>p){if((p=r.offset-p)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Hx;break}p>r.wnext?(p-=r.wnext,v=r.wsize-p):v=r.wnext-p,p>r.length&&(p=r.length),f=r.window}else f=i,v=a-r.offset,p=r.length;p>c&&(p=c),c-=p,r.length-=p;do{i[a++]=f[v++]}while(--p);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[a++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;d<32;){if(0===s)break e;s--,u|=n[o++]<<d,d+=8}if(h-=c,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=wx(r)?Vx(r.check,i,h,a-h):Ux(r.check,i,h,a-h)),h=c,(wx(r)?u:zx(u))!==r.check){e.msg="incorrect data check",r.mode=Hx;break}u=0,d=0}r.mode=28;case 28:if(r.wrap&&wx(r)){for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=Hx;break}u=0,d=0}r.mode=29;case 29:k=1;break e;case Hx:k=-3;break e;case 31:return-4;default:return jx}return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,(r.wsize||h!==e.avail_out&&r.mode<Hx&&(r.mode<27||4!==t))&&eO(e,e.output,e.next_out,h-e.avail_out),l-=e.avail_in,h-=e.avail_out,e.total_in+=l,e.total_out+=h,r.total+=h,r.wrap&&h&&(e.adler=r.check=wx(r)?Vx(r.check,i,h,e.next_out-h):Ux(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===Gx?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===h||4===t)&&0===k&&(k=-5),k},Cx.inflateEnd=function(e){if(!e||!e.state)return jx;var t=e.state;return t.window&&(t.window=null),e.state=null,0},Cx.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?jx:(r.head=t,t.done=!1,0):jx},Cx.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?jx:11===r.mode&&Ux(1,t,n,0)!==r.check?-3:eO(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,0):jx},Cx.inflateInfo="pako inflate (from Nodeca project)";var tO={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};var rO=Cx,nO=Uw,iO=rx,oO=tO,aO=wC,sO=ux,cO=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},uO=Object.prototype.toString;function dO(e){if(!(this instanceof dO))return new dO(e);this.options=nO.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new sO,this.strm.avail_out=0;var r=rO.inflateInit2(this.strm,t.windowBits);if(r!==oO.Z_OK)throw new Error(aO[r]);if(this.header=new cO,rO.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=iO.string2buf(t.dictionary):"[object ArrayBuffer]"===uO.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=rO.inflateSetDictionary(this.strm,t.dictionary))!==oO.Z_OK))throw new Error(aO[r])}function lO(e,t){var r=new dO(t);if(r.push(e,!0),r.err)throw r.msg||aO[r.err];return r.result}dO.prototype.push=function(e,t){var r,n,i,o,a,s=this.strm,c=this.options.chunkSize,u=this.options.dictionary,d=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?oO.Z_FINISH:oO.Z_NO_FLUSH,"string"==typeof e?s.input=iO.binstring2buf(e):"[object ArrayBuffer]"===uO.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new nO.Buf8(c),s.next_out=0,s.avail_out=c),(r=rO.inflate(s,oO.Z_NO_FLUSH))===oO.Z_NEED_DICT&&u&&(r=rO.inflateSetDictionary(this.strm,u)),r===oO.Z_BUF_ERROR&&!0===d&&(r=oO.Z_OK,d=!1),r!==oO.Z_STREAM_END&&r!==oO.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==oO.Z_STREAM_END&&(0!==s.avail_in||n!==oO.Z_FINISH&&n!==oO.Z_SYNC_FLUSH)||("string"===this.options.to?(i=iO.utf8border(s.output,s.next_out),o=s.next_out-i,a=iO.buf2string(s.output,i),s.next_out=o,s.avail_out=c-o,o&&nO.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(nO.shrinkBuf(s.output,s.next_out)))),0===s.avail_in&&0===s.avail_out&&(d=!0)}while((s.avail_in>0||0===s.avail_out)&&r!==oO.Z_STREAM_END);return r===oO.Z_STREAM_END&&(n=oO.Z_FINISH),n===oO.Z_FINISH?(r=rO.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===oO.Z_OK):n!==oO.Z_SYNC_FLUSH||(this.onEnd(oO.Z_OK),s.avail_out=0,!0)},dO.prototype.onData=function(e){this.chunks.push(e)},dO.prototype.onEnd=function(e){e===oO.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=nO.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},yx.Inflate=dO,yx.inflate=lO,yx.inflateRaw=function(e,t){return(t=t||{}).raw=!0,lO(e,t)},yx.ungzip=lO;var hO={};(0,Uw.assign)(hO,Vw,yx,tO);var pO,vO=hO,fO="BytePlusRTC",_O=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},mO=function(){function e(t){Vl(this,e),Jd(this,"storeName",void 0),Jd(this,"pendingList",[]),this.storeName=t,!fw()&&_O()&&this._checkAndCreateStore(t)}var t,r;return Ul(e,[{key:"_checkAndCreateStore",value:function(t,r){var n=this;e.db&&e.db.close();var i=r?_O().open(fO,r):_O().open(fO);i.onupgradeneeded=function(){i.result.createObjectStore(t)},i.onerror=function(e){console.error("IndexedDBInterface error",i.error)},i.onsuccess=function(){var r=i.result;e.db=r;try{e.db.transaction(n.storeName,"readonly"),n.pendingList.forEach(function(){var e=Rm(Tm().mark((function e(t){var r,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.txMode,i=t.resolve,o=t.reject,e.prev=1,e.next=4,n._getStore(r);case 4:a=e.sent,i(a),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o();case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}())}catch(o){n._checkAndCreateStore(t,r.version+1)}}}},{key:"_getStore",value:function(t){var r=this;return new Y_((function(n,i){e.db?n(e.db.transaction(r.storeName,t).objectStore(r.storeName)):r.pendingList.push({txMode:t,resolve:n,reject:i})}))}},{key:"put",value:(r=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readwrite");case 2:return n=e.sent,e.abrupt("return",new Y_((function(e,i){var o=n.put(t,r);o.onsuccess=function(){e()},o.onerror=function(e){i(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"get",value:(t=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readonly");case 2:return r=e.sent,e.abrupt("return",new Y_((function(e,n){var i=r.get(t);i.onsuccess=function(){e(i.result)},i.onerror=function(e){n(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();Jd(mO,"db",void 0),Jd(mO,"state","init");var yO={product_line:"rtc",report_version:"5",os:"web",user_agent:fw()?"":null===(pO=navigator)||void 0===pO?void 0:pO.userAgent,platform:"web",product:"webrtc",app_state:"active"},gO="ReportErrorBuffer",SO=function(){function e(){Vl(this,e),Jd(this,"_buffer",new mO(gO))}var t,r;return Ul(e,[{key:"set",value:(r=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._buffer.put(t,gO);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"get",value:(t=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.prev=1,e.next=4,this._buffer.get(gO);case 4:t=e.sent,e.next=9;break;case 7:e.prev=7,e.t0=e.catch(1);case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(){return t.apply(this,arguments)})}]),e}(),bO=function(){function e(){var t=this;Vl(this,e),Jd(this,"reportCommon",yO),Jd(this,"dataBuffer",[]),Jd(this,"logBuffer",[]),Jd(this,"posting",!1),Jd(this,"sucSendTimer",void 0),Jd(this,"preSucTime",0),Jd(this,"errSendTimer",void 0),Jd(this,"errSendDelay",100),Jd(this,"errSendBuffer",void 0),Jd(this,"_logServerUrl",void 0),Jd(this,"_retryCount",0),fw()||(window.addEventListener("beforeunload",(function(){clearTimeout(t.errSendTimer),clearTimeout(t.sucSendTimer),t.send(void 0,!0)})),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState?t.setCommonStats({app_state:"active"}):"hidden"===document.visibilityState&&t.setCommonStats({app_state:"background"})})))}var t;return Ul(e,[{key:"setUrl",value:function(e){this._logServerUrl=e}},{key:"setCommonStats",value:function(e){this.reportCommon=wb(this.reportCommon,e)}},{key:"enableErrorBuffer",value:function(){this.errSendBuffer=new SO,this.loadErrorBuffer()}},{key:"push",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?this.send(e):(this.dataBuffer.push(e),!this.posting&&!this.errSendTimer&&Date.now()-this.preSucTime>2e3&&(clearTimeout(this.sucSendTimer),this.send()))}},{key:"unshift",value:function(e){this.dataBuffer=Om(e).call(e,this.dataBuffer)}},{key:"send",value:function(e,t){var r,n,i=this;if((e||this.dataBuffer.length)&&this._logServerUrl){var o={data:e||rk(r=this.dataBuffer).call(r,0,EO(this.dataBuffer,5e5)),header:Zd(Zd({},this.reportCommon),{},{http_retry_count:this._retryCount}),from:"web",os:"web",version:"1"},a=new XMLHttpRequest;if(a.timeout=1e4,a.onreadystatechange=function(){if(4===a.readyState){var r,n,s,c;if(e||(i.posting=!1),200===a.status||304===a.status)try{r=JSON.parse(a.responseText)}catch(XW){n=XW}if(r&&0===r.StatusCode){if(!e&&!t)null===(s=i.errSendBuffer)||void 0===s||s.set([]),i.sucSend()}else if(setTimeout((function(){var e,t;PO(Om(e="reportor error, res:".concat(null===(t=r)||void 0===t?void 0:t.toString()," err:")).call(e,n),a.status,n)}),0),e)i.send(e);else i.unshift(o.data),null===(c=i.errSendBuffer)||void 0===c||c.set(Jk(i.dataBuffer)),t?i.send():i.errSend()}},a.open("POST",this._logServerUrl,!0),e||(this.posting=!0),!fw()&&mk(n=location.search).call(n,"_rtc_debug_"))a.send(Pm(o));else{var s=vO.gzip(Pm(o));a.setRequestHeader("Content-Encoding","gzip"),a.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),a.send(s)}}}},{key:"sucSend",value:function(){this.errSendDelay=100,this._retryCount=0,this.preSucTime=Date.now(),this.sucSendTimer=window.setTimeout(this.send.bind(this),2e3)}},{key:"errSend",value:function(){var e=this;this.errSendTimer=window.setTimeout((function(){e.send(),delete e.errSendTimer}),this.errSendDelay),this.errSendDelay*=2,this._retryCount++}},{key:"loadErrorBuffer",value:(t=Rm(Tm().mark((function e(){var t,r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this.errSendBuffer)||void 0===r?void 0:r.get();case 2:if(e.t1=t=e.sent,e.t0=null!==e.t1,!e.t0){e.next=6;break}e.t0=void 0!==t;case 6:if(!e.t0){e.next=10;break}e.t2=t,e.next=11;break;case 10:e.t2=[];case 11:e.t2.forEach((function(e){n.push(e)}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}();function EO(e,t){for(var r=0,n=0;n<e.length;n++)if((r+=Pm(e[n]).length)>t)return n-1;return e.length}var kO=new bO,TO=function(){function e(t){Vl(this,e),Jd(this,"report_id",0),Jd(this,"modify_ids",{}),this.id=t}return Ul(e,[{key:"report",value:function(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=Zd(Zd(Zd({event_key:e,report_id:this.report_id++,rtc_timestamp:Date.now()},this.modify_ids),t),{},{common_extra_info:Pm(i)});(kO.push(o),fw())||(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,this.id,o))}},{key:"set",value:function(e){this.modify_ids=wb(this.modify_ids,e)}},{key:"destroy",value:function(){}}]),e}(),IO=new Pw("MessageReportor",1),RO=function(){function e(t){Vl(this,e),Jd(this,"_preTime",Date.now()),Jd(this,"_one2oneNum",0),Jd(this,"_one2manyNum",0),Jd(this,"_one2oneMsgCache",new $S),Jd(this,"_one2manyMsgCache",new $S),Jd(this,"roomId",""),Jd(this,"userId",""),Jd(this,"rtsSessionId",""),this.id=t}return Ul(e,[{key:"needReport",value:function(t){return!!e.config&&(Date.now()-this._preTime>=36e5&&(this._preTime=Date.now(),this._one2oneNum=0,this._one2manyNum=0),"one2one"===t&&this._one2oneNum<e.config.max_one2one_fpt_per_hour&&Math.random()<=e.config.one2one_fpt_ratio/100||"one2many"===t&&this._one2manyNum<e.config.max_one2many_fpt_per_hour&&Math.random()<=e.config.one2many_fpt_ratio/100)}},{key:"cacheP2PMsg",value:function(t){var r;this._one2oneMsgCache.set(t.msg_id,Zd({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateP2PMsg",value:function(e,t){var r=this._one2oneMsgCache.get(e);r&&this._one2oneMsgCache.set(e,Zd(Zd({},r),t))}},{key:"cacheCustomMsg",value:function(t){var r;this._one2manyMsgCache.set(t.msg_id,Zd({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateOne2ManyMsg",value:function(e,t){var r=this._one2manyMsgCache.get(e);r&&this._one2manyMsgCache.set(e,Zd(Zd({},r),t))}},{key:"reportP2PMsg",value:function(e){var t,r=this._one2oneMsgCache.get(e);r&&(IO.info("reportP2PMsg",r.type,Pm(r)),null===(t=VO(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportOne2ManyMsg",value:function(e){var t,r=this._one2manyMsgCache.get(e);r&&(IO.info("reportOne2ManyMsg",r.type,Pm(r)),null===(t=VO(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportMsgRecv",value:function(t){var r,n;t.config_version=(null===(r=e.config)||void 0===r?void 0:r.version)||"",IO.info("reportMsgRecv",t.type,Pm(t)),null===(n=VO(this.id))||void 0===n||n.report("rts_message",t)}},{key:"destroy",value:function(){this._one2manyNum=0,this._one2oneNum=0,this._one2manyMsgCache.clear(),this._one2oneMsgCache.clear(),this._preTime=Date.now(),this.roomId="",this.userId="",this.rtsSessionId=""}}]),e}();Jd(RO,"config",void 0);var AO=new $S,wO={_cache:AO,setConfig:function(e){IO.info("setConfig","get config: ".concat(Pm(e))),RO.config=e},setRtsSessionId:function(e,t){var r=AO.get(e);r&&(r.rtsSessionId=t)},createRTSMsgReportor:function(e){var t=AO.get(e)||new RO(e);return AO.set(e,t),t},destroyRTSMsgReportor:function(e){var t=AO.get(e);t&&(t.destroy(),AO.delete(e))},setRoomId:function(e,t){var r=AO.get(e);r&&(r.roomId=t||"")},setUserId:function(e,t){var r=AO.get(e);r&&(r.userId=t||"")},samplingP2PMsg:function(e,t){var r=AO.get(e);if(null!=r&&r.needReport("one2one")){var n,i=Om(n="".concat(t.from)).call(n,t.id),o=t.to?"one2one":"one2server";t.enable_report=!0,t.report_msg_id=t.id,r.cacheP2PMsg({rts_session_id:r.rtsSessionId,msg_id:i,node_role:"src_sdk",from:t.from,to:t.to||"server",type:o,rts_room_id:t.room,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""})}return t},updateP2PMsgReq:function(e,t,r){var n,i;t.enable_report&&mw(t.report_msg_id)&&(null===(n=AO.get(e))||void 0===n||n.updateP2PMsg(Om(i="".concat(t.from)).call(i,t.report_msg_id),{send_ts:Date.now(),msg_size:r}))},updateP2PMsgAck:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i,o=AO.get(e);null==o||o.updateP2PMsg(Om(n="".concat(t.from)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportP2PMsg(Om(i="".concat(t.from)).call(i,t.report_msg_id))}},samplingOne2ManyMsg:function(e,t,r){var n,i=AO.get(e);null!=i&&i.needReport("one2many")&&(r.enable_report=!0,r.report_msg_id=t,i.cacheCustomMsg({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(r.clientId)).call(n,t),node_role:"src_sdk",from:r.clientId,to:i.roomId,type:"one2many",rts_room_id:i.roomId,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""}));return r},reportP2PMsgRecv:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i=AO.get(e),o=t.to?"one2one":"one2many";null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(t.from)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:o,rts_room_id:t.room,from:t.from,to:t.to||t.room,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:t.to?"":i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}},updateOne2ManyMsgAck:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i,o=AO.get(e);if(o)null==o||o.updateOne2ManyMsg(Om(n="".concat(t.clientId)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportOne2ManyMsg(Om(i="".concat(t.clientId)).call(i,t.report_msg_id))}},updateOne2ManyMsgReq:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i=AO.get(e);if(i)i.updateOne2ManyMsg(Om(n="".concat(t.clientId)).call(n,t.report_msg_id),{send_ts:Date.now(),msg_size:r})}},reportOne2ManyMsgRecv:function(e,t,r){if(t.enable_report&&mw(t.report_msg_id)){var n,i=AO.get(e);null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(t.clientId)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:"one2many",rts_room_id:t.roomId,from:t.clientId,to:t.roomId,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}}},CO=function(){function e(t){Vl(this,e),Jd(this,"_timer",void 0),Jd(this,"userMessage",{}),Jd(this,"roomMessage",{}),this.id=t,this._setTimer()}return Ul(e,[{key:"_setTimer",value:function(){var e=this;!function t(){e._reportAndgReset(),clearTimeout(e._timer),e._timer=setTimeout(t,1e4)}()}},{key:"_reportAndgReset",value:function(){(an(this.userMessage).length||an(this.roomMessage).length)&&(this._report(),this._reset())}},{key:"_report",value:function(){var e,t,r,n=this;null===(e=VO(this.id))||void 0===e||e.report("rtc_message_statistics",{dc_user_message:jm(t=an(this.userMessage)).call(t,(function(e){return n.userMessage[e]})),dc_room_message:jm(r=an(this.roomMessage)).call(r,(function(e){return n.roomMessage[e]})),media_server_ip:""})}},{key:"_reset",value:function(){this.userMessage={},this.roomMessage={}}},{key:"_checkInitUserMessage",value:function(e,t){var r,n;this.userMessage[Om(r="".concat(t,"-")).call(r,e)]||(this.userMessage[Om(n="".concat(t,"-")).call(n,e)]={dc_peer_user_id:e,dc_send_total:0,dc_recv_total:0,dc_send_ack:0,dc_send_fail:0,dc_fail_timeout:0,dc_fail_no_receiver:0,dc_fail_no_relay_path:0,dc_cost_time:0,dc_cost_e2s:0,dc_cost_s2s:0,dc_least_time:Number(1/0),dc_most_time:0,dc_cost_peer_s2e:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_message_type:t,dc_send_binary:0})}},{key:"_sendUserMessage",value:function(e,t,r){var n,i;(this._checkInitUserMessage(e,t),this.userMessage[Om(n="".concat(t,"-")).call(n,e)].dc_send_total++,r)&&this.userMessage[Om(i="".concat(t,"-")).call(i,e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){var r;this._checkInitUserMessage(e,t),this.userMessage[Om(r="".concat(t,"-")).call(r,e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n,i=this.userMessage[Om(n="".concat(t,"-")).call(n,e)];i&&(i.dc_send_fail++,this._handleUserFail(i,r))}},{key:"_handleUserFail",value:function(e,t){var r;t&&(t.code||t.err)&&(mk(r=["TIME_OUT","USER_MESSAGE_TIMEOUT"]).call(r,t.code)?e.dc_fail_timeout++:3===t.err?e.dc_fail_no_receiver++:4===t.err?e.dc_fail_no_relay_path++:1===t.err&&e.dc_fail_timeout++)}},{key:"_sendUserAck",value:function(e,t,r,n,i){var o,a=this.userMessage[Om(o="".concat(t,"-")).call(o,e)];a&&(a.dc_send_ack++,a.dc_cost_time+=r,a.dc_cost_s2s+=n||0,a.dc_cost_peer_s2e+=i,a.dc_cost_e2s+=r-(n||0)-i,r<=100?(a.dc_send_ack_100++,a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=200?(a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=400?(a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=1e3&&a.dc_send_ack_1s++,r<a.dc_least_time&&(a.dc_least_time=r),r>a.dc_most_time&&(a.dc_most_time=r))}},{key:"sendRoomMessage",value:function(e,t){this.roomMessage[e]||(this.roomMessage[e]={dc_room_id:e,dc_send_total:0,dc_send_ack:0,dc_cost_time:0,dc_least_time:Number(1/0),dc_most_time:0,dc_send_fail:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_send_binary:0}),this.roomMessage[e].dc_send_total++,t&&this.roomMessage[e].dc_send_binary++}},{key:"sendRoomFail",value:function(e){var t=this.roomMessage[e];t&&t.dc_send_fail++}},{key:"sendRoomAck",value:function(e,t){var r=this.roomMessage[e];r&&(r.dc_send_ack++,r.dc_cost_time+=t,t<r.dc_least_time&&(r.dc_least_time=t),t>r.dc_most_time&&(r.dc_most_time=t),t<=100?(r.dc_send_ack_100++,r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=200?(r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=400?(r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=1e3&&r.dc_send_ack_1s++)}},{key:"sendP2PMessage",value:function(e,t){this._sendUserMessage(e,"p2p",t)}},{key:"recvP2PMessage",value:function(e){this._recvUserMessage(e,"p2p")}},{key:"sendP2PFail",value:function(e,t){this._sendUserFail(e,"p2p",t)}},{key:"sendP2PAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p",t,r,n)}},{key:"sendP2POutRoomMessage",value:function(e,t){this._sendUserMessage(e,"p2p_outside_room",t)}},{key:"recvP2POutRoomMessage",value:function(e){this._recvUserMessage(e,"p2p_outside_room")}},{key:"sendP2POutRoomFail",value:function(e,t){this._sendUserFail(e,"p2p_outside_room",t)}},{key:"sendP2POutRoomAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p_outside_room",t,r,n)}},{key:"sendP2serverMessage",value:function(e){this._sendUserMessage("","p2server",e)}},{key:"sendP2serverFail",value:function(e){this._sendUserFail("","p2server",e)}},{key:"sendP2serveAck",value:function(e,t,r){this._sendUserAck("","p2server",e,t,r)}},{key:"countP2PMessage",value:function(e,t,r,n,i){this.sendP2PMessage(t,r),e?this.sendP2PAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2PFail(t,i)}},{key:"countRoomMessage",value:function(e,t,r,n){this.sendRoomMessage(t,r),e?this.sendRoomAck(t,Date.now()-n):this.sendRoomFail(t)}},{key:"countUserMessageOutsideRoom",value:function(e,t,r,n,i){this.sendP2POutRoomMessage(t,r),e?this.sendP2POutRoomAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2POutRoomFail(t,i)}},{key:"countServerMessage",value:function(e,t,r,n){this.sendP2serverMessage(t),e?(n=n||{},this.sendP2serveAck(Date.now()-r,n.s2s_time||0,n.s2e_time||0)):this.sendP2serverFail(n)}},{key:"destroy",value:function(){this._reset(),clearTimeout(this._timer)}}]),e}(),xO=function(e){kO.setCommonStats(e)},OO=function(e){kO.setUrl(e)},DO=new TO("global"),NO=function(e,t,r){DO.report("rtc_sdk_api_call",{sdk_api_name:e,error_code:t,message:r})},MO=function(e,t,r){DO.report("rtc_sdk_callback",{sdk_callback_name:e,error_code:t,message:r})},PO=function(e,t,r){DO.report("rtc_error",{message:e,error_code:t},r)},LO=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;DO.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)},UO=new $S,VO=function(e){return UO.get(e)};function FO(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e,r,n){if("function"==typeof n.value){var i=n.value;n.value=function(){for(var e,n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];var s,c,u=this.engineId||this.id,d={};(t.forEach((function(e,t){d[e]=o[t]})),"joinRoom"===r)&&(null===(s=VO(u))||void 0===s||s.set({room_id:o[1],user_id:null===(c=o[2])||void 0===c?void 0:c.userId}));null===(e=VO(u))||void 0===e||e.report("rtc_sdk_api_call",{sdk_api_name:r,message:Pm(GO(o)),error_code:0},d);var l=i.apply(this,o);return"function"==typeof(null==l?void 0:l.then)?l.then((function(e){return BO(u,r,[e||{}]),e})).catch((function(e){throw BO(u,r,e.message,e.code),e})):(BO(u,r,[l||{}]),l)}}}}var BO=function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4?arguments[4]:void 0,a={sdk_callback_name:t,error_code:i,message:Pm(Array.isArray(r)?GO(r):r)};o&&(a.room_id=o),null===(n=VO(e))||void 0===n||n.report("rtc_sdk_callback",a)},jO=function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",a=arguments.length>5?arguments[5]:void 0;null===(n=VO(e))||void 0===n||n.report("rtc_invoke_status",{sdk_api_name:t,message:r,error_code:i,stream_id:o,elapse:0},a)};function GO(e){return jm(e).call(e,(function e(t){var r;if(null!=t&&t._reportName)return t._reportName;if(t instanceof HTMLElement)return t.toString();if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)){var n,i,o=ArrayBuffer.isView(t)?t.buffer:t,a=o.byteLength,s=[];if(a>10){var c,u,d,l,h=new DataView(o),p=jm(c=qk({length:5})).call(c,(function(e,t){return h.getUint8(t)})),v=jm(u=jm(d=qk({length:5})).call(d,(function(e,t){return a-1-t})).reverse()).call(u,(function(e){return h.getUint8(e)}));s=Om(l=[]).call(l,Jk(p),["..."],Jk(v))}else s=qk(new Uint8Array(o));return Om(n=Om(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return jm(t).call(t,e);if(mk(r=["[object Object]","[object MediaStreamTrack]"]).call(r,Object.prototype.toString.call(t))){var f={};for(var _ in t)f[_]=e(t[_]);return f}return t}))}var HO=function(e){var t,r=VO(e.engineId),n={keys:sw(e),labelSelector:"",sdkVersion:e.sdkVersion,deviceType:"web",appId:e.appId,deviceId:e.deviceId,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0},i=jm(t=e.requestDomains).call(t,(function(e){return"https://".concat(e,"/decision/v1/multi")}));null==r||r.report("rtc_get_config",{error_code:0,message:Pm(n),elapse:0,host:i.join(","),type:"request",config_id:"",enable_cloud_proxy:!1});var o=jm(i).call(i,function(){var e=Rm(Tm().mark((function e(t,r){var i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"POST",body:Pm(n)}).then((function(e){return e.json()}));case 2:return i=e.sent,e.abrupt("return",{result:i,index:r});case 4:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}());return new Y_((function(e){(function(e){return new Y_((function(t,r){var n=(e=Array.isArray(e)?e:[]).length,i=[];0===n?r([]):e.forEach((function(e){e.then((function(e){t(e)}),(function(e){n--,i.push(e),0===n&&r(i)}))}))}))})(o).then((function(t){var n=t.result,o=t.index;null==r||r.report("rtc_get_config",{error_code:200,message:Pm(n),elapse:0,host:i[o],type:"response",config_id:"",enable_cloud_proxy:!1}),e(n)})).catch((function(e){var t;null==r||r.report("rtc_get_config",{error_code:500,message:null===(t=e[0])||void 0===t?void 0:t.message,elapse:0,host:"",type:"response",config_id:"",enable_cloud_proxy:!1})}))}))},zO={exports:{}},KO=n;Ar({global:!0,forced:KO.globalThis!==KO},{globalThis:KO});var XO=n,WO={exports:{}};!function(e,r){var n;e.exports=(n=n||function(e,r){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),void 0!==XO&&XO.crypto&&(n=XO.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==t&&t.crypto&&(n=t.crypto),!n)try{n=require("crypto")}catch(_){}var i=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(_){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(_){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),a={},s=a.lib={},c=s.Base={extend:function(e){var t=o(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=s.WordArray=c.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=t!=r?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<i;o++){var a=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var s=0;s<i;s+=4)t[n+s>>>2]=r[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e,t=c.clone.call(this);return t.words=km(e=this.words).call(e,0),t},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(i());return new u.init(t,e)}}),d=a.enc={},l=d.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=uy(e.substr(n,2),16)<<24-n%8*4;return new u.init(r,t/2)}},h=d.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new u.init(r,t)}},p=d.Utf8={stringify:function(e){try{return decodeURIComponent(escape(h.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return h.parse(unescape(encodeURIComponent(e)))}},v=s.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){var t;"string"==typeof e&&(e=p.parse(e)),Om(t=this._data).call(t,e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,s=o/(4*a),c=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*a,d=e.min(4*c,o);if(c){for(var l=0;l<c;l+=a)this._doProcessBlock(i,l);r=rk(i).call(i,0,c),n.sigBytes-=d}return new u.init(r,d)},clone:function(){var e=c.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=v.extend({cfg:c.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){v.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new f.HMAC.init(e,r).finalize(t)}}});var f=a.algo={};return a}(Math),n)}(WO),function(e,t){var r;e.exports=(r=WO.exports,function(){if("function"==typeof ArrayBuffer){var e=r.lib.WordArray,t=e.init,n=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,n=[],i=0;i<r;i++)n[i>>>2]|=e[i]<<24-i%4*8;t.call(this,n,r)}else t.apply(this,arguments)};n.prototype=e}}(),r.lib.WordArray)}(zO);var qO=zO.exports,YO={exports:{}},JO={exports:{}};!function(e,t){var r;e.exports=(r=WO.exports,function(){var e=r,t=e.lib.WordArray;function n(e,r,n){for(var i=[],o=0,a=0;a<r;a++)if(a%4){var s=n[e.charCodeAt(a-1)]<<a%4*2|n[e.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=s<<24-o%4*8,o++}return t.create(i,o)}e.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],o=0;o<r;o+=3)for(var a=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<r;s++)i.push(n.charAt(a>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,r=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o<r.length;o++)i[r.charCodeAt(o)]=o}var a=r.charAt(64);if(a){var s=xE(e).call(e,a);-1!==s&&(t=s)}return n(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),r.enc.Base64)}(JO);var QO={exports:{}};!function(e,t){var r;e.exports=(r=WO.exports,function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,a=t.algo,s=[];!function(){for(var t=0;t<64;t++)s[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=a.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,a=e[t+0],c=e[t+1],p=e[t+2],v=e[t+3],f=e[t+4],_=e[t+5],m=e[t+6],y=e[t+7],g=e[t+8],S=e[t+9],b=e[t+10],E=e[t+11],k=e[t+12],T=e[t+13],I=e[t+14],R=e[t+15],A=o[0],w=o[1],C=o[2],x=o[3];A=u(A,w,C,x,a,7,s[0]),x=u(x,A,w,C,c,12,s[1]),C=u(C,x,A,w,p,17,s[2]),w=u(w,C,x,A,v,22,s[3]),A=u(A,w,C,x,f,7,s[4]),x=u(x,A,w,C,_,12,s[5]),C=u(C,x,A,w,m,17,s[6]),w=u(w,C,x,A,y,22,s[7]),A=u(A,w,C,x,g,7,s[8]),x=u(x,A,w,C,S,12,s[9]),C=u(C,x,A,w,b,17,s[10]),w=u(w,C,x,A,E,22,s[11]),A=u(A,w,C,x,k,7,s[12]),x=u(x,A,w,C,T,12,s[13]),C=u(C,x,A,w,I,17,s[14]),A=d(A,w=u(w,C,x,A,R,22,s[15]),C,x,c,5,s[16]),x=d(x,A,w,C,m,9,s[17]),C=d(C,x,A,w,E,14,s[18]),w=d(w,C,x,A,a,20,s[19]),A=d(A,w,C,x,_,5,s[20]),x=d(x,A,w,C,b,9,s[21]),C=d(C,x,A,w,R,14,s[22]),w=d(w,C,x,A,f,20,s[23]),A=d(A,w,C,x,S,5,s[24]),x=d(x,A,w,C,I,9,s[25]),C=d(C,x,A,w,v,14,s[26]),w=d(w,C,x,A,g,20,s[27]),A=d(A,w,C,x,T,5,s[28]),x=d(x,A,w,C,p,9,s[29]),C=d(C,x,A,w,y,14,s[30]),A=l(A,w=d(w,C,x,A,k,20,s[31]),C,x,_,4,s[32]),x=l(x,A,w,C,g,11,s[33]),C=l(C,x,A,w,E,16,s[34]),w=l(w,C,x,A,I,23,s[35]),A=l(A,w,C,x,c,4,s[36]),x=l(x,A,w,C,f,11,s[37]),C=l(C,x,A,w,y,16,s[38]),w=l(w,C,x,A,b,23,s[39]),A=l(A,w,C,x,T,4,s[40]),x=l(x,A,w,C,a,11,s[41]),C=l(C,x,A,w,v,16,s[42]),w=l(w,C,x,A,m,23,s[43]),A=l(A,w,C,x,S,4,s[44]),x=l(x,A,w,C,k,11,s[45]),C=l(C,x,A,w,R,16,s[46]),A=h(A,w=l(w,C,x,A,p,23,s[47]),C,x,a,6,s[48]),x=h(x,A,w,C,y,10,s[49]),C=h(C,x,A,w,I,15,s[50]),w=h(w,C,x,A,_,21,s[51]),A=h(A,w,C,x,k,6,s[52]),x=h(x,A,w,C,v,10,s[53]),C=h(C,x,A,w,b,15,s[54]),w=h(w,C,x,A,c,21,s[55]),A=h(A,w,C,x,g,6,s[56]),x=h(x,A,w,C,R,10,s[57]),C=h(C,x,A,w,m,15,s[58]),w=h(w,C,x,A,T,21,s[59]),A=h(A,w,C,x,f,6,s[60]),x=h(x,A,w,C,E,10,s[61]),C=h(C,x,A,w,p,15,s[62]),w=h(w,C,x,A,S,21,s[63]),o[0]=o[0]+A|0,o[1]=o[1]+w|0,o[2]=o[2]+C|0,o[3]=o[3]+x|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(r.length+1),this._process();for(var s=this._hash,c=s.words,u=0;u<4;u++){var d=c[u];c[u]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8)}return s},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,n,i,o,a){var s=e+(t&r|~t&n)+i+a;return(s<<o|s>>>32-o)+t}function d(e,t,r,n,i,o,a){var s=e+(t&n|r&~n)+i+a;return(s<<o|s>>>32-o)+t}function l(e,t,r,n,i,o,a){var s=e+(t^r^n)+i+a;return(s<<o|s>>>32-o)+t}function h(e,t,r,n,i,o,a){var s=e+(r^(t|~n))+i+a;return(s<<o|s>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),r.MD5)}(QO);var ZO={exports:{}},$O={exports:{}};!function(e,t){var r,n,i,o,a,s,c,u;e.exports=(n=(r=u=WO.exports).lib,i=n.WordArray,o=n.Hasher,a=r.algo,s=[],c=a.SHA1=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],a=r[3],c=r[4],u=0;u<80;u++){if(u<16)s[u]=0|e[t+u];else{var d=s[u-3]^s[u-8]^s[u-14]^s[u-16];s[u]=d<<1|d>>>31}var l=(n<<5|n>>>27)+c+s[u];l+=u<20?1518500249+(i&o|~i&a):u<40?1859775393+(i^o^a):u<60?(i&o|i&a|o&a)-1894007588:(i^o^a)-899497514,c=a,a=o,o=i<<30|i>>>2,i=n,n=l}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=o._createHelper(c),r.HmacSHA1=o._createHmacHelper(c),u.SHA1)}($O);var eD={exports:{}};!function(e,t){var r,n,i;e.exports=(n=(r=WO.exports).lib.Base,i=r.enc.Utf8,void(r.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),a=this._iKey=t.clone(),s=o.words,c=a.words,u=0;u<r;u++)s[u]^=1549556828,c[u]^=909522486;o.sigBytes=a.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t,r=this._hasher,n=r.finalize(e);return r.reset(),r.finalize(Om(t=this._oKey.clone()).call(t,n))}})))}(eD),function(e,t){var r,n,i,o,a,s,c,u;e.exports=(n=(r=u=WO.exports).lib,i=n.Base,o=n.WordArray,a=r.algo,s=a.MD5,c=a.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),a=o.create(),s=a.words,c=n.keySize,u=n.iterations;s.length<c;){r&&i.update(r),r=i.update(e).finalize(t),i.reset();for(var d=1;d<u;d++)r=i.finalize(r),i.reset();Om(a).call(a,r)}return a.sigBytes=4*c,a}}),r.EvpKDF=function(e,t,r){return c.create(r).compute(e,t)},u.EvpKDF)}(ZO);var tD={exports:{}};!function(e,t){var r;e.exports=void((r=WO.exports).lib.Cipher||function(e){var t=r,n=t.lib,i=n.Base,o=n.WordArray,a=n.BufferedBlockAlgorithm,s=t.enc;s.Utf8;var c=s.Base64,u=t.algo.EvpKDF,d=n.Cipher=a.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?g:m}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()});n.StreamCipher=d.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var l=t.mode={},h=n.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),p=l.CBC=function(){var t=h.extend();function r(t,r,n){var i,o=this._iv;o?(i=o,this._iv=e):i=this._prevBlock;for(var a=0;a<n;a++)t[r+a]^=i[a]}return t.Encryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize;r.call(this,e,t,i),n.encryptBlock(e,t),this._prevBlock=km(e).call(e,t,t+i)}}),t.Decryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize,o=km(e).call(e,t,t+i);n.decryptBlock(e,t),r.call(this,e,t,i),this._prevBlock=o}}),t}(),v=(t.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,a=[],s=0;s<n;s+=4)a.push(i);var c=o.create(a,n);Om(e).call(e,c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};n.BlockCipher=d.extend({cfg:d.cfg.extend({mode:p,padding:v}),reset:function(){var e;d.reset.call(this);var t=this.cfg,r=t.iv,n=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=n.createEncryptor:(e=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(n,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4});var f=n.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),_=(t.format={}).OpenSSL={stringify:function(e){var t,r,n=e.ciphertext,i=e.salt;return(i?Om(t=Om(r=o.create([1398893684,1701076831])).call(r,i)).call(t,n):n).toString(c)},parse:function(e){var t,r=c.parse(e),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(t=o.create(km(n).call(n,2,4)),rk(n).call(n,0,4),r.sigBytes-=16),f.create({ciphertext:r,salt:t})}},m=n.SerializableCipher=i.extend({cfg:i.extend({format:_}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),o=i.finalize(t),a=i.cfg;return f.create({ciphertext:o,key:r,iv:a.iv,algorithm:e,mode:a.mode,padding:a.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),y=(t.kdf={}).OpenSSL={execute:function(e,t,r,n,i){var a;if(n||(n=o.random(8)),i)s=u.create({keySize:t+r,hasher:i}).compute(e,n);else var s=u.create({keySize:t+r}).compute(e,n);var c=o.create(km(a=s.words).call(a,t),4*r);return s.sigBytes=4*t,f.create({key:s,iv:c,salt:n})}},g=n.PasswordBasedCipher=m.extend({cfg:m.cfg.extend({kdf:y}),encrypt:function(e,t,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize,n.salt,n.hasher);n.iv=i.iv;var o=m.encrypt.call(this,e,t,i.key,n);return o.mixIn(i),o},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt,n.hasher);return n.iv=i.iv,m.decrypt.call(this,e,t,i.key,n)}})}())}(tD),function(e,t){var r;e.exports=(r=WO.exports,function(){var e=r,t=e.lib.BlockCipher,n=e.algo,i=[],o=[],a=[],s=[],c=[],u=[],d=[],l=[],h=[],p=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,n=0;for(t=0;t<256;t++){var v=n^n<<1^n<<2^n<<3^n<<4;v=v>>>8^255&v^99,i[r]=v,o[v]=r;var f=e[r],_=e[f],m=e[_],y=257*e[v]^16843008*v;a[r]=y<<24|y>>>8,s[r]=y<<16|y>>>16,c[r]=y<<8|y>>>24,u[r]=y,y=16843009*m^65537*_^257*f^16843008*r,d[v]=y<<24|y>>>8,l[v]=y<<16|y>>>16,h[v]=y<<8|y>>>24,p[v]=y,r?(r=f^e[e[e[m^f]]],n^=e[e[n]]):r=n=1}}();var v=[0,1,2,4,8,16,32,64,128,27,54],f=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a<n;a++)a<r?o[a]=t[a]:(u=o[a-1],a%r?r>6&&a%r==4&&(u=i[u>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u]):(u=i[(u=u<<8|u>>>24)>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u],u^=v[a/r|0]<<24),o[a]=o[a-r]^u);for(var s=this._invKeySchedule=[],c=0;c<n;c++){if(a=n-c,c%4)var u=o[a];else u=o[a-4];s[c]=c<4||a<=4?u:d[i[u>>>24]]^l[i[u>>>16&255]]^h[i[u>>>8&255]]^p[i[255&u]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,s,c,u,i)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,d,l,h,p,o),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,i,o,a,s){for(var c=this._nRounds,u=e[t]^r[0],d=e[t+1]^r[1],l=e[t+2]^r[2],h=e[t+3]^r[3],p=4,v=1;v<c;v++){var f=n[u>>>24]^i[d>>>16&255]^o[l>>>8&255]^a[255&h]^r[p++],_=n[d>>>24]^i[l>>>16&255]^o[h>>>8&255]^a[255&u]^r[p++],m=n[l>>>24]^i[h>>>16&255]^o[u>>>8&255]^a[255&d]^r[p++],y=n[h>>>24]^i[u>>>16&255]^o[d>>>8&255]^a[255&l]^r[p++];u=f,d=_,l=m,h=y}f=(s[u>>>24]<<24|s[d>>>16&255]<<16|s[l>>>8&255]<<8|s[255&h])^r[p++],_=(s[d>>>24]<<24|s[l>>>16&255]<<16|s[h>>>8&255]<<8|s[255&u])^r[p++],m=(s[l>>>24]<<24|s[h>>>16&255]<<16|s[u>>>8&255]<<8|s[255&d])^r[p++],y=(s[h>>>24]<<24|s[u>>>16&255]<<16|s[d>>>8&255]<<8|s[255&l])^r[p++],e[t]=f,e[t+1]=_,e[t+2]=m,e[t+3]=y},keySize:8});e.AES=t._createHelper(f)}(),r.AES)}(YO);var rD={exports:{}};!function(e,t){e.exports=WO.exports.enc.Hex}(rD);var nD=rD.exports,iD={exports:{}};!function(e,t){var r,n,i;e.exports=((i=WO.exports).mode.CTR=(r=i.lib.BlockCipherMode.extend(),n=r.Encryptor=r.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize,i=this._iv,o=this._counter;i&&(o=this._counter=km(i).call(i,0),this._iv=void 0);var a=km(o).call(o,0);r.encryptBlock(a,0),o[n-1]=o[n-1]+1|0;for(var s=0;s<n;s++)e[t+s]^=a[s]}}),r.Decryptor=n,r),i.mode.CTR)}(iD);var oD=iD.exports,aD={exports:{}};!function(e,t){var r;e.exports=((r=WO.exports).pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding)}(aD);var sD=aD.exports,cD=new TextDecoder,uD=new TextEncoder,dD=function(){return vw()},lD=function(){return Date.now()};function hD(e){for(var t=0,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];for(var o=0,a=n;o<a.length;o++){var s=a[o];t+=s.length}for(var c=new e(t),u=0,d=0,l=n;d<l.length;d++){var h=l[d];c.set(h,u),u+=h.length}return c}var pD=function(){function e(){Vl(this,e)}var t,r;return Ul(e,null,[{key:"token2auth",value:function(t,r,n,i){return i?"Bearer ".concat(i):"Basic ".concat(e.createUnsafeToken(t,r,n))}},{key:"createUnsafeToken",value:function(e,t,r){var n;return window.btoa(Gs(n=[e,t,r]).call(n,(function(e){return null!==e})).join(":"))}},{key:"merge",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,i=RA(t);n<i.length;n++){var o=eI(i[n],2),a=o[0],s=o[1];null!==s&&"object"===Wd(s)?e.merge(t[a],r[a]):void 0!==r[a]&&(t[a]=r[a])}}},{key:"ab2str",value:function(e){return cD.decode(e)}},{key:"ab2obj",value:function(t){try{var r=e.ab2str(t);return JSON.parse(r)}catch(n){return{}}}},{key:"str2ab",value:function(e){return uD.encode(e).buffer}},{key:"ab2b64str",value:(r=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Y_((function(e){var r=new FileReader;r.onload=function(){return e(r.result)},r.readAsDataURL(new Blob([t]))}));case 2:return r=e.sent,e.abrupt("return",r.split(",",2)[1]);case 4:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"b64str2ab",value:(t=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch("data:application/octet;base64,".concat(t)).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();function vD(){for(var e,t,r=Number(WA(e=km(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=WA(r).call(r,28,"1").split(""),i=[];n.length;)i.push(rk(n).call(n,0,7));return jm(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return YA(r+e.join(""),2)}))}var fD=function(){return Math.floor(65535*Math.random())};function _D(e){return"string"==typeof e&&xE(e).call(e,"__web__rtc__rtt__")>-1}var mD,yD,gD,SD,bD,ED,kD,TD,ID=function(){var e=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]&&i[0],(r=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"})).createDataChannel("default"),r.addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),t&&(r.addTransceiver("audio",{direction:"sendonly"}),r.addTransceiver("video",{direction:"sendonly"})),e.next=8,r.createOffer();case 8:return n=e.sent,r.close(),e.abrupt("return",n.sdp);case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),RD=function(e){return new Y_((function(t,r){var n=(e=Array.isArray(e)?e:[]).length,i=[];0===n?r([]):e.forEach((function(e){e.then((function(e){t(e)}),(function(e){n--,i.push(e),0===n&&r(i)}))}))}))};function AD(e){return Number(Math.max(-127,10*$A(Math.pow(e/255,2))).toFixed(2))}function wD(e){return(e&ul.AUDIO)===ul.AUDIO}function CD(e){return(e&ul.VIDEO)===ul.VIDEO}function xD(e){var t={};return an(e).forEach((function(r){"object"===Wd(e[r])?t[r]=xD(e[r]):hA(r).call(r,"_")||(t[r]=e[r])})),t}function OD(e){var t=new DataView(e.buffer);if(t.byteLength<=4||65535!==t.getUint16(0))return{seiCount:1,seis:[e]};for(var r={seiCount:0,seis:[]},n=!1,i=2;i<t.byteLength;){var o=t.getUint16(i);if(i+=2,t.byteLength-i<o){n=!0;break}var a=new Uint8Array(e.buffer,i,o);if(i+=o,t.byteLength-i>0&&t.byteLength-i<=2){n=!0;break}r.seiCount++,r.seis.push(a)}return n&&(r.seiCount=1,r.seis=[e]),r}function DD(e){return null==e?"undefined | null":"string"==typeof e?e:Pm({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function ND(e){return void 0===e}function MD(e){return function(t,r,n){var i=n.value;n.value=function(){var t;console.warn(Om(t="[RTC WebSDK]: Api: ".concat(r," has been abandoned from version ")).call(t,e));for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return i.apply(this,o)}}}function PD(e){console.warn("[RTC WebSDK]: ".concat(e))}function LD(e){return"number"==typeof e?e:"number"==typeof(null==e?void 0:e.exact)?e.exact:"number"==typeof(null==e?void 0:e.ideal)?e.ideal:"number"==typeof(null==e?void 0:e.max)?e.max:"number"==typeof(null==e?void 0:e.min)?e.min:1}function UD(e){for(var t=atob(e),r=t.length,n=new Uint8Array(r),i=0;i<r;i++)n[i]=t.charCodeAt(i);return n}function VD(e){for(var t="",r=e.byteLength,n=0;n<r;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function FD(e,t,r){var n=BD(e),i=BD(t),o=BD(r);return function(e){for(var t=e.toString(nD),r=new Uint8Array(t.length/2),n=0;n<t.length;n+=2)r[n/2]=uy(t.substr(n,2),16);return r}(YO.exports.encrypt(n,i,{iv:o,mode:oD,padding:sD}).ciphertext)}function BD(e){for(var t=[],r=0;r<e.length;r+=4)t.push(e[r]<<24|(e[r+1]||0)<<16|(e[r+2]||0)<<8|(e[r+3]||0));return qO.create(t,e.length)}var jD=function(){return"undefined"==typeof window},GD=jD()?"":window.navigator.userAgent;function HD(){var e="none";return jD()||(null!==GD.match("Firefox")?e="mozilla":null!==GD.match("Chrome")?(e="chrome-stable",null!==GD.match("Electron")&&(e="electron")):(null!==GD.match("Safari")||null!==GD.match("AppleWebKit"))&&(e="safari")),e}var zD="mozilla"===HD(),KD="safari"===HD(),XD="chrome-stable"===HD(),WD=!jD()&&/CriOS/i.test(GD),qD=!jD()&&/Edg\//i.test(GD),YD=!jD()&&/EdgA/i.test(GD),JD=!jD()&&/EdgiOS/i.test(GD),QD=qD||YD||JD;!jD()&&/(iPhone|iPod)/i.exec(GD);var ZD=!jD()&&(!!/(iPad)/i.exec(GD)||/Macintosh/i.test(GD)&&"ontouchend"in document),$D=!jD()&&/Macintosh/i.test(GD),eN=!jD()&&/MicroMessenger/i.test(GD),tN=!jD()&&mk(mD=GD.toLowerCase()).call(mD,"mobile");!jD()&&/SM-\w+/i.test(GD);var rN=!jD()&&!!/(iPhone|iPad|iPod)/i.exec(GD),nN=!jD()&&/Android/i.test(GD),iN=!jD()&&/Windows/i.test(GD),oN=0,aN=!jD()&&(null===(yD=GD.match(/version\/(\d+)/i))||void 0===yD?void 0:yD[1]);KD&&aN&&(oN=Number(aN));var sN=!jD()&&(null===(gD=GD.match(/Firefox\/(\d+)/i))||void 0===gD?void 0:gD[1]);zD&&sN&&(oN=Number(sN));var cN=oN,uN=oN,dN=null!==(SD=!jD()&&(null===(bD=GD.match(/ ([\d_]+) like Mac OS X/i))||void 0===bD||null===(ED=bD[1])||void 0===ED?void 0:jm(kD=ED.split("_")).call(kD,(function(e){return uy(e)}))))&&void 0!==SD?SD:[],lN=0,hN=!jD()&&(null===(TD=GD.match(/Chrome\/(\d+)/i))||void 0===TD?void 0:TD[1]);hN&&(lN=Number(hN));var pN=lN,vN="BytePlus",fN="RTC_DEVICE_ID",_N="RTC_ACCESS_NODE",mN="RTC_ACCESS_URLS",yN="ENGINE_WEB_CONFIG",gN="SERVER_CONFIG",SN=function(){function e(){Vl(this,e)}return Ul(e,[{key:"get",value:function(e){var t=localStorage.getItem(e);if(!t)return null;try{var r=JSON.parse(t);return r.ttl>0&&Date.now()-r.saveTime>r.ttl?(this.delete(e),null):r.message}catch(n){return null}}},{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n={ttl:r,saveTime:Date.now(),message:t};try{return localStorage.setItem(e,Pm(n)),!0}catch(i){return!1}}},{key:"getTtl",value:function(e){var t=localStorage.getItem(e);if(!t)return null;try{return JSON.parse(t).ttl}catch(r){return null}}},{key:"delete",value:function(e){try{return localStorage.removeItem(e),!0}catch(t){return!1}}}]),e}(),bN=function(e){NI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"_accessVersion","v2"),n}return Ul(r,[{key:"getDeviceId",value:function(){if(jD())return"";var e=this.get(fN);return e&&!/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(e)||(e=function(e){for(var t="",r=0;r<e;r++)t+=Math.floor(10*Math.random());return t}(30)),this.setDeviceId(e),e}},{key:"setDeviceId",value:function(e){return xO({device_id:e}),this.set(fN,e),e}},{key:"getAccessNode",value:function(e){var t,r;return this.get(Om(t=Om(r="".concat(_N,"_").concat(e,"-")).call(r,vN,"-")).call(t,this._accessVersion))}},{key:"setAccessNode",value:function(e,t,r){var n,i;return this.set(Om(n=Om(i="".concat(_N,"_").concat(e,"-")).call(i,vN,"-")).call(n,this._accessVersion),t,1e3*r)}},{key:"deleteAccessNode",value:function(e,t){var r,n,i=this.getAccessNode(e),o=this.getTtl(Om(r=Om(n="".concat(_N,"_").concat(e,"-")).call(n,vN,"-")).call(r,this._accessVersion));Array.isArray(i)&&i.length>0&&((i=Gs(i).call(i,(function(e){return e.mediaID!==t.mediaID&&e.msgKey!==t.msgKey}))).length>0?this.setAccessNode(e,i,o||0):this.clearAccessNode(e))}},{key:"clearAccessNode",value:function(e){var t,r;this.delete(Om(t=Om(r="".concat(_N,"_").concat(e,"-")).call(r,vN,"-")).call(t,this._accessVersion))}},{key:"getAccessUrls",value:function(){return this.get("".concat(mN,"-").concat(vN))}},{key:"setAccessUrls",value:function(e){var t=jm(e).call(e,(function(e){var t,r=e.host,n=e.path;return Om(t="https://".concat(r)).call(t,n)}));return this.set("".concat(mN,"-").concat(vN),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(mN,"-").concat(vN))}},{key:"getEngineWebConfig",value:function(e,t){var r,n,i,o=Om(r=Om(n="".concat(e,"_")).call(n,t,"_")).call(r,this.getDeviceId()),a=this.get(yN);return(null==a||null===(i=gE(a).call(a,(function(e){return e.key===o})))||void 0===i?void 0:i.config)||{}}},{key:"setEngineWebConfig",value:function(e,t,r){var n,i;if(r){var o=Om(n=Om(i="".concat(e,"_")).call(i,t,"_")).call(n,this.getDeviceId()),a=this.get(yN)||[];return(a=Gs(a).call(a,(function(e){return e.key!==o}))).push({key:o,config:r}),this.set(yN,km(a).call(a,-5))}}},{key:"getServerConfig",value:function(e){var t,r="".concat(e),n=this.get(gN);return(null==n||null===(t=gE(n).call(n,(function(e){return e.key===r})))||void 0===t?void 0:t.config)||{}}},{key:"setServerConfig",value:function(e,t){if(t){var r="".concat(e),n=this.get(gN)||[];return(n=Gs(n).call(n,(function(e){return e.key!==r}))).push({key:r,config:t}),this.set(gN,km(n).call(n,-5))}}}]),r}(SN),EN=new bN,kN=new Pw("JoinRoomConfig",0),TN=function(){function e(t){var r;Vl(this,e),Jd(this,"_useTcpAfterJoinTimeout",e.DEFAULT_CONF.useTcpAfterJoinTimeout),Jd(this,"_joinWithTcpOnly",e.DEFAULT_CONF.joinWithTcpOnly),Jd(this,"_joinWithTcpOnlyDelay",e.DEFAULT_CONF.joinWithTcpOnlyDelay),Jd(this,"_blackBrowserRegexList",[]),this._engineId=t,xE(r=location.search).call(r,"__rtc_tcp_only__")>-1&&(this._joinWithTcpOnly=!0,this._joinWithTcpOnlyDelay=0),this._report()}return Ul(e,[{key:"useTcpAfterJoinTimeout",get:function(){return this._useTcpAfterJoinTimeout}},{key:"useTcpJoin",get:function(){return this._joinWithTcpOnly}},{key:"useTcpJoinDelay",get:function(){return this._joinWithTcpOnlyDelay}},{key:"isBlackBrower",value:function(){var e;return gE(e=this._blackBrowserRegexList).call(e,(function(e){return new RegExp(e).test(navigator.userAgent)}))}},{key:"setServerConfig",value:function(e){var t,r,n,i,o,a,s=!1;"boolean"==typeof(null==e||null===(t=e.use_tcp_after_join_timeout)||void 0===t?void 0:t.enable)&&(this._useTcpAfterJoinTimeout=null===(i=e.use_tcp_after_join_timeout)||void 0===i?void 0:i.enable,s=!0);"boolean"==typeof(null==e||null===(r=e.join_with_tcp_only)||void 0===r?void 0:r.enable)&&(this._joinWithTcpOnly=null===(o=e.join_with_tcp_only)||void 0===o?void 0:o.enable,s=!0);"number"==typeof(null==e||null===(n=e.join_with_tcp_only)||void 0===n?void 0:n.delay_ms)&&(this._joinWithTcpOnlyDelay=null===(a=e.join_with_tcp_only)||void 0===a?void 0:a.delay_ms,s=!0);e&&Array.isArray(e.black_browser_regex_list)&&(this._blackBrowserRegexList=e.black_browser_regex_list,s=!0),s&&this._report()}},{key:"toString",value:function(){return Pm({use_tcp_after_join_timeout:this._useTcpAfterJoinTimeout,join_with_tcp_only:this._joinWithTcpOnly,join_with_tcp_only_delay:this._joinWithTcpOnlyDelay,black_browser_regex_list:this._blackBrowserRegexList})}},{key:"_report",value:function(){kN.print("_report",this.toString()),jO(this._engineId,"web_join_room_config",this.toString())}}],[{key:"setDefaulConf",value:function(t){var r=t.useTcpAfterJoinTimeout,n=t.joinWithTcpOnly,i=t.joinWithTcpOnlyDelay;return"boolean"==typeof r&&(e.DEFAULT_CONF.useTcpAfterJoinTimeout=r),"boolean"==typeof n&&(e.DEFAULT_CONF.joinWithTcpOnly=n),"number"==typeof i&&(e.DEFAULT_CONF.joinWithTcpOnlyDelay=Math.max(0,i)),e.DEFAULT_CONF}}]),e}();Jd(TN,"DEFAULT_CONF",{useTcpAfterJoinTimeout:!0,joinWithTcpOnly:!1,joinWithTcpOnlyDelay:5e3});var IN="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function RN(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://".concat(e)),"".concat(e,"/dispatch/v1/AccessInfo?Action=GetAccessInfo")}var AN="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",wN="rtc.rtcplus.com".split(","),CN={VERSION:"4.55.12",ICE_CONFIG_REQUEST_URLS_INTERNAL:jm(IN).call(IN,RN),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:AN,CONFIG_REQUEST_DOMAINS:wN,DEVICE_ID:"",OVERSEA:!1,PLATFORM:"",PRODUCT:"",FORCE_ENABLED_REPORT_CALLBACKS:[],SKIP_WEB_AUDIO_IN_TRACK:!1,AUDIO_STALL:!0,VIDEO_STALL:!0,STATS_SCALLBACK_SUPPORT:!0,JOIN_ROOM_CONFIG:TN.DEFAULT_CONF,IOS_SAFARI_ORIENTATION:!1,ENABLE_REPORT_ERROR_BUFFER:!1,PUB_SUB_MODE:"recv_and_send",ENABLE_FALLBACK_HANDLER:!1};function xN(e,t){var r;if(NO("setParameter",0,Om(r="key: ".concat(e,", value: ")).call(r,t)),"VERSION"!==e){if("JOIN_ROOM_CONFIG"===e)return TN.setDefaulConf(t);if("ICE_CONFIG_REQUEST_URLS"===e)return"string"==typeof t&&(t=[t]),void(CN.ICE_CONFIG_REQUEST_URLS=jm(t).call(t,RN));if("PLATFORM"!==e||"string"!=typeof t)if("PRODUCT"!==e||"string"!=typeof t){if("FORCE_ENABLED_REPORT_CALLBACKS"===e)return"string"==typeof t&&(t=[t]),void(CN.FORCE_ENABLED_REPORT_CALLBACKS=t);if("LOG_SERVER_URL"===e){var n=t===pl.overseas?"https://web-log-report.rtcplus.com/video/v1/webrtc_log/":t===pl.domestic?AN:"string"==typeof t?t:void 0;n&&(CN.LOG_SERVER_URL=n,OO(n))}else if("OVERSEA"===e)return xO({extra_is_oversea:t?"1":"0"}),void(CN.OVERSEA=t);"DEVICE_ID"===e&&EN.setDeviceId(t),"ENABLE_REPORT_ERROR_BUFFER"===e&&t&&kO.enableErrorBuffer(),CN[e]=t}else xO({product:t});else xO({platform:t})}}function ON(e){return"DEVICE_ID"===e?EN.getDeviceId():CN[e]}function DN(e,t,r){var n,i,o,a,s,c,u,d,l;return{type:"publicstream",action:t,publicStreamID:e,publicStreamMeta:{audio:{},video:{fps:(null===(n=r.video)||void 0===n?void 0:n.fps)||15,bitrate:1e3*((null===(i=r.video)||void 0===i?void 0:i.kBitRate)||40),width:(null===(o=r.video)||void 0===o?void 0:o.width)||640,height:(null===(a=r.video)||void 0===a?void 0:a.height)||360},layout:{layoutMode:2,interpolationMode:(null===(s=r.layout)||void 0===s?void 0:s.interpolationMode)||_l.PREV_FRAME,canvas:{bgColor:(null===(c=r.layout)||void 0===c?void 0:c.backgroundColor)||"#000000",bgImage:(null===(u=r.layout)||void 0===u?void 0:u.backgroundImage)||""},regions:(null===(d=r.layout)||void 0===d||null===(l=d.regions)||void 0===l?void 0:jm(l).call(l,(function(e){return{roomId:e.roomId,userId:e.userId,alterImage:e.alertImage||"",alpha:!e.alpha||Number(e.alpha)>1||Number(e.alpha)<=0?1:Number(e.alpha),x:!e.x||Number(e.x)>=1||Number(e.x)<0?0:Number(e.x),y:!e.y||Number(e.y)>=1||Number(e.y)<0?0:Number(e.y),w:!e.w||Number(e.w)>1||Number(e.w)<=0?1:Number(e.w),h:!e.h||Number(e.h)>1||Number(e.h)<=0?1:Number(e.h),zorder:!e.zorder||Number(e.zorder)<0||Number(e.zorder)>100?0:Number(e.zorder),renderMode:void 0===e.renderMode?1:e.renderMode,streamType:e.isScreenStream?1:0,mediaType:e.mediaType||0,sourceCrop:e.sourceCrop}})))||[]}}}}var NN={width:640,height:480,frameRate:15,maxKbps:600},MN={width:1920,height:1080,frameRate:15,maxKbps:3e3};function PN(e,t){if("boolean"!=typeof e)throw new mA(pA.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}function LN(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(e<r||e>n||"number"!=typeof e){var i,o,a=new mA(pA.INVALID_PARAMS,Om(i=Om(o="Invalid ".concat(t,": the value range is [")).call(o,r,", ")).call(i,n,"]. integer only"));throw a}}function UN(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(null==e)throw new mA(pA.INVALID_PARAMS,"".concat(t," cannot be empty"));if(!HN(e,i,o))throw new mA(pA.INVALID_PARAMS,Om(r=Om(n="Invalid ".concat(t,": The value should be string type. Length of the string: [")).call(n,i,",")).call(r,o,"]"))}function VN(e,t,r){var n;if(!mk(r).call(r,e))throw new mA(pA.INVALID_PARAMS,Om(n="Invalid ".concat(t,": The value can only be set as ")).call(n,Pm(r)))}function FN(e){if(!(e instanceof MediaStreamTrack))throw new mA(pA.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}function BN(e,t){if(zN(e))throw new mA(pA.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function jN(e,t){if(!(e instanceof ArrayBuffer))throw new mA(pA.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function GN(e){try{for(var t=navigator.mediaDevices.getSupportedConstraints(),r=0,n=an(e);r<n.length;r++){var i=n[r];t[i]||delete e[i]}}catch(o){}}function HN(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.POSITIVE_INFINITY;return"string"==typeof e&&e.length<=r&&e.length>=t}function zN(e){return null==e}function KN(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new mA(pA.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function XN(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new mA(pA.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function WN(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new mA(pA.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function qN(e){BN(e,"userInfo"),XN(e.userId),zN(e.extraInfo)||UN(e.extraInfo,"userInfo.extraInfo",1,200)}function YN(e){BN(e,"roomConfig"),PN(e.isAutoPublish,"roomConfig.isAutoPublish"),PN(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),PN(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo"),zN(e.roomProfileType)||VN(e.roomProfileType,"roomConfig",[bl.communication,bl.chat,bl.chatRoom,bl.coHost,bl.meeting,bl.classRoom])}function JN(e){BN(e,"videoPlayerOption")}function QN(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64;if(!e||0===(null==e?void 0:e.byteLength))throw new mA(pA.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:pD.str2ab(Pm(e)))||void 0===t?void 0:t.byteLength)>1e3*r)throw new mA(pA.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function ZN(e){var t,r=ON("FORCE_ENABLED_REPORT_CALLBACKS");return!(null==r||!mk(r).call(r,e))||!mk(t=[Pl.onRemoteStreamStats,Pl.onLocalStreamStats,Pl.onAudioVolumeIndication,Pl.onLocalAudioPropertiesReport,Pl.onRemoteAudioPropertiesReport]).call(t,e)}function $N(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new mA(pA.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}function eM(e,t){if("number"!=typeof e||Number.isNaN(e)||!(e>=1)){var r=e;if(!(null!=r&&r.min||null!=r&&r.max||null!=r&&r.exact||null!=r&&r.ideal))throw new mA(pA.INVALID_PARAMS,"".concat(t," is not a valid ConstrainULong"))}}function tM(e){var t,r=$T(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;LN(null==n?void 0:n.maxKbps,"maxKbps"),eM(null==n?void 0:n.width,"width"),eM(null==n?void 0:n.height,"height"),eM(null==n?void 0:n.frameRate,"frameRate")}}catch(i){r.e(i)}finally{r.f()}}function rM(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.NEGATIVE_INFINITY,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;return LN(e,t,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),e=(e=e>r?e:r)<n?e:n}var nM={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?km(n).call(n,1):n);return xs?Om(i).call(i,xs(e)):i},s.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,a=new Array(o);i<o;i++)a[i]=n[i].fn;return a},s.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var c,u,d=this._events[s],l=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),l){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,n),!0;case 4:return d.fn.call(d.context,t,n,i),!0;case 5:return d.fn.call(d.context,t,n,i,o),!0;case 6:return d.fn.call(d.context,t,n,i,o,a),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];d.fn.apply(d.context,c)}else{var h,p=d.length;for(u=0;u<p;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),l){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,n);break;case 4:d[u].fn.call(d[u].context,t,n,i);break;default:if(!c)for(h=1,c=new Array(l-1);h<l;h++)c[h-1]=arguments[h];d[u].fn.apply(d[u].context,c)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var c=0,u=[],d=s.length;c<d;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(nM);var iM=nM.exports,oM=new Pw("VERTC",0),aM=function(e){NI(r,e);var t=QI(r);function r(){return Vl(this,r),t.apply(this,arguments)}return Ul(r,[{key:"safeEmit",value:function(e){var t=this.listenerCount(e);try{for(var n,i,o=arguments.length,a=new Array(o>1?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return(n=OI(CI(r.prototype),"emit",this)).call.apply(n,Om(i=[this,e]).call(i,a))}catch(XW){return oM.error("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,XW),console.error(XW),Boolean(t)}}}]),r}(nM.exports.EventEmitter),sM=O,cM=tr,uM=$,dM=nI,lM=Jt,hM=A,pM=mc,vM=V;Ar({target:"Reflect",stat:!0,forced:i((function(){var e=function(){},t=lM.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}))},{set:function e(t,r,n){var i,o,a,s=arguments.length<4?t:arguments[3],c=hM.f(cM(t),r);if(!c){if(uM(o=pM(t)))return e(o,r,n,s);c=vM(0)}if(dM(c)){if(!1===c.writable||!uM(s))return!1;if(i=hM.f(s,r)){if(i.get||i.set||!1===i.writable)return!1;i.value=n,lM.f(s,r,i)}else lM.f(s,r,vM(0,n))}else{if(void 0===(a=c.set))return!1;sM(a,s,n)}return!0}});var fM=ee.Reflect.set,_M=hi.f("asyncIterator");function mM(e){var t,r,n,i=2;for(void 0!==wd&&(r=_M,n=Xd);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new yM(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function yM(e){function t(e){if(Object(e)!==e)return Y_.reject(new TypeError(e+" is not an object."));var t=e.done;return Y_.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(yM=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Y_.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Y_.reject(e):t(r.apply(this.s,arguments))}},new yM(e)}var gM=[{maxLayers:3,totalPixels:2073600},{maxLayers:3,totalPixels:921600},{maxLayers:3,totalPixels:518400},{maxLayers:2,totalPixels:230400},{maxLayers:2,totalPixels:129600},{maxLayers:1,totalPixels:57600},{maxLayers:1,totalPixels:0}];Yy("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),hg);var SM=ee.Set;Ar({target:"Set",stat:!0,forced:!0},{from:bg}),Ar({target:"Set",stat:!0,forced:!0},{of:kg});var bM=O,EM=Ce,kM=tr,TM=function(){for(var e=kM(this),t=EM(e.add),r=0,n=arguments.length;r<n;r++)bM(t,e,arguments[r]);return e};Ar({target:"Set",proto:!0,real:!0,forced:!0},{addAll:TM}),Ar({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:Ag});var IM=gh,RM=tr,AM=Yt,wM=IM,CM=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=RM(this),r=wM(t),n=AM(e,arguments.length>1?arguments[1]:void 0);return!CM(r,(function(e,r){if(!n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var xM=oe,OM=O,DM=Ce,NM=tr,MM=Rp,PM=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){var t=NM(this),r=new(MM(t,xM("Set")))(t),n=DM(r.delete);return PM(e,(function(e){OM(n,r,e)})),r}});var LM=oe,UM=O,VM=Ce,FM=tr,BM=Yt,jM=Rp,GM=IM,HM=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=FM(this),r=GM(t),n=BM(e,arguments.length>1?arguments[1]:void 0),i=new(jM(t,LM("Set"))),o=VM(i.add);return HM(r,(function(e){n(e,e,t)&&UM(o,i,e)}),{IS_ITERATOR:!0}),i}});var zM=tr,KM=Yt,XM=IM,WM=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=zM(this),r=XM(t),n=KM(e,arguments.length>1?arguments[1]:void 0);return WM(r,(function(e,r){if(n(e,e,t))return r(e)}),{IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var qM=oe,YM=O,JM=Ce,QM=tr,ZM=Rp,$M=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){var t=QM(this),r=new(ZM(t,qM("Set"))),n=JM(t.has),i=JM(r.add);return $M(e,(function(e){YM(n,t,e)&&YM(i,r,e)})),r}});var eP=O,tP=Ce,rP=tr,nP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){var t=rP(this),r=tP(t.has);return!nP(e,(function(e,n){if(!0===eP(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var iP=oe,oP=O,aP=Ce,sP=R,cP=tr,uP=gh,dP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){var t=uP(this),r=cP(e),n=r.has;return sP(n)||(r=new(iP("Set"))(e),n=aP(r.has)),!dP(t,(function(e,t){if(!1===oP(n,r,e))return t()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var lP=O,hP=Ce,pP=tr,vP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){var t=pP(this),r=hP(t.has);return!vP(e,(function(e,n){if(!1===lP(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var fP=Ar,_P=tr,mP=yn,yP=IM,gP=Uh,SP=E([].join),bP=[].push;fP({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=_P(this),r=yP(t),n=void 0===e?",":mP(e),i=[];return gP(r,bP,{that:i,IS_ITERATOR:!0}),SP(i,n)}});var EP=oe,kP=Yt,TP=O,IP=Ce,RP=tr,AP=Rp,wP=IM,CP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=RP(this),r=wP(t),n=kP(e,arguments.length>1?arguments[1]:void 0),i=new(AP(t,EP("Set"))),o=IP(i.add);return CP(r,(function(e){TP(o,i,n(e,e,t))}),{IS_ITERATOR:!0}),i}});var xP=Ce,OP=tr,DP=IM,NP=Uh,MP=TypeError;Ar({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=OP(this),r=DP(t),n=arguments.length<2,i=n?void 0:arguments[1];if(xP(e),NP(r,(function(r){n?(n=!1,i=r):i=e(i,r,r,t)}),{IS_ITERATOR:!0}),n)throw MP("Reduce of empty set with no initial value");return i}});var PP=tr,LP=Yt,UP=IM,VP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=PP(this),r=UP(t),n=LP(e,arguments.length>1?arguments[1]:void 0);return VP(r,(function(e,r){if(n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var FP=oe,BP=O,jP=Ce,GP=tr,HP=Rp,zP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){var t=GP(this),r=new(HP(t,FP("Set")))(t),n=jP(r.delete),i=jP(r.add);return zP(e,(function(e){BP(n,r,e)||BP(i,r,e)})),r}});var KP=oe,XP=Ce,WP=tr,qP=Rp,YP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){var t=WP(this),r=new(qP(t,KP("Set")))(t);return YP(e,XP(r.add),{that:r}),r}});var JP=SM,QP=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!jD()&&window.RTCPeerConnection&&window.RTCPeerConnection.prototype.addTransceiver&&window.RTCPeerConnection.prototype.createDataChannel){e.next=3;break}return e.abrupt("return",!1);case 3:return e.next=5,cL();case 5:if(e.t0=e.sent,!e.t0){e.next=10;break}return e.next=9,sL();case 9:e.t0=e.sent;case 10:return e.abrupt("return",e.t0);case 13:return e.prev=13,e.t1=e.catch(0),e.abrupt("return",!1);case 16:case"end":return e.stop()}}),e,null,[[0,13]])})));return function(){return e.apply(this,arguments)}}(),ZP=function(){var e=Rm(Tm().mark((function e(t){var r,n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t||"recv_and_send",n=[],e.next=4,cL();case 4:return i=e.sent,e.next=7,sL();case 7:return o=e.sent,e.next=10,dL();case 10:return a=e.sent,e.next=13,uL();case 13:return s=e.sent,"send_only"===r&&(o&&n.push("H264"),s&&n.push("vp8")),"recv_only"===r&&(i&&n.push("H264"),a&&n.push("vp8")),"recv_and_send"===r&&(o&&i&&n.push("H264"),s&&a&&n.push("vp8")),e.abrupt("return",n);case 18:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),$P=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Pm(rL));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),eL=function(){var e=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ZP();case 2:return t=e.sent,e.abrupt("return",jm(t).call(t,(function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),tL={},rL={};function nL(e){var t,r=!1,n=$T(e.split("\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value;if(mk(i).call(i,"level-asymmetry-allowed=1")&&mk(i).call(i,"packetization-mode=1")&&mk(i).call(i,"profile-level-id=42e0")){r=!0;break}}}catch(d){n.e(d)}finally{n.f()}if(r){for(var o=navigator.userAgent.toLowerCase(),a=!1,s=0,c=["miuibrowser"];s<c.length;s++){var u=c[s];mk(o).call(o,u)&&(a=!0)}return!a}return!1}var iL=function(){var e=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection({sdpSemantics:"unified-plan"})).addTransceiver("video",{direction:t}),e.next=4,r.createOffer();case 4:return n=e.sent,r.close(),e.abrupt("return",n.sdp.toLowerCase());case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),oL=function(){var e=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,iL("sendonly");case 2:if(r=e.sent,!mk(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,iL("sendonly");case 6:r=e.sent;case 7:return tL.h264encode=nL(r),rL.h264encode=r,tL.vp8encode=xE(r).call(r,"vp8")>-1,rL.vp8encode="same as h264encode",e.abrupt("return",tL);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),aL=function(){var e=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,iL("recvonly");case 2:if(r=e.sent,!mk(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,iL("recvonly");case 6:r=e.sent;case 7:return tL.h264decode=nL(r),rL.h264decode=r,tL.vp8decode=xE(r).call(r,"vp8")>-1,rL.vp8decode="same as h264decode",e.abrupt("return",tL);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),sL=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==tL.h264encode){e.next=10;break}return e.prev=1,e.next=4,oL();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),rL.h264encode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",tL.h264encode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),cL=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==tL.h264decode){e.next=10;break}return e.prev=1,e.next=4,aL();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),rL.h264decode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",tL.h264decode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),uL=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==tL.vp8encode){e.next=10;break}return e.prev=1,e.next=4,oL();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),rL.vp8encode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",tL.vp8encode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),dL=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==tL.vp8decode){e.next=10;break}return e.prev=1,e.next=4,aL();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),rL.vp8decode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",tL.vp8decode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),lL=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},hL=function(){return $D?XD&&pN>=70||zD&&uN>=80||KD&&cN>=14:iN?XD&&pN>=70||zD&&uN>=80:rN?dN[0]>=14:!!nN&&(XD&&pN>=86)},pL=XD&&pN<=114,vL=new $S,fL=function(){var e=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Y_((function(e,r){var n=ON("STATS_SCALLBACK_SUPPORT");if(XD&&void 0===window.InstallTrigger&&pL&&n)try{t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!mk(gL).call(gL,e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(Zd(Zd({},t),{},{id:e.id,type:e.type,timestamp:e.timestamp}))}})),e({all:r,getTrackStats:function(e){return Gs(r).call(r,(function(t){return"ssrc"!==t.type||t.googTrackId===e}))}})}))}catch(XW){r(XW)}else e({all:[],getTrackStats:function(){return[]}})})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),_L=function(){var e=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getStats();case 2:return n=e.sent,i={all:[]},o=new $S,n.forEach((function(e){var t=o.get(e.type)||new $S;t.set(e.id,e),o.set(e.type,t),i.all.push(e)})),a=function(e,t){e.forEach((function(e){var r,n,i,a,s,c,u=e.codecId,d=e.transportId,l=e.trackId,h=e.playoutId;if(null===(r=o.get(yL.codec))||void 0===r||r.forEach((function(e){e.id===u&&t.add(e)})),null===(n=o.get(yL.transport))||void 0===n||n.forEach((function(e){e.id===d&&(s=e,t.add(e))})),null===(i=o.get(yL.track))||void 0===i||i.forEach((function(e){e.id===l&&t.add(e)})),null===(a=o.get(yL.mediaPlayout))||void 0===a||a.forEach((function(e){e.id===h&&t.add(e)})),s){var p,v,f=s,_=f.localCertificateId,m=f.remoteCertificateId,y=f.selectedCandidatePairId;null===(p=o.get(yL.certificate))||void 0===p||p.forEach((function(e){(e.id===_||e.id===m)&&t.add(e)})),null===(v=o.get(yL.candidatePair))||void 0===v||v.forEach((function(e){e.id===y&&(c=e,t.add(e))}))}if(c){var g,S,b=c,E=b.localCandidateId,k=b.remoteCandidateId;null===(g=o.get(yL.localCandidate))||void 0===g||g.forEach((function(e){e.id===E&&t.add(e)})),null===(S=o.get(yL.remoteCandidate))||void 0===S||S.forEach((function(e){e.id===k&&t.add(e)}))}}))},o.get(yL.mediaSource)?null===(s=o.get(yL.mediaSource))||void 0===s||s.forEach((function(e){var t,r=new JP;r.add(e);var n=[];null===(t=o.get(yL.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=o.get(yL.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=qk(r)})):o.get(yL.track)&&(null===(c=o.get(yL.track))||void 0===c||c.forEach((function(e){var t,r=new JP;r.add(e);var n=[];null===(t=o.get(yL.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.trackId===e.id&&(r.add(t),n.push(t),null===(i=o.get(yL.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=qk(r)}))),null===(r=o.get(yL.inboundRtp))||void 0===r||r.forEach((function(e){var t,r=new JP;r.add(e),null===(t=o.get(yL.remoteOutboundRtp))||void 0===t||t.forEach((function(t){t.localId===e.id&&r.add(t)})),a([e],r);var n,s=e.trackIdentifier;s||(null===(n=o.get(yL.track))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(s=t.trackIdentifier)})));i[s]=qk(r)})),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),mL=function(){var e=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null==r?void 0:r.id,t instanceof RTCPeerConnection){e.next=3;break}return e.abrupt("return",[]);case 3:if(!zD&&!KD){e.next=10;break}return o=[],e.next=7,t.getStats(r);case 7:return e.sent.forEach((function(e){o.push(e)})),e.abrupt("return",o);case 10:return(!(a=vL.get(t))||Date.now()-a.timestamp>150)&&(a={timestamp:Date.now(),statsPromise:_L(t),extraStatsPromise:fL(t)},vL.set(t,a)),e.next=14,a.statsPromise;case 14:if(s=e.sent,c=(i?s[i]:s.all)||[],n){e.next=21;break}return e.next=19,a.extraStatsPromise;case 19:u=e.sent,c=Om(c).call(c,(i?u.getTrackStats(i):u.all)||[]);case 21:return e.abrupt("return",c);case 22:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),yL=function(e){return e.codec="codec",e.inboundRtp="inbound-rtp",e.outboundRtp="outbound-rtp",e.remoteInboundRtp="remote-inbound-rtp",e.remoteOutboundRtp="remote-outbound-rtp",e.mediaSource="media-source",e.csrc="csrc",e.peerConnection="peer-connection",e.dataChannel="data-channel",e.stream="stream",e.track="track",e.transceiver="transceiver",e.sender="sender",e.receiver="receiver",e.transport="transport",e.sctpTransport="sctp-transport",e.candidatePair="candidate-pair",e.localCandidate="local-candidate",e.remoteCandidate="remote-candidate",e.certificate="certificate",e.iceServer="ice-server",e.mediaPlayout="media-playout",e}(yL||{}),gL=["codec","inbound-rtp","outbound-rtp","remote-inbound-rtp","remote-outbound-rtp","media-source","csrc","peer-connection","data-channel","stream","track","transceiver","sender","receiver","transport","sctp-transport","candidate-pair","local-candidate","remote-candidate","certificate","ice-server"],SL={},bL={},EL={exports:{}},kL=EL.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 null!=e.address?"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 null!=e.subtype?"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 null!=e.sessionConfig?"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 t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{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 t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{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 null!=e.maxMessageSize?"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"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{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"]}]};an(kL).forEach((function(e){kL[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))})),function(e){var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,n){var i=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:i&&!r[e.name]&&(r[e.name]={});var o=e.push?{}:i?r[e.name]:r;!function(e,r,n,i){if(i&&!n)r[i]=t(e[1]);else for(var o=0;o<n.length;o+=1)null!=e[o+1]&&(r[n[o]]=t(e[o+1]))}(n.match(e.reg),o,e.names,e.name),e.push&&r[e.push].push(o)},n=EL.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t,o={},a=[],s=o;return Gs(t=e.split(/(\r\n|\r|\n)/)).call(t,i).forEach((function(e){var t=e[0],i=km(e).call(e,2);"m"===t&&(a.push({rtp:[],fmtp:[]}),s=a[a.length-1]);for(var o=0;o<(n[t]||[]).length;o+=1){var c=n[t][o];if(c.reg.test(i))return r(c,s,i)}})),o.media=a,o};var o=function(e,r){var n=r.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&r.length>1&&(e[n[0]]=void 0),e};e.parseParams=function(e){var t;return pb(t=e.split(/;\s?/)).call(t,o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){var t;return jm(t=e.toString().split(" ")).call(t,Number)},e.parseRemoteCandidates=function(e){for(var r,n=[],i=jm(r=e.split(" ")).call(r,t),o=0;o<i.length;o+=3)n.push({component:i[o],ip:i[o+1],port:i[o+2]});return n},e.parseImageAttributes=function(e){var t;return jm(t=e.split(" ")).call(t,(function(e){var t;return pb(t=e.substring(1,e.length-1).split(",")).call(t,o,{})}))},e.parseSimulcastStreamList=function(e){var r;return jm(r=e.split(";")).call(r,(function(e){var r;return jm(r=e.split(",")).call(r,(function(e){var r,n=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),n=!0),{scid:r,paused:n}}))}))}}(bL);var TL=EL.exports,IL=/%[sdv%]/g,RL=function(e){var t=1,r=arguments,n=r.length;return e.replace(IL,(function(e){if(t>=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}}))},AL=function(e,t,r){var n=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var o=t.names[i];t.name?n.push(r[t.name][o]):n.push(r[t.names[i]])}else n.push(r[t.name]);return RL.apply(null,n)},wL=["v","o","s","i","u","e","p","c","b","t","r","z","a"],CL=["i","c","b","a"],xL=bL,OL=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||wL,n=t.innerOrder||CL,i=[];return r.forEach((function(t){TL[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(AL(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(AL(t,r,e))}))}))})),e.media.forEach((function(e){i.push(AL("m",TL.m[0],e)),n.forEach((function(t){TL[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(AL(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(AL(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"};SL.write=OL,SL.parse=xL.parse,SL.parseParams=xL.parseParams,SL.parseFmtpConfig=xL.parseFmtpConfig,SL.parsePayloads=xL.parsePayloads,SL.parseRemoteCandidates=xL.parseRemoteCandidates,SL.parseImageAttributes=xL.parseImageAttributes,SL.parseSimulcastStreamList=xL.parseSimulcastStreamList;var DL=Xe,NL=Pr,ML=Br,PL=function(e){for(var t=DL(this),r=ML(t),n=arguments.length,i=NL(n>1?arguments[1]:void 0,r),o=n>2?arguments[2]:void 0,a=void 0===o?r:NL(o,r);a>i;)t[i++]=e;return t};Ar({target:"Array",proto:!0},{fill:PL});var LL=Us("Array").fill,UL=ae,VL=LL,FL=Array.prototype,BL=function(e){var t=e.fill;return e===FL||UL(FL,e)&&t===FL.fill?VL:t},jL=new Pw("FirefoxHandler",3),GL=Math.pow(2,32),HL="kp34Za0H+aVf862l",zL="o/i14u9pJrxRKAsu";function KL(e){return e>GL-18?(jL.warn("generateAllSsrc","reset start id",e),KL(e=e-GL+1e4+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var XL=function(e,t,r){var n,i,o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:zL;return[{id:r,attribute:"cname",value:a},{id:r,attribute:"msid",value:Om(n=Om(i="".concat(e," ")).call(i,e,"-")).call(n,t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:Om(o="".concat(e,"-")).call(o,t)}]},WL=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.video,o=t.videoRtx,a=t.videoFec,s=[i,o],c=n.cname,u=n.flexfec;u&&s.push(a);var d,l=pb(s).call(s,(function(t,r){return Om(t).call(t,XL(e,"video",r,c))}),[]),h=[{semantics:"FID",ssrcs:Om(r="".concat(i," ")).call(r,o)}];u&&h.push({semantics:"FEC-FR",ssrcs:Om(d="".concat(i," ")).call(d,a)});return{ssrcs:l,ssrcGroups:h}};function qL(e){return e.direction="inactive",e.port=0,delete e.ext,delete e.ssrcs,delete e.ssrcGroups,delete e.simulcast,delete e.simulcast_03,delete e.rids,delete e.extmapAllowMixed,delete e.msid,delete e.bundleOnly,e}var YL=function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=Zd(Zd({},e),{},{media:[]});return n&&(i.invalid=[{value:"realx-exts:rscp"}]),t&&i.media.push(t),r&&i.media.push(r),delete i.groups,delete i.msidSemantic,SL.write(i)};function JL(e){return QL.apply(this,arguments)}function QL(){return(QL=Rm(Tm().mark((function e(t){var r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={},n=t.publicIPs,i=t.certFingerprint,o=t.iceParams,a=t.iceConfig,r.fingerprint={type:"sha-256",hash:i},r.icePwd=o.serverIcePwd,e.next=6,$L(o.serverIceUfrag);case 6:return r.iceUfrag=e.sent,r.candidates=ZL(n,a),r.setup="active",r.iceOptions="renomination",e.abrupt("return",r);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ZL(e,t){if(!Array.isArray(e))return[];var r=0,n=2130706431,i=[];return e.forEach((function(e){var o={component:1,ip:e.ip,type:"host",generation:e.generation};e.udpPorts&&!t.tcpOnly&&e.udpPorts.forEach((function(e){i.push(Zd(Zd({},o),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){i.push(Zd(Zd({},o),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),i}var $L=function(){var e=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new TextEncoder,n=r.encode("PREC"),e.t0=Uint8Array,e.next=5,pD.b64str2ab(t);case 5:return e.t1=e.sent,i=new e.t0(e.t1),o=new Uint8Array(4),crypto.getRandomValues(o),(a=new Uint8Array(2))[0]=0,a[1]=1,s=hD(Uint8Array,n,i,o,a),e.next=15,pD.ab2b64str(s.buffer);case 15:return c=e.sent,e.abrupt("return",c);case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),eU=function(e){return e[e.kICEConfigTypeSrtpDtlsType=0]="kICEConfigTypeSrtpDtlsType",e[e.kICEConfigTypeRenominationType=1]="kICEConfigTypeRenominationType",e[e.kICEConfigTypeTcpType=2]="kICEConfigTypeTcpType",e[e.kICEConfigTypeMultiSendType=3]="kICEConfigTypeMultiSendType",e[e.kICEConfigTypeKcpType=4]="kICEConfigTypeKcpType",e[e.kICEConfigTypeSrtpSdesType=5]="kICEConfigTypeSrtpSdesType",e}(eU||{});function tU(e){var t,r=e.random,n=e.serverUfrag,i=e.serverPwd,o=e.clientPwd,a=e.options,s=(new TextEncoder).encode("WPRE");r||(r=new Uint8Array(4),crypto.getRandomValues(r));var c=UD(n);c.byteLength;var u=FD(UD(o),UD(i).subarray(0,16),UD(n).subarray(0,16));u.byteLength;var d=new Uint8Array(pb(t=an(a)).call(t,(function(e,t){var r=Number(t);return e.push(r),e.push(a[r]?1:0),e}),[]));d.byteLength;var l,h=hD(Uint8Array,s,r,[c.byteLength],c,[u.byteLength],u,d);h.byteLength%3!=0&&(h=hD(Uint8Array,h,BL(l=new Uint8Array(3-h.byteLength%3)).call(l,255)));return[VD(h),VD(hD(Uint8Array,r,c.subarray(0,20)))]}var rU=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=$T(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o,a,s,c=n.value;if(mk(o=c.config).call(o,"level-asymmetry-allowed=1")&&mk(a=c.config).call(a,"packetization-mode=1")&&mk(s=c.config).call(s,"profile-level-id=42e0")){r=c.payload;break}}}catch(v){i.e(v)}finally{i.f()}for(var u=0;u<e.rtp.length;u++){var d=e.rtp[u];if("H264"===t){if(d.payload===r){var l;e.rtp.unshift(rk(l=e.rtp).call(l,u,1)[0]);break}}else if(d.codec===t){var h;e.rtp.unshift(rk(h=e.rtp).call(h,u,1)[0]);break}}var p=[];e.rtp.forEach((function(e){return p.push(e.payload)})),e.payloads=p.join(" ")}},nU=new Pw("BasicHandler",3),iU=function(e){NI(n,e);var t,r=QI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this)),"_peerConnection",void 0),Jd(tI(i),"_dataChannel",void 0),Jd(tI(i),"_context",void 0),Jd(tI(i),"peerConnectionMode",0),Jd(tI(i),"peerConnectionId",""),Jd(tI(i),"id",void 0),Jd(tI(i),"_monitor",void 0),Jd(tI(i),"_nextSsrc",Math.floor(Math.random()*GL+1e4)),Jd(tI(i),"_aSendonlyAnswerTpl",void 0),Jd(tI(i),"_vSendonlyAnswerTpl",void 0),Jd(tI(i),"_enableSubFlexfec",!1),Jd(tI(i),"audioTrack4ff",void 0),Jd(tI(i),"setLocalDescription",void 0),Jd(tI(i),"setRemoteDescription",void 0),i.peer=t,i.id=e.id,i._monitor=VO(i.id),i._peerConnection=t.getOriginRTCPeerConnection(),i._dataChannel=t.getOriginRTCDataChannel(),i.setLocalDescription=t.setLocalDescription.bind(t),i.setRemoteDescription=t.setRemoteDescription.bind(t),i._context=e,i.peer.on("ontrack",(function(e){i.emit("ontrack",e)})),i}return Ul(n,[{key:"destroy",value:function(){nU.info("destroy",this.peerConnectionId||""),OI(CI(n.prototype),"removeAllListeners",this).call(this)}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"getConnectionState",value:function(){return this._peerConnection.connectionState}},{key:"_simulcast",value:function(e,t,r,n,i){var o,a,s,c=[];1===e.videoEncodeConfig.length?(c=function(e,t){var r=[];if(t<=1)return r;var n=Math.min(e.width,e.height)/90;return r.push({scaleResolutionDownBy:n,width:Math.floor(e.width/n),height:Math.floor(e.height/n),maxkbps:100,frameRate:10}),t<=2||r.unshift({scaleResolutionDownBy:2,width:Math.floor(e.width/2),height:Math.floor(e.height/2),maxkbps:Math.floor(e.maxKbps/2),frameRate:e.frameRate>=30?Math.floor(e.frameRate/2):e.frameRate}),r}(t,i),nU.info("simulcast() ","simulcastLayers: %o",c)):(c=jm(o=km(a=km(s=e.videoEncodeConfig).call(s,1)).call(a,1-i)).call(o,(function(e){var r=LD(e.width),n=t.width/r;return{width:r,height:Math.floor(t.height/n),scaleResolutionDownBy:n,frameRate:LD(e.frameRate)||15,maxkbps:e.maxKbps||600}})),nU.info("simulcast() ","simulcastLayers2: %o",c));var u=[!0];c.forEach((function(e,t){var i,o={maxBitrate:1e3*e.maxkbps,scaleResolutionDownBy:e.scaleResolutionDownBy,rid:"".concat(t+1),maxFramerate:e.frameRate};null===(i=r.sendEncodings)||void 0===i||i.unshift(o),n.push({width:e.width,height:e.height,framerate:e.frameRate,maxkbps:e.maxkbps,rid:"".concat(t+1)}),u.push(!0)})),this._context&&(this._context.activeSimStreams=u)}},{key:"internalPublish",value:function(e){var t=e.stream,r=e.videoTrack,n=e.audioTrack,i=e.enableSimulcast,o=e.pubAudio,a=e.pubVideo,s={direction:"sendonly",streams:[t]},c={direction:"sendonly",streams:[t]},u=[],d=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var l=null==r?void 0:r.getTrack(),h=Zd({},NN);if(l){var p=null==l?void 0:l.getSettings();h={width:Math.floor(p.width),height:Math.floor(p.height),frameRate:Math.floor(p.frameRate)}}"number"!=typeof h.frameRate&&(h.frameRate=30);var v=null==e?void 0:e.videoEncodeConfig[0],f={maxBitrate:1e3*v.maxKbps,rid:"0"};if(e.prevBitrate=v.maxKbps,c.sendEncodings=[f],u.push({width:h.width,height:h.height,framerate:h.frameRate,maxkbps:v.maxKbps,rid:"0"}),!zD&&i){var _,m,y=function(e){for(var t=0,r=e.width*e.height,n=0;n<gM.length;n++)if(r>=gM[n].totalPixels){t=n;break}if(0===t)return gM[t].maxLayers;var i=gM[t-1].totalPixels;return(i-r)/(i-gM[t].totalPixels)<.1?gM[t-1].maxLayers:gM[t].maxLayers}(h);if(nU.info("simulcast() ","maxLayers: %o",y),y>1)this._simulcast(e,Zd(Zd({},h),{},{maxKbps:v.maxKbps}),c,u,y),null!==(_=this._context)&&void 0!==_&&null!==(m=_.serverConfig)&&void 0!==m&&m.simulcastOnDemand&&(d=jm(u).call(u,(function(e,t){return Zd(Zd({},e),{},{video_index:t,sub_index:t})})))}}nU.info("publish videoTransceiverInit videoDescriptions","",c,u);var g=null==n?void 0:n.getTrack("preprocessing");(null==n?void 0:n.mixType)!==Dl.PLAYOUT&&null!=n&&n.mixedAudioTrack&&(g=null==n?void 0:n.mixedAudioTrack),g=o&&g?g:"audio";var S=null==r?void 0:r.getTrack("preprocessing");S=a&&S?S:"video";try{this._reportRtcInvokeStatus("Handler.internalPublish",Pm({aTrack:DD(g),vTrack:DD(S),audioTransceiverInit:s,videoTransceiverInit:c}))}catch(XW){}return{semantics:"unified-plan",videoDescriptions:u,subVideoDescriptions:d,audioTransceiverInit:{track:g,init:s},videoTransceiverInit:{track:S,init:c}}}},{key:"updateMaxBitrate",value:function(e){var t,r,n,i;nU.info("updateMaxBitrate()");var o=null===(t=e.videoTrack)||void 0===t?void 0:t.getTrack(),a=e.videoTransceiver;if(o&&e.pubVideo&&a){var s=null===(r=e.videoEncodeConfig)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.maxKbps;if(s){if(s===e.prevBitrate)return void nU.warn("updateMaxBitrate()","no change");e.prevBitrate=s}var c=null===(i=a.sender)||void 0===i?void 0:i.getParameters();if(c){var u;c.encodings=null==c||null===(u=c.encodings)||void 0===u?void 0:jm(u).call(u,(function(t){var r,n=Number(t.rid)||0,i=null===(r=e.videoEncodeConfig[n])||void 0===r?void 0:r.maxKbps;return"number"==typeof i&&(t.maxBitrate=1e3*i),t})),null==a||a.sender.setParameters(c);try{this._reportRtcInvokeStatus("Handler.updateScaleResolutionDownBy",Pm(c.encodings))}catch(XW){}}}else nU.warn("updateMaxBitrate()","no pub")}},{key:"getStats",value:function(e,t){return mL(this._peerConnection,e,t)}},{key:"setCurrentDescription",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineAnswerTpl",value:function(e){var t=this;SL.parse(e).media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r,n=null==e?void 0:gE(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&null!=e&&e.fmtp){var i,o=null==e?void 0:gE(i=e.fmtp).call(i,(function(e){return e.payload===n.payload}));o&&t._context&&(o.config+=";stereo=1;sprop-stereo=1")}t._aSendonlyAnswerTpl=e}}else"video"===e.type&&("sendonly"===e.direction&&(t._vSendonlyAnswerTpl=e),Array.isArray(e.rtp)&&e.rtp.forEach((function(e){var r;null!==(r=e.codec)&&void 0!==r&&mk(r).call(r,"flexfec")&&(t._enableSubFlexfec=!0)})))}))}},{key:"pc",get:function(){return this._peerConnection}},{key:"addBitrateLimit",value:function(e,t){null==e||e.rtp.forEach((function(r){var n,i=r.codec,o=r.payload;if(mk(n=["vp8","h264"]).call(n,i.toLocaleLowerCase())){var a,s,c=gE(a=e.fmtp).call(a,(function(e){return e.payload===o}));if(c)c.config=Om(s=[]).call(s,Jk(c.config.split(";")),["x-google-min-bitrate=100","x-google-start-bitrate=".concat(t)]).join(";");else e.fmtp.push({payload:o,config:"x-google-min-bitrate=100;x-google-start-bitrate=".concat(t)})}}))}},{key:"_report",value:function(e,t,r){var n;null===(n=this._monitor)||void 0===n||n.report(e,Zd(Zd({},t),{},{connection_id:this.peer.getConnectionId(),group_connection_id:this.peer.getGroupConnectionId()}),r)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)}}]),n}(nM.exports.EventEmitter),oU=E,aU=Qy,sU=dy.exports.getWeakData,cU=mp,uU=tr,dU=z,lU=$,hU=Uh,pU=Ye,vU=Zi.set,fU=Zi.getterFor,_U=Mo.find,mU=Mo.findIndex,yU=oU([].splice),gU=0,SU=function(e){return e.frozen||(e.frozen=new bU)},bU=function(){this.entries=[]},EU=function(e,t){return _U(e.entries,(function(e){return e[0]===t}))};bU.prototype={get:function(e){var t=EU(this,e);if(t)return t[1]},has:function(e){return!!EU(this,e)},set:function(e,t){var r=EU(this,e);r?r[1]=t:this.entries.push([e,t])},delete:function(e){var t=mU(this.entries,(function(t){return t[0]===e}));return~t&&yU(this.entries,t,1),!!~t}};var kU,TU={getConstructor:function(e,t,r,n){var i=e((function(e,i){cU(e,o),vU(e,{type:t,id:gU++,frozen:void 0}),dU(i)||hU(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=fU(t),s=function(e,t,r){var n=a(e),i=sU(uU(t),!0);return!0===i?SU(n).set(t,r):i[n.id]=r,e};return aU(o,{delete:function(e){var t=a(this);if(!lU(e))return!1;var r=sU(e);return!0===r?SU(t).delete(e):r&&pU(r,t.id)&&delete r[t.id]},has:function(e){var t=a(this);if(!lU(e))return!1;var r=sU(e);return!0===r?SU(t).has(e):r&&pU(r,t.id)}}),aU(o,r?{get:function(e){var t=a(this);if(lU(e)){var r=sU(e);return!0===r?SU(t).get(e):r?r[t.id]:void 0}},set:function(e,t){return s(this,e,t)}}:{add:function(e){return s(this,e,!0)}}),i}},IU=n,RU=E,AU=Qy,wU=dy.exports,CU=Yy,xU=TU,OU=$,DU=my,NU=Zi.enforce,MU=Vi,PU=!IU.ActiveXObject&&"ActiveXObject"in IU,LU=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},UU=CU("WeakMap",LU,xU);if(MU&&PU){kU=xU.getConstructor(LU,"WeakMap",!0),wU.enable();var VU=UU.prototype,FU=RU(VU.delete),BU=RU(VU.has),jU=RU(VU.get),GU=RU(VU.set);AU(VU,{delete:function(e){if(OU(e)&&!DU(e)){var t=NU(this);return t.frozen||(t.frozen=new kU),FU(this,e)||t.frozen.delete(e)}return FU(this,e)},has:function(e){if(OU(e)&&!DU(e)){var t=NU(this);return t.frozen||(t.frozen=new kU),BU(this,e)||t.frozen.has(e)}return BU(this,e)},get:function(e){if(OU(e)&&!DU(e)){var t=NU(this);return t.frozen||(t.frozen=new kU),BU(this,e)?jU(this,e):t.frozen.get(e)}return jU(this,e)},set:function(e,t){if(OU(e)&&!DU(e)){var r=NU(this);r.frozen||(r.frozen=new kU),BU(this,e)?GU(this,e,t):r.frozen.set(e,t)}else GU(this,e,t);return this}})}var HU=ee.WeakMap;Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{emplace:Og}),Ar({target:"WeakMap",stat:!0,forced:!0},{from:bg}),Ar({target:"WeakMap",stat:!0,forced:!0},{of:kg}),Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{deleteAll:Ag}),Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{upsert:ZS});var zU=HU,KU=function(e){NI(p,e);var t,r,n,i,o,a,s,c,u,d,l,h=QI(p);function p(){var e,t,r;return Vl(this,p),Jd(tI(r=h.call(this)),"inited",!1),Jd(tI(r),"deviceMap",{audioinput:new $S,audiooutput:new $S,videoinput:new $S}),Jd(tI(r),"checkDeviceChangeTimer",null),Jd(tI(r),"isSupportedPermissionsQuery",!1),Jd(tI(r),"isGrantedMicrophonePermission",!1),Jd(tI(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!jD()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(tI(r)),!jD()&&r.refreshDevices(),r}return Ul(p,[{key:"refreshDevices",value:(l=Rm(Tm().mark((function e(){var t,r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(navigator.mediaDevices){e.next=2;break}return e.abrupt("return");case 2:if(t=void 0,!zD){e.next=12;break}return e.prev=4,e.next=7,navigator.mediaDevices.getUserMedia({audio:!0});case 7:t=e.sent,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:return e.next=14,navigator.mediaDevices.enumerateDevices();case 14:r=e.sent,t&&t.getTracks().forEach((function(e){return e.stop()})),r.forEach((function(e){var t;e.deviceId&&(null===(t=n.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e))})),this.inited||this.initListener(),this.inited=!0;case 19:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return l.apply(this,arguments)})},{key:"initListener",value:(d=Rm(Tm().mark((function e(){var t,r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(null===(t=navigator.mediaDevices)||void 0===t?void 0:t.ondevicechange)&&"function"==typeof(null===(r=navigator.mediaDevices)||void 0===r?void 0:r.addEventListener)?navigator.mediaDevices.addEventListener("devicechange",(function(){o._handleDeviceChange(),setTimeout((function(){o._handleDeviceChange()}),300)})):this.checkDeviceChangeTimer=window.setInterval((function(){o._handleDeviceChange()}),3e3),!this.isSupportedPermissionsQuery){e.next=22;break}return e.prev=2,e.next=5,navigator.permissions.query({name:"microphone"});case 5:n=e.sent,this.isGrantedMicrophonePermission="granted"===n.state,n.addEventListener("change",(function(){o.isGrantedMicrophonePermission="granted"===n.state})),e.next=12;break;case 10:e.prev=10,e.t0=e.catch(2);case 12:return e.prev=12,e.next=15,navigator.permissions.query({name:"camera"});case 15:i=e.sent,this.isGrantedCameraPermission="granted"===i.state,i.addEventListener("change",(function(){o.isGrantedCameraPermission="granted"===i.state})),e.next=22;break;case 20:e.prev=20,e.t1=e.catch(12);case 22:case"end":return e.stop()}}),e,this,[[2,10],[12,20]])}))),function(){return d.apply(this,arguments)})},{key:"_handleDeviceChange",value:(u=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=void 0,!zD){e.next=5;break}return e.next=4,navigator.mediaDevices.getUserMedia({audio:!0});case 4:o=e.sent;case 5:return e.next=7,navigator.mediaDevices.enumerateDevices();case 7:a=e.sent,a=Gs(a).call(a,(function(e){return!!e.deviceId})),o&&o.getTracks().forEach((function(e){return e.stop()})),s=qk(Om(t=[]).call(t,Jk(oR(r=this.deviceMap.audioinput).call(r)),Jk(oR(n=this.deviceMap.videoinput).call(n)),Jk(oR(i=this.deviceMap.audiooutput).call(i)))),(tN||ZD)&&!s.length&&a.length&&a.forEach((function(e){var t;null===(t=c.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e)})),a.forEach((function(e){var t,r,n=c.deviceMap[e.kind].get(e.deviceId);c.deviceMap[e.kind].set(e.deviceId,e),n||(mk(t=e.kind).call(t,"video")?c.emit(Pl.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):mk(r=e.kind).call(r,"audio")&&c.emit(Pl.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),s.forEach((function(e){var t,r;gE(a).call(a,(function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(c.deviceMap[e.kind].delete(e.deviceId),mk(t=e.kind).call(t,"video")?c.emit(Pl.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):mk(r=e.kind).call(r,"audio")&&c.emit(Pl.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 14:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"getUserMedia",value:(c=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.getUserMedia(t);case 2:return r=e.sent,null!=t&&t.audio&&(this.isGrantedMicrophonePermission=!0),null!=t&&t.video&&(this.isGrantedCameraPermission=!0),this.refreshDevices(),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"checkPermissionsByDevices",value:(s=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t={audio:!1,video:!1},navigator.mediaDevices){e.next=3;break}return e.abrupt("return",t);case 3:return e.next=5,navigator.mediaDevices.enumerateDevices();case 5:return r=e.sent,t.audio=Gs(r).call(r,(function(e){return"audioinput"===e.kind&&e.label&&e.deviceId})).length>0,t.video=Gs(r).call(r,(function(e){return"videoinput"===e.kind&&e.label&&e.deviceId})).length>0,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e)}))),function(){return s.apply(this,arguments)})},{key:"getPermissions",value:(a=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=l.length>0&&void 0!==l[0]?l[0]:{},n=r.audio,i=r.video,o=r.force,n||i||(n=!0,i=!0),a={audio:!1,video:!1,reason:void 0},o){e.next=30;break}if(!this.isSupportedPermissionsQuery){e.next=20;break}if(!n||!i){e.next=14;break}if(!this.isGrantedMicrophonePermission||!this.isGrantedCameraPermission){e.next=12;break}return a.audio=!0,a.video=!0,e.abrupt("return",a);case 12:e.next=18;break;case 14:if(!(n&&this.isGrantedMicrophonePermission||i&&this.isGrantedCameraPermission)){e.next=18;break}return a.audio=this.isGrantedMicrophonePermission,a.video=this.isGrantedCameraPermission,e.abrupt("return",a);case 18:e.next=30;break;case 20:return e.next=22,this.checkPermissionsByDevices();case 22:if(s=e.sent,!n||!i){e.next=28;break}if(!s.audio||!s.video){e.next=26;break}return e.abrupt("return",s);case 26:e.next=30;break;case 28:if(!(n&&s.audio||i&&s.video)){e.next=30;break}return e.abrupt("return",s);case 30:if(null===(t=navigator.mediaDevices)||void 0===t||!t.getUserMedia){e.next=70;break}return e.prev=31,e.next=34,navigator.mediaDevices.getUserMedia({audio:n,video:i});case 34:(c=e.sent)&&(c.getTracks().forEach((function(e){return e.stop()})),n&&(a.audio=!0,this.isGrantedMicrophonePermission=!0),i&&(a.video=!0,this.isGrantedCameraPermission=!0)),e.next=70;break;case 38:if(e.prev=38,e.t0=e.catch(31),a.reason=e.t0,!this.isSupportedPermissionsQuery){e.next=70;break}if(!n){e.next=56;break}return e.next=45,navigator.permissions.query({name:"microphone"}).catch((function(){}));case 45:if(e.t2=u=e.sent,e.t1=null===e.t2,e.t1){e.next=49;break}e.t1=void 0===u;case 49:if(!e.t1){e.next=53;break}e.t3=void 0,e.next=54;break;case 53:e.t3=u.state;case 54:e.t4=e.t3,a.audio="granted"===e.t4;case 56:if(!i){e.next=70;break}return e.next=59,navigator.permissions.query({name:"camera"}).catch((function(){}));case 59:if(e.t6=d=e.sent,e.t5=null===e.t6,e.t5){e.next=63;break}e.t5=void 0===d;case 63:if(!e.t5){e.next=67;break}e.t7=void 0,e.next=68;break;case 67:e.t7=d.state;case 68:e.t8=e.t7,a.video="granted"===e.t8;case 70:return e.next=72,this.refreshDevices();case 72:return e.abrupt("return",a);case 73:case"end":return e.stop()}}),e,this,[[31,38]])}))),function(){return a.apply(this,arguments)})},{key:"enumerateDevices",value:(o=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions();case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qk(Om(t=[]).call(t,Jk(oR(r=this.deviceMap.audioinput).call(r)),Jk(oR(n=this.deviceMap.videoinput).call(n)),Jk(oR(i=this.deviceMap.audiooutput).call(i)))));case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"enumerateAudioCaptureDevices",value:(i=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qk(oR(t=this.deviceMap.audioinput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"enumerateVideoCaptureDevices",value:(n=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({video:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qk(oR(t=this.deviceMap.videoinput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"enumerateAudioPlaybackDevices",value:(r=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qk(oR(t=this.deviceMap.audiooutput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getDeviceById",value:(t=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.enumerateDevices();case 2:return r=e.sent,e.abrupt("return",gE(r).call(r,(function(e){return e.deviceId===t})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),p}(aM),XU=new KU;!jD()&&(window.__rtc_dd__=XU);var WU=new Pw("InternalEventBus",1),qU=function(e){return e.ON_IOS_INTERRUPTION_START="ON_IOS_INTERRUPTION_START",e.ON_IOS_INTERRUPTION_END="ON_IOS_INTERRUPTION_END",e.ON_IOS_LOCAL_TRACK_MUTE="ON_IOS_LOCAL_TRACK_MUTE",e.ON_IOS_LOCAL_TRACK_UNMUTE="ON_IOS_LOCAL_TRACK_UNMUTE",e}(qU||{}),YU=function(e){NI(r,e);var t=QI(r);function r(){return Vl(this,r),t.apply(this,arguments)}return Ul(r,[{key:"emit",value:function(e){var t,n;WU.info(e);for(var i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return(t=OI(CI(r.prototype),"emit",this)).call.apply(t,Om(n=[this,e]).call(n,o))}}]),r}(nM.exports.EventEmitter),JU=new YU,QU=new Pw("AudioContext",1),ZU=function(){function e(){var t=this;Vl(this,e),Jd(this,"_audioContextInstance",void 0),Jd(this,"_previousState",""),Jd(this,"_currentState",""),Jd(this,"_contextStuckAt",0);var r=0;jD()||setInterval((function(){if(t._audioContextInstance){var e=t._audioContextInstance.currentTime;t._contextStuckAt?t._contextStuckAt!==e&&(t._contextStuckAt=0,QU.info("currentTime resume"),LO("currentTime resume","")):e&&r===e&&(t._contextStuckAt=e,QU.warn("currentTime stuck",t._contextStuckAt),t._audioContextInstance.suspend(),t._audioContextInstance.resume(),LO("AudioContext currentTime stuck",t._contextStuckAt)),r=e}}),3e3)}return Ul(e,[{key:"getAudioContextInstance",value:function(){var e=this;if(!this._audioContextInstance){var t=window.AudioContext||window.webkitAudioContext;this._audioContextInstance=new t,this._audioContextInstance.onstatechange=function(){var t,r,n;QU.warn("state change",null===(t=e._audioContextInstance)||void 0===t?void 0:t.state),e._previousState=e._currentState,e._currentState=(null===(r=e._audioContextInstance)||void 0===r?void 0:r.state)||"","interrupted"===(null===(n=e._audioContextInstance)||void 0===n?void 0:n.state)&&e._audioContextInstance.resume(),(rN||ZD)&&("running"===e._previousState&&"interrupted"===e._currentState&&JU.emit(qU.ON_IOS_INTERRUPTION_START),"interrupted"===e._previousState&&"running"===e._currentState&&JU.emit(qU.ON_IOS_INTERRUPTION_END))}}return this._audioContextInstance}}]),e}(),$U=function(){function e(t){Vl(this,e),Jd(this,"_ctx",void 0),Jd(this,"_analyserNode",void 0),Jd(this,"_audioSource",void 0);var r=eV.getAudioContextInstance();if(t instanceof MediaStreamTrack){var n=new MediaStream;n.addTrack(t),this._audioSource=r.createMediaStreamSource(n)}else this._audioSource=r.createMediaElementSource(t),this._audioSource.connect(r.destination);var i=r.createAnalyser();this._audioSource.connect(i),this._analyserNode=i,this._ctx=r}var t;return Ul(e,[{key:"getAudioLevel",value:function(){var e;"suspended"===(null===(e=this._ctx)||void 0===e?void 0:e.state)&&this._ctx.resume();var t=new Uint8Array(2048);this._analyserNode.getByteTimeDomainData(t);var r=0;t.forEach((function(e){return r=Math.max(r,Math.abs(e-128))}));var n=r/128*255;return n>2?n:0}},{key:"resume",value:(t=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=this._ctx)||void 0===t?void 0:t.resume();case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._audioSource.disconnect(),this._analyserNode.disconnect()}}]),e}(),eV=new ZU,tV=function(e){return e[e.CAPTURE=0]="CAPTURE",e[e.PRE_PROCESSING=1]="PRE_PROCESSING",e[e.ENCODE=2]="ENCODE",e[e.TRANSFER=3]="TRANSFER",e[e.POST_PROCESSING=4]="POST_PROCESSING",e[e.DECODE=5]="DECODE",e[e.RENDERING=6]="RENDERING",e}(tV||{}),rV=function(){function e(t){Vl(this,e),Jd(this,"_plugins",new $S),this.id=t}var t;return Ul(e,[{key:"register",value:function(e){var t=this._plugins.get(e.type)||[];if(QR(t).call(t,(function(t){return t.name===e.name}))>-1)throw new Error("Failed to register ".concat(e.name,": name is repeated."));t.push(e),this._plugins.set(e.type,t)}},{key:"getPluginsByType",value:function(e){return this._plugins.get(e)||[]}},{key:"getPluginByName",value:function(e,t){var r;return gE(r=this._plugins.get(e)||[]).call(r,(function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=Rm(Tm().mark((function e(t){var r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this._plugins.get(1)||[],n=t.getTrack(),i=$T(r),e.prev=3,i.s();case 5:if((o=i.n()).done){e.next=12;break}return a=o.value,e.next=9,a.effect(t,n);case 9:n=e.sent;case 10:e.next=5;break;case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(3),i.e(e.t0);case 17:return e.prev=17,i.f(),e.finish(17);case 20:return e.abrupt("return",n);case 21:case"end":return e.stop()}}),e,this,[[3,14,17,20]])}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._plugins.forEach((function(e){e.forEach((function(e){return e.destroy()}))})),this._plugins.clear()}}]),e}(),nV=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(nV||{}),iV=new Pw("VERTC",0),oV=new zU,aV=function(e){NI(r,e);var t=QI(r);function r(e,n){var i;return Vl(this,r),Jd(tI(i=t.call(this)),"sourceType",1),Jd(tI(i),"mediaType",void 0),Jd(tI(i),"_trackId",void 0),Jd(tI(i),"_ac",void 0),Jd(tI(i),"_sourceNode",void 0),Jd(tI(i),"_gainNode",void 0),Jd(tI(i),"_destNode",void 0),Jd(tI(i),"_channelCount",void 0),i._trackId=e,i.mediaType=n,"audio"===n&&hL()&&!ON("SKIP_WEB_AUDIO_IN_TRACK")&&(i._ac=eV.getAudioContextInstance(),i._gainNode=i._ac.createGain(),i._destNode=i._ac.createMediaStreamDestination(),i._gainNode.connect(i._destNode)),i}return Ul(r,[{key:"getId",value:function(){return this._trackId}},{key:"setVolume",value:function(e){this._gainNode&&(this._gainNode.gain.value=e/100)}},{key:"getVolume",value:function(){return this._gainNode?Math.round(100*this._gainNode.gain.value):-1}},{key:"channelCount",get:function(){var e;return null!==(e=this._channelCount)&&void 0!==e?e:0}},{key:"connectAudioTrack",value:function(e){var t;if(this._channelCount=e.getSettings().channelCount,!hL()||ON("SKIP_WEB_AUDIO_IN_TRACK"))return e;this._sourceNode&&(this._sourceNode.mediaStream.getTracks().forEach((function(e){e.stop()})),delete this._sourceNode);var r,n=new MediaStream;(n.addTrack(e),this._sourceNode=null===(t=this._ac)||void 0===t?void 0:t.createMediaStreamSource(n),this._gainNode)&&(null===(r=this._sourceNode)||void 0===r||r.connect(this._gainNode));return this._destNode.stream.getTracks()[0]}},{key:"destroy",value:function(){var e,t,r,n;(null===(e=this._sourceNode)||void 0===e||e.mediaStream.getTracks().forEach((function(e){e.stop()})),13!==cN)&&(null===(n=this._destNode)||void 0===n||n.stream.getTracks().forEach((function(e){e.stop()})));null===(t=this._sourceNode)||void 0===t||t.disconnect(),null===(r=this._gainNode)||void 0===r||r.disconnect(),delete this._sourceNode,delete this._gainNode,delete this._destNode}}]),r}(aM),sV=function(e){NI(n,e);var t,r=QI(n);function n(e,t,i){var o;return Vl(this,n),Jd(tI(o=r.call(this,t,i)),"_mediaTrack",void 0),Jd(tI(o),"_preProcessingTrack",void 0),Jd(tI(o),"_originTrack",void 0),Jd(tI(o),"captureSessionId",""),Jd(tI(o),"handleTrackEnded",(function(){o.emit("track-ended",tI(o)),o.close()})),Jd(tI(o),"handleMute",(function(){o.emit("track-mute",tI(o))})),Jd(tI(o),"handleUnmute",(function(){o.emit("track-unmute",tI(o))})),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o._initListeners(),o}return Ul(n,[{key:"getTrack",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"origin";return"origin"===e?this._mediaTrack:this._preProcessingTrack||this._mediaTrack}},{key:"setTrack",value:function(e,t){this._mediaTrack="audio"===this.mediaType?this.connectAudioTrack(e):e,this._originTrack=e,t&&this.generatePreProcessingTrack(t)}},{key:"generatePreProcessingTrack",value:(t=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._preProcessingTrack=void 0,e.prev=1,e.next=4,t.getPreProcessingTrack(this);case 4:(r=e.sent)instanceof MediaStreamTrack&&(this._preProcessingTrack=r),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),console.error(e.t0);case 11:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e){return t.apply(this,arguments)})},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){var e,t,r,n,i;return this._mediaTrack.onended=null,this._mediaTrack.onmute=null,this._mediaTrack.onunmute=null,null===(e=this._originTrack)||void 0===e||e.removeEventListener("ended",this.handleTrackEnded),null===(t=this._originTrack)||void 0===t||t.removeEventListener("mute",this.handleMute),null===(r=this._originTrack)||void 0===r||r.removeEventListener("unmute",this.handleUnmute),null===(n=this._preProcessingTrack)||void 0===n||n.stop(),"audio"===this.mediaType?this.destroy():null===(i=this._mediaTrack)||void 0===i?void 0:i.stop()}},{key:"_initListeners",value:function(){this._originTrack instanceof MediaStreamTrack&&(this._originTrack.addEventListener("ended",this.handleTrackEnded),this._originTrack.addEventListener("mute",this.handleMute),this._originTrack.addEventListener("unmute",this.handleUnmute))}}]),n}(aV),cV=function(e){NI(r,e);var t=QI(r);function r(e,n,i){var o;return Vl(this,r),Jd(tI(o=t.call(this,n,i)),"_mediaTrack",void 0),Jd(tI(o),"_originTrack",void 0),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o}return Ul(r,[{key:"getTrack",value:function(){return this._mediaTrack}},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){return this.destroy()}}]),r}(aV),uV=function(e){NI(n,e);var t,r=QI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this,e,t,"video")),"resolution",void 0),Jd(tI(i),"dummy",!1),i.resolution={width:0,height:0},i}return Ul(n,[{key:"updateVideoCaptureConfig",value:(t=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getTrack()){e.next=2;break}return e.abrupt("return");case 2:return iV.info("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=Zd({},t)).contentHint,zD&&this.streamIndex===cl.STREAM_INDEX_MAIN&&(r.frameRate={ideal:30,max:30}),e.next=8,this.getTrack().applyConstraints(r);case 8:((n=this.getTrack().getSettings()).width&&n.width!==this.resolution.width||n.height&&n.height!==this.resolution.height)&&(this.resolution={width:n.width,height:n.height},this.emit("resolution-change",this.resolution));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"replaceTrack",value:function(e){this.setTrack(e)}},{key:"setContentHint",value:function(e){var t;this._mediaTrack&&"contentHint"in this._mediaTrack&&mk(t=["text","motion","detail"]).call(t,e)&&(this._mediaTrack.contentHint=e)}}]),n}(sV),dV=function(e){NI(n,e);var t,r=QI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this,e,t,"audio")),"audioCaptureConfig",void 0),Jd(tI(i),"_audioLevelFetcher",void 0),Jd(tI(i),"mixedAudioTrack",void 0),Jd(tI(i),"mixType",Dl.PLAYOUT_AND_PUBLISH),i}return Ul(n,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new $U(this.getTrack("preprocessing"))),this._audioLevelFetcher.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.audioCaptureConfig){e.next=2;break}return e.abrupt("return");case 2:return iV.info("updateAudioCaptureConfig","update localAudioTrack: ",this.audioCaptureConfig),e.next=5,null===(t=this.getOrgTrack())||void 0===t?void 0:t.applyConstraints(this.audioCaptureConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),n}(sV),lV=function(e){NI(r,e);var t=QI(r);function r(e,n){return Vl(this,r),t.call(this,e,n,"video")}return Ul(r)}(cV),hV=function(e){NI(r,e);var t=QI(r);function r(e,n){var i;return Vl(this,r),Jd(tI(i=t.call(this,e,n,"audio")),"_audioLevelFetcher",void 0),i}return Ul(r,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new $U(this.getOrgTrack())),this._audioLevelFetcher.getAudioLevel()}}]),r}(cV),pV=function(e){NI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),n}return Ul(r)}(dV),vV=function(e){NI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),n}return Ul(r)}(uV),fV=function(e){NI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(uV),_V=function(e){NI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(dV),mV=function(e){NI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),n}return Ul(r)}(uV),yV=function(e){NI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),n}return Ul(r)}(dV),gV=function(e){NI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(uV),SV=function(e){NI(r,e);var t=QI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(dV);function bV(e,t){return EV.apply(this,arguments)}function EV(){return(EV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new vV(t,dD())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function kV(e,t){return TV.apply(this,arguments)}function TV(){return(TV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new mV(t,dD())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function IV(e,t){return RV.apply(this,arguments)}function RV(){return(RV=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=VO(r.id),s=dD(),e.prev=3,iV.info("createCameraVideoTrack","constraints:",t),null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o,capture_session_id:s}),c=lD(),zD&&(t.frameRate={ideal:30,max:30}),e.next=10,XU.getUserMedia({video:t});case 10:i=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:o,reason:"success",elapse:lD()-c,capture_session_id:s}),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(3),null==a||a.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:o,error_code:e.t0.code,reason:e.t0.name+e.t0.message,capture_session_id:s}),new mA(pA.GET_VIDEO_TRACK_FAILED,Om(u="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(u,e.t0.message||"unknown message","."),e.t0);case 18:return d=i.getVideoTracks()[0],oV.set(d,i),(l=new vV(d,dD())).captureSessionId=s,e.next=24,l.generatePreProcessingTrack(r);case 24:return e.abrupt("return",l);case 25:case"end":return e.stop()}}),e,null,[[3,14]])})))).apply(this,arguments)}function AV(e,t){return wV.apply(this,arguments)}function wV(){return(wV=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return iV.info("createMicrophoneAudioTrack","constraints:",t),o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=VO(r.id),s=dD(),e.prev=4,null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_begin",media_device_id:o,event_session_id:s}),u=lD(),(d=r.getPluginByName(tV.PRE_PROCESSING,"RTCAIAnsExtension"))&&(d.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=11,XU.getUserMedia({audio:t});case 11:i=e.sent,null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_result",media_device_id:o,media_device_name:(null===(c=i.getAudioTracks()[0])||void 0===c?void 0:c.label)||"",reason:"success",elapse:lD()-u,event_session_id:s}),e.next=19;break;case 15:throw e.prev=15,e.t0=e.catch(4),null==a||a.report("rtc_audio_device_event",{device_type:"audio_record",event_type:"start_end",media_device_id:o,error_code:e.t0.code,reason:e.t0.name+e.t0.message,event_session_id:s}),new mA(pA.GET_AUDIO_TRACK_FAILED,Om(l="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(l,e.t0.message||"unknown message","."),e.t0);case 19:return h=i.getAudioTracks()[0],oV.set(h,i),(p=new pV(h,dD())).captureSessionId=s,e.next=25,p.generatePreProcessingTrack(r);case 25:return e.abrupt("return",p);case 26:case"end":return e.stop()}}),e,null,[[4,15]])})))).apply(this,arguments)}function CV(){return xV.apply(this,arguments)}function xV(){return xV=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=h.length>0&&void 0!==h[0]&&h[0],r=h.length>1?h[1]:void 0,n=h.length>2?h[2]:void 0,iV.info("createScreenTracks","withAudio: %o, constraints: %o",t,n),o=VO(r.id),a=dD(),e.prev=6,null==o||o.report("rtc_video_capture_event",{event_type:"start",media_device_id:"screen",capture_session_id:a}),s=lD(),e.next=11,navigator.mediaDevices.getDisplayMedia({video:!(n&&(!KD||16!==cN))||n,audio:!!t&&{channelCount:2,noiseSuppression:!1,echoCancellation:!0,autoGainControl:!1}});case 11:i=e.sent,null==o||o.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:"screen",reason:"success",elapse:lD()-s,capture_session_id:a}),e.next=19;break;case 15:throw e.prev=15,e.t0=e.catch(6),null==o||o.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:"screen",error_code:e.t0.code,reason:e.t0.name+e.t0.message,capture_session_id:a}),new mA(pA.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 19:return c=i.getVideoTracks()[0],u=new mV(c,dD()),e.next=23,u.generatePreProcessingTrack(r);case 23:if(!(d=i.getAudioTracks()[0])){e.next=29;break}return l=new yV(d,dD()),e.next=28,l.generatePreProcessingTrack(r);case 28:return e.abrupt("return",[u,l]);case 29:return e.abrupt("return",[u,void 0]);case 30:case"end":return e.stop()}}),e,null,[[6,15]])}))),xV.apply(this,arguments)}function OV(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dD();return new hV(e,t)}function DV(e,t){return NV.apply(this,arguments)}function NV(){return(NV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new fV(t,dD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function MV(e,t){return PV.apply(this,arguments)}function PV(){return(PV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new _V(t,dD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function LV(e,t){return UV.apply(this,arguments)}function UV(){return(UV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new gV(t,dD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function VV(e,t){return FV.apply(this,arguments)}function FV(){return(FV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new SV(t,dD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var BV=dV,jV=hV,GV=function(e){return e[e.NONE=0]="NONE",e}(GV||{}),HV={getNalunits:function(e){if(e.length-e.position<4)return[];var t=e.position;return 1===e.getInt32(t)||0===e.getInt16(t)&&1===e.getInt8(t+2)?HV.getAnnexbNals(e):HV.getAvccNals(e)},getAnnexbNals:function(e){for(var t=[],r=HV.getHeaderPositionAnnexB(e),n=r.pos,i=n;n<e.length-4;){var o,a,s=new Uint8Array(km(o=e.buffer).call(o,n,n+r.headerLength));r.pos===e.position&&e.skip(r.headerLength),i=(r=HV.getHeaderPositionAnnexB(e)).pos;var c={header:s,body:new Uint8Array(km(a=e.buffer).call(a,n+s.byteLength,i)),type:-1};HV.analyseNal(c),c.type<=9&&0!==c.type&&t.push(c),e.skip(i-e.position),n=i}return t},getAvccNals:function(e){for(var t=[];e.position<e.length-4;){var r=e.getInt32(e.position);if(!(e.length-e.position>=r))break;var n,i,o=new Uint8Array(km(n=e.buffer).call(n,e.position,e.position+4));e.skip(4);var a=new Uint8Array(km(i=e.buffer).call(i,e.position,e.position+r));e.skip(r);var s={header:o,body:a,type:-1};HV.analyseNal(s),s.type<=9&&0!==s.type&&t.push(s)}return t},analyseNal:function(e){var t=31&e.body[0];switch(e.type=t,t){case 1:e.ndr=!0;break;case 5:e.idr=!0;break;case 6:e.sei=!0;break;case 7:e.sps=!0;break;case 8:e.pps=!0}},getHeaderPositionAnnexB:function(e){for(var t=e.position,r=0,n=e.length;3!==r&&4!==r&&t<n-4;)0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:1===e.getInt8(t+2)?r=3:t++:t++;return t===n-4&&(0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:t=n:(t++,0===e.getInt16(t)&&1===e.getInt8(t)?r=3:t=n)),{pos:t,headerLength:r}}},zV=function(){function e(t){Vl(this,e),Jd(this,"_position",0),Jd(this,"_dataview",void 0),this._dataview=new DataView(t)}return Ul(e,[{key:"length",get:function(){return this.buffer.byteLength}},{key:"buffer",get:function(){return this._dataview.buffer}},{key:"position",get:function(){return this._position},set:function(e){this._position=e}},{key:"back",value:function(e){this.position-=e}},{key:"getUint8",value:function(e){return this._dataview.getUint8(e)}},{key:"getInt8",value:function(e){return this._dataview.getInt8(e)}},{key:"getInt16",value:function(e){return this._dataview.getInt16(e)}},{key:"getUint16",value:function(e){return this._dataview.getUint16(e)}},{key:"getUint32",value:function(e){return this._dataview.getUint32(e)}},{key:"getInt32",value:function(e){return this._dataview.getInt32(e)}},{key:"skip",value:function(t){for(var r=Math.floor(t/4),n=t%4,i=0;i<r;i++)e.readByte(this,4);n>0&&e.readByte(this,n)}},{key:"readUint8",value:function(){return e.readByte(this,1)}},{key:"readUint16",value:function(){return e.readByte(this,2)}},{key:"readUint24",value:function(){return e.readByte(this,3)}},{key:"readUint32",value:function(){return e.readByte(this,4)}},{key:"readUint64",value:function(){return e.readByte(this,8)}},{key:"readInt8",value:function(){return e.readByte(this,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this,4,!0)}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}}],[{key:"readByte",value:function(e,t,r){var n;switch(t){case 1:n=r?e.getInt8(e.position):e.getUint8(e.position);break;case 2:n=r?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(r)throw new Error("not supported for readByte 3");n=e.getUint8(e.position)<<16,n|=e.getUint8(e.position+1)<<8,n|=e.getUint8(e.position+2);break;case 4:n=r?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(r)throw new Error("not supported for readBody 8");n=e.getUint32(e.position)<<32,n|=e.getUint32(e.position+4);break;default:n=""}return e.position+=t,n}}]),e}(),KV=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(KV||{}),XV=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),WV=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]),qV=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]&&t.push(3),t.push(e[r]);return new Uint8Array(t)};function YV(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function JV(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=0;255===e[t]&&t<e.byteLength;)t++,r+=255;return t<e.byteLength&&(r+=e[t++]),[r,t]}var QV=function(){function e(){Vl(this,e)}return Ul(e,null,[{key:"generateSEI",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=new Uint8Array([0,0,0,1]),i=new Uint8Array([6]),o=new Uint8Array([5]),a=r?XV:WV,s=YV(e.byteLength+a.byteLength),c=qV(e);return new Uint8Array(Om(t=[]).call(t,Jk(n),Jk(i),Jk(o),Jk(s),Jk(a),Jk(c),[128]))}},{key:"decodeSeiBody",value:function(e){var t=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]||t.push(e[r]);return new Uint8Array(t)}(e=km(e).call(e,0,e.length-1));if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=eI(JV(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=WV.byteLength&&i>=WV.byteLength&&km(t).call(t,r,r+WV.byteLength).toString()===WV.toString()?(r+=WV.byteLength,o=1):t.byteLength>=WV.byteLength&&i>=WV.byteLength&&km(t).call(t,r,r+XV.byteLength).toString()===XV.toString()&&(r+=XV.byteLength,o=0),{type:o,payload:km(t).call(t,r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new $S,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=eI(JV(e.payload,r),2),i=n[0];r=n[1];var o,a=eI(JV(e.payload,r),2),s=a[0];if(r=a[1],t.get(i)||!(s<=e.payload.byteLength-r))break;t.set(i,km(o=e.payload).call(o,r,r+s)),r+=s}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=$T(e);try{for(n.s();!(t=n.n()).done;){var i=eI(t.value,2),o=i[0],a=i[1],s=YV(o),c=YV(a.byteLength);r.push(s,c,a)}}catch(l){n.e(l)}finally{n.f()}var u=pb(r).call(r,(function(e,t){return e+t.byteLength}),0),d=new Uint8Array(u);return pb(r).call(r,(function(e,t){return d.set(t,e),e+t.byteLength}),0),d}}]),e}(),ZV=new Pw("Stats",3),$V=function(){function e(t){Vl(this,e),Jd(this,"player",void 0),Jd(this,"_timer",void 0),Jd(this,"handler",void 0),Jd(this,"_monitor",void 0),Jd(this,"_destroyed",!1),this._context=t,this._monitor=VO(t.id)}return Ul(e,[{key:"setVar",value:function(e){this.handler=e}},{key:"stopReport",value:function(e){var t;this._timer&&(ZV.info("stopReport","invoke"),clearTimeout(this._timer),delete this._timer,jO(this._context.id,"del_media_statistics_timer",Om(t="reason: ".concat(e,", stack: ")).call(t,(new Error).stack),0,this._stream.streamId||""))}},{key:"filterIllegal",value:function(e){var t={};return an(e).forEach((function(r){null===e[r]||void 0===e[r]||Number.isNaN(e[r])||(t[r]=e[r])})),t}},{key:"destroy",value:function(){ZV.info("destroy","invoke"),jO(this._context.id,"media_statistics_destroy","".concat((new Error).stack),0,"".concat(this._stream.streamId)),this.stopReport("destroy"),this._destroyed=!0}}]),e}(),eF=function(e){NI(i,e);var t,r,n=QI(i);function i(e,t){var r;return Vl(this,i),(r=n.call(this,e))._stream=t,r}return Ul(i,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t){var r,n,i,o=this;if(!this._timer){ZV.info("setLocalStreamStatsEvtInterval","invoke"),this.setVar(t),this._destroyed=!1;var a={audio:{},video:{}},s=this._stream,c=null===(r=s.audioTrack)||void 0===r?void 0:r.getTrack("preprocessing"),u=null===(n=s.videoTrack)||void 0===n?void 0:n.getTrack("preprocessing");this.getAudioStats(c,a,null===(i=s.audioTrack)||void 0===i?void 0:i.getAudioLevel()),this.getVideoStats(u,a);var d=function(){var e=Rm(Tm().mark((function e(){var t,r,n,i,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=s.audioTrack)||void 0===t?void 0:t.getTrack("preprocessing"),c=null===(r=s.videoTrack)||void 0===r?void 0:r.getTrack("preprocessing"),e.next=4,o.getAudioStats(i,a,null===(n=s.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return u=e.sent,e.next=7,o.getVideoStats(c,a);case 7:return d=e.sent,e.abrupt("return",{audioStats:u,videoStats:d,isScreen:s.isScreen});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),l=function(){var t=Rm(Tm().mark((function t(){var r;return Tm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,d();case 2:r=t.sent,e(r),o._destroyed||(o._timer=setTimeout(l,2e3));case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();this._timer=setTimeout(l,2e3)}}},{key:"getAudioStats",value:(r=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m,y;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s={},c={timestamp:Date.now()},u=this._stream,d=u.streamId,l=u.audioMid,h=u.isScreen,p=u.pubAttributes,v=u.pubAudio,f=u.audioTrack,_={media_type:"audio",is_screen:!!h,direction:"up",stream_id:d,vid:l,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:p.localaudio?"capture_state_on":"capture_state_off",mute_state:v?"mute_state_off":"mute_state_on"},f&&(_.playback_volume=f.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",s);case 7:return e.next=9,this.handler.getStats(t);case 9:if((m=e.sent).length){e.next=12;break}return e.abrupt("return",s);case 12:if(m.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,i=e.bytesSent,o=e.clockRate,a=e.roundTripTime,u=e.channels,d=e.audioLevel;e.googRtt;var l=e.mimeType,h=e.availableIncomingBitrate,p=e.availableOutgoingBitrate,v=e.bytesReceived,f=e.nominated,m=e.id,y=e.currentRoundTripTime,g=e.state,S=e.writable,b=e.requestsReceived,E=e.responsesReceived,k=e.requestsSent,T=e.consentRequestsSent,I=e.responsesSent,R=e.jitter,A=e.candidateType,w=e.ip,C=e.address,x=e.networkType,O=e.port,D=e.protocol,N=e.nackCount,M=e.retransmittedBytesSent,P=e.retransmittedPacketsSent,L=e.audioInputLevel,U=e.ssrc,V=e.totalAudioEnergy,F=e.totalSamplesDuration,B=e.mediaType,j=e.fractionLost;"outbound-rtp"===t?(c.packetsSent=r,c.bytesSent=i,_.bytes=i,_.packetsSent=r,_.nackCount=N,_.ssrc=U,_.retransmitted_bytes_sent=M,_.retransmitted_packets_sent=P,c.retransmittedBytesSent=M,c.retransmittedPacketsSent=P):"remote-inbound-rtp"===t?(c.packetsLost=n,_.packetsLost=n,_.net_jitter=1e3*R,s.rtt=1e3*a,_.rtt=s.rtt,s._fractionLost=j||0):"codec"===t?(s.recordSampleRate=o,s.numChannels=u,_.codecName=l):"media-source"===t&&void 0!==d?(_.audio_level=d?-10*$A(Math.pow(d,2)):d,_.volume=255*d,_.total_audio_energy=V,_.totalInputDuration=F):"ssrc"===t&&"audio"===B?_.send_level=L:"candidate-pair"===t?(_.ice_available_incoming_bitrate=h,_.ice_available_outgoing_bitrate=p,_.ice_bytes_received=v,_.ice_bytes_sent=i,_.ice_nominated=Number(f),_.ice_pair_id=m,_.ice_pair_rtt=y,_.ice_pair_state=g,_.ice_pair_writable=S,_.recv_ping_requests=b,_.recv_ping_responses=E,_.sent_ping_requests_before_first_response=k,_.sent_ping_requests_total=k+(T||0),_.sent_ping_responses=I):"local-candidate"===t?(_.local_candidate_type=A,_.local_ip=w||C,_.local_network_type=x,_.local_port=O,_.protocol=D):"remote-candidate"===t&&(_.remote_candidate_type=A,_.remote_ip=w||C,_.remote_port=O);var G=ON("STATS_SCALLBACK_SUPPORT");pL&&G||"media-source"===t&&(_.send_level=d)})),void 0===_.volume&&void 0!==n&&(_.volume=n,_.audio_level=n?-10*$A(Math.pow(n/255,2)):n),(y=r.audio).timestamp){e.next=18;break}return r.audio=c,e.abrupt("return",this.filterIllegal(s));case 18:return void 0!==c.packetsLost&&(s.audioLossRate=(c.packetsLost-y.packetsLost)/(c.packetsSent-y.packetsSent),s.audioLossRate=Number.isNaN(s.audioLossRate)?0:s.audioLossRate,_.fraction_lost=s.audioLossRate),s.statsInterval=c.timestamp-y.timestamp,_.stats_interval=s.statsInterval,s.sendKBitrate=(c.bytesSent-y.bytesSent||0)/s.statsInterval*8,_.mediaBitratebps=Math.round(1e3*s.sendKBitrate),_.bandwidth=Math.round(_.mediaBitratebps/1024),void 0!==c.retransmittedBytesSent&&(_.retransmitBitratebps=(c.retransmittedBytesSent-y.retransmittedBytesSent||0)/s.statsInterval),r.audio=c,_.vendor_mode=(null===(i=this._stream)||void 0===i?void 0:i.vendorCode)||0,_.pc_session_id=null===(o=this.handler)||void 0===o?void 0:o.peerConnectionId,null===(a=this._monitor)||void 0===a||a.report("rtc_media_statistics",_),s._retransmittedRate=(c.retransmittedPacketsSent-y.retransmittedPacketsSent)/(c.packetsSent-y.packetsSent),void 0===s.audioLossRate&&(s.audioLossRate=s._retransmittedRate,_.fraction_lost=s.audioLossRate),s._fractionLost=Math.max(s._fractionLost,s.audioLossRate),e.abrupt("return",this.filterIllegal(s));case 33:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},i={timestamp:Date.now(),simulcast:{}},o=this._stream,a=o.streamId,s=o.videoMid,c=o.isScreen,u=o.pubAttributes,d=o.enableSimulcast,l=o.pubVideo,e.t0=Zd,e.t1={media_type:"video",is_screen:!!c,direction:"up",stream_id:a,vid:s,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:u.localvideo?"capture_state_on":"capture_state_off",mute_state:l?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,h=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",n);case 11:return h.cap_frame_width=t.getSettings().width,h.cap_frame_height=t.getSettings().height,h.frameRateSent=t.getSettings().frameRate,n.isScreen=c,e.next=17,this.handler.getStats(t);case 17:if((p=e.sent).length){e.next=20;break}return e.abrupt("return",n);case 20:if(v=0,p.forEach((function(e){var t=e.type,o=e.framesEncoded,a=e.packetsLost,s=e.bytesSent,c=e.framesSent,u=e.retransmittedBytesSent,l=e.totalPacketSendDelay,p=e.totalEncodeTime,f=e.firCount,_=e.targetBitrate,m=e.roundTripTime,y=e.mimeType,g=e.frameWidth,S=e.frameHeight,b=e.packetsSent,E=e.googActualEncBitrate,k=e.googAvailableReceiveBandwidth,T=e.googAvailableSendBandwidth,I=e.googAvgEncodeMs,R=e.googBucketDelay,A=e.googEncodeUsagePercent,w=e.googFrameRateInput,C=e.availableIncomingBitrate,x=e.availableOutgoingBitrate,O=e.bytesReceived,D=e.nominated,N=e.id,M=e.currentRoundTripTime,P=e.state,L=e.writable,U=e.candidateType,V=e.ip,F=e.address,B=e.networkType,j=e.port,G=e.nackCount,H=e.pliCount,z=e.protocol,K=e.qpSum,X=e.requestsReceived,W=e.responsesReceived,q=e.googRetransmitBitrate,Y=e.requestsSent,J=e.consentRequestsSent,Q=e.responsesSent,Z=e.ssrc,$=e.googTargetEncBitrate,ee=e.googTransmitBitrate,te=e.retransmittedPacketsSent,re=e.encoderImplementation,ne=e.jitter,ie=e.rid,oe=e.fractionLost,ae=e.googAdaptationChanges,se=e.qualityLimitationReason,ce=e.qualityLimitationDurations,ue=e.googFirsReceived,de=e.googFrameRateSent,le=e.keyFramesEncoded,he=e.scalabilityMode,pe=e.framesPerSecond,ve=e.frames;"outbound-rtp"===t?(d&&(ie?i.simulcast[ie]=e:i.simulcast[v]=e,v++),i.framesEncoded=o||i.framesEncoded||0,h.key_frames_encoded=le||0,i.bytesSent=s||i.bytesSent||0,i.framesSent=c||i.framesSent,h.bytes=s||h.bytes||0,i.packetsSent=b||i.packetsSent||0,h.packetsSent=b||h.packetsSent||0,h.nackCount=G||h.nackCount||0,h.pli_count=H||h.pli_count||0,h.qp_sum=K||h.qp_sum||0,h.ssrc=Z||h.ssrc||0,h.retransmitted_packets_sent=te,i.retransmittedPacketsSent=te,i.retransmittedBytesSent=u,h.encoder_implementation=re,h.qualityLimitationReason=se,h.qualityLimitationDurations=ce,h.scalabilityMode=he,void 0!==g&&((!n.encodedFrameWidth||g>n.encodedFrameWidth)&&(n.encodedFrameWidth=g),(!n.encodedFrameHeight||S>n.encodedFrameHeight)&&(n.encodedFrameHeight=S),h.frame_size_height=S,h.frame_size_width=g)):"track"===t?(n.encodedFrameWidth=g,n.encodedFrameHeight=S,h.frame_size_height=S,h.frame_size_width=g):"remote-inbound-rtp"===t?(i.packetsLost=a,n.rtt=1e3*m,h.rtt=n.rtt,h.jitter=1e3*ne,h.packetsLost=a,n._fractionLost=oe||0):"codec"===t?(n.codecType=y,h.codecName=y):"candidate-pair"===t?(h.ice_available_incoming_bitrate=C,h.ice_available_outgoing_bitrate=x,h.ice_bytes_received=O,h.ice_bytes_sent=s,h.ice_nominated=Number(D),h.ice_pair_id=N,h.ice_pair_rtt=M,h.ice_pair_state=P,h.ice_pair_writable=L,h.recv_ping_requests=X,h.recv_ping_responses=W,h.sent_ping_requests_before_first_response=Y,h.sent_ping_requests_total=Y+J,h.sent_ping_responses=Q):"local-candidate"===t?(h.local_candidate_type=U,h.local_ip=V||F,h.local_network_type=B,h.local_port=j,h.protocol=z):"remote-candidate"===t?(h.remote_candidate_type=U,h.remote_ip=V||F,h.remote_port=j):"VideoBwe"===t?(h.encBitratebps=E,h.available_receive_bandwidth=k,h.available_send_bandwidth=T,h.bucket_delay=R,h.retransmitBitratebps=q,h.targetEncBitratebps=$,h.transmit_bitrate=ee,n._sendBandWidth=Number(T)):"ssrc"===t&&(h.avg_encode_ms=I,h.encodeUsage=A,h.frame_rate_input=w,h.orignal_input_Framerate=Number(w),h.ddaptationChanges=ae,h.firsReceived=ue,h.frameRateSent=de);var fe=ON("STATS_SCALLBACK_SUPPORT");if(!pL||!fe){var _e=r.video,me=i.timestamp-_e.timestamp;if("outbound-rtp"===t){var ye=s-_e.bytesSent,ge=u-_e.retransmittedBytesSent;h.encBitratebps=Math.round(8e3*(ye-ge)/me),h.bucket_delay=l/b,h.retransmitBitratebps=Math.round(8e3*ge/me),h.targetEncBitratebps=_,h.transmit_bitrate=Math.round(1e3*(s-_e.bytesSent)*8/me),h.avg_encode_ms=1e3*p/o,h.firsReceived=f+H}else"candidate-pair"===t?(h.available_send_bandwidth=x,n._sendBandWidth=x):"media-source"===t&&(h.frame_rate_input=pe,h.orignal_input_Framerate=Number(pe),h.frame_input=ve)}})),(f=r.video).timestamp){e.next=26;break}return r.video=i,e.abrupt("return",this.filterIllegal(n));case 26:return n.statsInterval=i.timestamp-f.timestamp,h.stats_interval=n.statsInterval,_=an(i.simulcast),d?(h.sim_enc_width=[],h.sim_enc_height=[],h.sim_enc_bps=[],h.sim_enc_framerate=[],h.sim_enc_key_frames=[],h.sim_rids=[],h.sim_enc_bandwidth=[],h.sim_sent_framerate=[],h.sim_fraction_lost=[],h.sim_keyencoded=[],h.active_sim_streams=(null===(m=this._context)||void 0===m?void 0:m.activeSimStreams)||[],h.sim_retransmittedRate=[],b=!1,GR(_).call(_,(function(e,t){return Number(e)-Number(t)})).forEach((function(e){var t=i.simulcast[e],r=t.frameWidth,o=t.frameHeight,a=t.bytesSent,s=t.framesEncoded,c=t.framesSent,u=t.packetsLost,d=t.packetsSent,l=t.qualityLimitationReason,p=t.qualityLimitationDurations,v=t.qualityLimitationResolutionChanges,_=t.retransmittedPacketsSent,m=t.pliCount,y=t.keyFramesEncoded;void 0!==l&&(h.sim_qualityLimitationReason||(h.sim_qualityLimitationReason=[],h.sim_qualityLimitationDurations=[],h.sim_qualityLimitationResolutionChanges=[]),h.sim_qualityLimitationReason.push(l),h.sim_qualityLimitationDurations.push(p),h.sim_qualityLimitationResolutionChanges.push(v));var g=f.simulcast[e];if(h.sim_enc_width.push(r||0),h.sim_enc_height.push(o||0),h.sim_enc_key_frames.push(y||0),g){var S=(a-g.bytesSent||0)/n.statsInterval;h.sim_enc_bps.push(Math.round(8e3*S)),h.sim_enc_bandwidth.push(Math.round(8e3*S/1024));var E=1e3*(s-g.framesEncoded)/n.statsInterval;h.sim_enc_framerate.push(Math.round(E)),h.sim_rids.push(e);var k=void 0!==c?c-g.framesSent:s-g.framesEncoded,T=1e3*k/n.statsInterval;h.sim_sent_framerate.push(Math.round(T));var I=(u-g.packetsLost)/(d-g.packetsSent);n._retransmittedRate=(_-g.retransmittedPacketsSent)/(d-g.packetsSent),I=Number.isNaN(I)?0:I,h.sim_fraction_lost.push(I),h.sim_keyencoded.push(m-g.pliCount>0),h.sim_retransmittedRate.push(n._retransmittedRate),r>0&&!b&&(n.sentKBitrate=8*S,n.encoderOutputFrameRate=E,n.encodedFrameCount=k,n.sentFrameRate=T,n.videoLossRate=I,b=!0)}})),h.vendor_mode=(null===(y=this._stream)||void 0===y?void 0:y.vendorCode)||0,h.pc_session_id=null===(g=this.handler)||void 0===g?void 0:g.peerConnectionId,null===(S=this._monitor)||void 0===S||S.report("rtc_media_statistics",h)):(n.encodedFrameCount=void 0!==i.framesSent?i.framesSent-f.framesSent:i.framesEncoded-f.framesEncoded,n.sentKBitrate=(i.bytesSent-f.bytesSent||0)/n.statsInterval*8,h.bitrate=Math.round(1e3*n.sentKBitrate),h.bandwidth=Math.round(h.bitrate/1024),n.encoderOutputFrameRate=1e3*(i.framesEncoded-f.framesEncoded)/n.statsInterval,h.frame_rate_encoded=Math.round(n.encoderOutputFrameRate),n.sentFrameRate=1e3*n.encodedFrameCount/n.statsInterval,h.frame_rate_sent=Math.round(n.sentFrameRate),n.videoLossRate=(i.packetsLost-f.packetsLost)/(i.packetsSent-f.packetsSent),n.videoLossRate=Number.isNaN(n.videoLossRate)?0:n.videoLossRate,h.fraction_lost=n.videoLossRate,n._retransmittedRate=(i.retransmittedPacketsSent-f.retransmittedPacketsSent)/(i.packetsSent-f.packetsSent),h.vendor_mode=(null===(E=this._stream)||void 0===E?void 0:E.vendorCode)||0,h.pc_session_id=null===(k=this.handler)||void 0===k?void 0:k.peerConnectionId,null===(T=this._monitor)||void 0===T||T.report("rtc_media_statistics",h)),r.video=i,n._fractionLost=Math.max(n._fractionLost,n.videoLossRate),e.abrupt("return",this.filterIllegal(n));case 33:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}($V),tF=function(e){NI(o,e);var t,r,n,i=QI(o);function o(e,t){var r;return Vl(this,o),Jd(tI(r=i.call(this,e)),"isPaused",void 0),Jd(tI(r),"pauseStart",void 0),Jd(tI(r),"pauseDuration",void 0),Jd(tI(r),"_audioStallCount",void 0),Jd(tI(r),"_setAudioStallCount",void 0),Jd(tI(r),"_audioStallTimer",void 0),Jd(tI(r),"_audioStallInterval",void 0),Jd(tI(r),"_audioStallRatio",void 0),Jd(tI(r),"_videoInWaiting",void 0),r._stream=t,r._videoInWaiting=!1,r.pauseDuration=0,r}return Ul(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=Rm(Tm().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,p,v,f,_,m,y,g=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._timer){e.next=2;break}return e.abrupt("return");case 2:return ZV.info("setRemoteStreamStatsEvtInterval","invoke"),this.setVar(r),this._audioStallInterval=o.audioStallInterval||100,this._audioStallRatio=o.audioStallRatio||.6,s={audio:{},video:{}},this._destroyed=!1,c=this._stream,u=null===(n=c.audioTrack)||void 0===n?void 0:n.getOrgTrack(),d=null===(i=c.videoTrack)||void 0===i?void 0:i.getTrack(),this.getRemoteVideoStats(d,s),e.next=14,this.getRemoteAudioStats(u,s,null===(a=this._stream.audioTrack)||void 0===a?void 0:a.getAudioLevel());case 14:this._stopAudioStallTimer(),l=0,h=0,v=[],f=0,_=lD(),this._setAudioStallCount=function(){if(CN.AUDIO_STALL&&g._audioStallInterval>0&&void 0!==s.audio.concealedSamples){var e=s.audio.concealedSamples,t=s.audio.totalSamplesReceived;_=lD();var r={isStall:!1,counted:!1,diff:0},n=.5*g._audioStallInterval;g._audioStallCount=Rm(Tm().mark((function i(){var o,a,s,u,d,p,m,y,S,b,E,k,T,I,R,A,w,C,x,O;return Tm().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=c.hasAudio,s=c.subAudio,u=c.virtual,d=c.virtualOccupy,!c.removeTrack){i.next=4;break}return clearTimeout(g._audioStallTimer),i.abrupt("return");case 4:if(a&&s){i.next=10;break}return r.isStall=!1,r.counted=!1,v.push({reason:Om(p="hasAudio: ".concat(a,", subAudio: ")).call(p,s)}),_=lD(),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 10:if(!u||d){i.next=16;break}return r.isStall=!1,r.counted=!1,v.push({reason:Om(m="virtual: ".concat(u,", virtualOccupy: ")).call(m,d)}),_=lD(),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 16:return y=null===(o=c.audioTrack)||void 0===o?void 0:o.getOrgTrack(),S=Date.now(),i.next=20,g.handler.getStats(y,!0);case 20:if(b=i.sent,E=Date.now(),k=lD(),!((T=k-_)<n)){i.next=27;break}return v.push({diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,reason:Om(I="diff(".concat(T,") < minInterval(")).call(I,n,")")}),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 27:if(R=b.length,A=gE(b).call(b,(function(e){return"inbound-rtp"===e.type}))){i.next=32;break}return v.push({diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,reason:R?"no inbound-rtp":"no report"}),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 32:return w=A.concealedSamples,C=A.totalSamplesReceived,O=C-t,(x=w-e)>=0&&O>=0&&x>=g._audioStallRatio*O?(v.push({concealed:x,received:O,diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,is_stall:!0}),r.isStall?(r.counted?h+=T:(h=h+r.diff+T,l++),r.counted=!0):T>=200?(h+=T,l++,r.counted=!0):(r.counted=!1,r.diff=T),r.isStall=!0):(v.push({concealed:x,received:O,diff:T,start:_,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E}),r.isStall=!1,r.counted=!1),e=w,t=C,_=k,f++,i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:f});case 41:case"end":return i.stop()}}),i)}))),p=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!g._audioStallCount&&g._setAudioStallCount&&g._setAudioStallCount(),!g._audioStallCount){e.next=6;break}return e.next=4,g._audioStallCount();case 4:g._audioStallTimer&&clearTimeout(g._audioStallTimer),g._audioStallTimer=setTimeout(p,g._audioStallInterval);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),g._audioStallTimer&&clearTimeout(g._audioStallTimer),g._audioStallTimer=setTimeout(p,g._audioStallInterval)}},this._setAudioStallCount(),m=function(){var e=Rm(Tm().mark((function e(){var t,r,n,i,o,a,u;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=c.audioTrack)||void 0===t?void 0:t.getOrgTrack(),o=null===(r=c.videoTrack)||void 0===r?void 0:r.getTrack(),e.next=4,g.getRemoteAudioStats(i,s,null===(n=g._stream.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return a=e.sent,l=0,h=0,v=[],f=0,e.next=11,g.getRemoteVideoStats(o,s);case 11:return u=e.sent,e.abrupt("return",{audioStats:a,videoStats:u,isScreen:c.isScreen,userId:c.userId,streamId:c.streamId});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),y=function(){var e=Rm(Tm().mark((function e(){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,m();case 2:r=e.sent,t(r),p&&(_=lD(),g._audioStallTimer&&clearTimeout(g._audioStallTimer),g._audioStallTimer=setTimeout(p,g._audioStallInterval)),g._timer&&clearTimeout(g._timer),g._destroyed||(g._timer=setTimeout(y,2e3));case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),this._timer&&clearTimeout(this._timer),this._timer=setTimeout(y,2e3);case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_stopAudioStallTimer",value:function(){clearTimeout(this._audioStallTimer),this._audioStallCount=void 0,this._setAudioStallCount=void 0,this.pauseDuration=0}},{key:"unsubscribe",value:function(){ZV.info("unsubscribe","invoke"),OI(CI(o.prototype),"stopReport",this).call(this,"unsubscribe"),this._stopAudioStallTimer(),this._videoInWaiting=!1}},{key:"getRemoteAudioStats",value:(r=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(d={},l={},h=this._stream,p=h.streamId,v=h.userId,f=h.isScreen,_=h.audioMid,m=h.subMediaType,y=h._attributes,g=h.virtual,S=h.audioTrack,b={media_type:"audio",is_screen:!!f,direction:"down",stream_id:p,stream_user_id:v,vid:_,audio_mux:g,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:wD(m)?"mute_state_off":"mute_state_on",remote_user_capture_state:y.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:y.localaudio&&y.audiostream?"mute_state_off":"mute_state_on"},S&&(b.playback_volume=S.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",d);case 7:return e.next=9,this.handler.getStats(t);case 9:if((E=e.sent).length){e.next=12;break}return e.abrupt("return",d);case 12:if(E.forEach((function(e){var t=e.type,r=e.packetsLost,i=e.packetsReceived,o=e.bytesReceived,a=e.jitterBufferDelay,s=e.jitterBufferEmittedCount,c=e.clockRate,u=e.channels,h=e.totalSamplesReceived,v=e.concealedSamples,f=e.silentConcealedSamples,_=e.concealmentEvents,m=e.totalRoundTripTime,y=e.packetsDiscarded,g=e.state,S=e.currentRoundTripTime,E=e.audioLevel,k=e.totalAudioEnergy,T=e.totalSamplesDuration,I=e.mimeType,R=e.googDecodingNormal,A=e.googDecodingMuted,w=e.availableIncomingBitrate,C=e.availableOutgoingBitrate,O=e.bytesSent,D=e.nominated,N=e.id,M=e.writable,P=e.jitter,L=e.candidateType,U=e.ip,V=e.address,F=e.networkType,B=e.port,j=e.protocol,G=e.audioOutputLevel,H=e.requestsReceived,z=e.responsesReceived,K=e.requestsSent,X=e.consentRequestsSent,W=e.responsesSent,q=e.ssrc;e.kind;var Y=e.nackCount,J=e.lastPacketReceivedTimestamp,Q=e.concealmentevents,Z=e.fecPacketsReceived;if("inbound-rtp"===t)l.packetsLost=r,l.packetsReceived=i,b.packetsLost=r,b.packetsReceived=i,b.packetsDiscarded=y,b.nackCount=Y,b.lastPacketReceivedTimestamp=J,b.concealmentevents=Q,l.bytesReceived=o,void 0!==a&&(d.jitterBufferDelay=a/s*1e3,b.average_jitter_buffer_delay_ms=d.jitterBufferDelay),void 0!==h&&(l.totalSamplesReceived=h,d.concealedSamples=v,l.concealedSamples=v,l.silentConcealedSamples=f,b.concealedSamples=v,d.concealmentEvents=_,b.totalSamplesReceived=h),void 0!==Z&&(b.fec_packets_received=Z,l.fecPacketsReceived=Z),b.jitter=1e3*P,b.ssrc=q,void 0!==E&&0!==E?(b.audio_level=E?-10*$A(Math.pow(E,2)):E,b.volume=255*E):(b.volume=null!=n?n:255*E,b.audio_level=n?-10*$A(Math.pow(n/255,2)):n),void 0!==k&&(b.total_audio_energy=k),void 0!==T&&(b.totalAudioDuration=T);else if("codec"===t)d.recordSampleRate=c,u&&(d.numChannels=u),b.codecName=I;else if("candidate-pair"===t){var $,ee,te;b.ice_available_incoming_bitrate=w,b.ice_available_outgoing_bitrate=C,b.ice_bytes_received=o,b.ice_bytes_sent=O,b.ice_nominated=Number(D),b.ice_pair_id=N,b.ice_pair_rtt=S,b.rtt=1e3*S,b.rtt&&null!==($=x._context)&&void 0!==$&&null!==(ee=$.streamRTT)&&void 0!==ee&&null!==(te=ee[p])&&void 0!==te&&te.audio&&(b.total_rtt_ms=Math.round(b.rtt+x._context.streamRTT[p].audio)),b.ice_pair_state=g,b.ice_pair_writable=M,b.recv_ping_requests=H,b.recv_ping_responses=z,b.sent_ping_requests_before_first_response=K,b.sent_ping_requests_total=K+(X||0),b.sent_ping_responses=W,"succeeded"===g&&(d.rtt=1e3*S,d.total_rtt=1e3*m)}else"track"===t&&void 0!==E?(0===E&&0!==n?(b.volume=n,b.audio_level=n?-10*$A(Math.pow(n/255,2)):n):(b.audio_level=E?-10*$A(Math.pow(E,2)):E,b.volume=255*E),b.total_audio_energy=k,b.totalAudioDuration=T):"ssrc"===t?(b.decodingNormal=R,b.recvAudioLevel=G,b.decodingMuted=A):"local-candidate"===t?(b.local_candidate_type=L,b.local_ip=U||V,b.local_network_type=F,b.local_port=B,b.protocol=j):"remote-candidate"===t&&(b.remote_candidate_type=L,b.remote_ip=U||V,b.remote_port=B)})),(k=r.audio).timestamp){e.next=18;break}return l.timestamp=Date.now(),r.audio=l,e.abrupt("return",this.filterIllegal(d));case 18:if(T={},void 0!==l.concealedSamples&&(b.interval_concealed_samples=l.concealedSamples-k.concealedSamples,b.interval_samples_received=l.totalSamplesReceived-k.totalSamplesReceived,b.interval_silent_concealed_samples=l.silentConcealedSamples-k.silentConcealedSamples),!(this._audioStallInterval>0&&void 0!==k.concealedSamples)){e.next=36;break}if(!this._audioStallCount&&this._setAudioStallCount&&this._setAudioStallCount(),clearTimeout(this._audioStallTimer),!this._audioStallCount){e.next=36;break}return e.next=26,this._audioStallCount();case 26:I=e.sent,R=I.stall_count,A=I.stall_duration,w=I.stall_list,C=I.stats_count,T.stall_list=w,T.stats_count=C,b.concealedSamples===b.interval_concealed_samples&&b.totalSamplesReceived===b.interval_samples_received?(b.stall_count=0,b.stall_duration=0):(b.stall_count=R,b.stall_duration=A),d.stallCount=b.stall_count,d.stallDuration=b.stall_duration;case 36:return l.timestamp=Date.now(),d.audioLossRate=(l.packetsLost-k.packetsLost)/(l.packetsReceived-k.packetsReceived+(l.packetsLost-k.packetsLost)),d.audioLossRate=Number.isNaN(d.audioLossRate)?0:d.audioLossRate,b.fraction_lost=d.audioLossRate,d.statsInterval=l.timestamp-k.timestamp,b.stats_interval=d.statsInterval,d.receivedKBitrate=(l.bytesReceived-k.bytesReceived||0)/d.statsInterval*8,b.bandwidth=Math.round(1e3*d.receivedKBitrate/1024),void 0!==l.concealedSamples&&(d.receivedSampleRate=1e3*b.interval_samples_received/d.statsInterval),void 0!==l.fecPacketsReceived&&(b.fecBitratebps=(l.fecPacketsReceived-k.fecPacketsReceived||0)/d.statsInterval),b.average_jitter_buffer_delay_ms&&b.total_rtt_ms&&(d.e2eDelay=b.average_jitter_buffer_delay_ms+b.total_rtt_ms),null!==(i=this._context)&&void 0!==i&&null!==(o=i.streamRTT)&&void 0!==o&&null!==(a=o[p])&&void 0!==a&&a.audio&&(d.totalRtt=(b.rtt?b.rtt:0)+this._context.streamRTT[p].audio),r.audio=l,b.vendor_mode=(null===(s=this._stream)||void 0===s?void 0:s.vendorCode)||0,b.pc_session_id=null===(c=this.handler)||void 0===c?void 0:c.peerConnectionId,null===(u=this._monitor)||void 0===u||u.report("rtc_media_statistics",b,T),e.abrupt("return",this.filterIllegal(d));case 53:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u={},d={timestamp:Date.now()},l=this._stream,h=l.streamId,p=l.userId,v=l.isScreen,f=l.subMediaType,_=l._attributes,e.t0=Zd,e.t1={media_type:"video",is_screen:!!v,direction:"down",stream_id:h,stream_user_id:p,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:CD(f)?"mute_state_off":"mute_state_on",remote_user_capture_state:_.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:_.localvideo&&_.videostream?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,m=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",u);case 11:return u.isScreen=v,e.next=14,this.handler.getStats(t);case 14:if((y=e.sent).length){e.next=17;break}return e.abrupt("return",u);case 17:if(y.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,i=e.packetsLost,o=e.packetsReceived,a=e.bytesReceived,s=e.framesDecoded,c=e.jitterBufferDelay,l=e.jitterBufferEmittedCount,p=e.mimeType,v=e.firCount,f=e.availableIncomingBitrate,_=e.availableOutgoingBitrate,y=e.bytesSent,g=e.nominated,S=e.id,E=e.currentRoundTripTime,k=e.state,T=e.writable,I=e.candidateType,R=e.ip,A=e.address,w=e.networkType,C=e.port,x=e.nackCount,O=e.pliCount,D=e.protocol,N=e.requestsReceived,M=e.responsesReceived,P=e.requestsSent,L=e.consentRequestsSent,U=e.responsesSent,V=e.ssrc,F=e.jitter,B=e.framesReceived,j=e.keyFramesDecoded,G=e.totalDecodeTime,H=e.decoderImplementation,z=e.lastPacketReceivedTimestamp,K=e.framesDropped;if("inbound-rtp"===t)d.packetsLost=i,m.packetsLost=i,d.packetsReceived=o,m.packetsReceived=o,d.bytesReceived=a,m.bytes=a,d.framesDecoded=s,d.totalDecodeTime=G,void 0!==c&&(d.jitterBufferDelay=c/l*1e3,m.average_jitter_buffer_delay_ms=d.jitterBufferDelay),m.fir_count=v,m.nackCount=x,d.nackCount=x,m.pli_count=O,m.ssrc=V,m.framesDropped=K,m.jitter=1e3*F,m.framesReceived=B,d.framesReceived=B,m.framesDecoded=s,m.key_frames_decoded=j,m.decoder_name=H,m.last_packet_received_timestamp=z,void 0!==n&&(u.width=n,m.frame_size_width=n,u.height=r,m.frame_size_height=r);else if("track"===t&&void 0!==n)u.width=n,m.frame_size_width=n,u.height=r,m.frame_size_height=r,void 0!==B&&(m.framesReceived=B,d.framesReceived=B);else if("codec"===t)m.codecName=p;else if("candidate-pair"===t){var X,W,q;m.ice_available_incoming_bitrate=f,m.ice_available_outgoing_bitrate=_,m.ice_bytes_received=a,m.ice_bytes_sent=y,m.ice_nominated=Number(g),m.ice_pair_id=S,m.ice_pair_rtt=E,m.rtt=1e3*E,m.rtt&&null!==(X=b._context)&&void 0!==X&&null!==(W=X.streamRTT)&&void 0!==W&&null!==(q=W[h])&&void 0!==q&&q.video&&(m.total_rtt_ms=Math.round(m.rtt+b._context.streamRTT[h].video)),u.rtt=m.rtt,m.ice_pair_state=k,m.ice_pair_writable=T,m.recv_ping_requests=N,m.recv_ping_responses=M,m.sent_ping_requests_before_first_response=P,m.sent_ping_requests_total=P+(L||0),m.sent_ping_responses=U}else"local-candidate"===t?(m.local_candidate_type=I,m.local_ip=R||A,m.local_network_type=w,m.local_port=C,m.protocol=D):"remote-candidate"===t&&(m.remote_candidate_type=I,m.remote_ip=R||A,m.remote_port=C)})),(g=r.video).timestamp){e.next=22;break}return r.video=d,e.abrupt("return",this.filterIllegal(u));case 22:return u.videoLossRate=(d.packetsLost-g.packetsLost)/(d.packetsReceived-g.packetsReceived+(d.packetsLost-g.packetsLost)),g.totalDecodeTime&&g.framesDecoded&&d.framesDecoded!==g.framesDecoded&&(m.decode_elapse_per_frame=Number(((d.totalDecodeTime-g.totalDecodeTime)/(d.framesDecoded-g.framesDecoded)*1e3).toFixed(2))),u._retransmittedRate=(d.nackCount-g.nackCount)/(d.packetsReceived-g.packetsReceived+(d.packetsLost-g.packetsLost)),u.videoLossRate=Number.isNaN(u.videoLossRate)?0:u.videoLossRate,m.fraction_lost=u.videoLossRate,u.statsInterval=d.timestamp-g.timestamp,m.stats_interval=u.statsInterval,u.receivedKBitrate=(d.bytesReceived-g.bytesReceived||0)/u.statsInterval*8,m.bitrate=Math.round(1e3*u.receivedKBitrate),m.bandwidth=Math.round(m.bitrate/1024),u.decoderOutputFrameRate=1e3*(d.framesDecoded-g.framesDecoded)/u.statsInterval,u.receivedFrameRate=1e3*(d.framesReceived-g.framesReceived)/u.statsInterval,m.frame_rate_decoded=Math.round(u.decoderOutputFrameRate),m.frame_rate_received=Math.round(u.receivedFrameRate),m.average_jitter_buffer_delay_ms&&m.total_rtt_ms&&(u.e2eDelay=m.average_jitter_buffer_delay_ms+m.total_rtt_ms),null!==(n=this._context)&&void 0!==n&&null!==(i=n.streamRTT)&&void 0!==i&&null!==(o=i[h])&&void 0!==o&&o.video&&(u.totalRtt=(m.rtt?m.rtt:0)+this._context.streamRTT[h].video),r.video=d,this.processStall(this._stream,m,u,v),this.isPaused?(S=d.timestamp-(this.pauseStart||0),m.pause_duration=this.pauseDuration+(S>500?S:0),this.pauseStart=d.timestamp):m.pause_duration=this.pauseDuration,m.pause_duration=Math.min(m.stall_duration||m.stuck_length||0,m.pause_duration),this.pauseDuration=0,m.vendor_mode=(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,m.pc_session_id=null===(s=this.handler)||void 0===s?void 0:s.peerConnectionId,null===(c=this._monitor)||void 0===c||c.report("rtc_media_statistics",m),e.abrupt("return",this.filterIllegal(u));case 47:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"processStall",value:function(e,t,r,n){var i=0,o=0,a=0;if(e.recordedVideoFrames&&this.player&&this.player.played){e.recordedVideoFrames.forEach((function(e){e.isStall&&(i+=e.stallCount,o+=e.stallDuration),a=e.playTime})),e.recordedVideoFrames.length||(o=2e3,i=this._videoInWaiting?0:1,this._videoInWaiting=!0);var s=e.recordedVideoFrames.pop();s&&(s.isStall?this._videoInWaiting=!0:this._videoInWaiting=!1),e.recordedVideoFrames=[]}t.stall_count=i,n?(t.stuck_length=Math.min(o,t.stats_interval),t.stall_duration=void 0):(t.stall_duration=Math.min(o,t.stats_interval),t.stuck_length=void 0),t.play_time=a,r.stallCount=i,r.stallDuration=o}},{key:"destroy",value:function(){OI(CI(o.prototype),"destroy",this).call(this),OI(CI(o.prototype),"stopReport",this).call(this,"destroy"),this._stopAudioStallTimer(),this._videoInWaiting=!1}}],[{key:"audioStallConfig",set:function(e){o.audioStallInterval=((null==e?void 0:e.audio_stall_interval)||200)/2,o.audioStallRatio=null==e?void 0:e.audio_stall_ratio}}]),o}($V);Jd(tF,"audioStallInterval",void 0),Jd(tF,"audioStallRatio",void 0);var rF,nF,iF=new Pw("Stream",0),oF=function(e){NI(r,e);var t=QI(r);function r(e){var n;return Vl(this,r),Jd(tI(n=t.call(this)),"videoDom",void 0),Jd(tI(n),"audioMid",void 0),Jd(tI(n),"videoMid",void 0),Jd(tI(n),"videoTransceiver",void 0),Jd(tI(n),"audioTransceiver",void 0),Jd(tI(n),"vendorHandler",void 0),Jd(tI(n),"vendorCode",0),Jd(tI(n),"engineId",void 0),n.engineId=e.id,n}return Ul(r,[{key:"requestVideoFrameCallback",value:function(){var e=this;return new Y_((function(t){var r,n=null===(r=e.videoDom)||void 0===r?void 0:r.requestVideoFrameCallback;if("function"==typeof n){var i=function(e,r){var n={};an(r).forEach((function(e){var t=e.replace(/[a-z]{1}[A-Z]{1}/g,(function(e){var t;return Om(t="".concat(e[0],"_")).call(t,e[1].toLowerCase())}));n["video_".concat(t)]=r[e]})),clearInterval(o),t(n)};n.call(e.videoDom,i);var o=setTimeout((function(){var r;null===(r=e.videoDom)||void 0===r||r.cancelVideoFrameCallback(i),t({})}),500)}else t({})}))}},{key:"stopReport",value:function(e){this.statsReport.stopReport(e)}},{key:"destroy",value:function(){var e,t;delete this.audioMid,delete this.videoMid,this.statsReport.destroy(),null===(e=this.observer)||void 0===e||e.reset(),delete this.videoTransceiver,delete this.audioTransceiver,null===(t=this.vendorHandler)||void 0===t||t.destroy(),this.vendorCode=0,delete this.vendorHandler}}]),r}(aM),aF=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}(aF||{}),sF=function(e){NI(r,e);var t=QI(r);function r(e){var n;return Vl(this,r),Jd(tI(n=t.call(this,e)),"isScreen",!1),Jd(tI(n),"stream",void 0),Jd(tI(n),"streamId",void 0),Jd(tI(n),"seiList",[]),Jd(tI(n),"videoTrack",void 0),Jd(tI(n),"audioTrack",void 0),Jd(tI(n),"videoEncodeConfig",[NN]),Jd(tI(n),"subVideoDescriptions",[]),Jd(tI(n),"enableSimulcast",!1),Jd(tI(n),"observer",void 0),Jd(tI(n),"statsReport",void 0),Jd(tI(n),"prevBitrate",0),Jd(tI(n),"pubAudio",!1),Jd(tI(n),"pubVideo",!1),Jd(tI(n),"pubAttributes",void 0),Jd(tI(n),"pcSessionId",void 0),n.stream=new MediaStream,n.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1},n.statsReport=new eF(e,tI(n)),n}return Ul(r,[{key:"audioHasCapture",get:function(){return this.pubAttributes.localaudio}},{key:"audioHasPublish",get:function(){return this.pubAttributes.audiostream}},{key:"videoHasCapture",get:function(){return this.pubAttributes.localvideo}},{key:"videoHasPublish",get:function(){return this.pubAttributes.videostream}},{key:"hasPublished",get:function(){return!!this.audioMid&&!!this.videoMid}},{key:"isEmptyStream",get:function(){return!this.audioTrack&&!this.videoTrack}},{key:"initStreamId",get:function(){return this.stream.id}},{key:"startReport",value:function(e,t){this.statsReport.setLocalStreamStatsEvtInterval(e,t)}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.sender){var t=this.videoTransceiver.sender;if(lL()){var r=t.createEncodedStreams(),n=r.readable,i=r.writable,o=new TransformStream({transform:function(t,r){var n=e.seiList[0];if(n){var i,o=QV.generateSEI(n.content),a=new Uint8Array(o.byteLength+t.data.byteLength);if(0===n.repeatCount)rk(i=e.seiList).call(i,0,1);n.repeatCount--,a.set(new Uint8Array(t.data)),a.set(o,t.data.byteLength),t.data=a.buffer,r.enqueue(t)}else r.enqueue(t)}});n.pipeThrough(o).pipeTo(i)}}else iF.warn("no sender found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.sender){var e=this.audioTransceiver.sender.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else iF.warn("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){jO(this.engineId,"localstream_clean","".concat((new Error).stack),0,this.streamId||""),OI(CI(r.prototype),"destroy",this).call(this),this.prevBitrate=0,this.subVideoDescriptions=[]}},{key:"switchTrackEnableState",value:function(e,t){var r,n;"audio"===e?n=this.audioTrack:"video"===e&&(n=this.videoTrack);var i=null===(r=n)||void 0===r?void 0:r.getTrack();return!(!i||(null==i?void 0:i.enabled)===t)&&(i.enabled=t,!0)}}]),r}(oF),cF=function(e){NI(r,e);var t=QI(r);function r(e,n,i,o,a,s){var c;return Vl(this,r),Jd(tI(c=t.call(this,e)),"streamId",void 0),Jd(tI(c),"userId",void 0),Jd(tI(c),"isScreen",void 0),Jd(tI(c),"isPublic",void 0),Jd(tI(c),"hasVideo",void 0),Jd(tI(c),"hasAudio",void 0),Jd(tI(c),"_attributes",void 0),Jd(tI(c),"streamState",void 0),Jd(tI(c),"removeTrack",!1),Jd(tI(c),"observer",void 0),Jd(tI(c),"statsReport",void 0),Jd(tI(c),"subVideo",void 0),Jd(tI(c),"subAudio",void 0),Jd(tI(c),"subMediaType",void 0),Jd(tI(c),"subLayer",void 0),Jd(tI(c),"_sequenceId",void 0),Jd(tI(c),"stream",void 0),Jd(tI(c),"videoTrack",void 0),Jd(tI(c),"audioTrack",void 0),Jd(tI(c),"recordedVideoFrames",void 0),Jd(tI(c),"stillExist",void 0),Jd(tI(c),"originalMediaType",void 0),Jd(tI(c),"priority",void 0),Jd(tI(c),"originalStreamIndex",0),Jd(tI(c),"virtual",void 0),Jd(tI(c),"pcSessionId",void 0),Jd(tI(c),"_virtualOccupy",void 0),c.virtual=!1,c._virtualOccupy=!1,c.userId=n,c.isScreen=o,c.isPublic=a,c.streamId=i,c.hasAudio=s.audiostream&&s.localaudio,c.hasVideo=s.videostream&&s.localvideo,c._attributes=s,c.vendorCode=(null==s?void 0:s.vendorCode)||0,c.subVideo=!1,c.subAudio=!1,c._sequenceId=0,c.subMediaType=GV.NONE,c.subLayer={spatialLayer:0,spatialSubLayer:-1},c.streamState=0,c.statsReport=new tF(e,tI(c)),c.enableVendorMode&&(c.pcSessionId=_w()),c}return Ul(r,[{key:"vendor",get:function(){return this._attributes.vendorCode}},{key:"audioHasCapture",get:function(){return this._attributes.localaudio}},{key:"audioHasPublish",get:function(){return this._attributes.audiostream}},{key:"videoHasCapture",get:function(){return this._attributes.localvideo}},{key:"videoHasPublish",get:function(){return this._attributes.videostream}},{key:"sequenceId",get:function(){return this._sequenceId||-1},set:function(e){"number"==typeof e&&(this._sequenceId=e)}},{key:"enableVendorMode",get:function(){return"number"==typeof this.attributes.vendorCode&&0!==this.attributes.vendorCode}},{key:"hasSubscribed",get:function(){return 2===this.streamState}},{key:"attributes",get:function(){return this._attributes},set:function(e){this.hasVideo=e.localvideo&&e.videostream,this.hasAudio=e.localaudio&&e.audiostream,this._attributes=e,this.vendorCode=e.vendorCode||0}},{key:"virtualOccupy",get:function(){return this._virtualOccupy},set:function(e){var t;if(this._virtualOccupy&&!e)null===(t=this.observer)||void 0===t||t.setPushTrack(!1);else if(!this._virtualOccupy&&e){var r;null===(r=this.observer)||void 0===r||r.setPushTrack(!0)}this._virtualOccupy=e}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.receiver){var t=this.videoTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){HV.getNalunits(new zV(t.data)).forEach((function(t){if(t.sei){var r=QV.decodeSeiBody(t.body);r&&r.type!==KV.internal&&e.safeEmit("onSEIMessage",r.payload)}})),r.enqueue(t)}})).pipeTo(n)}else iF.warn("no receiver found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.receiver){var e=this.audioTransceiver.receiver.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){e.data.byteLength<=1e3?t.enqueue(e):iF.print("too large audio frame",e.data.byteLength)}})).pipeTo(r)}else iF.warn("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r,n,i,o,a;try{var s;jO(this.engineId,"Stream.ontrack",Pm({uid:this.userId,streamId:this.streamId,streams:pb(s=e.streams).call(s,(function(e,t){return e+(null==(r=t)?"undefined | null":"string"==typeof r?r:Pm({id:r.id,active:r.active}));var r}),""),transceiver:(i=e.transceiver,null==i?"undefined | null":"string"==typeof i?i:Pm({currentDirection:i.currentDirection,direction:i.direction,mid:i.mid,stopped:i.stopped,receiver:(a=i.receiver,null==a?"undefined | null":"string"==typeof a?a:Pm({track:DD(a.track)})),sender:(o=i.sender,null==o?"undefined | null":"string"==typeof o?o:Pm({track:DD(o.track)}))})),track:DD(e.track)}),0,this.streamId||"")}catch(XW){}if(this.enableVendorMode||null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&mk(n).call(n,this.streamId)){var c,u=e.track;"video"===(null==u?void 0:u.kind)?this._setVideoTrack(u):"audio"===(null===(c=e.track)||void 0===c?void 0:c.kind)&&this._setAudioTrack(u),this._setStream(e.streams[0])}this.safeEmit("ontrack",e)}},{key:"clean",value:function(){var e,t;iF.info("clean",Om(e="exec stream.clean ".concat(this.streamId," ")).call(e,this.userId)),jO(this.engineId,"remotestream_clean","".concat((new Error).stack),0,this.streamId),OI(CI(r.prototype),"destroy",this).call(this),this.subAudio=!1,this.subVideo=!1,this.sequenceId=0,this.videoTrack=void 0,null===(t=this.audioTrack)||void 0===t||t.close(),this.audioTrack=void 0,this.stream=void 0,this.recordedVideoFrames=void 0,delete this.priority}},{key:"destroy",value:function(){this.clean(),this.attributes={audiostream:!1,localaudio:!1,localvideo:!1,videostream:!1,extvideo:!1,extaudio:!1,videoDescriptions:[]}}},{key:"resetHasSubscribed",value:function(){this.streamState=0}},{key:"_setStream",value:function(e){var t=this;this.stream=e,e.onaddtrack=function(e){"video"===e.track.kind?t._setVideoTrack(e.track):"audio"===e.track.kind&&t._setAudioTrack(e.track)}}},{key:"_setAudioTrack",value:function(e){var t,r;(null===(t=this.audioTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.audioTrack=OV(e),this.emit("ontrack",this.audioTrack))}},{key:"_setVideoTrack",value:function(e){var t,r;(null===(t=this.videoTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.videoTrack=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dD();return new lV(e,t)}(e),this.emit("ontrack",this.videoTrack))}}]),r}(oF),uF=new Pw("queue",4),dF=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(dF||{}),lF=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}(lF||{}),hF=(Jd(rF={},"publish","unpublish"),Jd(rF,"subscribe","unsubscribe"),Jd(rF,"pushtrack","removetrack"),rF),pF=(Jd(nF={},"publish",0),Jd(nF,"subscribe",0),Jd(nF,"pushtrack",0),Jd(nF,"unpublish",1),Jd(nF,"unsubscribe",1),Jd(nF,"removetrack",1),nF),vF=function(e){NI(r,e);var t=QI(r);function r(){var e;return Vl(this,r),Jd(tI(e=t.call(this)),"_queue",void 0),e._queue=[],e}return Ul(r,[{key:"queue",get:function(){return this._queue}},{key:"enqueue",value:function(e){var t,r=this._queue.length,n="";return this._queue=Gs(t=this._queue).call(t,(function(t){return t.streamId!==e.streamId||e.action!==hF[t.action]||(n=t.streamId,uF.info("offsetStreamId",n),!1)})),this._queue.length===r&&this._queue.push(e),this.emit("start"),n}},{key:"dequeue",value:function(){var e;if(!this._queue.length)return null;var t=this._queue.length;XD&&pN>=86&&pN<=92&&(t=Math.min(this._queue.length,5));for(var r=pF[this._queue[0].action],n=1;n<t;n++){var i;if(pF[this._queue[n].action]!==r)return{sdpStrategy:r,items:rk(i=this._queue).call(i,0,n)}}return{sdpStrategy:r,items:rk(e=this._queue).call(e,0,t)}}}]),r}(iM),fF="object"==typeof global&&global&&global.Object===Object&&global,_F="object"==typeof self&&self&&self.Object===Object&&self,mF=fF||_F||Function("return this")(),yF=mF.Symbol,gF=Object.prototype,SF=gF.hasOwnProperty,bF=gF.toString,EF=yF?yF.toStringTag:void 0;var kF=Object.prototype.toString;var TF=yF?yF.toStringTag:void 0;function IF(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":TF&&TF in Object(e)?function(e){var t=SF.call(e,EF),r=e[EF];try{e[EF]=void 0;var n=!0}catch(o){}var i=bF.call(e);return n&&(t?e[EF]=r:delete e[EF]),i}(e):function(e){return kF.call(e)}(e)}function RF(e){return null!=e&&"object"==typeof e}var AF=Array.isArray;function wF(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function CF(e){return e}function xF(e){if(!wF(e))return!1;var t=IF(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var OF,DF=mF["__core-js_shared__"],NF=(OF=/[^.]+$/.exec(DF&&DF.keys&&DF.keys.IE_PROTO||""))?"Symbol(src)_1."+OF:"";var MF=Function.prototype.toString;function PF(e){if(null!=e){try{return MF.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var LF=/^\[object .+?Constructor\]$/,UF=Function.prototype,VF=Object.prototype,FF=UF.toString,BF=VF.hasOwnProperty,jF=RegExp("^"+FF.call(BF).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function GF(e){return!(!wF(e)||(t=e,NF&&NF in t))&&(xF(e)?jF:LF).test(PF(e));var t}function HF(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return GF(r)?r:void 0}var zF=HF(mF,"WeakMap"),KF=Object.create,XF=function(){function e(){}return function(t){if(!wF(t))return{};if(KF)return KF(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();function WF(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var qF=Date.now;var YF,JF,QF,ZF=function(){try{var e=HF(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),$F=ZF,eB=$F?function(e,t){return $F(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:CF,tB=(YF=eB,JF=0,QF=0,function(){var e=qF(),t=16-(e-QF);if(QF=e,t>0){if(++JF>=800)return arguments[0]}else JF=0;return YF.apply(void 0,arguments)}),rB=tB;var nB=/^(?:0|[1-9]\d*)$/;function iB(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&nB.test(e))&&e>-1&&e%1==0&&e<t}function oB(e,t,r){"__proto__"==t&&$F?$F(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function aB(e,t){return e===t||e!=e&&t!=t}var sB=Object.prototype.hasOwnProperty;function cB(e,t,r){var n=e[t];sB.call(e,t)&&aB(n,r)&&(void 0!==r||t in e)||oB(e,t,r)}function uB(e,t,r,n){var i=!r;r||(r={});for(var o=-1,a=t.length;++o<a;){var s=t[o],c=n?n(r[s],e[s],s,r,e):void 0;void 0===c&&(c=e[s]),i?oB(r,s,c):cB(r,s,c)}return r}var dB=Math.max;function lB(e,t){return rB(function(e,t,r){return t=dB(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=dB(n.length-t,0),a=Array(o);++i<o;)a[i]=n[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=n[i];return s[t]=r(a),WF(e,this,s)}}(e,t,CF),e+"")}function hB(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function pB(e){return null!=e&&hB(e.length)&&!xF(e)}var vB=Object.prototype;function fB(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||vB)}function _B(e){return RF(e)&&"[object Arguments]"==IF(e)}var mB=Object.prototype,yB=mB.hasOwnProperty,gB=mB.propertyIsEnumerable,SB=_B(function(){return arguments}())?_B:function(e){return RF(e)&&yB.call(e,"callee")&&!gB.call(e,"callee")},bB=SB;var EB="object"==typeof exports&&exports&&!exports.nodeType&&exports,kB=EB&&"object"==typeof module&&module&&!module.nodeType&&module,TB=kB&&kB.exports===EB?mF.Buffer:void 0,IB=(TB?TB.isBuffer:void 0)||function(){return!1},RB={};function AB(e){return function(t){return e(t)}}RB["[object Float32Array]"]=RB["[object Float64Array]"]=RB["[object Int8Array]"]=RB["[object Int16Array]"]=RB["[object Int32Array]"]=RB["[object Uint8Array]"]=RB["[object Uint8ClampedArray]"]=RB["[object Uint16Array]"]=RB["[object Uint32Array]"]=!0,RB["[object Arguments]"]=RB["[object Array]"]=RB["[object ArrayBuffer]"]=RB["[object Boolean]"]=RB["[object DataView]"]=RB["[object Date]"]=RB["[object Error]"]=RB["[object Function]"]=RB["[object Map]"]=RB["[object Number]"]=RB["[object Object]"]=RB["[object RegExp]"]=RB["[object Set]"]=RB["[object String]"]=RB["[object WeakMap]"]=!1;var wB="object"==typeof exports&&exports&&!exports.nodeType&&exports,CB=wB&&"object"==typeof module&&module&&!module.nodeType&&module,xB=CB&&CB.exports===wB&&fF.process,OB=function(){try{var e=CB&&CB.require&&CB.require("util").types;return e||xB&&xB.binding&&xB.binding("util")}catch(t){}}(),DB=OB&&OB.isTypedArray,NB=DB?AB(DB):function(e){return RF(e)&&hB(e.length)&&!!RB[IF(e)]},MB=Object.prototype.hasOwnProperty;function PB(e,t){var r=AF(e),n=!r&&bB(e),i=!r&&!n&&IB(e),o=!r&&!n&&!i&&NB(e),a=r||n||i||o,s=a?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],c=s.length;for(var u in e)!t&&!MB.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||iB(u,c))||s.push(u);return s}function LB(e,t){return function(r){return e(t(r))}}var UB=LB(Object.keys,Object),VB=Object.prototype.hasOwnProperty;function FB(e){return pB(e)?PB(e):function(e){if(!fB(e))return UB(e);var t=[];for(var r in Object(e))VB.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}var BB=Object.prototype.hasOwnProperty;function jB(e){if(!wF(e))return function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}(e);var t=fB(e),r=[];for(var n in e)("constructor"!=n||!t&&BB.call(e,n))&&r.push(n);return r}function GB(e){return pB(e)?PB(e,!0):jB(e)}var HB,zB=(HB=function(e,t){uB(t,GB(t),e)},lB((function(e,t){var r=-1,n=t.length,i=n>1?t[n-1]:void 0,o=n>2?t[2]:void 0;for(i=HB.length>3&&"function"==typeof i?(n--,i):void 0,o&&function(e,t,r){if(!wF(r))return!1;var n=typeof t;return!!("number"==n?pB(r)&&iB(t,r.length):"string"==n&&t in r)&&aB(r[t],e)}(t[0],t[1],o)&&(i=n<3?void 0:i,n=1),e=Object(e);++r<n;){var a=t[r];a&&HB(e,a,r,i)}return e}))),KB=HF(Object,"create");var XB=Object.prototype.hasOwnProperty;var WB=Object.prototype.hasOwnProperty;function qB(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function YB(e,t){for(var r=e.length;r--;)if(aB(e[r][0],t))return r;return-1}qB.prototype.clear=function(){this.__data__=KB?KB(null):{},this.size=0},qB.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},qB.prototype.get=function(e){var t=this.__data__;if(KB){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return XB.call(t,e)?t[e]:void 0},qB.prototype.has=function(e){var t=this.__data__;return KB?void 0!==t[e]:WB.call(t,e)},qB.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=KB&&void 0===t?"__lodash_hash_undefined__":t,this};var JB=Array.prototype.splice;function QB(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}QB.prototype.clear=function(){this.__data__=[],this.size=0},QB.prototype.delete=function(e){var t=this.__data__,r=YB(t,e);return!(r<0)&&(r==t.length-1?t.pop():JB.call(t,r,1),--this.size,!0)},QB.prototype.get=function(e){var t=this.__data__,r=YB(t,e);return r<0?void 0:t[r][1]},QB.prototype.has=function(e){return YB(this.__data__,e)>-1},QB.prototype.set=function(e,t){var r=this.__data__,n=YB(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};var ZB=HF(mF,"Map");function $B(e,t){var r,n,i=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof t?"string":"hash"]:i.map}function ej(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function tj(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}ej.prototype.clear=function(){this.size=0,this.__data__={hash:new qB,map:new(ZB||QB),string:new qB}},ej.prototype.delete=function(e){var t=$B(this,e).delete(e);return this.size-=t?1:0,t},ej.prototype.get=function(e){return $B(this,e).get(e)},ej.prototype.has=function(e){return $B(this,e).has(e)},ej.prototype.set=function(e,t){var r=$B(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};var rj=LB(Object.getPrototypeOf,Object);function nj(e){var t=this.__data__=new QB(e);this.size=t.size}nj.prototype.clear=function(){this.__data__=new QB,this.size=0},nj.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},nj.prototype.get=function(e){return this.__data__.get(e)},nj.prototype.has=function(e){return this.__data__.has(e)},nj.prototype.set=function(e,t){var r=this.__data__;if(r instanceof QB){var n=r.__data__;if(!ZB||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new ej(n)}return r.set(e,t),this.size=r.size,this};var ij="object"==typeof exports&&exports&&!exports.nodeType&&exports,oj=ij&&"object"==typeof module&&module&&!module.nodeType&&module,aj=oj&&oj.exports===ij?mF.Buffer:void 0,sj=aj?aj.allocUnsafe:void 0;function cj(){return[]}var uj=Object.prototype.propertyIsEnumerable,dj=Object.getOwnPropertySymbols,lj=dj?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var r=-1,n=null==e?0:e.length,i=0,o=[];++r<n;){var a=e[r];t(a,r,e)&&(o[i++]=a)}return o}(dj(e),(function(t){return uj.call(e,t)})))}:cj;var hj=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)tj(t,lj(e)),e=rj(e);return t}:cj;function pj(e,t,r){var n=t(e);return AF(e)?n:tj(n,r(e))}function vj(e){return pj(e,FB,lj)}function fj(e){return pj(e,GB,hj)}var _j=HF(mF,"DataView"),mj=HF(mF,"Promise"),yj=HF(mF,"Set"),gj="[object Map]",Sj="[object Promise]",bj="[object Set]",Ej="[object WeakMap]",kj="[object DataView]",Tj=PF(_j),Ij=PF(ZB),Rj=PF(mj),Aj=PF(yj),wj=PF(zF),Cj=IF;(_j&&Cj(new _j(new ArrayBuffer(1)))!=kj||ZB&&Cj(new ZB)!=gj||mj&&Cj(mj.resolve())!=Sj||yj&&Cj(new yj)!=bj||zF&&Cj(new zF)!=Ej)&&(Cj=function(e){var t=IF(e),r="[object Object]"==t?e.constructor:void 0,n=r?PF(r):"";if(n)switch(n){case Tj:return kj;case Ij:return gj;case Rj:return Sj;case Aj:return bj;case wj:return Ej}return t});var xj=Cj,Oj=Object.prototype.hasOwnProperty;var Dj=mF.Uint8Array;function Nj(e){var t=new e.constructor(e.byteLength);return new Dj(t).set(new Dj(e)),t}var Mj=/\w*$/;var Pj=yF?yF.prototype:void 0,Lj=Pj?Pj.valueOf:void 0;function Uj(e,t,r){var n,i,o,a=e.constructor;switch(t){case"[object ArrayBuffer]":return Nj(e);case"[object Boolean]":case"[object Date]":return new a(+e);case"[object DataView]":return function(e,t){var r=t?Nj(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(e,t){var r=t?Nj(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}(e,r);case"[object Map]":case"[object Set]":return new a;case"[object Number]":case"[object String]":return new a(e);case"[object RegExp]":return(o=new(i=e).constructor(i.source,Mj.exec(i))).lastIndex=i.lastIndex,o;case"[object Symbol]":return n=e,Lj?Object(Lj.call(n)):{}}}var Vj=OB&&OB.isMap,Fj=Vj?AB(Vj):function(e){return RF(e)&&"[object Map]"==xj(e)};var Bj=OB&&OB.isSet,jj=Bj?AB(Bj):function(e){return RF(e)&&"[object Set]"==xj(e)},Gj="[object Arguments]",Hj="[object Function]",zj="[object Object]",Kj={};function Xj(e,t,r,n,i,o){var a,s=1&t,c=2&t,u=4&t;if(r&&(a=i?r(e,n,i,o):r(e)),void 0!==a)return a;if(!wF(e))return e;var d=AF(e);if(d){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&Oj.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(e),!s)return function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}(e,a)}else{var l=xj(e),h=l==Hj||"[object GeneratorFunction]"==l;if(IB(e))return function(e,t){if(t)return e.slice();var r=e.length,n=sj?sj(r):new e.constructor(r);return e.copy(n),n}(e,s);if(l==zj||l==Gj||h&&!i){if(a=c||h?{}:function(e){return"function"!=typeof e.constructor||fB(e)?{}:XF(rj(e))}(e),!s)return c?function(e,t){return uB(e,hj(e),t)}(e,function(e,t){return e&&uB(t,GB(t),e)}(a,e)):function(e,t){return uB(e,lj(e),t)}(e,function(e,t){return e&&uB(t,FB(t),e)}(a,e))}else{if(!Kj[l])return i?e:{};a=Uj(e,l,s)}}o||(o=new nj);var p=o.get(e);if(p)return p;o.set(e,a),jj(e)?e.forEach((function(n){a.add(Xj(n,t,r,n,e,o))})):Fj(e)&&e.forEach((function(n,i){a.set(i,Xj(n,t,r,i,e,o))}));var v=d?void 0:(u?c?fj:vj:c?GB:FB)(e);return function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););}(v||e,(function(n,i){v&&(n=e[i=n]),cB(a,i,Xj(n,t,r,i,e,o))})),a}Kj[Gj]=Kj["[object Array]"]=Kj["[object ArrayBuffer]"]=Kj["[object DataView]"]=Kj["[object Boolean]"]=Kj["[object Date]"]=Kj["[object Float32Array]"]=Kj["[object Float64Array]"]=Kj["[object Int8Array]"]=Kj["[object Int16Array]"]=Kj["[object Int32Array]"]=Kj["[object Map]"]=Kj["[object Number]"]=Kj[zj]=Kj["[object RegExp]"]=Kj["[object Set]"]=Kj["[object String]"]=Kj["[object Symbol]"]=Kj["[object Uint8Array]"]=Kj["[object Uint8ClampedArray]"]=Kj["[object Uint16Array]"]=Kj["[object Uint32Array]"]=!0,Kj["[object Error]"]=Kj[Hj]=Kj["[object WeakMap]"]=!1;function Wj(e){return Xj(e,5)}function qj(e,t){return function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}(t,(function(t){return e[t]}))}function Yj(e){return null==e?[]:qj(e,FB(e))}var Jj,Qj,Zj=new Pw("ChromeHandler",3),$j=lL(),eG=function(e){NI(u,e);var t,r,n,i,o,a,s,c=QI(u);function u(e,t){var r;return Vl(this,u),Jd(tI(r=c.call(this,e,t)),"name","chrome"),Jd(tI(r),"_queueBusy",!1),Jd(tI(r),"_sdpQueue",void 0),Jd(tI(r),"_aSendonlyOfferTpl",void 0),Jd(tI(r),"_vSendonlyOfferTpl",void 0),Jd(tI(r),"_aRecvonlyOfferTpl",void 0),Jd(tI(r),"_vRecvonlyOfferTpl",void 0),Jd(tI(r),"_mid",10),Jd(tI(r),"_inactiveMlineIndex",[]),Jd(tI(r),"_mlinesCache",{}),Jd(tI(r),"setDescription",void 0),r.setDescription=t.setDescription.bind(t),r._sdpQueue=new vF,r._sdpQueue.on("start",(function(){r._queueBusy||"stable"!==r._peerConnection.signalingState||(Zj.info("dequeue start"),r.dequeue())})),r}return Ul(u,[{key:"destroy",value:function(){OI(CI(u.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(s=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,D,N,M,P,L,U,V,F;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d=t.stream,l=t.enableSimulcast,h=OI(CI(u.prototype),"internalPublish",this).call(this,t),p=h.videoDescriptions,v=h.subVideoDescriptions,f=h.audioTransceiverInit,_=h.videoTransceiverInit,m=KL(this._nextSsrc),this._nextSsrc=m.next,y="".concat(this._mid++),g="".concat(this._mid++),S=Zd(Zd(Zd({},this._aSendonlyOfferTpl),this.peer._offerIce),{},{mid:y,msid:Om(r="".concat(d.id," ")).call(r,d.id,"-audio"),ssrcs:XL(d.id,"audio",m.audio,HL)}),b=Zd(Zd(Zd({},this._vSendonlyOfferTpl),this.peer._offerIce),{},{mid:g,msid:Om(n="".concat(d.id," ")).call(n,d.id,"-video")}),l?(Zj.info("subVideoDesc","desc: %o ",v),delete b.ssrcGroups,delete b.ssrcs,E=[],b.rids=jm(p).call(p,(function(e){var t=e.rid;return E.unshift(t),{id:t,direction:"send"}})),b.simulcast={dir1:"send",list1:E.join(";")}):(k=WL(d.id,m,{cname:HL}),T=k.ssrcs,I=k.ssrcGroups,b.ssrcs=T,b.ssrcGroups=I),null!==(i=this._context)&&void 0!==i&&null!==(o=i.serverConfig)&&void 0!==o&&o.audioRed&&Array.isArray(S.rtp)&&(-1!==(A=QR(R=S.rtp).call(R,(function(e){return"red"===e.codec})))&&(C=rk(w=S.rtp).call(w,A,1),x=eI(C,1),O=x[0],S.rtp.unshift(O)),D=[],S.rtp.forEach((function(e){return D.push(e.payload)})),S.payloads=D.join(" ")),null!==(a=this._context)&&void 0!==a&&null!==(s=a.serverConfig)&&void 0!==s&&s.videoCodec&&rU(b,null===(N=this._context)||void 0===N||null===(M=N.serverConfig)||void 0===M?void 0:M.videoCodec),!ON("IOS_SAFARI_ORIENTATION")&&(KD||rN)&&Array.isArray(b.ext)&&(b.ext=Gs(P=b.ext).call(P,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&mk(t).call(t,"video-orientation"))}))),(L=null==S?void 0:gE(c=S.rtp).call(c,(function(e){return"opus"===e.codec})))&&S.fmtp&&(F=gE(U=S.fmtp).call(U,(function(e){return e.payload===L.payload})))&&null!==(V=this._context)&&void 0!==V&&V.audioProfileManager&&(F.config=this._context.audioProfileManager.getOpusConfigStr(F.config)),l||KD||this.addBitrateLimit(b,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[S,b],e.abrupt("return",{partialSdp:YL(this.peer._offerSession,S,b),audioMid:y,videoMid:g,type:"incroffer",semantics:"unified-plan",videoDescriptions:p,subVideoDescriptions:v,audioTransceiverInit:f,videoTransceiverInit:_,peerConnectionMode:this.peerConnectionMode});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"subscribe",value:(a=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,D,N,M,P,L,U,V=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Zj.info("subscribe"),a="incroffer",s="unified-plan",this._aRecvonlyOfferTpl&&this._vRecvonlyOfferTpl){e.next=9;break}return e.next=6,this._genOfferSdp();case 6:return c=e.sent,e.next=9,this.createAVMlineOfferTpl(c);case 9:if(u="",d="",l=!1,h=!1,p=void 0,v=void 0,this._mlinesCache[t.streamId]=[p,v],t.virtual?(u="".concat(this._mid++),l=!0):r.multiChatMode?(u="".concat(this._mid++),d="".concat(this._mid++),h=!0):(l=!0,h=!0,u="".concat(this._mid++),d="".concat(this._mid++)),u&&(p=Zd(Zd({},Wj(this._aRecvonlyOfferTpl)),{},{mid:u})),l&&(this._mlinesCache[t.streamId][0]=p,f={track:"audio",init:{direction:"recvonly"}}),d&&(v=Zd(Zd({},Wj(this._vRecvonlyOfferTpl)),{},{mid:d})),h&&(this._mlinesCache[t.streamId][1]=v,_={track:"video",init:{direction:"recvonly"}}),m=YL(this.peer._offerSession,p,v),y=void 0,t.enableVendorMode||r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._vSendonlyAnswerTpl){e.next=32;break}return y=KL(this._nextSsrc),this._nextSsrc=y.next,R=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Om(g=Om(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-audio"," ")).call(g,t.streamId,"-audio"),ssrcs:XL(t.streamId,"audio",y.audio)}),A=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:d,msid:Om(E=Om(k="".concat(t.streamId)).call(k,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-video"," ")).call(E,t.streamId,"-video")},WL(t.streamId,y,{flexfec:this._enableSubFlexfec})),w=new Y_((function(e){V._sdpQueue.enqueue({action:lF.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:f,videoTransceiverInit:_,signalingAck:{sdp:SL.write(Zd(Zd({},V.peer._answerSession),{},{media:[R,A]})),sequenceId:t.sequenceId?++t.sequenceId:0},stream:t,sdp:m,onSuccess:function(){Zj.info("subscribe()","sub success"),e(0)}})})),e.next=31,w;case 31:null===(I=y)||void 0===I||delete I.next;case 32:return(C=null===(n=p)||void 0===n?void 0:gE(i=n.rtp).call(i,(function(e){return"opus"===e.codec})))&&null!==(o=p)&&void 0!==o&&o.fmtp&&(D=null===(x=p)||void 0===x?void 0:gE(O=x.fmtp).call(O,(function(e){return e.payload===C.payload})))&&this._context&&(D.config+=";stereo=1;sprop-stereo=1"),t.isPublic&&pN>=86&&null!=(L=null===(N=v)||void 0===N?void 0:Gs(M=N.rtp).call(M,(function(e){return"H264"===e.codec})))&&L.length&&null!==(P=v)&&void 0!==P&&P.fmtp&&(null===(U=v)||void 0===U||U.fmtp.forEach((function(e){gE(L).call(L,(function(t){return t.payload===e.payload}))&&(e.config+=";sps-pps-idr-in-keyframe=1")}))),e.abrupt("return",{partialSdp:m,audioMid:u,videoMid:d,type:a,semantics:s,audioTransceiverInit:f,videoTransceiverInit:_,allSsrc:y,peerConnectionMode:this.peerConnectionMode});case 36:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"handleAck",value:(o=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Zj.info("handleAck()","item: %o",t),!t.generatorSsrc){e.next=4;break}return Zj.warn("already set remote"),e.abrupt("return","");case 4:return e.abrupt("return",this._sdpQueue.enqueue(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"dequeue",value:(i=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._queueBusy=!0,t=this._sdpQueue.dequeue(),Zj.info("dequeue()","ret: %o",t),t){e.next=6;break}return this._queueBusy=!1,e.abrupt("return");case 6:if(e.prev=6,r=t.items,n=t.sdpStrategy,i=[],o=[],a=[],n!==dF.ADD){e.next=15;break}return e.delegateYield(Tm().mark((function e(){var t,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(t=Zd({},_.peer._answerIce)).candidates,s=!1,c=!1,e.prev=4,d=mM(r);case 6:return e.next=8,d.next();case 8:if(!(s=!(l=e.sent).done)){e.next=16;break}if(n=l.value,"break"!==function(){var e=n.audioMid,r=n.videoMid,s=n.action,c=n.audioTransceiverInit,u=n.videoTransceiverInit,d=n.signalingAck,l=n.stream,h=l instanceof cF;if(n.onSuccess&&a.push(n.onSuccess),h&&(null==d?void 0:d.sequenceId)<l.sequenceId)return"break";var p,v={},f={},m=SL.parse(d.sdp);Array.isArray(m.media)&&GR(p=m.media).call(p,(function(e,t){var r;return null==e||null===(r=e.type)||void 0===r?void 0:r.localeCompare(null==t?void 0:t.type)})).forEach((function(n){"audio"===(n=Zd(Zd({},n),t)).type?(v=n).mid=e:(f=n).mid=r}));var y,g=l.streamId;if(s===lF.publish&&(g=null===(y=l.stream)||void 0===y?void 0:y.id),!_._mlinesCache[g])return"break";var S=eI(_._mlinesCache[g],2),b=S[0],E=S[1];if(c&&b){l.audioTransceiver=_._peerConnection.addTransceiver(c.track,c.init),_._reportRtcInvokeStatus("chromeHandler.addTrack",Pm({audioStreamTrack:DD(c.track)}));var k=_._inactiveMlineIndex.shift();k||(k=_.peer._offerMlines.length),_.peer._offerMlines[k]=Zd({},b),_.peer._answerMlines[k]=v,$j&&l.initAudioEncodedTransform()}if(u&&E){var T,I;l.videoTransceiver=_._peerConnection.addTransceiver(u.track,u.init),_._reportRtcInvokeStatus("chromeHandler.addTrack",Pm({videoStreamTrack:DD(u.track)}));var R,A,w=_._inactiveMlineIndex.shift();w||(w=_.peer._offerMlines.length),_.peer._offerMlines[w]=Zd({},E),s===lF.publish&&null!==(T=_._context)&&void 0!==T&&null!==(I=T.serverConfig)&&void 0!==I&&I.videoCodec&&rU(f,null===(R=_._context)||void 0===R||null===(A=R.serverConfig)||void 0===A?void 0:A.videoCodec),_.peer._answerMlines[w]=f,$j&&l.initVideoEncodedTransform()}i.push(l.streamId||""),o.push(h?l.userId:"local"),h&&(l.sequenceId=null==d?void 0:d.sequenceId),delete _._mlinesCache[g]}()){e.next=13;break}return e.abrupt("break",16);case 13:s=!1,e.next=6;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(4),c=!0,u=e.t0;case 22:if(e.prev=22,e.prev=23,!s||null==d.return){e.next=27;break}return e.next=27,d.return();case 27:if(e.prev=27,!c){e.next=30;break}throw u;case 30:return e.finish(27);case 31:return e.finish(22);case 32:case"end":return e.stop()}}),e,null,[[4,18,22,32],[23,,27,31]])}))(),"t0",13);case 13:e.next=20;break;case 15:f={},r.forEach((function(e){var t=e.audioMid,r=e.videoMid,n=e.action;f[t]=t,n!==lF.removetrack&&(f[r]=r),f[t]=t})),this.peer._offerMlines=jm(h=this.peer._offerMlines).call(h,(function(e,t){return f[e.mid]&&(e=qL(e),_._inactiveMlineIndex.push(t)),e})),GR(p=this._inactiveMlineIndex).call(p,(function(e,t){return e-t})),this.peer._answerMlines=jm(v=this.peer._answerMlines).call(v,(function(e){return f[e.mid]&&(e=qL(e)),e}));case 20:return e.next=22,this.setDescription(i.length?{streamId:i.join(","),streamUserId:o.join(",")}:void 0);case 22:try{a.forEach((function(e){return e()}))}catch(XW){}Zj.info("dequeue","loop"),e.next=29;break;case 26:e.prev=26,e.t1=e.catch(6),Zj.error("dequeue","unknown error: %o",e.t1);case 29:return e.prev=29,this.dequeue(),e.finish(29);case 32:case"end":return e.stop()}}),e,this,[[6,26,29,32]])}))),function(){return i.apply(this,arguments)})},{key:"getDefaultSdp",value:(n=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._genOfferSdp();case 2:return r=e.sent,this.createAVMlineOfferTpl(r),n=SL.parse(r),i=[],n.media=Gs(t=n.media).call(t,(function(e){var t;return"recvonly"===e.direction&&(Array.isArray(e.ext)&&(e.ext=Gs(t=e.ext).call(t,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))),i.push("".concat(e.mid)),!0)})),n.groups=[{mids:i.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:SL.write(n),semantics:"unified-plan",type:"incroffer"});case 9:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"rollback",value:(r=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete this._mlinesCache[t];case 1:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;SL.parse(e).media.forEach((function(e){if("audio"===e.type)if("sendonly"===e.direction)t._aSendonlyOfferTpl=e;else{var r;if(Array.isArray(e.ext))e.ext=Gs(r=e.ext).call(r,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._aRecvonlyOfferTpl=e}else if("video"===e.type)if("sendonly"===e.direction)t._vSendonlyOfferTpl=e;else{var n;if(Array.isArray(e.ext))e.ext=Gs(n=e.ext).call(n,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._vRecvonlyOfferTpl=e}}))}},{key:"_genOfferSdp",value:(t=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,ID(!0);case 3:if(t=e.sent){e.next=6;break}throw"pc.createOffer() return empty.";case 6:e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),r="Get offer Error. ".concat(e.t0.message|e.t0),new mA(pA.NOT_SUPPORTED,r);case 12:return e.abrupt("return",t);case 13:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(){return t.apply(this,arguments)})}]),u}(iU),tG=new Pw("FirefoxHandler",3),rG=function(e){NI(d,e);var t,r,n,i,o,a,s,c,u=QI(d);function d(){var e,t;Vl(this,d);for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return Jd(tI(t=u.call.apply(u,Om(e=[this]).call(e,n))),"name","firefox"),Jd(tI(t),"_aRecvonlyOfferTpl",void 0),t}return Ul(d,[{key:"publish",value:(c=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,p,v,f,_,m=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=OI(CI(d.prototype),"internalPublish",this).call(this,t),o=i.videoDescriptions,a=i.subVideoDescriptions,s=i.audioTransceiverInit,c=i.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(s.track,s.init),t.videoTransceiver=this._peerConnection.addTransceiver(c.track,c.init),u=lD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=7,this._peerConnection.createOffer();case 7:return l=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:lD()-u}),(h=SL.parse(l.sdp)).media=null===(r=h.media)||void 0===r?void 0:jm(r).call(r,(function(e){return Zd(Zd({},e),m.peer._offerIce)})),e.next=13,this.setLocalDescription(SL.write(h));case 13:return p=t.audioTransceiver.mid,v=t.videoTransceiver.mid,f=null,_=null,h.media=null===(n=h.media)||void 0===n?void 0:jm(n).call(n,(function(e){if("".concat(e.mid)===p){var t,r,n=null===(t=f=e)||void 0===t?void 0:gE(r=t.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&f.fmtp){var i,o,a=gE(i=f.fmtp).call(i,(function(e){return e.payload===n.payload}));a&&null!==(o=m._context)&&void 0!==o&&o.audioProfileManager&&(a.config=m._context.audioProfileManager.getOpusConfigStr(a.config))}}else if("".concat(e.mid)===v){var s,c,u,d;null!==(s=m._context)&&void 0!==s&&null!==(c=s.serverConfig)&&void 0!==c&&c.videoCodec&&rU(e,null===(u=m._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.videoCodec),_=e}return e})),this.addBitrateLimit(_,t.videoEncodeConfig[0].maxKbps),e.next=21,this.setLocalDescription(SL.write(h));case 21:return e.abrupt("return",{partialSdp:YL(h,f,_,!1),audioMid:p,videoMid:v,type:"incroffer",semantics:"unified-plan",videoDescriptions:o,subVideoDescriptions:a,audioTransceiverInit:s,videoTransceiverInit:c,peerConnectionMode:this.peerConnectionMode});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return tG.info("subscribe()"),c="",u="",d=!1,l=!1,h=void 0,p=void 0,t.virtual?d=!0:(r.multiChatMode||(d=!0),l=!0),d&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),l&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),v=lD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=14,this._peerConnection.createOffer();case 14:return f=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:lD()-v}),(_=SL.parse(f.sdp)).media=null===(n=_.media)||void 0===n?void 0:jm(n).call(n,(function(e){return Zd(Zd({},e),A.peer._offerIce)})),jm(i=_.media).call(i,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Gs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Gs(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=21,this.setLocalDescription(SL.write(_),{streamId:t.streamId||"",streamUserId:t.userId});case 21:if(c=null===(o=t.audioTransceiver)||void 0===o?void 0:o.mid,u=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid,null===(s=_.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===c?h=e:"".concat(e.mid)===u&&(p=e)})),c&&h||(c="audio_".concat(u),h=Zd(Zd({},this._aRecvonlyOfferTpl),{},{mid:c})),t.audioMid=c,t.videoMid=u,m=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=36;break}return m=KL(this._nextSsrc),this._nextSsrc=m.next,I=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:c,msid:Om(y=Om(g="".concat(t.streamId)).call(g,null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:XL(t.streamId,"audio",m.audio)}),R=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Om(b=Om(E="".concat(t.streamId)).call(E,null!==(k=this._context)&&void 0!==k&&k.avSync?"":"-video"," ")).call(b,t.streamId,"-video")},WL(t.streamId,m,{flexfec:this._enableSubFlexfec})),e.next=35,this._internalSetRemoteDescription([I,R],t);case 35:null===(T=m)||void 0===T||delete T.next;case 36:return e.abrupt("return",{partialSdp:YL(_,h,p,!1),audioMid:c,videoMid:u,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:m,peerConnectionMode:this.peerConnectionMode});case 37:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==lF.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==lF.unpublish&&i!==lF.unsubscribe){e.next=7;break}return e.next=6,this.close(n);case 6:return e.abrupt("return",n.streamId||"");case 7:if(!t.generatorSsrc){e.next=10;break}return tG.warn("already set remote"),e.abrupt("return","");case 10:return o=SL.parse(null==r?void 0:r.sdp),e.next=13,this._internalSetRemoteDescription(o.media,n);case 13:return e.abrupt("return","");case 14:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=SL.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){if("audio"===(e=Zd(Zd({},e),l.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type){if(r instanceof sF&&uN<=87){var t,n,i,o,a={};Array.isArray(e.rtp)&&(e.rtp=Gs(t=e.rtp).call(t,(function(e){return"rtx"!==e.codec||(a[e.payload]=e.payload,!1)}))),"string"==typeof e.payloads&&(e.payloads=Gs(n=e.payloads.split(" ")).call(n,(function(e){return!a[e]})).join(" ")),Array.isArray(e.fmtp)&&(e.fmtp=Gs(i=e.fmtp).call(i,(function(e){return!a[e.payload]}))),Array.isArray(e.rtcpFb)&&(e.fmtp=Gs(o=e.fmtp).call(o,(function(e){return!a[e.payload]})))}r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e}})),u=SL.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=jm(o=u.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=d,jm(a=c.media).call(a,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Gs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Gs(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=11,this.setRemoteDescription(SL.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Rm(Tm().mark((function e(){var t,r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=SL.parse(null===(t=this._peerConnection.localDescription)||void 0===t?void 0:t.sdp),this.createAVMlineOfferTpl(null===(r=this._peerConnection.localDescription)||void 0===r?void 0:r.sdp),o=[],i.media=Gs(n=i.media).call(n,(function(e){return"recvonly"===e.direction&&(e.mid=e.mid+1,o.push("".concat(e.mid)),!0)})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:SL.write(i),semantics:"unified-plan",type:"incroffer"});case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=Rm(Tm().mark((function e(t,r,n){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return tG.warn("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return tG.info("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(u=SL.parse(null==c?void 0:c.sdp)).media=jm(n=u.media).call(n,(function(e){return a[e.mid]&&(e=qL(e)),"inactive"!==e.direction&&s.push(e.mid),Zd(Zd({},e),h.peer._offerIce)})),d=SL.parse(null===(i=this._peerConnection.remoteDescription)||void 0===i?void 0:i.sdp),l={},d.media.forEach((function(e){void 0!==e.mid&&(l[e.mid]=e)})),d.media=jm(o=u.media).call(o,(function(e){return"inactive"===e.direction?e:l[e.mid]})),u.groups&&d.groups&&(u.groups[0].mids=s.join(" "),d.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(SL.write(u));case 17:return e.next=19,this.setRemoteDescription(SL.write(d));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer();case 2:if(!this._peerConnection.localDescription||!this._peerConnection.remoteDescription){e.next=7;break}return e.next=5,this._peerConnection.setLocalDescription(this._peerConnection.localDescription);case 5:return e.next=7,this._peerConnection.setRemoteDescription(this._peerConnection.remoteDescription);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;SL.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(iU),nG=new Pw("FallbackHandler",3),iG=function(e){NI(d,e);var t,r,n,i,o,a,s,c,u=QI(d);function d(e,t){var r;return Vl(this,d),Jd(tI(r=u.call(this,e,t)),"name","fallback"),Jd(tI(r),"_aRecvonlyOfferTpl",void 0),nG.warn("ctor","using fallback handler"),r._report("rtc_error",{message:"using fallback handler",error_code:-1}),r}return Ul(d,[{key:"publish",value:(c=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,p,v,f;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=OI(CI(d.prototype),"internalPublish",this).call(this,t),i=n.videoDescriptions,o=n.subVideoDescriptions,a=n.audioTransceiverInit,s=n.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(a.track,a.init),t.videoTransceiver=this._peerConnection.addTransceiver(s.track,s.init),c=lD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=7,this._peerConnection.createOffer();case 7:return u=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:lD()-c}),l=SL.parse(u.sdp),e.next=12,this.setLocalDescription(u.sdp);case 12:return h=t.audioTransceiver.mid,p=t.videoTransceiver.mid,v=null,f=null,l.media=null===(r=l.media)||void 0===r?void 0:jm(r).call(r,(function(e){return"".concat(e.mid)===h?v=e:"".concat(e.mid)===p&&(f=e),e})),lL()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:YL(l,v,f,!1),audioMid:h,videoMid:p,type:"incroffer",semantics:"unified-plan",videoDescriptions:i,subVideoDescriptions:o,audioTransceiverInit:a,videoTransceiverInit:s,peerConnectionMode:this.peerConnectionMode});case 19:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return nG.info("subscribe()"),a="",s="",c=!1,u=!1,d=void 0,l=void 0,t.virtual?c=!0:(r.multiChatMode||(c=!0),u=!0),c&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),u&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),h=lD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=14,this._peerConnection.createOffer();case 14:return p=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:lD()-h}),v=SL.parse(p.sdp),e.next=19,this.setLocalDescription(p.sdp,{streamId:t.streamId||"",streamUserId:t.userId});case 19:if(a=null===(n=t.audioTransceiver)||void 0===n?void 0:n.mid,s=null===(i=t.videoTransceiver)||void 0===i?void 0:i.mid,null===(o=v.media)||void 0===o||o.forEach((function(e){"".concat(e.mid)===a?d=e:"".concat(e.mid)===s&&(l=e)})),a&&d||(a="audio_".concat(s),d=Zd(Zd({},this._aRecvonlyOfferTpl),{},{mid:a})),t.audioMid=a,t.videoMid=s,f=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=34;break}return f=KL(this._nextSsrc),this._nextSsrc=f.next,k=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:a,msid:Om(_=Om(m="".concat(t.streamId)).call(m,null!==(y=this._context)&&void 0!==y&&y.avSync?"":"-audio"," ")).call(_,t.streamId,"-audio"),ssrcs:XL(t.streamId,"audio",f.audio)}),T=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:s,msid:Om(g=Om(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-video"," ")).call(g,t.streamId,"-video")},WL(t.streamId,f,{flexfec:this._enableSubFlexfec})),e.next=33,this._internalSetRemoteDescription([k,T],t);case 33:null===(E=f)||void 0===E||delete E.next;case 34:return lL()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:YL(v,d,l,!1),audioMid:a,videoMid:s,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:f,peerConnectionMode:this.peerConnectionMode});case 36:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==lF.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==lF.unpublish&&i!==lF.unsubscribe){e.next=7;break}return e.next=6,this.close(n);case 6:return e.abrupt("return",n.streamId||"");case 7:if(!t.generatorSsrc){e.next=10;break}return nG.warn("already set remote"),e.abrupt("return","");case 10:return o=SL.parse(null==r?void 0:r.sdp),e.next=13,this._internalSetRemoteDescription(o.media,n);case 13:return e.abrupt("return","");case 14:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=SL.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){"audio"===(e=Zd(Zd({},e),l.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type&&(r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e)})),u=SL.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=jm(o=u.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=d,jm(a=c.media).call(a,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Gs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Gs(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=11,this.setRemoteDescription(SL.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Rm(Tm().mark((function e(){var t,r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=SL.parse(null===(t=this._peerConnection.localDescription)||void 0===t?void 0:t.sdp),this.createAVMlineOfferTpl(null===(r=this._peerConnection.localDescription)||void 0===r?void 0:r.sdp),o=[],i.media=Gs(n=i.media).call(n,(function(e){return"recvonly"===e.direction&&(e.mid=e.mid+1,o.push("".concat(e.mid)),!0)})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:SL.write(i),semantics:"unified-plan",type:"incroffer"});case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=Rm(Tm().mark((function e(t,r,n){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return nG.warn("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return nG.info("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(u=SL.parse(null==c?void 0:c.sdp)).media=jm(n=u.media).call(n,(function(e){return a[e.mid]&&(e=qL(e)),"inactive"!==e.direction&&s.push(e.mid),Zd(Zd({},e),h.peer._offerIce)})),d=SL.parse(null===(i=this._peerConnection.remoteDescription)||void 0===i?void 0:i.sdp),l={},d.media.forEach((function(e){void 0!==e.mid&&(l[e.mid]=e)})),d.media=jm(o=u.media).call(o,(function(e){return"inactive"===e.direction?e:l[e.mid]})),u.groups&&d.groups&&(u.groups[0].mids=s.join(" "),d.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(null==c?void 0:c.sdp);case 17:return e.next=19,this.setRemoteDescription(SL.write(d));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer();case 2:if(!this._peerConnection.localDescription||!this._peerConnection.remoteDescription){e.next=7;break}return e.next=5,this._peerConnection.setLocalDescription(this._peerConnection.localDescription);case 5:return e.next=7,this._peerConnection.setRemoteDescription(this._peerConnection.remoteDescription);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;SL.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(iU),oG=function(e,t){return e.enableFallbackHandler?new iG(e,t):zD?new rG(e,t):new eG(e,t)},aG=function(e){return e.streamRemovedBySchedule308="stream removed",e.clientRePublish="client republish",e.publishStreamFaied="publish failed",e.clientUnPublish="client unpublished",e.clientDisconnected="client disconnected",e.videoMuted="video muted",e}(aG||{}),sG=function(e){return e.PushLimitWarn="PushLimitWarn",e}(sG||{}),cG=function(e){return e.ON_ADD_STREAM="onAddStream",e.ON_ADD_STREAM_LIST="onAddStreamList",e.ON_REMOVE_STREAM="onRemoveStream",e.ON_REMOVE_STREAM_LIST="onRemoveStreamList",e.USER_DISCONNECTION="userDisconnection",e.USER_DISCONNECTION_LIST="userDisconnectionList",e.USER_CONNECTION="userConnection",e.USER_CONNECTION_LIST="userConnectionList",e.ON_UPDATE_STREAM_ATTRIBUTES="onUpdateStreamAttributes",e.ON_UPDATE_ROOM_ATTRIBUTES="onUpdateRoomAttributes",e.ON_UPDATE_USER_ATTRIBUTES="onUpdateUserAttributes",e.ON_PUSH_TRACK="onPushTrack",e.ON_REMOVE_TRACK="onRemoveTrack",e.ON_CUSTOM_MESSAGE="onCustomMessage",e.NODE_CHANGE="nodeChange",e.USER_MESSAGE_RECEIVED="userMessageReceived",e.USER_BINARY_MESSAGE_RECEIVED="userBinaryMessageReceived",e.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM="userMessageReceivedOutsideRoom",e.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM="userBinaryMessageReceivedOutsideRoom",e.POST_PROCESSING_MESSAGE="postProcessingMessage",e.ON_USER_TOKEN_WILL_EXPIRE="onUserTokenWillExpire",e.STREAM_CONTROL_MESSAGE="streamControlMessage",e.ON_SPEAKER_CHANGE="onSpeakerChange",e.ON_STREAM_FAILED="streamFailed",e.ON_NOTIFY_RECONNECT="notifyReconnect",e.ON_FORWARD_DST_ROOM_USER_KICK="onForwardDstRoomUserKick",e}(cG||{}),uG=function(e){return e.RSCP="RSCP",e.RTT="RTT",e.SSC="SSC",e}(uG||{}),dG=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ON_VENDOR_CONNECTION_STATE_CHANGE="onVendorConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e}(dG||{}),lG=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(lG||{}),hG=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(hG||{}),pG=new Pw("Locker",2),vG=1,fG=function(){function e(t){var r;Vl(this,e),Jd(this,"lockingPromise",Y_.resolve()),Jd(this,"locks",0),Jd(this,"name",""),Jd(this,"lockId",void 0),this.lockId=vG++,t&&(this.name=t),pG.info(Om(r="[lock-".concat(this.name,"-")).call(r,this.lockId,"] is created."))}return Ul(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t,r,n=this;this.locks+=1,pG.info(Om(e=Om(t="[lock-".concat(this.name,"-")).call(t,this.lockId,"] locked, current queue ")).call(e,this.locks,"."));var i=new Y_((function(e){r=function(){var t,r;n.locks-=1,pG.info(Om(t=Om(r="[lock-".concat(n.name,"-")).call(r,n.lockId,"] unlocked, current queue ")).call(t,n.locks,".")),e()}})),o=this.lockingPromise.then((function(){return r}));return this.lockingPromise=this.lockingPromise.then((function(){return i})),o}}]),e}(),_G=function(e){return e.RESUBSCRIBE="resubscribe",e.STREAM_FAILED="stream_failed",e.SUBSCRIBE_PUSH_TRACK="subscribe_push_track",e.REMOVE_PUSH_TRACK="remove_push_track",e.VIDEO_FIRST_FRAME="video_first_frame",e.ON_USER_PUBLISH_STATE_CHANGE="on_user_publish_state_change",e.ON_USER_START_AUDIO_CAPTURE="on_user_start_audio_capture",e.ON_USER_STOP_AUDIO_CAPTURE="on_user_stop_audio_capture",e.ON_USER_START_VIDEO_CAPTURE="on_user_start_video_capture",e.ON_USER_STOP_VIDEO_CAPTURE="on_user_stop_video_capture",e.ON_SEI_MESSAGED_RECEIVED="on_sei_messaged_received",e.ON_PUBLISH_RESULT="on_publish_result",e.ON_UPDATE_TOKEN_SUCCESS="on_update_token_success",e.ON_REMOTE_STREAM_STATS="ON_REMOTE_STREAM_STATS",e.ON_LOCAL_STREAM_STATS="ON_LOCAL_STREAM_STATS",e.ON_USER_LEAVE="on_user_leave",e.ON_ROOM_ERROR="on_room_error",e.ON_NETWORK_QUALITY="on_network_quality",e.ON_SIMULCAST_SUBSCRIBE_FALLBACK="on_simulcast_subscribe_fallback",e.ON_REMOTE_VIDEO_SIZE_CHANGED="on_remote_video_size_changed",e.RECONNECT_FAILED="reconnect_failed",e.ON_SUBTITLE_STATE_CHANGED="ON_SUBTITLE_STATE_CHANGED",e.ON_SUBTITLE_MESSAGE_RECEIVED="ON_SUBTITLE_MESSAGE_RECEIVED",e.ON_VIDEO_STREAM_BANNED="ON_VIDEO_STREAM_BANNED",e.ON_AUDIO_STREAM_BANNED="ON_AUDIO_STREAM_BANNED",e.ON_FORWARD_STREAM_ERROR="ON_FORWARD_STREAM_ERROR",e.ON_REJOIN_WITH_TCP="ON_REJOIN_WITH_TCP",e.ON_ICE_CONNECT_WITH_TCP="ON_ICE_CONNECT_WITH_TCP",e}(_G||{}),mG=function(e){return e[e.START=1]="START",e[e.START_SUCCESS=2]="START_SUCCESS",e[e.START_FAILED=3]="START_FAILED",e[e.UPDATE=4]="UPDATE",e[e.UPDATE_SUCCESS=5]="UPDATE_SUCCESS",e[e.UPDATE_FAILED=6]="UPDATE_FAILED",e[e.STOP=7]="STOP",e[e.STOP_SUCCESS=8]="STOP_SUCCESS",e[e.STOP_FAILED=9]="STOP_FAILED",e}(mG||{}),yG=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(yG||{}),gG=function(e){return e[e.SUB=0]="SUB",e[e.UNSUB=1]="UNSUB",e}(gG||{}),SG=(Jd(Jj={},bl.communication,[0]),Jd(Jj,bl.chat,[0]),Jd(Jj,bl.chatRoom,[1,"IES_chatroom"]),Jd(Jj,bl.coHost,[1,"IES_PK"]),Jd(Jj,bl.meeting,[16]),Jd(Jj,bl.classRoom,[0]),Jj),bG=lL(),EG=function(e){NI(s,e);var t,r,n,i,o,a=QI(s);function s(e,t){var r;return Vl(this,s),Jd(tI(r=a.call(this,e,t)),"peerConnectionId",dD()),Jd(tI(r),"peerConnectionMode",1),Jd(tI(r),"name","vendor"),Jd(tI(r),"direction","up"),Jd(tI(r),"stream",void 0),t.on("ice_state",(function(e){r._report("rtc_ice_state",{pc_session_id:r.peerConnectionId,direction:r.direction,error_code:0,ice_state:e.toUpperCase(),message:"",peer_connection_id:r.peerConnectionId,stream_id:"",stream_user_id:""})})),r}return Ul(s,[{key:"publish",value:(o=Rm(Tm().mark((function e(t){var r,n,i,o,a,c,u,d,l,h,p=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.enableSimulcast=!1,this.stream=t,r=OI(CI(s.prototype),"internalPublish",this).call(this,t),n=r.videoDescriptions,i=r.subVideoDescriptions,o=r.audioTransceiverInit,a=r.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(o.track,o.init),t.videoTransceiver=this._peerConnection.addTransceiver(a.track,a.init),bG&&(t.initAudioEncodedTransform(),t.initVideoEncodedTransform()),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:(null==t?void 0:t.vendorCode)||0}),e.next=9,this._peerConnection.createOffer();case 9:return c=e.sent,u=lD(),d=SL.parse(c.sdp),Array.isArray(d.media)&&(d.media=jm(l=d.media).call(l,(function(e){var r,n,i,o,a;if("video"===e.type)null!==(r=p._context)&&void 0!==r&&null!==(n=r.serverConfig)&&void 0!==n&&n.videoCodec&&rU(e,null===(i=p._context)||void 0===i||null===(o=i.serverConfig)||void 0===o?void 0:o.videoCodec),(KD||rN)&&Array.isArray(e.ext)&&(e.ext=Gs(a=e.ext).call(a,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&mk(t).call(t,"video-orientation"))}))),KD||p.addBitrateLimit(e,t.videoEncodeConfig[0].maxKbps);else if("audio"===e.type){var s,c=null==e?void 0:gE(s=e.rtp).call(s,(function(e){return"opus"===e.codec}));if(c&&e.fmtp){var u,d,l=gE(u=e.fmtp).call(u,(function(e){return e.payload===c.payload}));l&&null!==(d=p._context)&&void 0!==d&&d.audioProfileManager&&(l.config=p._context.audioProfileManager.getOpusConfigStr(l.config))}}return e}))),h=new RTCSessionDescription({type:"offer",sdp:SL.write(d)}),e.prev=14,e.next=17,this._peerConnection.setLocalDescription(h);case 17:this._report("rtc_set_description",{error_code:0,message:h.sdp||"",is_local:"1",direction:"up",stream_id:"",stream_user_id:"",elapse:lD()-u},{type:"offer"}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(14),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+h.sdp,is_local:"1",direction:"up",stream_id:"",stream_user_id:"",elapse:lD()-u},{type:"offer"}),e.t0;case 24:return e.abrupt("return",{partialSdp:h.sdp||"",audioMid:"0",videoMid:"1",type:"offer",semantics:"unified-plan",videoDescriptions:n,subVideoDescriptions:i,audioTransceiverInit:o,videoTransceiverInit:a,peerConnectionMode:this.peerConnectionMode,peerConnectionId:this.peerConnectionId});case 25:case"end":return e.stop()}}),e,this,[[14,20]])}))),function(e){return o.apply(this,arguments)})},{key:"subscribe",value:(i=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.stream=t,this.direction="down",t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"}),bG&&(t.initAudioEncodedTransform(),t.initVideoEncodedTransform()),this._report("rtc_begin_create_offer",{direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:t.vendorCode||0}),e.next=8,this._peerConnection.createOffer();case 8:return r=e.sent,n=lD(),i=SL.parse(r.sdp),Array.isArray(i.media)&&(i.media=jm(o=i.media).call(o,(function(e){if("audio"===e.type){var t,r=null==e?void 0:gE(t=e.rtp).call(t,(function(e){return"opus"===e.codec}));if(r&&null!=e&&e.fmtp){var n,i=null==e?void 0:gE(n=e.fmtp).call(n,(function(e){return e.payload===r.payload}));i&&s._context&&(i.config+=";stereo=1;sprop-stereo=1")}}return e}))),a=new RTCSessionDescription({type:"offer",sdp:SL.write(i)}),e.prev=13,e.next=16,this._peerConnection.setLocalDescription(a);case 16:this._report("rtc_set_description",{error_code:0,message:a.sdp||"",is_local:"1",direction:"down",stream_id:t.streamId,stream_user_id:t.userId,elapse:lD()-n},{type:"offer"}),e.next=23;break;case 19:throw e.prev=19,e.t0=e.catch(13),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+a.sdp,is_local:"1",direction:"down",stream_id:t.streamId,stream_user_id:t.userId,elapse:lD()-n},{type:"offer"}),e.t0;case 23:return e.abrupt("return",{partialSdp:a.sdp||"",audioMid:"0",videoMid:"1",type:"offer",semantics:"unified-plan",peerConnectionMode:this.peerConnectionMode,peerConnectionId:this.peerConnectionId});case 24:case"end":return e.stop()}}),e,this,[[13,19]])}))),function(e){return i.apply(this,arguments)})},{key:"handleAck",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.action!==lF.publish&&t.action!==lF.subscribe){e.next=16;break}return n=new RTCSessionDescription({sdp:null===(r=t.signalingAck)||void 0===r?void 0:r.sdp,type:"answer"}),i=lD(),e.prev=3,e.next=6,this._peerConnection.setRemoteDescription(n);case 6:this._report("rtc_set_description",{error_code:0,message:n.sdp||"",is_local:"1",direction:"down",stream_id:null===(o=t.stream)||void 0===o?void 0:o.userId,stream_user_id:(null===(a=t.stream)||void 0===a?void 0:a.streamId)||"",elapse:lD()-i},{type:"answer"}),e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(3),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+n.sdp,is_local:"1",direction:"down",stream_id:null===(s=t.stream)||void 0===s?void 0:s.userId,stream_user_id:(null===(c=t.stream)||void 0===c?void 0:c.streamId)||"",elapse:lD()-i},{type:"offer"}),e.t0;case 13:"function"==typeof t.onSuccess&&t.onSuccess(),e.next=17;break;case 16:t.action!==lF.unpublish&&t.action!==lF.unsubscribe||this.destroy();case 17:return e.abrupt("return","");case 18:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(e){return n.apply(this,arguments)})},{key:"destroy",value:function(){this.peer.destroy(),OI(CI(s.prototype),"destroy",this).call(this)}},{key:"getDefaultSdp",value:(r=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{sdp:"",type:"offer",semantics:""});case 1:case"end":return e.stop()}}),e)}))),function(){return r.apply(this,arguments)})},{key:"connect",value:function(){throw new Error("Method not implemented.")}},{key:"rollback",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{this._peerConnection.close()}catch(t){}case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),s}(iU),kG=function(e){return e[e.AUTOPLAY_FAILED=-1e3]="AUTOPLAY_FAILED",e[e.TRACK_ERROR=-1001]="TRACK_ERROR",e[e.Fetch_MODIFY=-1002]="Fetch_MODIFY",e[e.BLACK_BROWSER=-1003]="BLACK_BROWSER",e[e.DC_SEND_ERROR=-1004]="DC_SEND_ERROR",e}(kG||{}),TG={start_interval:100,multiplier:2,max_interval:3e4},IG=function(){function e(){Vl(this,e),Jd(this,"_times",0),Jd(this,"_config",TG),Jd(this,"initTs",lD())}return Ul(e,[{key:"getRetryDelay",value:function(){return Math.min(this._config.max_interval,Math.pow(this._config.multiplier,this._times++)*this._config.start_interval)}},{key:"setConfig",value:function(e){this._config=e}},{key:"reset",value:function(){this._times=0}}]),e}(),RG=new Pw("ICERequest",4),AG=function(){function e(t){Vl(this,e),Jd(this,"_reconnectTimer",void 0),Jd(this,"_abortControllers",[]),Jd(this,"_monitor",void 0),Jd(this,"_groupConfigId",dD()),Jd(this,"_retryLimiter",new IG),Jd(this,"_timer",void 0),this._ctx=t,this._monitor=VO(t.id)}var t,r,n,i;return Ul(e,[{key:"getICENode",value:(i=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return RG.info("getICENode","invoke"),e.prev=1,e.next=4,this._getAccessWithRetry(t);case 4:if(0!==(r=e.sent).length){e.next=7;break}throw"server return empty nodes.";case 7:e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(1),this._reportRtcInvokeStatus("es.join.getNodeFailed",e.t0),new mA(pA.ICE_SERVER_WRONG,"get ICE config failed: ".concat(e.t0),e.t0);case 13:return RG.success("getICENode","success"),this._reportRtcInvokeStatus("es.join.getNodeSuccess",r),e.abrupt("return",r);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return i.apply(this,arguments)})},{key:"_getAccessWithRetry",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return 0!==r&&RG.info("_getAccessWithRetry()","invoke feedbackInfo: %o, 201count: %o",e,r),new Y_((function(n,i){t._getAccessNode(e).then((function(e){t._retryLimiter.reset(),n(e)})).catch((function(o){if(Array.isArray(o)&&o.length>0){if(QR(o).call(o,(function(e){return 400<=e.code&&e.code<500}))>-1)return t._retryLimiter.reset(),i("HTTP request failed(4xx)");if(o.every((function(e){var t;return 201===e.code||201===(null===(t=e.error)||void 0===t?void 0:t.code)}))&&r++,3===r)return t._retryLimiter.reset(),i("HTTP request failed(201)")}var a=t._retryLimiter.getRetryDelay();RG.warn("_getAccessWithRetry()","_getAccessWithRetry error, will retry after ".concat(a,"ms"),o),t._reconnectTimer=self.setTimeout((function(){t._getAccessWithRetry(e,r).then(n).catch(i)}),a)}))}))}},{key:"_getAccessNode",value:(n=Rm(Tm().mark((function e(t){var r=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Y_((function(e,n){var i=EN.getAccessNode(r._ctx.appId);i?(RG.info("getAccessNode","use cache node."),e(Array.isArray(i)?i:[i]),r._timer=window.setTimeout((function(){r._getAccessNodeFromServer(t),r._reportRtcInvokeStatus("es.R.node.cache",i),delete r._timer}),0)):r._getAccessNodeFromServer(t).then(e).catch(n)})));case 1:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"_getAccessNodeFromServer",value:(r=Rm(Tm().mark((function e(t){var r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this._getAccessUrls(),n=r.urls,i=r.needFallback,e.abrupt("return",this.getICEConfigFromServer(n,t).then((function(e){var t=e.nodes;return!o._ctx.useCloudProxy&&EN.setAccessNode(o._ctx.appId,t,e.ttl||11200),e.dispatchDomains&&!o._ctx.useCloudProxy&&EN.setAccessUrls(e.dispatchDomains),t})).catch((function(e){if(i)return o._reportRtcInvokeStatus("es.R.req.fallback",""),EN.clearAccessUrls(),o._getAccessNodeFromServer(t);throw e})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_getAccessUrls",value:function(){var e=EN.getAccessUrls()||[],t=!0;return this._reportRtcInvokeStatus("es.R.req.cache.urls",e),0===e.length&&(e=CN.ICE_CONFIG_REQUEST_URLS,t=!1,this._reportRtcInvokeStatus("es.R.req.external.urls",e)),0===e.length&&(e=CN.ICE_CONFIG_REQUEST_URLS_INTERNAL,t=!1,this._reportRtcInvokeStatus("es.R.req.internal.urls",e)),{urls:e,needFallback:t}}},{key:"getICEConfigFromServer",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=dD(),o={appID:this._ctx.appId,deviceID:EN.getDeviceId(),connectSessionID:i,os:"web",sdkVersion:CN.VERSION,isOversea:CN.OVERSEA,expectedAddr:ON("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC,accessParams:Pm({requireICEUfragV2:!0})},r&&(o.feedbackInfo=r,delete o.expectedAddr),a=Date.now(),null===(n=this._monitor)||void 0===n||n.report("rtc_get_access",{error_code:0,message:Pm(o),elapse:0,type:"request",host:t.join(","),config_id:i,group_config_id:this._groupConfigId}),s=jm(t).call(t,function(){var e=Rm(Tm().mark((function e(t,r){var n,i,a,s,u;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new AbortController,c._abortControllers.push(i),e.prev=2,e.next=5,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:Pm(o),signal:i.signal});case 5:a=e.sent,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(2),yw(fetch)||null===(s=c._monitor)||void 0===s||s.report("rtc_error",{error_code:kG.Fetch_MODIFY,message:"get access failed, possibly due to modifying the browser's Fetch API."},{origin_error:e.t0}),e.t0;case 12:if(c._abortControllers=Gs(n=c._abortControllers).call(n,(function(e){return e!==i})),200===a.status){e.next=15;break}throw{message:a.statusText,code:a.status};case 15:return e.next=17,a.json();case 17:if(200===(u=e.sent).code){e.next=20;break}throw u;case 20:if(0!==u.nodes.length){e.next=22;break}throw{code:u.code,message:Pm(u)};case 22:return e.abrupt("return",{url:t,result:u});case 23:case"end":return e.stop()}}),e,null,[[2,8]])})));return function(t,r){return e.apply(this,arguments)}}()),e.abrupt("return",RD(s).then((function(e){var t,r=e.result,n=e.url;return null===(t=c._monitor)||void 0===t||t.report("rtc_get_access",{error_code:200,message:Pm(r),elapse:Date.now()-a,type:"response",host:n,config_id:i,group_config_id:c._groupConfigId}),r})).catch((function(e){var r,n,o,s;throw null===(r=c._monitor)||void 0===r||r.report("rtc_get_access",{error_code:Number((null===(n=e[0])||void 0===n?void 0:n.code)||(null===(o=e[0])||void 0===o?void 0:o.server_code)),message:null===(s=e[0])||void 0===s?void 0:s.message,elapse:Date.now()-a,type:"response",host:t.join(","),config_id:i,group_config_id:c._groupConfigId},{error:Pm(e)}),e})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._abortControllers.forEach((function(e){return e.abort()})),this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer),this._timer&&(window.clearTimeout(this._timer),delete this._timer)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0;null===(r=this._monitor)||void 0===r||r.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:n,stream_id:"",elapse:0,group_config_id:this._groupConfigId},i)}}]),e}(),wG={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",encodedInsertableStreams:!!lL()||void 0},CG=function(e){return e[e.DC_ERROR=0]="DC_ERROR",e[e.DC_CLOSE=1]="DC_CLOSE",e[e.ICE_FAILED=2]="ICE_FAILED",e[e.DESTROY=3]="DESTROY",e[e.TIMEOUT=4]="TIMEOUT",e}(CG||{}),xG=0,OG=function(e){NI(s,e);var t,r,n,i,o,a=QI(s);function s(e,t){var r;return Vl(this,s),Jd(tI(r=a.call(this)),"uuid",(xG++).toString()),Jd(tI(r),"_peerConnectionId",""),Jd(tI(r),"audioTrack4ff",void 0),Jd(tI(r),"_pc",void 0),Jd(tI(r),"_dc",void 0),Jd(tI(r),"_iceNode",void 0),Jd(tI(r),"_initSctpEvents",!1),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_offerIce",{}),Jd(tI(r),"_answerIce",{}),Jd(tI(r),"_offerSession",void 0),Jd(tI(r),"_answerSession",void 0),Jd(tI(r),"_offerMlines",[]),Jd(tI(r),"_answerMlines",[]),Jd(tI(r),"_connectReject",void 0),Jd(tI(r),"_logger",new Pw("PeerConnection_".concat(r.uuid),4)),r._ctx=e,r._groupConnectionId=t,r._monitor=VO(e.id),r._ctx.enableFallbackHandler&&r._logger.warn("ctor","PeerConnection running in fallback mode"),r._pc=new RTCPeerConnection(wG),r._pc.ontrack=function(e){var t,n,i,o,a=null===(t=e.streams)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.id;r._print("pc.ontrack",Om(i=Om(o="".concat(e.track.kind," ")).call(o,e.track.id," ")).call(i,a)),"ff-stream"===a&&(r.audioTrack4ff=e.track),r.emit("ontrack",e)},r._pc.onconnectionstatechange=function(e){var t;r._print("onconnectionstatechange",Om(t="".concat(r._pc.connectionState,". ice -> ")).call(t,r._pc.iceConnectionState)),"failed"!==r._pc.iceConnectionState&&"closed"!==r._pc.iceConnectionState&&"failed"!==r._pc.connectionState||r.emit("disconnect","ice failed")},r._pc.oniceconnectionstatechange=function(){var e=r._pc.iceConnectionState;r._report("rtc_pre_ice_state",{message:e,ice_state:e.toUpperCase()}),r.emit("ice_state",e)},r}return Ul(s,[{key:"getOriginRTCPeerConnection",value:function(){return this._pc}},{key:"getOriginRTCDataChannel",value:function(){return this._dc}},{key:"getConnectionId",value:function(){return this._peerConnectionId}},{key:"getGroupConnectionId",value:function(){return this._groupConnectionId}},{key:"connect",value:(o=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._print("connect","invoke. %o",t),this._iceNode=t,this._dc=this._pc.createDataChannel("signaling",{negotiated:!0,id:100}),this._dc.binaryType="arraybuffer",e.next=6,this._genIceInfo(t);case 6:return r=e.sent,n=r.offerIce,i=r.answerIce,this._offerIce=n,this._answerIce=i,(zD||this._ctx.enableFallbackHandler)&&(this._pc.addTransceiver("audio",{direction:"recvonly"}),this._pc.addTransceiver("video",{direction:"recvonly"})),e.next=14,this._pc.createOffer();case 14:if((o=e.sent).sdp){e.next=17;break}throw new mA(pA.NOT_SUPPORTED,"create offer sdp failed.");case 17:if(a=SL.parse(o.sdp),this._peerConnectionId=i.iceUfrag||"",!n.iceUfrag&&!n.icePwd&&((d="renomination"===(null===(s=a.media[0])||void 0===s?void 0:s.iceOptions))||(delete n.iceOptions,delete i.iceOptions),delete n.iceUfrag,delete n.icePwd,l=tU({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null===(c=a.media[0])||void 0===c?void 0:c.icePwd,options:(u={},Jd(u,eU.kICEConfigTypeSrtpDtlsType,!0),Jd(u,eU.kICEConfigTypeRenominationType,d),u)}),h=eI(l,2),p=h[0],v=h[1],this._peerConnectionId=v,i.iceUfrag=p,this._logger.info("use serverUfrag v2",Pm({dtls:!0,renomination:d}))),f=eI(a.media,1),_=f[0],this._offerIce.fingerprint=a.fingerprint||_.fingerprint,!zD&&!this._ctx.enableFallbackHandler){e.next=39;break}if(a.media=jm(m=a.media).call(m,(function(e){var t,r,n=Zd(Zd({},e),S._offerIce);return"video"===n.type&&(n.ext=null===(t=n.ext)||void 0===t?void 0:Gs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),n.rtcpFb=null===(r=n.rtcpFb)||void 0===r?void 0:Gs(r).call(r,(function(e){return"goog-remb"!==e.type}))),n})),(g=Zd({},a)).fingerprint=this._answerIce.fingerprint,g.media=jm(y=g.media).call(y,(function(e){return delete(e=Zd(Zd({},e),S._answerIce)).bundleOnly,e.port=9,"application"===e.type?e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}:("audio"===e.type&&(e.msid="ff-stream ff-stream-audio"),e.direction="sendonly"),e})),!this._ctx.enableFallbackHandler){e.next=33;break}return e.next=31,this.setLocalDescription(o.sdp);case 31:e.next=35;break;case 33:return e.next=35,this.setLocalDescription(SL.write(a));case 35:return e.next=37,this.setRemoteDescription(SL.write(g));case 37:e.next=47;break;case 39:delete a.media,this._offerSession=Zd({},a),this._answerSession=Zd({},a),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),this._offerMlines=[Zd(Zd(Zd({},_),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[Zd(Zd(Zd({},_),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription();case 47:return e.next=49,new Y_((function(e,t){S._connectReject=t,S._dc.onopen=function(){S._print("connect","dataChannel open"),S._reportRtcInvokeStatus("es.dc.open",""),e(""),delete S._connectReject},S._dc.onerror=function(e){var t,r;S._report("rtc_signaling_msg_error",{error_code:e.error.sdpLineNumber,message:e.error.errorDetail,reason:"invalid data"}),S._reportRtcInvokeStatus("es.dc.error",""),null===(t=S._connectReject)||void 0===t||t.call(S,{message:"dc.onerror, ".concat(null===(r=e.error)||void 0===r?void 0:r.errorDetail),code:0}),S.emit("disconnect","dc onerror"),delete S._connectReject},S._dc.onclose=function(e){var t;S._reportRtcInvokeStatus("es.dc.close",""),null===(t=S._connectReject)||void 0===t||t.call(S,{message:"dc.onclose",code:1}),S.emit("disconnect","dc onclose"),delete S._connectReject},S._pc.addEventListener("connectionstatechange",(function(e){var t,r;"failed"!==S._pc.iceConnectionState&&"closed"!==S._pc.iceConnectionState&&"failed"!==S._pc.connectionState||(null===(t=S._connectReject)||void 0===t||t.call(S,{message:Om(r="pc.connectionstatechange -> ".concat(S._pc.connectionState,", ice -> ")).call(r,S._pc.iceConnectionState),code:2}),delete S._connectReject)})),setTimeout((function(){var e;null===(e=S._connectReject)||void 0===e||e.call(S,{code:4,message:"connect timeout"}),delete S._connectReject}),8e3)}));case 49:return this._print("connect","dataChannel establish success"),e.abrupt("return",this._dc);case 51:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"setDescription",value:(i=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._print("setDescription","invoke."),this._offerSession.media=this._offerMlines,this._answerSession.media=this._answerMlines,r=[],this._offerMlines.forEach((function(e){"inactive"!==e.direction&&r.push(e.mid)})),this._offerSession.groups&&this._answerSession.groups&&(this._offerSession.groups[0].mids=r.join(" "),this._answerSession.groups[0].mids=r.join(" ")),n=lD(),t&&this._report("rtc_begin_create_offer",{direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,pc_session_id:this._peerConnectionId,vendor_mode:0}),e.next=10,this._pc.createOffer();case 10:return t&&this._report("rtc_create_offer",{error_code:0,direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,elapse:lD()-n}),e.next=13,this.setLocalDescription(SL.write(this._offerSession),t);case 13:return e.next=15,this.setRemoteDescription(SL.write(this._answerSession),t);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setLocalDescription",value:(n=Rm(Tm().mark((function e(t,r){var n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=lD(),e.prev=1,e.next=4,this._pc.setLocalDescription({type:"offer",sdp:t});case 4:this._report("rtc_set_description",{error_code:0,message:t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:lD()-n},{type:"offer"}),this._initSctpEvents||(this._initSctpEvents=!0,(o=null===(i=this._pc)||void 0===i?void 0:i.sctp)&&(o.onstatechange=function(){a._reportRtcInvokeStatus("sctp","sctp state change TO: ".concat(o.state))},o.transport&&(o.transport.onstatechange=function(){var e;a._reportRtcInvokeStatus("dtls","dtls state change TO: ".concat(null==o||null===(e=o.transport)||void 0===e?void 0:e.state))}))),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),console.error("setLocal",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:"",stream_user_id:"",elapse:lD()-n},{type:"offer"});case 12:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e,t){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(r=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=lD(),e.prev=1,e.next=4,this._pc.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:t}));case 4:this._report("rtc_set_description",{error_code:0,message:t,is_local:"0",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:lD()-n},{type:"answer"}),e.next=11;break;case 7:e.prev=7,e.t0=e.catch(1),console.error("setRemote",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"0",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:lD()-n},{type:"answer"});case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"disconnect",value:function(){var e,t;null===(e=this._connectReject)||void 0===e||e.call(this,{code:3,message:"invoke destroy()"}),delete this._connectReject,this._pc.close(),null===(t=this._dc)||void 0===t||t.close(),this._pc.ontrack=null}},{key:"destroy",value:function(){this._print("destroy",this._peerConnectionId),OI(CI(s.prototype),"removeAllListeners",this).call(this),this.disconnect()}},{key:"_genIceInfo",value:(t=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={iceUfrag:null===(r=t.iceParams)||void 0===r?void 0:r.clientIceUfrag,icePwd:null===(n=t.iceParams)||void 0===n?void 0:n.clientIcePwd,iceOptions:"renomination"},e.next=3,JL(t);case 3:return o=e.sent,e.abrupt("return",{offerIce:i,answerIce:o});case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"_print",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];(t=this._logger).info.apply(t,Om(r=["".concat(e)]).call(r,i))}},{key:"_report",value:function(e,t,r){var n,i,o,a;null===(n=this._monitor)||void 0===n||n.report(e,Zd(Zd({},t),{},{connection_id:this._peerConnectionId,group_connection_id:this._groupConnectionId}),Zd(Zd({},r),{},{tcp_only:null===(i=this._iceNode)||void 0===i?void 0:i.iceConfig.tcpOnly,ms_addr:Pm((null===(o=this._iceNode)||void 0===o?void 0:jm(a=o.publicIPs).call(a,(function(e){return{ip:e.ip,tcp:e.tcpPorts,udp:e.udpPorts}})))||[])}))}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)}}],[{key:"checkSupported",value:function(){if(!RTCPeerConnection)throw new mA(pA.NOT_SUPPORTED,"missing RTCPeerConnection API.");["addTransceiver","createDataChannel","createOffer","setLocalDescription","setRemoteDescription"].forEach((function(e){var t,r;if(null===(t=RTCPeerConnection)||void 0===t||null===(r=t.prototype)||void 0===r||!r[e])throw new mA(pA.NOT_SUPPORTED,"missing peer.".concat(e," API."))}))}}]),s}(aM);function DG(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=an(e);for(n=0;n<o.length;n++)r=o[n],xE(t).call(t,r)>=0||(i[r]=e[r]);return i}(e,t);if(xs){var o=xs(e);for(n=0;n<o.length;n++)r=o[n],xE(t).call(t,r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var NG=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(NG||{}),MG=function(e){return e[e.P2P=0]="P2P",e[e.SIGNAL=1]="SIGNAL",e[e.BROADCAST=2]="BROADCAST",e[e.BUSINESS_SERVER=3]="BUSINESS_SERVER",e}(MG||{}),PG=function(e){return e[e.SUCCESS=0]="SUCCESS",e[e.TIMEOUT=1]="TIMEOUT",e[e.BROKEN=2]="BROKEN",e[e.NO_RECEIVER=3]="NO_RECEIVER",e[e.NO_RELAYPATH=4]="NO_RELAYPATH",e[e.EXCEED_QPS=5]="EXCEED_QPS",e[e.SEND_TO_SERVER_ERROR=17]="SEND_TO_SERVER_ERROR",e[e.SERVER_RESPONSE_ERROR=18]="SERVER_RESPONSE_ERROR",e[e.NOT_JOIN=100]="NOT_JOIN",e[e.NOT_LOGIN=105]="NOT_LOGIN",e[e.SERVER_PARAMS_NOTSET=106]="SERVER_PARAMS_NOTSET",e[e.UNKNOWN=1e3]="UNKNOWN",e}(PG||{}),LG=(Jd(Qj={},0,[0,"success"]),Jd(Qj,1,[pA.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),Jd(Qj,2,[pA.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),Jd(Qj,3,[pA.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),Jd(Qj,4,[pA.USER_MESSAGE_NO_RECEIVER,"cannot find relay path."]),Jd(Qj,5,[pA.USER_MESSAGE_EXCEED_QPS,"cannot find relay path."]),Jd(Qj,17,[pA.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),Jd(Qj,18,[pA.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),Jd(Qj,100,[pA.USER_MESSAGE_NOT_JOIN,"not join room"]),Jd(Qj,105,[pA.USER_MESSAGE_NOT_LOGIN,"not login."]),Jd(Qj,106,[pA.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),Jd(Qj,1e3,[pA.USER_MESSAGE_UNKNOWN,"unknown."]),Qj),UG=["msg"],VG=new Pw("DataChannelSignaling",3),FG=[],BG=function(e){return e[e.C2S=0]="C2S",e[e.C2C=1]="C2C",e[e.C2GW=2]="C2GW",e[e.C2CDirect=3]="C2CDirect",e[e.C2RTM=4]="C2RTM",e}(BG||{}),jG=function(e){NI(a,e);var t,r,n,i,o=QI(a);function a(e,t){var r;return Vl(this,a),Jd(tI(r=o.call(this)),"_singlingCache",new $S),Jd(tI(r),"_p2pCache",new $S),Jd(tI(r),"_rttIds",{}),Jd(tI(r),"_p2pMessageId",1),Jd(tI(r),"_clearDataChannelListener",void 0),Jd(tI(r),"_monitor",void 0),r.id=e,r._dataChannel=t,r._clearDataChannelListener=r._handleHandler(),r._monitor=VO(e),r}return Ul(a,[{key:"destroy",value:function(){var e=this;this._dataChannel&&(this._clearDataChannelListener(),this._dataChannel.close()),this._singlingCache.forEach((function(t,r){t.error(new mA(pA.OPERATION_CANCEL,"disconnect")),e._singlingCache.delete(r)})),this._singlingCache.clear(),this._p2pCache.clear(),this._p2pMessageId=1,this._rttIds={}}},{key:"sendSignaling",value:function(e,t,r){var n,i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:6e4;return null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:Pm(t),signaling_event:"call-".concat(e),signaling_type:"Send",stream_id:t.streamId,stream_user_id:t.streamUserId,direction:"up"}),new Y_((function(n,a){var s,c=i._genHeader(r);c.id=vD();var u=c.id.join("-"),d="customMessage"===e;d&&wO.samplingOne2ManyMsg(i.id,Number(c.id.join("")),t);var l=setTimeout((function(){i._singlingCache.delete(u),a(new mA(pA.TIME_OUT,"".concat(e," message time out"))),d&&wO.updateOne2ManyMsgAck(i.id,t,999)}),o);i._singlingCache.set(u,{signalingType:e,success:function(e){clearTimeout(l),n(e),d&&wO.updateOne2ManyMsgAck(i.id,t,0)},error:function(e){clearTimeout(l),a(e),d&&wO.updateOne2ManyMsgAck(i.id,t,e.code)}}),VG.info("Signal",Om(s=">>>>>> [".concat(e,"][")).call(s,u,"]"),t),i._sendMessage(e,c,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(i=Rm(Tm().mark((function e(t,r){var n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,i=DG(t,UG),o=n instanceof ArrayBuffer,e.t0=this,e.t1=wO,e.t2=this.id,e.t3=Zd,e.t4=Zd({ver:1,id:this._p2pMessageId++,time:Date.now(),dir:NG.SEND,type:MG.P2P,err:PG.SUCCESS},i),e.t5={},e.t6=o,!o){e.next=15;break}return e.next=12,pD.ab2b64str(n);case 12:e.t7=e.sent,e.next=16;break;case 15:e.t7=n;case 16:return e.t8=e.t7,e.t9={binary:e.t6,msg:e.t8},e.t10=(0,e.t3)(e.t4,e.t5,e.t9),e.t11=e.t1.samplingP2PMsg.call(e.t1,e.t2,e.t10),e.t12=r,e.abrupt("return",e.t0._sendP2PMessage.call(e.t0,e.t11,e.t12));case 22:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"_sendP2PMessage",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return _D(e.msg)?this._rttIds[e.id]=e.id:e.dir===NG.SEND&&VG.info("_sendP2PMessage [DC Signaling p2p >>]",Pm(e)),new Y_((function(n,i){var o=t._genHeader(Zd(Zd({needAck:!0,functionType:1},r),{},{id:vD()}));if(e.dir===NG.SEND){var a=setTimeout((function(){t._p2pCache.delete(e.id),i(new mA(pA.USER_MESSAGE_TIMEOUT,"P2P message timeout")),wO.updateP2PMsgAck(t.id,e,999)}),12e3);t._p2pCache.set(e.id,{success:function(r,i){clearTimeout(a),n(i),wO.updateP2PMsgAck(t.id,e,0)},error:function(r){var n;clearTimeout(a),wO.updateP2PMsgAck(t.id,e,r.err);var o=eI(LG[r.err]||[pA.USER_MESSAGE_UNKNOWN,Om(n="err: ".concat(r.err,", msg: ")).call(n,r.msg)],2),s=o[0],c=o[1];i({err:r.err,code:s,message:r.msg||c})}})}try{t._sendMessage("p2p",o,e)}catch(s){throw s.code===pA.NOT_CONNECTED_YET&&(s.code=pA.USER_MESSAGE_BROKEN),s}}))}},{key:"_sendMessage",value:function(e,t,r){var n;if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new mA(pA.NOT_CONNECTED_YET,"DataChannel not open");var i=t.version+(Number(t.zip)<<5)+(Number(t.encrypt)<<6),o=Number(t.needAck)+(Number(t.direction)<<1)+(Number(t.functionType)<<2)+(Number(t.binary)<<6),a=pD.str2ab(Pm([e,r])),s=hD(Uint8Array,Om(n=[i,o]).call(n,Jk(t.id||[])),new Uint8Array(a));try{this._dataChannel.send(s.buffer)}catch(u){var c;throw null===(c=this._monitor)||void 0===c||c.report("rtc_error",{message:"datachannel send error: ".concat(u.message),error_code:kG.DC_SEND_ERROR}),u}"p2p"===e?wO.updateP2PMsgReq(this.id,r,s.buffer.byteLength):"customMessage"===e&&wO.updateOne2ManyMsgReq(this.id,r,s.buffer.byteLength)}},{key:"_dispartData",value:function(e){var t=new Uint8Array(e),r=0,n=t[r++],i=t[r++],o={version:15&n,zip:16==(16&n),encrypt:32==(32&n),needAck:1==(1&i),direction:(2&i)>>1,functionType:(60&i)>>2,binary:64==(64&i)};if(o.needAck||1===o.direction){for(;r<=6;r++)if(128!=(128&t[r])){r++;break}o.id=qk(km(t).call(t,2,r))}return{header:o,data:km(t).call(t,r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n,i,o=this._genHeader({needAck:!0,direction:1,id:jm(n=e.split("-")).call(n,(function(e){return Number(e)}))});mk(FG).call(FG,t)||VG.info("Signal",Om(i=">>>>>> [".concat(t,"-res][")).call(i,e,"]"));this._sendMessage("".concat(t,"-res"),o,r)}},{key:"_handleMessage",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=Date.now(),n=t.byteLength,i=this._dispartData(t),o=i.data,(a=i.header).zip&&((s=new vO.Inflate).push(o,!0),o=s.result),c=pD.ab2str(o),u=[],e.prev=8,u=JSON.parse(c),e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(8),e.t0 instanceof Error&&(null===(d=this._monitor)||void 0===d||d.report("rtc_signaling_msg_error",{error_code:-1,message:e.t0.message,reason:"message parse failed"})),e.abrupt("return");case 16:e.t1=a.functionType,e.next=0===e.t1?19:1===e.t1?21:2===e.t1?23:25;break;case 19:return this.C2S(a,u,c,n,r),e.abrupt("break",26);case 21:return this.C2C(u,n,r),e.abrupt("break",26);case 23:return this.C2GW(a,u,c),e.abrupt("break",26);case 25:return e.abrupt("break",26);case 26:case"end":return e.stop()}}),e,this,[[8,12]])}))),function(e){return n.apply(this,arguments)})},{key:"C2S",value:(r=Rm(Tm().mark((function e(t,r,n,i,o){var a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=(null===(a=t.id)||void 0===a?void 0:a.join("-"))||"",1!==t.direction){e.next=5;break}this._handleAckMessage(s,r[0]||{},n),e.next=18;break;case 5:if(!Array.isArray(r)){e.next=18;break}if(u=r[0],r=r[1],mk(FG).call(FG,u)||VG.info("Signal","<<<<<< ".concat(u),r,s),this._feedbackSignaling(s,u,u===cG.ON_CUSTOM_MESSAGE?Zd(Zd({},r),{},{message:""}):""),!r.binary||"string"!=typeof r.message){e.next=14;break}return e.next=13,pD.b64str2ab(r.message);case 13:r.message=e.sent;case 14:d=Date.now(),this.emit(u,Zd({},r)),u===cG.ON_CUSTOM_MESSAGE&&wO.reportOne2ManyMsgRecv(this.id,r,{msg_size:i,recv_msg_ts:o,fwd_msg_ts:d}),null===(c=this._monitor)||void 0===c||c.report("rtc_signaling",{error_code:0,message:n,signaling_event:"on-".concat(u),signaling_type:"Recv",stream_id:r.streamId,stream_user_id:r.clientId,direction:"down"});case 18:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"C2C",value:(t=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Array.isArray(t)&&(t=t[1]),c=null===(i=t)||void 0===i?void 0:i.id,this._rttIds[c]||(null===(o=t)||void 0===o?void 0:o.dir)===NG.FEEDBACK||_D(null===(a=t)||void 0===a?void 0:a.msg)?delete this._rttIds[c]:VG.info("Signal","<<<<<< p2p response",t),e.t0=t.dir,e.next=e.t0===NG.SEND?6:e.t0===NG.FEEDBACK?46:48;break;case 6:if(u=Date.now(),_D(null===(s=t)||void 0===s?void 0:s.msg)){e.next=43;break}if(l=(d=t).binary,h=d.msg,p=d.room,v=d.to,f=d.from,_=""===p?l?cG.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:cG.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:l?cG.USER_BINARY_MESSAGE_RECEIVED:cG.USER_MESSAGE_RECEIVED,v){e.next=27;break}if(e.t1=this,e.t2=cG.ON_CUSTOM_MESSAGE,e.t3=f,e.t4=l,!l){e.next=21;break}return e.next=18,pD.b64str2ab(h);case 18:e.t5=e.sent,e.next=22;break;case 21:e.t5=h;case 22:e.t6=e.t5,e.t7={clientId:e.t3,binary:e.t4,message:e.t6},e.t1.emit.call(e.t1,e.t2,e.t7),e.next=43;break;case 27:if(e.t8=this,e.t9=_,e.t10=Zd,e.t11=Zd({},t),e.t12={},!l){e.next=38;break}return e.next=35,pD.b64str2ab(h);case 35:e.t13=e.sent,e.next=39;break;case 38:e.t13=h;case 39:e.t14=e.t13,e.t15={msg:e.t14},e.t16=(0,e.t10)(e.t11,e.t12,e.t15),e.t8.emit.call(e.t8,e.t9,e.t16);case 43:return this._sendP2PMessage(Zd(Zd({},t),{},{dir:NG.FEEDBACK,msg:""})),wO.reportP2PMsgRecv(this.id,t,{msg_size:r,recv_msg_ts:n,fwd_msg_ts:u}),e.abrupt("break",49);case 46:return this._handleP2PMsgFeedback(t),e.abrupt("break",49);case 48:return e.abrupt("break",49);case 49:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"C2GW",value:function(e,t,r){if(1===e.direction){var n,i=(null===(n=e.id)||void 0===n?void 0:n.join("-"))||"";this._handleAckMessage(i,t[0]||{},r)}else{var o=eI(t,2),a=o[0],s=o[1],c=void 0===s?{}:s;if("RXMediaMsg"===a){var u,d=c.type,l=c.data;switch(null===(u=this._monitor)||void 0===u||u.report("rtc_signaling",{error_code:0,message:r,signaling_event:"on-".concat(d),signaling_type:"Recv",stream_id:"",stream_user_id:"",direction:"down"}),d){case"RSCP":try{var h=JSON.parse(l);Array.isArray(h)&&this.emit(d,h)}catch(f){}break;case"RTT":try{var p=JSON.parse(l);p.length&&this.emit(d,p[0])}catch(f){}break;case"SSC":try{var v=JSON.parse(l);v.length&&this.emit(d,v[0])}catch(f){}}}}}},{key:"_handleHandler",value:function(){var e=this,t=function(e){VG.warn("_handleHandler","dataChannel close",e)},r=function(e){VG.error("_handleHandler","dataChannel error",e)},n=function(t){e._handleMessage(t.data)};return this._dataChannel.addEventListener("close",t),this._dataChannel.addEventListener("error",r),this._dataChannel.addEventListener("message",n),function(){e._dataChannel.removeEventListener("close",t),e._dataChannel.removeEventListener("error",r),e._dataChannel.removeEventListener("message",n)}}},{key:"_genHeader",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Zd({version:2,zip:!1,encrypt:!1,needAck:!0,direction:0,functionType:0,binary:!1},e)}},{key:"_handleAckMessage",value:function(e,t,r){var n,i,o=this._singlingCache.get(e);o&&(this._singlingCache.delete(e),200===t.code?o.success(t):o.error(t),VG.info("Signal",Om(i="<<<<<< [".concat(o.signalingType,"-ack] ")).call(i,e),t));null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:r,signaling_event:null==o?void 0:o.signalingType,signaling_type:"Ack",stream_id:"",stream_user_id:"",direction:"down"})}},{key:"_handleP2PMsgFeedback",value:function(e){var t=this._p2pCache.get(e.id);t&&(this._p2pCache.delete(e.id),e.err===PG.SUCCESS?t.success(e.id,e):t.error(e))}}]),a}(nM.exports.EventEmitter),GG=new Pw("ConnectionManager",3),HG=function(e){NI(o,e);var t,r,n,i=QI(o);function o(e){var t;return Vl(this,o),Jd(tI(t=i.call(this)),"id",void 0),Jd(tI(t),"_monitor",void 0),Jd(tI(t),"_getAccessManager",void 0),Jd(tI(t),"_connectionPool",new $S),Jd(tI(t),"_curConnection",void 0),Jd(tI(t),"_hasReportBrowerWarning",!1),Jd(tI(t),"_reconnectTimer",void 0),Jd(tI(t),"_connecting",!1),Jd(tI(t),"_isFirstTimeConnected",!0),Jd(tI(t),"_feedbackNodes",[]),Jd(tI(t),"_preIceStartTime",-1),Jd(tI(t),"_tcpOnlyTimer",void 0),Jd(tI(t),"_destroyed",!1),t._ctx=e,GG.info("constructor","invoke"),t.id=e.id,t._monitor=VO(t.id),t._getAccessManager=new AG(e),t}return Ul(o,[{key:"connect",value:function(){var e=this;GG.info("connect","invoke");try{OG.checkSupported()}catch(t){this.safeEmit("disconnected",t)}this._connecting||(this._onConnectStart("init"),Y_.resolve().then((function(){return e.emit("__onGetIceConfigHook")})),this._getAccess())}},{key:"reconnectByNodeChange",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:GG.info("reconnectByNodeChange","invoke %o",t),o=t.nodes,a=t.reason,null===(r=this._monitor)||void 0===r||r.report("rtc_node_change",{error_code:0,message:Pm(t),reason:Pm(a)}),EN.clearAccessNode(this._ctx.appId),s=(null===(n=this._curConnection)||void 0===n||null===(i=n.node.publicIPs[0])||void 0===i?void 0:i.ip)||"",this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart("node change"),Array.isArray(o)&&o.length>0?this._startIceConnect(o):this._getAccess([{feedbackIP:s,feedbackReason:{type:"NODE_CHANGED",reason:a}}]);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"reconnect",value:(r=Rm(Tm().mark((function e(t){var r,n=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],GG.info("reconnect","invoke. ".concat(r?"ICE over TCP":"")),this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart(t),this._getAccess(void 0,r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){GG.info("destroy","invoke"),this._destroyed=!0,this.safeEmit("disconnected",new mA(pA.OPERATION_CANCEL,"destroy")),OI(CI(o.prototype),"removeAllListeners",this).call(this),this._clearReconnectTimer(),this._clearConnectionPool(),this._getAccessManager.destroy(),this._closeCurrentConnection()}},{key:"_getAccess",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._getAccessManager.getICENode(e).then((function(e){t.emit("__onGetIceSuccessHook",e),t._startIceConnect(e,r)})).catch((function(e){t.safeEmit("disconnected",e)})).finally((function(){t._feedbackNodes=[]}))}},{key:"_startIceConnect",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this._destroyed){GG.info("_startIceConnect","invoke");var n=_w();this._preIceStartTime=lD();var i=this._ctx.joinRoomConfig.useTcpJoin,o=this._ctx.joinRoomConfig.useTcpJoinDelay,a=function(){var e=Rm(Tm().mark((function e(i){var o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r&&((i=Wj(i)).iceConfig.tcpOnly=!0),o={node:i},e.prev=2,a=new OG(t._ctx,n),o.pc=a,t._connectionPool.set(a.uuid,o),e.next=8,a.connect(i);case 8:return s=e.sent,c=new jG(t.id,s),o.signaling=c,e.next=13,c.sendPingSignaling();case 13:t._onConnectSuccess({node:i,pc:a,signaling:c,dc:s}),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(2),t._onConnectionFailed(o,e.t0);case 19:case"end":return e.stop()}}),e,null,[[2,16]])})));return function(t){return e.apply(this,arguments)}}();this.emit("__onIceConnectStartHook"),e.forEach(a),i&&!r&&(GG.info("_startIceConnect","tcp-only will try after ".concat(o,"ms")),this._tcpOnlyTimer=window.setTimeout((function(){t.emit("connectWidthTcp"),e.forEach((function(e){(e=Wj(e)).iceConfig.tcpOnly=!0,a(e)})),delete t._tcpOnlyTimer}),o))}}},{key:"_onConnectSuccess",value:function(e){var t,r,n,i=this;(GG.info("connect","peer_%s connect success.",e.pc.uuid),this.emit("__onIceConnectSuccessHook",e),this._curConnection)?(e.pc.destroy(),null===(t=e.signaling)||void 0===t||t.destroy(),this._connectionPool.delete(e.pc.uuid)):(this._curConnection=e,this._addConnectionHandler(e.pc,e.dc),null===(r=this._monitor)||void 0===r||r.set({connection_id:e.pc.getConnectionId(),rtc_vid:(null===(n=e.node.iceConfig)||void 0===n?void 0:n._abtest_vid)||""}),this._connectionPool.delete(e.pc.uuid),this._feedbackNodes.forEach((function(e){return i._feedbackBySignaling(e)})),this._feedbackNodes=[],this._onConnectEnded(e))}},{key:"_onConnectionFailed",value:function(e,t){var r,n,i=this;(GG.info("connect","peer_%s connect failed. %s",(null===(r=e.pc)||void 0===r?void 0:r.uuid)||"",t.message),this.emit("__onIceConnectFailedHook",e),t.code!==CG.DESTROY&&t.code!==pA.OPERATION_CANCEL)&&(this._curConnection?this._feedbackBySignaling(e.node):this._feedbackNodes.push(e.node),GG.info("connect","remove cache node"),EN.deleteAccessNode(this._ctx.appId,e.node),e.pc&&(this._connectionPool.delete(e.pc.uuid),e.pc.destroy()),null===(n=e.signaling)||void 0===n||n.destroy());0!==this._connectionPool.size||this._curConnection||this._destroyed||(GG.error("connect","establish peerConnection failed"),this._checkBrowserUA(),lD()-this._preIceStartTime<1e3?(this._clearReconnectTimer(),this._reconnectTimer=window.setTimeout((function(){delete i._reconnectTimer,i._reconnectWithIceFailed(i._feedbackNodes)}),1e3)):this._reconnectWithIceFailed(this._feedbackNodes))}},{key:"_feedbackBySignaling",value:function(e){var t;null===(t=this._curConnection)||void 0===t||t.signaling.sendSignaling("scheduleMessage",{type:"feedback",body:{feedbackIP:e.publicIPs[0].ip,feedbackReason:{type:"ICE_FAILED",reason:{}}}})}},{key:"_reconnectWithIceFailed",value:(t=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._onConnectStart("ice failed"),GG.warn("reconnect","because of ice failed"),this._getAccess(jm(t).call(t,(function(e){return{feedbackIP:e.publicIPs[0].ip,feedbackReason:{type:"ICE_FAILED",reason:{}}}})));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_checkBrowserUA",value:function(){var e;!this._hasReportBrowerWarning&&this._ctx.joinRoomConfig.isBlackBrower()&&(this._hasReportBrowerWarning=!0,null===(e=this._monitor)||void 0===e||e.report("rtc_error",{error_code:kG.BLACK_BROWSER,message:"failed to establish data-channel, and the current browser is on the browser blacklist."}))}},{key:"_onConnectStart",value:function(e){var t;GG.info("_onConnectStart","invoke, reason: ".concat(e)),this._connecting=!0,this.safeEmit(this._isFirstTimeConnected?"connecting":"reconnecting");var r,n=_w();(null===(t=this._monitor)||void 0===t||t.set({connect_session_id:n}),this._isFirstTimeConnected)||(null===(r=this._monitor)||void 0===r||r.report("rtc_reconnect",{error_code:1002,message:"peerconnection reconnecting",reconnect_id:n,reconnect_type:"peerconnection"},{reason:e}))}},{key:"_onConnectEnded",value:function(e){var t;(GG.info("_onConnectEnded","invoke"),this._connecting=!1,this._isFirstTimeConnected=!1,this.safeEmit("connected",e),this._isFirstTimeConnected)||(null===(t=this._monitor)||void 0===t||t.report("rtc_reconnected",{message:"peerconnection reconnected",reconnect_type:"peerconnection"}));e.node.iceConfig.tcpOnly&&(GG.info("_onConnectEnded","use tcp only"),jO(this._ctx.id,"connected_with_tcp_only",Pm(e.node))),this._tcpOnlyTimer&&(window.clearTimeout(this._tcpOnlyTimer),delete this._tcpOnlyTimer),this._clearConnectionPool()}},{key:"_addConnectionHandler",value:function(e,t){var r=this;e.on("disconnect",(function(e){r._closeCurrentConnection(),r._clearReconnectTimer(),navigator.onLine?r.reconnect(e):r._reconnectTimer=window.setTimeout((function(){return r.reconnect(e)}),3e3)}))}},{key:"_closeCurrentConnection",value:function(){var e,t;null===(e=this._curConnection)||void 0===e||e.pc.destroy(),null===(t=this._curConnection)||void 0===t||t.signaling.destroy(),delete this._curConnection}},{key:"_clearConnectionPool",value:function(){var e=this;this._connectionPool.forEach((function(t,r){var n,i;null===(n=t.pc)||void 0===n||n.destroy(),null===(i=t.signaling)||void 0===i||i.destroy(),e._connectionPool.delete(r)}))}},{key:"_clearReconnectTimer",value:function(){this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer)}}]),o}(aM),zG=ad,KG=tc,XG=function(e,t,r,n){for(var i,o=n>1?void 0:n?KG(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&zG(t,r,o),o},WG=new Pw("MediaServerClient",2),qG=6e4,YG=function(e){return e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTED="connected",e.CONNECTING="connecting",e}(YG||{}),JG=function(e,t){WG.info(e,"userId: %o, subAudio: %o, subVideo: %o, audioMid: %o, videoMid: %o, sequenceId: %o",t.userId,t.subAudio,t.subVideo,t.audioMid,t.videoMid,t.sequenceId)},QG=function(e){NI(T,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k=QI(T);function T(e){var t;return Vl(this,T),Jd(tI(t=k.call(this)),"id",void 0),Jd(tI(t),"_token",void 0),Jd(tI(t),"_roomId",void 0),Jd(tI(t),"_roomAttributes",void 0),Jd(tI(t),"_vendorConfig",{enableMultiVendor:!1,vendorCode:0}),Jd(tI(t),"_clientId",void 0),Jd(tI(t),"_businessId",void 0),Jd(tI(t),"_userInfo",void 0),Jd(tI(t),"_authorization",void 0),Jd(tI(t),"_sessionId",""),Jd(tI(t),"_liveControlMessage",void 0),Jd(tI(t),"isReconnecting",!1),Jd(tI(t),"_ontrackCallbackMap",new $S),Jd(tI(t),"_subResolves",{}),Jd(tI(t),"supportConcurrent",!1),Jd(tI(t),"_handler",void 0),Jd(tI(t),"_pubSubLock",void 0),Jd(tI(t),"_joinLeaveLock",void 0),Jd(tI(t),"_state",void 0),Jd(tI(t),"_dataChannelSignal",void 0),Jd(tI(t),"_joinRoomStartTs",void 0),Jd(tI(t),"_subConfig",{}),Jd(tI(t),"_monitor",void 0),Jd(tI(t),"_roomProfile",bl.communication),Jd(tI(t),"_context",void 0),Jd(tI(t),"_subStreamQueue",{}),Jd(tI(t),"_connectionManager",void 0),Jd(tI(t),"_joinRoom5xxTimer",void 0),Jd(tI(t),"_joinResolve",void 0),Jd(tI(t),"_joinReject",void 0),WG.info("constructor","invoke"),t.id=e.id,t._monitor=VO(t.id),t._pubSubLock=new fG("pubSubLock"),t._joinLeaveLock=new fG("joinLeaveLock"),t._state="disconnected",t._roomAttributes={multiChatMode:!1,bigRoomMode:!1},t._context=e,t.on("SUB_END",(function(e){return t._handleSubStreamQueue(e)})),t._connectionManager=new HG(e),t._addConnectHandler(),t}return Ul(T,[{key:"_addSignalEventHandler",value:function(){var e,t,r=this;[cG.ON_ADD_STREAM,cG.ON_ADD_STREAM_LIST,cG.ON_REMOVE_STREAM,cG.ON_REMOVE_STREAM_LIST,cG.USER_CONNECTION,cG.USER_CONNECTION_LIST,cG.USER_DISCONNECTION,cG.USER_DISCONNECTION_LIST,cG.ON_UPDATE_STREAM_ATTRIBUTES,cG.ON_UPDATE_ROOM_ATTRIBUTES,cG.ON_PUSH_TRACK,cG.ON_REMOVE_TRACK,cG.ON_CUSTOM_MESSAGE,cG.USER_MESSAGE_RECEIVED,cG.USER_BINARY_MESSAGE_RECEIVED,cG.POST_PROCESSING_MESSAGE,cG.ON_USER_TOKEN_WILL_EXPIRE,cG.STREAM_CONTROL_MESSAGE,cG.ON_UPDATE_USER_ATTRIBUTES,cG.ON_SPEAKER_CHANGE,uG.RSCP,uG.RTT,cG.ON_STREAM_FAILED,cG.ON_NOTIFY_RECONNECT,uG.SSC,cG.ON_FORWARD_DST_ROOM_USER_KICK].forEach((function(e){var t;null===(t=r._dataChannelSignal)||void 0===t||t.on(e,(function(t){r.safeEmit(e,t)}))})),null===(e=this._dataChannelSignal)||void 0===e||e.on(cG.NODE_CHANGE,(function(e){r._connectionManager.reconnectByNodeChange(e)})),null===(t=this._dataChannelSignal)||void 0===t||t.on(cG.ON_NOTIFY_RECONNECT,(function(){r._connectionManager.reconnect("recv notifyReconnect signaling")}))}},{key:"_removeSignalEventHandler",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.removeAllListeners(),null===(t=this._handler)||void 0===t||t.removeAllListeners()}},{key:"connectionState",get:function(){return this._state},set:function(e){this._state!==e&&(this.safeEmit(dG.ON_CONNECTION_STATE_CHANGE,{prev:this._state,next:e}),this._state=e)}},{key:"businessId",set:function(e){this._businessId=e}},{key:"setLiveControlMessage",value:function(e){this._liveControlMessage=e}},{key:"connect",value:function(){var e=this;return new Y_((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"join",value:(E=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return WG.info("join()","info: %o",t),this._token=t.token,this._roomId=t.roomId,this._clientId=t.userInfo.userId,this._businessId=t.userInfo.businessId,this._userInfo=t.userInfo,this._roomProfile=t.roomProfile,this._reportJoinRoomStart(),e.next=10,new Y_((function(e,t){n._joinResolve=e,n._joinReject=t,(n._handler?Y_.resolve():n.connect()).then((function(){n._callJoinRoom()})).catch((function(e){var t=Array.isArray(e)&&e.length>0?e[0]:e;n._joinRoomFailed(t.message)}))}));case 10:return r=e.sent,e.abrupt("return",r);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"_callJoinRoom",value:(b=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m=this,y=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=y.length>0&&void 0!==y[0]&&y[0],WG.info("_callJoinRoom","invoke"),e.t0=pD.token2auth(this._context.appId,this._roomId,this._clientId,this._token),e.t1=this._sessionId,e.t2=Date.now(),e.t3=this._liveControlMessage,e.t4={extra_info:this._userInfo.extraInfo,role:this._userInfo.role},e.next=9,null===(t=this._handler)||void 0===t?void 0:t.getDefaultSdp();case 9:return e.t5=e.sent,e.next=12,ZP(ON("PUB_SUB_MODE"));case 12:return e.t6=e.sent,e.t7=window.navigator.userAgent,e.t8=CN.VERSION,e.t9=EN.getDeviceId(),e.t10=this._context.appId,e.t11=this._roomId,e.t12=this._clientId,e.t13=this._businessId,e.t14=this._context.useCloudProxy,e.t15=SG[this._roomProfile]?"".concat(SG[this._roomProfile][0]):"0",e.t16={supportedCodecs:e.t6,deviceType:"web",userAgent:e.t7,sdkVersion:e.t8,deviceId:e.t9,appId:e.t10,roomId:e.t11,userId:e.t12,businessId:e.t13,enableCloudProxy:e.t14,channelProfile:e.t15},e.t17={supportTokenExpireCallBack:!0,enableSceneConfigV2:!0,enableUnBundleMode:!0,enableAudioMux:!0,enableBigRoomMode:!0,needNegotiateSDP:!0,supportMultiVendor:!0},e.t18=Pm({requireICEUfragV2:!0}),n={Authorization:e.t0,sessionId:e.t1,timestamp:e.t2,controlMessage:e.t3,userAttributes:e.t4,sdpInfo:e.t5,params:e.t16,options:e.t17,accessParams:e.t18},e.prev=26,e.t19=jO,e.t20=this.id,e.t21=Pm,e.next=32,$P();case 32:e.t22=e.sent,e.t23=ON("PUB_SUB_MODE")||"recv_and_send",e.t24={supportedCodecsSdpOffer:e.t22,pubSubMode:e.t23},e.t25=(0,e.t21)(e.t24),(0,e.t19)(e.t20,"MediaClient.internalGetSupportedCodecsSdpOffer",e.t25),e.next=41;break;case 39:e.prev=39,e.t26=e.catch(26);case 41:return Y_.resolve().then((function(){return m.emit("onSendingJoinMessageHook")})),e.prev=42,o=r?"reconnected":"joinRoom",e.next=46,this._joinRoomWithRetry(o,n);case 46:a=e.sent,WG.success("join","send join message success"),s=a.config||{},c=s.engine_WEB,this.connectionState="connected",this._authorization=n.Authorization,EN.setEngineWebConfig(this._context.appId,this._roomId,c),this._context&&(this._context.serverConfig={videoCodec:(null==c?void 0:c.video_codec)||"H264",audioRed:!(null==c||!c.pub_audio_red),muteReplaceUnsub:!(null===(u=a.config)||void 0===u||!u.mute_replace_unsub),simulcastOnDemand:!(zD||!1===(null===(d=a.config)||void 0===d||null===(l=d.engine_VPM)||void 0===l||null===(h=l.ondemand)||void 0===h?void 0:h.enable)),forceUniHandler:1===(null==a||null===(p=a.config)||void 0===p||null===(v=p.vendor_param)||void 0===v?void 0:v.vendor_stream_sub_mode)},"boolean"==typeof(null==c?void 0:c.av_sync)&&(this._context.avSync=c.av_sync)),a.vendorConfig&&(this._vendorConfig=a.vendorConfig),tF.audioStallConfig=c,null!=a&&null!==(i=a.relayMessage)&&void 0!==i&&i.sdp&&(null===(f=this._handler)||void 0===f||f.createAVMlineAnswerTpl(a.relayMessage.sdp)),this.emit("joinSuccess",{joinRes:a,reconnect:r}),this._joinRoomSuccess(a),e.next=63;break;case 60:e.prev=60,e.t27=e.catch(42),(null===e.t27||void 0===e.t27?void 0:e.t27.code)>=700&&(null===e.t27||void 0===e.t27?void 0:e.t27.code)<800?this._joinRoomFailed("token_error",pA.INVALID_TOKEN):(null===e.t27||void 0===e.t27?void 0:e.t27.code)===pA.TIME_OUT&&this._context.joinRoomConfig.useTcpAfterJoinTimeout?(_="joinRoom timeout, retry with tcp only",WG.error("join",_),this.safeEmit(_G.ON_REJOIN_WITH_TCP),this._connectionManager.reconnect(_,!0)):e.t27.code===pA.OPERATION_CANCEL&&"connecting"===this.connectionState||this._joinRoomFailed((null===e.t27||void 0===e.t27?void 0:e.t27.message)||"signaling_error");case 63:case"end":return e.stop()}}),e,this,[[26,39],[42,60]])}))),function(){return b.apply(this,arguments)})},{key:"publish",value:(S=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,D,N,M,P=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(WG.info("publish()","localStream: %o",t),r=t.videoTrack,n=t.audioTrack,i=lD(),o="",a="",s=this._handler,e.prev=7,!this._vendorConfig.enableMultiVendor){e.next=20;break}return T=new OG(this._context,""),t.vendorHandler=new EG(this._context,T),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),e.next=14,t.vendorHandler.publish(t);case 14:k=e.sent,(s=t.vendorHandler).on("ice_state",(function(e){P.emit(dG.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:ll.CONNECTION_STATE_CONNECTING,connected:ll.CONNECTION_STATE_CONNECTED,disconnected:ll.CONNECTION_STATE_RECONNECTING}[e],userId:P._clientId})})),T.once("disconnect",Rm(Tm().mark((function e(){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=s)||void 0===r||r.removeAllListeners(),"connected"===(null===(n=P._handler)||void 0===n||null===(i=n.pc)||void 0===i?void 0:i.iceConnectionState)){e.next=4;break}return WG.error("vendor ice failed",t.streamId),e.abrupt("return");case 4:t.clean(),P.unpublish(t),P.publish(t);case 7:case"end":return e.stop()}}),e)})))),e.next=23;break;case 20:return e.next=22,null===(I=this._handler)||void 0===I?void 0:I.publish(t);case 22:k=e.sent;case 23:if(null===(c=t.observer)||void 0===c||c.setHandler(s),k){e.next=26;break}throw new mA(pA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 26:if("H264"!==(null===(u=this._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.videoCodec)){e.next=32;break}return e.next=29,sL();case 29:if(e.sent){e.next=32;break}throw new mA(pA.PUBLISH_FAILED,"h264 is not supported");case 32:return o=k.audioMid,a=k.videoMid,t.pubAttributes={localaudio:!!n,localvideo:!!r,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(r instanceof fV),extaudio:!!(n instanceof _V)},R={attributes:Zd({videoDescriptions:k.videoDescriptions},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:o,videoMid:a,sdpInfo:{msid:t.stream.id,type:k.type,sdp:k.partialSdp,semantics:k.semantics},peerConnectionMode:null===(l=k)||void 0===l?void 0:l.peerConnectionMode,supportMultiVendor:!0},(A=!this._vendorConfig.enableMultiVendor&&t.enableSimulcast&&(null===(h=this._context)||void 0===h||null===(p=h.serverConfig)||void 0===p?void 0:p.simulcastOnDemand)&&(null===(v=k.subVideoDescriptions)||void 0===v?void 0:v.length))&&(R.attributes.subVideoDescriptions=k.subVideoDescriptions),null!==(f=k)&&void 0!==f&&f.peerConnectionId&&(R.peerConnectionId=k.peerConnectionId),e.next=41,null===(_=this._dataChannelSignal)||void 0===_?void 0:_.sendSignaling("publish",R);case 41:if(200===(null==(w=e.sent)?void 0:w.code)){e.next=44;break}throw new mA(pA.PUBLISH_FAILED,(null==w?void 0:w.message)||"publish failed");case 44:if(null===(m=this._monitor)||void 0===m||m.report("rtc_recv_answer",{error_code:0,answer_type:null==w?void 0:w.relayMessage.type,sequence_id:(null==w||null===(y=w.relayMessage)||void 0===y?void 0:y.sequenceId)||0,message:null==w||null===(g=w.relayMessage)||void 0===g?void 0:g.sdp,direction:"up",stream_id:"",stream_user_id:"",pc_session_id:(null===(S=s)||void 0===S?void 0:S.peerConnectionId)||""}),C=new Y_((function(e,r){var n,i,c,u,d,l;null===(n=s)||void 0===n||n.handleAck({action:lF.publish,streamId:w.streamId,audioMid:o,videoMid:a,audioTransceiverInit:null===(i=k)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(c=k)||void 0===c?void 0:c.videoTransceiverInit,signalingAck:{sdp:null==w||null===(u=w.relayMessage)||void 0===u?void 0:u.sdp,sequenceId:null==w||null===(d=w.relayMessage)||void 0===d?void 0:d.sequenceId},sdp:null===(l=k)||void 0===l?void 0:l.sdp,stream:t,onSuccess:function(){WG.info("publish()","publish success"),e(0)}})})),"chrome"!==(null===(b=this.handler)||void 0===b?void 0:b.name)){e.next=49;break}return e.next=49,C;case 49:return A&&this.emit(uG.RSCP,[{StreamIds:[t.stream.id],Metadata:{VideoIndex:0}}],!0),t.streamId=w.streamId,t.videoMid=a,t.audioMid=o,t.subVideoDescriptions=k.subVideoDescriptions,null===(E=this._monitor)||void 0===E||E.report("rtc_publish_stat",{result:"success",is_screen:"0",start:i,message:"unknown"}),e.abrupt("return");case 58:return e.prev=58,e.t0=e.catch(7),e.t0 instanceof Error?null===(O=this._monitor)||void 0===O||O.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:i,message:Om(D="".concat(e.t0.name,": ")).call(D,e.t0.message)}):e.t0 instanceof mA&&(null===(N=this._monitor)||void 0===N||N.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:i,message:Om(M="".concat(e.t0.code,": ")).call(M,e.t0.message)})),e.next=63,null===(x=s)||void 0===x?void 0:x.rollback(t.stream.id,t);case 63:throw e.t0;case 64:case"end":return e.stop()}}),e,this,[[7,58]])}))),function(e){return S.apply(this,arguments)})},{key:"updatePubTrack",value:(g=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,D;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(WG.info("updatePubTrack()","localStream: %o",t),i=t.videoTrack,o=t.audioTrack,a=t.pubAudio,s=t.pubVideo,c=t.vendorHandler||this.handler,u=null==o?void 0:o.getTrack("preprocessing"),d=null==i?void 0:i.getTrack("preprocessing"),!s||!d){e.next=10;break}return e.next=8,null===(l=t.videoTransceiver)||void 0===l?void 0:l.sender.replaceTrack(d);case 8:e.next=12;break;case 10:return e.next=12,null===(h=t.videoTransceiver)||void 0===h?void 0:h.sender.replaceTrack(null);case 12:if(null==c||c.updateMaxBitrate(t),!a||!u){e.next=20;break}return v=o.mixType,(f=o.mixedAudioTrack)&&v!==Dl.PLAYOUT&&u.enabled&&(u=f),e.next=18,null===(p=t.audioTransceiver)||void 0===p?void 0:p.sender.replaceTrack(u);case 18:e.next=23;break;case 20:return e.next=22,null===(_=t.audioTransceiver)||void 0===_?void 0:_.sender.replaceTrack(null);case 22:jO(this.id,"MediaClient.updatePubTrack(audio)","null");case 23:try{jO(this.id,"MediaClient.updatePubTrack",Pm({audioStreamTrack:DD(u),videoStreamTrack:DD(d)}))}catch(XW){}for(y={},g=0,S=RA(m={localaudio:!!o,localvideo:!!i,videostream:s,audiostream:a,extvideo:!!(i instanceof fV),extaudio:!!(o instanceof _V)});g<S.length;g++)b=eI(S[g],2),E=b[0],(k=b[1])!==dI(t.pubAttributes,E)&&fM(y,E,k);if(an(y).length){e.next=29;break}return e.abrupt("return");case 29:return t.observer&&(T=t.observer,I=y.audiostream,R=y.videostream,A=y.localaudio,w=y.localvideo,C=y.extaudio,x=y.extvideo,void 0!==w?void 0!==x?T.setPushVideo(x):T.setEnableVideo(w):void 0!==R&&T.setUnmuteVideo(R),void 0!==A?void 0!==C?T.setPushAudio(C):T.setEnableAudio(A):void 0!==I&&T.setUnmuteAudio(I)),t.pubAttributes=m,O={roomId:this._roomId,streamId:t.streamId,attributes:y},e.next=34,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateStreamAttributes",O);case 34:if(200===(null==(D=e.sent)?void 0:D.code)){e.next=37;break}throw new mA(pA.UPDATE_TRACK_FAILED,(null==D?void 0:D.message)||"update track failed");case 37:if("chrome"===(null===(n=this.handler)||void 0===n?void 0:n.name)){e.next=40;break}return e.next=40,null==c?void 0:c.setCurrentDescription();case 40:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"updateToken",value:(y=Rm(Tm().mark((function e(t){var r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(WG.info("updateToken()","newToken: %o",t),this._token=t,this._context.appId&&null!==(r=this._userInfo)&&void 0!==r&&r.userId&&this._roomId){e.next=4;break}return e.abrupt("return");case 4:return i={roomId:this._roomId,userId:null===(n=this._userInfo)||void 0===n?void 0:n.userId,appId:this._context.appId,token:"Bearer ".concat(t)},e.prev=5,e.next=8,null===(o=this._dataChannelSignal)||void 0===o?void 0:o.sendSignaling("updateToken",i);case 8:if(200===(null==(a=e.sent)?void 0:a.code)){e.next=11;break}throw new mA(pA.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 11:e.next=16;break;case 13:throw e.prev=13,e.t0=e.catch(5),new mA(pA.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 16:case"end":return e.stop()}}),e,this,[[5,13]])}))),function(e){return y.apply(this,arguments)})},{key:"unpublish",value:(m=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return WG.info("unpublish()","localStream: %o",t),n={roomId:this._roomId,initStreamId:t.initStreamId,streamId:t.streamId},null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unpublish",n),i=t.vendorHandler||this._handler,e.next=6,null==i?void 0:i.handleAck({action:lF.unpublish,audioMid:t.audioMid,videoMid:t.videoMid,stream:t,streamId:t.streamId});case 6:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"subscribe",value:(_=Rm(Tm().mark((function e(t,r,n){var i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Y_(function(){var e=Rm(Tm().mark((function e(o,a){var s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,D,N,M,P,L,U,V,F,B,j,G,H,z,K,X,W,q,Y,J,Q,Z,$;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.streamState!==aF.SUB_ED){e.next=2;break}return e.abrupt("return",i._updateSubTrack(t,r,gG.SUB).then(o,a));case 2:if(t.streamState!==aF.SUB_ING){e.next=7;break}return i._subStreamQueue[t.streamId]||(i._subStreamQueue[t.streamId]=[]),WG.info("_subStreamQueue","streamId: %o, enqueue",t.streamId),i._subStreamQueue[t.streamId].push({fn:i.subscribe,args:[t,r,n],resolve:o,reject:a}),e.abrupt("return");case 7:if(WG.info("subscribe()","mediaType: %o",r),JG("subscribe()",t),t.streamState=aF.SUB_ING,c=!1,u=!1,wD(r)&&(u=!0),CD(r)&&(c=!0),c||!i.multiChatMode()){e.next=17;break}return t.streamState=aF.INIT,i.emit("SUB_END",t.streamId),e.abrupt("return",o(null));case 17:if(d=lD(),l=t.subVideo,h=[],p=!i.multiChatMode(),i._subResolves[t.streamId]||(i._subResolves[t.streamId]=[]),h.push(new Y_((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mA(pA.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),qG);t.on("ontrack",(function r(i){"video"===i.mediaType&&(WG.success("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p&&h.push(new Y_((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mA(pA.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),qG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(WG.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v=function(e){t.ontrack(e)},null===(s=i._handler)||void 0===s||s.on("ontrack",v),i._ontrackCallbackMap.set(t,v),f=i._handler,e.prev=28,null!==(_=i._context.serverConfig)&&void 0!==_&&_.forceUniHandler||!t.enableVendorMode){e.next=42;break}return V=new OG(i._context,""),t.vendorHandler=new EG(i._context,V),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),(f=t.vendorHandler).on("ontrack",v),e.next=37,t.vendorHandler.subscribe(t);case 37:U=e.sent,f.on("ice_state",(function(e){i.emit(dG.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:ll.CONNECTION_STATE_CONNECTING,connected:ll.CONNECTION_STATE_CONNECTED,disconnected:ll.CONNECTION_STATE_RECONNECTING}[e],userId:t.userId})})),V.once("disconnect",Rm(Tm().mark((function e(){var r,n,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=f)||void 0===r||r.removeAllListeners(),"connected"===(null===(n=i._handler)||void 0===n||null===(o=n.pc)||void 0===o?void 0:o.iceConnectionState)){e.next=4;break}return WG.error("vendor ice failed",t.streamId),e.abrupt("return");case 4:return t.resetHasSubscribed(),i.unsubscribe(t,ul.AUDIO_AND_VIDEO,!0),e.next=8,i.subscribe(t,t.subMediaType);case 8:i.emit(_G.RESUBSCRIBE,{stream:t});case 9:case"end":return e.stop()}}),e)})))),e.next=45;break;case 42:return e.next=44,null===(F=i._handler)||void 0===F?void 0:F.subscribe(t,{multiChatMode:i.multiChatMode()});case 44:U=e.sent;case 45:if(null===(m=t.observer)||void 0===m||m.setHandler(f),U){e.next=48;break}throw new mA(pA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 48:return B=U.audioMid,j=U.videoMid,t.subVideo=c,G={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},H={audio:!i.multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:j,audioMid:B,sdpInfo:{sdp:null===(y=U)||void 0===y?void 0:y.partialSdp,semantics:null===(g=U)||void 0===g?void 0:g.semantics,type:null===(S=U)||void 0===S?void 0:S.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!i.multiChatMode()||u,video:c},qualityLayer:G},extra:{enableSendRTT:!0},peerConnectionMode:null===(b=U)||void 0===b?void 0:b.peerConnectionMode,supportMultiVendor:!0},null!==(E=U)&&void 0!==E&&E.peerConnectionId&&(H.peerConnectionId=U.peerConnectionId),z=i._context||{},K=z.subscribeFallbackOption,X=z.userPriority,"number"==typeof K&&(H.config.fallbackOption=K),X.has(t.userId)&&(H.config.priority=X.get(t.userId)),null!==(k=U)&&void 0!==k&&k.allSsrc&&(H.extra.subscribeSSRC=U.allSsrc),e.next=60,null===(T=i._dataChannelSignal)||void 0===T?void 0:T.sendSignaling("subscribe",H);case 60:if(200===(null==(W=e.sent)?void 0:W.code)){e.next=63;break}throw new mA(pA.SUBSCRIBE_FAILED,(null==W?void 0:W.message)||"subscribe failed");case 63:return q=null==W?void 0:W.relayMessage,Y=q.audioMid,J=q.videoMid,Jd(I={},B,Y),Jd(I,j,J),Q=I,WG.info("sub midmap",t.userId,Q),t.videoMid=j,t.audioMid=B,t.subMediaType=r,t.streamState=aF.SUB_ED,t.subLayer=G,null===(R=i._monitor)||void 0===R||R.report("rtc_recv_answer",{error_code:0,answer_type:null==W||null===(A=W.relayMessage)||void 0===A?void 0:A.type,sequence_id:(null==W||null===(w=W.relayMessage)||void 0===w?void 0:w.sequenceId)||0,message:null==W||null===(C=W.relayMessage)||void 0===C?void 0:C.sdp,direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:(null===(x=f)||void 0===x?void 0:x.peerConnectionId)||""}),e.next=74,null===(O=f)||void 0===O?void 0:O.handleAck({action:lF.subscribe,streamId:t.streamId,audioMid:B,videoMid:j,audioTransceiverInit:null===(D=U)||void 0===D?void 0:D.audioTransceiverInit,videoTransceiverInit:null===(N=U)||void 0===N?void 0:N.videoTransceiverInit,signalingAck:{sdp:null==W||null===(M=W.relayMessage)||void 0===M?void 0:M.sdp,sequenceId:null==W||null===(P=W.relayMessage)||void 0===P?void 0:P.sequenceId},stream:t,sdp:U.sdp,generatorSsrc:!!U.allSsrc});case 74:return e.next=76,Y_.all(h);case 76:i.multiChatMode()||(t.subAudio=u),null===(L=i._monitor)||void 0===L||L.report("rtc_subscribe_stat",{result:"success",start:d,message:"unknown",stream_user_id:t.userId}),i._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return i.emit("onRemoteStreamStats",e)}),f),o(null),i.emit("SUB_END",t.streamId),e.next=92;break;case 83:return e.prev=83,e.t0=e.catch(28),e.t0 instanceof Error&&(null===($=i._monitor)||void 0===$||$.report("rtc_subscribe_stat",{result:"fail",start:d,message:e.t0.message,stream_user_id:t.userId})),t.subVideo=l,t.streamState=aF.INIT,e.next=90,null===(Z=f)||void 0===Z?void 0:Z.rollback(t.streamId,t);case 90:a(e.t0),i.emit("SUB_END",t.streamId);case 92:case"end":return e.stop()}}),e,null,[[28,83]])})));return function(t,r){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e)}))),function(e,t,r){return _.apply(this,arguments)})},{key:"_handleSubStreamQueue",value:function(e){var t,r=this;if(null!==(t=this._subStreamQueue[e])&&void 0!==t&&t.length){WG.info("_subStreamQueue","streamId: %o, exec",e);var n=this._subStreamQueue[e].shift(),i=n.fn,o=n.args,a=n.resolve,s=n.reject;i.apply(this,o).then(a,s).finally((function(){return r._handleSubStreamQueue(e)}))}else WG.warn("_subStreamQueue","streamId: %o, END",e)}},{key:"controlMessage",value:(f=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return WG.info("controlMessage()","params: %o",t),n=t,"transcode"===t.type&&(n.roomId=this._roomId),e.next=5,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("controlMessage",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"updateUserAttributes",value:(v=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return WG.info("updateUserAttributes()","attributes: %o",t),e.next=3,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateUserAttributes",{roomId:this._roomId,sessionId:this._sessionId,attributes:t});case 3:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"updateSubTrack",value:(p=Rm(Tm().mark((function e(t,r,n){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._updateSubTrack(t,r,n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return p.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(h=Rm(Tm().mark((function e(t,r){var n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(WG.info("updateSubTrack()","subLayer: %o",r),t.subLayer.spatialLayer!==r.spatialLayer||t.subLayer.spatialSubLayer!==r.spatialSubLayer){e.next=4;break}return WG.warn("updateSubTrack()","subLayer no change"),e.abrupt("return");case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{qualityLayer:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(o=e.sent)?void 0:o.code)){e.next=10;break}throw new mA(pA.UPDATE_TRACK_FAILED,(null==o?void 0:o.message)||"update track failed");case 10:return t.subLayer=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"updateSubPriority",value:(l=Rm(Tm().mark((function e(t,r){var n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(WG.info("updateSubPriority()","priority: %o",r),t.priority!==r){e.next=4;break}return WG.warn("updateSubPriority()","priority no change"),e.abrupt("return",t);case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{priority:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(o=e.sent)?void 0:o.code)){e.next=10;break}throw new mA(pA.UPDATE_TRACK_FAILED,(null==o?void 0:o.message)||"update track failed");case 10:return t.priority=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"_updateSubTrack",value:(d=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(WG.info("updateSubTrack()","mediaType: %o",r),JG("updateSubTrack()",t),!this.multiChatMode()||r!==ul.AUDIO){e.next=5;break}return WG.warn("updateSubTrack","multiChatMode mediaType only audio"),e.abrupt("return",t);case 5:return a=0,a=n===gG.SUB?t.subMediaType|r:t.subMediaType-(t.subMediaType&r),WG.info("updateSubTrack","prev: %o, direction: %o, mediaType: %o, newMediaType: %o",t.subMediaType,n,r,a),t.subMediaType===a&&WG.info("updateSubTrack","mediaType no change"),s=!1,c=!1,wD(a)&&(c=!0),CD(a)&&(s=!0),u={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:s,audio:!!this.multiChatMode()||c}}},e.next=15,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("updateSubscribe",u);case 15:if(200===(null==(d=e.sent)?void 0:d.code)){e.next=18;break}throw new mA(pA.UPDATE_TRACK_FAILED,(null==d?void 0:d.message)||"update track failed");case 18:return this.multiChatMode()||(null===(l=t.observer)||void 0===l||l.setUnmuteAudio(c),t.subAudio=c),null===(o=t.observer)||void 0===o||o.setUnmuteVideo(s),t.subVideo=s,t.subMediaType=a,e.abrupt("return",t);case 23:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return d.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(u=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return WG.info("subscribe4pushTrack()","streamInfo: %o",r),JG("subscribe4pushTrack()",t),t.subAudio=!0,e.next=5,null===(n=this._handler)||void 0===n?void 0:n.subscribe(t,{multiChatMode:this.multiChatMode()});case 5:if(a=e.sent){e.next=8;break}throw new mA(pA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 8:return s=a.audioMid,c=a.videoMid,(u=[]).push(new Y_((function(e,r){var n=setTimeout((function(){return r(new mA(pA.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),qG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(WG.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),d=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",d),this._ontrackCallbackMap.set(t,d),e.next=17,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:lF.pushtrack,streamId:t.streamId,audioMid:s,videoMid:c,stream:t,audioTransceiverInit:null==a?void 0:a.audioTransceiverInit,videoTransceiverInit:null==a?void 0:a.videoTransceiverInit,signalingAck:null==r?void 0:r.message,sdp:a.sdp});case 17:return e.next=19,Y_.all(u);case 19:this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return l.emit("onRemoteStreamStats",e)}),this._handler);case 20:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(c=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(JG("unsubscribe4removeTrack()",t),WG.info("unsubscribe4removeTrack()","sequenceId: ",r.sequenceId,"trackType: ",n),!(r.sequenceId<t.sequenceId)){e.next=5;break}return WG.warn("unsubscribe4removeTrack()","sequenceId return"),e.abrupt("return");case 5:return u=!!((c=n+1)&ul.AUDIO),d=!!(c&ul.VIDEO),e.next=10,null===(i=this._handler)||void 0===i?void 0:i.handleAck({action:lF.removetrack,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 10:null===(o=t.observer)||void 0===o||o.setPushTrack(!1),null===(a=t.observer)||void 0===a||a.setUnmuteAudio(!u),t.subAudio=!u,null===(s=t.observer)||void 0===s||s.setUnmuteVideo(!d),t.subVideo=!d,t.subMediaType=t.subMediaType-(t.subMediaType&c),t.virtual&&(t.clean(),t.resetHasSubscribed(),t.statsReport.unsubscribe());case 17:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return c.apply(this,arguments)})},{key:"unsubscribe",value:(s=Rm(Tm().mark((function e(t,r){var n,i,o=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>2&&void 0!==o[2]&&o[2],JG("unsubscribe()",t),!n){e.next=4;break}return e.abrupt("return",this._unsubscribe(t,r));case 4:if(!this.multiChatMode()||!CD(r)){e.next=6;break}return e.abrupt("return",this._unsubscribe(t,r));case 6:if(i=t.subMediaType-(t.subMediaType&r),this.multiChatMode()||i!==GV.NONE){e.next=9;break}return e.abrupt("return",this._unsubscribe(t,r));case 9:return e.abrupt("return",this._updateSubTrack(t,r,gG.UNSUB));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"_unsubscribe",value:(a=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subConfig.muteReplaceUnsub){e.next=2;break}return e.abrupt("return",this._updateSubTrack(t,r,gG.UNSUB));case 2:return a={roomId:this._roomId,streamId:t.streamId,userId:t.userId},s=t.vendorHandler||this.handler,null===(n=this._dataChannelSignal)||void 0===n||n.sendSignaling("unsubscribe",a).catch((function(){})),t.streamState=aF.INIT,this._subStreamQueue[t.streamId]&&(this._subStreamQueue[t.streamId].forEach((function(e){return(0,e.resolve)(null)})),delete this._subStreamQueue[t.streamId]),t.subVideo=!1,null===(i=t.observer)||void 0===i||i.setSubscribeVideo(!1),!this.multiChatMode()&&(null===(o=t.observer)||void 0===o||o.setSubscribeAudio(!1)),e.next=12,null==s?void 0:s.handleAck({action:lF.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 12:c=e.sent,this._subResolves[c]&&this._subResolves[c].forEach((function(e){return e(0)})),WG.info("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 18:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"removeOnTrackListener",value:function(e){var t=this._ontrackCallbackMap.get(e);if(t){var r=e.vendorHandler||this._handler;null==r||r.off("ontrack",t),this._ontrackCallbackMap.delete(e)}}},{key:"handleRemoveStream",value:(o=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(JG("handleRemoveStream()",t),t.subVideo=!1,t.streamState!==aF.INIT){e.next=4;break}return e.abrupt("return");case 4:this.unsubscribe(t,ul.AUDIO_AND_VIDEO,!0);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"leave",value:(i=Rm(Tm().mark((function e(){var t,r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(WG.info("leave()"),this._stopJoinRoom5xxRetry(),this._joinRoomFailed("leave_room"),"connected"!==this.connectionState){e.next=20;break}return t={Authorization:this._authorization,roomId:this._roomId,sessionId:this._sessionId},e.next=7,this._joinLeaveLock.lock();case 7:return r=e.sent,e.prev=8,e.next=11,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("leaveRoom",t);case 11:r(),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(8),r(),e.t0;case 18:e.next=21;break;case 20:return e.abrupt("return",Y_.reject(new mA(pA.NOT_CONNECTED_YET,"server not connected")));case 21:case"end":return e.stop()}}),e,this,[[8,14]])}))),function(){return i.apply(this,arguments)})},{key:"subscribePublicStream",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this._handler)||void 0===r?void 0:r.subscribe(t,{multiChatMode:!1});case 2:if(s=e.sent){e.next=5;break}throw new mA(pA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return c=lD(),u=s.audioMid,d=s.videoMid,e.t0=this._context.appId,e.t1=t.streamId,e.t2=u,e.t3=d,e.t4={sdp:null==s?void 0:s.partialSdp,semantics:null==s?void 0:s.semantics,type:null==s?void 0:s.type},e.next=15,ZP();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=CN.VERSION,e.t8=EN.getDeviceId(),e.t9=this._context.appId,e.t10=this._businessId,e.t11=this._context.useCloudProxy,e.t12={supportedCodecs:e.t5,deviceType:"web",userAgent:e.t6,sdkVersion:e.t7,deviceId:e.t8,appId:e.t9,businessId:e.t10,enableCloudProxy:e.t11},e.t13={enableMediaType:{audio:!0,video:!0},qualityLayer:{spatialLayer:0,temporalLayer:0}},l={appId:e.t0,streamId:e.t1,audio:!0,video:!0,data:!0,audioMid:e.t2,videoMid:e.t3,sdpInfo:e.t4,params:e.t12,config:e.t13},e.next=27,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("startPullStream",l);case 27:return h=e.sent,p=[],this._subResolves[t.streamId]=[],p.push(new Y_((function(e,r){y._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mA(pA.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),qG);t.on("ontrack",(function r(i){"video"===i.mediaType&&(WG.success("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p.push(new Y_((function(e,r){y._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new mA(pA.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),qG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(WG.success("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",v),this._ontrackCallbackMap.set(t,v),f=null==h?void 0:h.relayMessage,_=f.sequenceId,m=f.sdp,t.videoMid=d,t.audioMid=u,t.sequenceId=_,t.streamState=aF.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=44,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:lF.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:{sdp:m,sequenceId:_},stream:t});case 44:return e.next=46,Y_.all(p);case 46:null===(a=this._monitor)||void 0===a||a.report("rtc_subscribe_stat",{result:"success",start:c,message:"unknown",stream_user_id:t.userId}),this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return y.emit("onRemoteStreamStats",e)}),this._handler);case 48:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unsubscribePublicStream",value:(r=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return JG("unsubscribePublicStream()",t),n={appId:this._context.appId,streamId:t.streamId},e.prev=2,e.next=5,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("stopPullStream",n);case 5:e.next=9;break;case 7:e.prev=7,e.t0=e.catch(2);case 9:return t.streamState=aF.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._handler)||void 0===r?void 0:r.handleAck({action:lF.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 14:t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;WG.info("destroy()"),this._joinRoomFailed("leave_room"),this._token=void 0,this._roomId=void 0,this._clientId=void 0,this._authorization=void 0,this._sessionId="",this._stopJoinRoom5xxRetry(),null===(e=this._handler)||void 0===e||e.destroy(),this._handler=void 0,null===(t=this._dataChannelSignal)||void 0===t||t.destroy(),this._dataChannelSignal=void 0,this._connectionManager.destroy(),null===(r=this._monitor)||void 0===r||r.set({connection_id:""}),this._removeSignalEventHandler(),this.removeAllListeners(),this.connectionState="disconnected"}},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendP2PMessage({to:e,from:this._userInfo.userId,room:this._roomId,app:this._context.appId,msg:t})}},{key:"sendRoomMessage",value:function(e){var t;return null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("customMessage",e)}},{key:"_joinRoomWithRetry",value:function(e,t,r){var n=this;return new Y_((function(i,o){n._dataChannelSignal.sendSignaling(e,t,void 0,1e4).then((function(e){n.emit("onJoinRoomAck",e),i(e)})).catch((function(a){if(r=r||new IG,a.code>=500&&a.code<600&&lD()-r.initTs<6e4){var s,c=r.getRetryDelay();return WG.warn("_joinRoomWithRetry",Om(s="joinRoom failed(code: ".concat(a.code,"), will retry after ")).call(s,c,"ms")),void(n._joinRoom5xxTimer=window.setTimeout((function(){delete n._joinRoom5xxTimer,n._joinRoomWithRetry(e,t,r).then(i).catch(o)}),c))}o(a)}))}))}},{key:"_stopJoinRoom5xxRetry",value:function(){this._joinRoom5xxTimer&&(clearTimeout(this._joinRoom5xxTimer),delete this._joinRoom5xxTimer)}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n,i;WG.info("connectStateChange","connected"),e.connectionState="connected",null===(r=e._dataChannelSignal)||void 0===r||r.destroy(),null===(n=e._handler)||void 0===n||n.destroy(),e._handler=oG(e._context,t.pc),e._dataChannelSignal=t.signaling,e.supportConcurrent="chrome"===(null===(i=e._handler)||void 0===i?void 0:i.name),e._addSignalEventHandler(),e.isReconnecting&&(e._reportJoinRoomStart(),e._callJoinRoom(!0))})),this._connectionManager.on("disconnected",(function(t){e.connectionState="disconnected",WG.error("connectStateChange","disconnected. %o",t),e.isReconnecting&&e.safeEmit(_G.RECONNECT_FAILED)})),this._connectionManager.on("connecting",(function(){var t;e.isReconnecting=!1,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e.connectionState="connecting",WG.info("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(){var t;e.connectionState="disconnected",e.isReconnecting=!0,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e.connectionState="connecting",WG.warn("connectStateChange","reconnecting"),e.safeEmit("reconnecting")})),this._connectionManager.on("connectWidthTcp",(function(){e.safeEmit(_G.ON_ICE_CONNECT_WITH_TCP)})),["__onGetIceConfigHook","__onIceConnectSuccessHook"].forEach((function(t){e._connectionManager.on(t,(function(){return e.emit(t)}))}))}},{key:"_reportJoinRoomStart",value:function(){var e;this._joinRoomStartTs=lD(),this.emit("__joinRoomStartReport"),null===(e=this._monitor)||void 0===e||e.report("join_room",{type:"begin",start:this._joinRoomStartTs,result:!1,reason:""},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC})}},{key:"_joinRoomSuccess",value:function(e){var t,r;(this._joinReject&&this._joinResolve&&(this._joinResolve(e),delete this._joinReject,delete this._joinResolve),this._joinRoomStartTs)&&(this.emit("__joinRoomSuccessReport"),null===(t=this._monitor)||void 0===t||t.report("join_room",{type:"end",start:this._joinRoomStartTs,result:!0,reason:""},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC}),null===(r=this._monitor)||void 0===r||r.report("rtc_join_room",{error_code:0,deviceModel:"web",deviceManufacturer:"web",elapse:lD()-this._joinRoomStartTs}),delete this._joinRoomStartTs)}},{key:"_joinRoomFailed",value:function(e,t){var r;(this._joinReject&&this._joinResolve&&(this._joinReject(new mA(t||pA.JOIN_ROOM_FAILED,e)),delete this._joinReject,delete this._joinResolve),this._joinRoomStartTs)&&(this.emit("__joinRoomFailedReport"),null===(r=this._monitor)||void 0===r||r.report("join_room",{type:"end",start:this._joinRoomStartTs,result:!1,reason:e},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC}),delete this._joinRoomStartTs)}},{key:"multiChatMode",value:function(){var e;return null===(e=this._roomAttributes)||void 0===e?void 0:e.multiChatMode}},{key:"sendForwardStreamSignal",value:(t=Rm(Tm().mark((function e(t,r,n){var i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o={forwardStreamType:t,roomId:r},("start"===t||"update"===t)&&(o.dstRoomInfos=null==n?void 0:jm(n).call(n,(function(e){return{dstRoomId:e.roomId,dstToken:pD.token2auth(a._context.appId,e.roomId,a._clientId,e.token)}}))),e.abrupt("return",null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("forwardStream",o));case 4:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"handler",get:function(){return this._handler}},{key:"roomAttributes",get:function(){return this._roomAttributes},set:function(e){this._roomAttributes=e}},{key:"vendorConfig",get:function(){return this._vendorConfig}}]),T}(aM);function ZG(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var r,i,o,a=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._handler||"connected"!==this._state){e.next=6;break}for(r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=4,n.apply(this,i);case 4:e.next=7;break;case 6:throw new mA(pA.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 7:case"end":return e.stop()}}),e,this)}))),r}function $G(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var t,r,i,o,a=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._pubSubLock.lock();case 2:for(t=e.sent,this.supportConcurrent&&t(),e.prev=4,r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=8,n.apply(this,i);case 8:return e.abrupt("return",e.sent);case 9:return e.prev=9,this.supportConcurrent||t(),e.finish(9);case 12:case"end":return e.stop()}}),e,this,[[4,,9,12]])}))),r}XG([function(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var t,r,i,o,a=this,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=s.length,r=new Array(t),i=0;i<t;i++)r[i]=s[i];return o=!1,e.abrupt("return",new Y_(function(){var e=Rm(Tm().mark((function e(t,i){var s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a.on("INTERRUPT",(function(){o=!0,i(new mA(pA.OPERATION_CANCEL,"operation not finish when leave"))})),e.prev=1,e.next=4,n.apply(a,r);case 4:s=e.sent,t(s),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o||i(e.t0);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t,r){return e.apply(this,arguments)}}()));case 3:case"end":return e.stop()}}),e)}))),r}],QG.prototype,"join",1),XG([$G,ZG],QG.prototype,"publish",1),XG([$G,ZG],QG.prototype,"updatePubTrack",1),XG([$G,ZG],QG.prototype,"unpublish",1),XG([$G,ZG],QG.prototype,"subscribe",1),XG([ZG],QG.prototype,"controlMessage",1),XG([ZG],QG.prototype,"updateUserAttributes",1),XG([ZG],QG.prototype,"updateSubTrack",1),XG([ZG],QG.prototype,"updateSubTrackLayer",1),XG([ZG],QG.prototype,"updateSubPriority",1),XG([$G,ZG],QG.prototype,"subscribe4pushTrack",1),XG([$G,ZG],QG.prototype,"unsubscribe4removeTrack",1),XG([$G,ZG],QG.prototype,"unsubscribe",1),XG([ZG],QG.prototype,"handleRemoveStream",1),XG([$G],QG.prototype,"subscribePublicStream",1),XG([$G],QG.prototype,"unsubscribePublicStream",1);var eH,tH=function(){var e=Rm(Tm().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,v,f,_,m,y;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u="",d=-1,l="video"===t?null==n||null===(o=n.videoTrack)||void 0===o?void 0:o.getOrgTrack():null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.getOrgTrack(),h="video"===t?null==n||null===(s=n.videoTransceiver)||void 0===s?void 0:s.receiver:null==n||null===(c=n.audioTransceiver)||void 0===c?void 0:c.receiver,e.prev=5,e.t0=null==r?void 0:r.pc,!e.t0){e.next=11;break}return e.next=10,mL(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return v=e.t0,f=gE(p=v||[]).call(p,(function(e){return"inbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(_=e.sent,m=[],null==_||_.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==(null==v?void 0:v.length)||0===m.length){e.next=22;break}return e.next=21,mL(r.pc);case 21:y=e.sent;case 22:u=Pm({type:t,reports:jm(v).call(v,(function(e){return e.type})),reports2:m,pc:(null==r?void 0:r.pc)||null,track:(null==l?void 0:l.id)||null,bytes:null==f?void 0:f.bytesReceived,framesReceived:null==f?void 0:f.framesReceived,packetsReceived:null==f?void 0:f.packetsReceived,allReports:y}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Pm(e.t1);case 29:null==i||i.report("rtc_invoke_status",{sdk_api_name:"first_frame_recv_timeout",error_code:d,message:u,stream_id:(null==n?void 0:n.streamId)||"",stream_user_id:null==n?void 0:n.userId,elapse:0}),e.next=34;break;case 32:e.prev=32,e.t2=e.catch(0);case 34:case"end":return e.stop()}}),e,null,[[0,32],[5,25]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),rH=function(){var e=Rm(Tm().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,v,f,_,m,y;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u="",d=-1,l="video"===t?null==n||null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack("preprocessing"):null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.getTrack("preprocessing"),h="video"===t?null==n||null===(s=n.videoTransceiver)||void 0===s?void 0:s.sender:null==n||null===(c=n.audioTransceiver)||void 0===c?void 0:c.sender,e.prev=5,e.t0=null==r?void 0:r.pc,!e.t0){e.next=11;break}return e.next=10,mL(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return v=e.t0,f=gE(p=v||[]).call(p,(function(e){return"outbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(_=e.sent,m=[],null==_||_.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==v.length||0===m.length){e.next=22;break}return e.next=21,mL(r.pc);case 21:y=e.sent;case 22:u=Pm({type:t,reports:jm(v).call(v,(function(e){return e.type})),reports2:m,pc:(null==r?void 0:r.pc)||null,track:(null==l?void 0:l.id)||null,bytes:null==f?void 0:f.bytesSent,framesSent:null==f?void 0:f.framesSent,packetsSent:null==f?void 0:f.packetsSent,allReports:y}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Pm(e.t1);case 29:null==i||i.report("rtc_invoke_status",{sdk_api_name:"first_frame_send_timeout",error_code:d,message:u,stream_id:(null==n?void 0:n.streamId)||"",stream_user_id:null==n?void 0:n.userId,elapse:0}),e.next=34;break;case 32:e.prev=32,e.t2=e.catch(0);case 34:case"end":return e.stop()}}),e,null,[[0,32],[5,25]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),nH=new Pw("RecvFrameObserver",0),iH=function(e){NI(a,e);var t,r,n,i,o=QI(a);function a(e,t){var r;return Vl(this,a),Jd(tI(r=o.call(this)),"_audioEventSessionId",fD()),Jd(tI(r),"_videoEventSessionId",fD()),Jd(tI(r),"_handler",void 0),Jd(tI(r),"_stream",void 0),Jd(tI(r),"_firstAudioFrameTimer",void 0),Jd(tI(r),"_firstVideoFrameTimer",void 0),Jd(tI(r),"_transportDelayInterval",void 0),Jd(tI(r),"_transportDelay",void 0),Jd(tI(r),"_firstVideoFrameInterval",void 0),Jd(tI(r),"_firstAudioFrameInterval",void 0),Jd(tI(r),"_isScreen",!1),Jd(tI(r),"_audioFirstFrameState",0),Jd(tI(r),"_videoFirstFrameState",0),Jd(tI(r),"_timeout",1e4),Jd(tI(r),"_currentAudioRecv",{startTime:0,eventSessionId:0,type:"login"}),Jd(tI(r),"_currentVideoRecv",{startTime:0,eventSessionId:0,type:"login"}),Jd(tI(r),"_login",!1),Jd(tI(r),"_unMuteAudio",!1),Jd(tI(r),"_enableAudio",!1),Jd(tI(r),"_unMuteVideo",!1),Jd(tI(r),"_enableVideo",!1),Jd(tI(r),"_remoteUnmuteAudio",!1),Jd(tI(r),"_remoteUnmuteVideo",!1),Jd(tI(r),"_audioExternal",!1),Jd(tI(r),"_pushAudio",!1),Jd(tI(r),"_videoExternal",!1),Jd(tI(r),"_pushVideo",!1),Jd(tI(r),"_autoSubscribeVideo",!1),Jd(tI(r),"_autoSubscribeAudio",!1),Jd(tI(r),"_autoSubscribe",!1),Jd(tI(r),"_publishVideo",!1),Jd(tI(r),"_publishAudio",!1),Jd(tI(r),"_subscribeAudio",!1),Jd(tI(r),"_subscribeVideo",!1),Jd(tI(r),"_subscribe",!1),Jd(tI(r),"_pushTrack",!1),Jd(tI(r),"_multiChatMode",!1),Jd(tI(r),"_monitor",void 0),r._stream=e,r._handler=t,r.getTransportDelay(),r._monitor=VO(e.engineId),r}return Ul(a,[{key:"beginRecvFrame",value:(i=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:i=this._transportDelay,o=!0,xE(n=["login","unmute","subscribe","push_track"]).call(n,r)>=0&&(i=0,o=!1),"audio"===t?(o||this._audioEventSessionId++,this._currentAudioRecv={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:r},p={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(a=this._stream)||void 0===a||!a.isScreen),start:null===(s=this._currentAudioRecv)||void 0===s?void 0:s.startTime,event_session_id:this._audioEventSessionId,stream_user_id:null===(c=this._stream)||void 0===c?void 0:c.userId,transport_delay:i,vendor_mode:(null===(u=this._stream)||void 0===u?void 0:u.vendorCode)||0,pc_session_id:(null===(d=this._stream)||void 0===d?void 0:d.pcSessionId)||(null===(l=this._handler)||void 0===l?void 0:l.peerConnectionId)},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){tH("audio",E._handler,E._stream,E._monitor),E.stopRecvFrame("audio","timeout"),E._firstAudioFrameInterval&&window.clearInterval(E._firstAudioFrameInterval)}),this._timeout),nH.info("rtcFirstFrameRecv",Pm(p)),null===(h=this._monitor)||void 0===h||h.report("rtc_first_frame",p),this._watchForFirstAudioFrameRecv(),this._audioFirstFrameState=1,this._login=!0,this._unMuteAudio=!0,this._enableAudio=!0,this._remoteUnmuteAudio=!0):"video"===t&&(o||this._videoEventSessionId++,this._currentVideoRecv={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:r},b={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(v=this._stream)||void 0===v||!v.isScreen),start:null===(f=this._currentVideoRecv)||void 0===f?void 0:f.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,transport_delay:i,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(y=this._stream)||void 0===y?void 0:y.pcSessionId)||(null===(g=this._handler)||void 0===g?void 0:g.peerConnectionId)},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){tH("video",E._handler,E._stream,E._monitor),E.stopRecvFrame("video","timeout"),E._firstVideoFrameInterval&&window.clearInterval(E._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),nH.info("rtcFirstFrameRecv",Pm(b)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",b),this._videoFirstFrameState=1,this._login=!0,this._unMuteVideo=!0,this._enableVideo=!0,this._remoteUnmuteVideo=!0);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"stopRecvFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c,u;if(1!==this._audioFirstFrameState)return;var d={event_type:"recv_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioRecv)||void 0===n?void 0:n.startTime,reason:t,result:!1,stream_user_id:null===(i=this._stream)||void 0===i?void 0:i.userId,event_session_id:this._audioEventSessionId,type:null===(o=this._currentAudioRecv)||void 0===o?void 0:o.type,vendor_mode:(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,pc_session_id:(null===(s=this._stream)||void 0===s?void 0:s.pcSessionId)||(null===(c=this._handler)||void 0===c?void 0:c.peerConnectionId)};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,nH.info("rtcFirstFrameRecv",Pm(d)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",d),this._audioFirstFrameState=2}else if("video"===e){var l,h,p,v,f,_,m,y;if(1!==this._videoFirstFrameState)return;var g={event_type:"recv_end",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),start:null===(h=this._currentVideoRecv)||void 0===h?void 0:h.startTime,reason:t,result:!1,stream_user_id:null===(p=this._stream)||void 0===p?void 0:p.userId,event_session_id:this._videoEventSessionId,type:null===(v=this._currentVideoRecv)||void 0===v?void 0:v.type,vendor_mode:(null===(f=this._stream)||void 0===f?void 0:f.vendorCode)||0,pc_session_id:(null===(_=this._stream)||void 0===_?void 0:_.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId)};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,nH.info("rtcFirstFrameRecv",Pm(g)),null===(y=this._monitor)||void 0===y||y.report("rtc_first_frame",g),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:if(r=this._transportDelay,"audio"!==t){e.next=19;break}if(1===this._audioFirstFrameState){e.next=6;break}return e.abrupt("return");case 6:if(this._currentAudioRecv){e.next=8;break}return e.abrupt("return");case 8:d=this._currentAudioRecv,l=d.type,h=d.startTime,xE(n=["login","unmute","subscribe","push_track"]).call(n,l)>=0&&(r=0),p={event_type:"recv_end",media_type:t,start:h,result:!0,is_screen:!(null===(i=this._stream)||void 0===i||!i.isScreen),stream_user_id:null===(o=this._stream)||void 0===o?void 0:o.userId,event_session_id:this._audioEventSessionId,type:l,transport_delay:r,vendor_mode:(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,pc_session_id:(null===(s=this._stream)||void 0===s?void 0:s.pcSessionId)||(null===(c=this._handler)||void 0===c?void 0:c.peerConnectionId)},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),nH.info("rtcFirstFrameRecv",Pm(p)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",p),this.emit("recvAudioFirstFrame"),this._audioFirstFrameState=3,e.next=33;break;case 19:if("video"!==t){e.next=33;break}if(1===this._videoFirstFrameState){e.next=22;break}return e.abrupt("return");case 22:if(this._currentVideoRecv){e.next=24;break}return e.abrupt("return");case 24:b=this._currentVideoRecv,E=b.type,k=b.startTime,xE(v=["login","unmute","subscribe","push_track"]).call(v,E)>=0&&(r=0),T={event_type:"recv_end",media_type:t,is_screen:!(null===(f=this._stream)||void 0===f||!f.isScreen),start:k,result:!0,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,event_session_id:this._videoEventSessionId,type:E,transport_delay:r,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(y=this._stream)||void 0===y?void 0:y.pcSessionId)||(null===(g=this._handler)||void 0===g?void 0:g.peerConnectionId)},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),nH.info("rtcFirstFrameRecv",Pm(T)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",T),this.emit("recvVideoFirstFrame"),this._videoFirstFrameState=3;case 33:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setLogin",value:function(e){var t,r,n,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0,video:!0};this._login!==e&&(this._login=e,e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&o.audio&&this.beginRecvFrame("audio","login"),e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&o.video&&this.beginRecvFrame("video","login"),!e&&null!==(n=this._stream)&&void 0!==n&&n.hasAudio&&this.stopRecvFrame("audio","leave_room"),!e&&null!==(i=this._stream)&&void 0!==i&&i.hasVideo&&this.stopRecvFrame("video","leave_room"))}},{key:"setUnmuteAudio",value:function(e){var t,r,n;if(this._unMuteAudio!==e){this._unMuteAudio=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasAudio);null!==(r=this._stream)&&void 0!==r&&r.audioHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.audioHasPublish&&(this._unMuteAudio&&i?this.beginRecvFrame("audio","unmute"):i&&this.stopRecvFrame("audio","mute"))}}},{key:"setRemoteUnmuteAudio",value:function(e){this._remoteUnmuteAudio!==e&&(this._remoteUnmuteAudio=e,this._remoteUnmuteAudio?this.beginRecvFrame("audio","remote_unmute"):this.stopRecvFrame("audio","remote_mute"))}},{key:"setEnableAudio",value:function(e){this._enableAudio!==e&&(this._enableAudio=e,this._enableAudio?this.beginRecvFrame("audio","enable"):this.stopRecvFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t,r,n;if(this._unMuteVideo!==e){this._unMuteVideo=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasVideo);null!==(r=this._stream)&&void 0!==r&&r.videoHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.videoHasPublish&&(this._unMuteVideo&&i?this.beginRecvFrame("video","unmute"):i&&this.stopRecvFrame("video","mute"))}}},{key:"setHandler",value:function(e){this._handler=e}},{key:"setRemoteUnmuteVideo",value:function(e){this._remoteUnmuteVideo!==e&&(this._remoteUnmuteVideo=e,this._remoteUnmuteVideo?this.beginRecvFrame("video","remote_unmute"):this.stopRecvFrame("video","remote_mute"))}},{key:"setEnableVideo",value:function(e){this._enableVideo!==e&&(this._enableVideo=e,this._enableVideo?this.beginRecvFrame("video","enable"):this.stopRecvFrame("video","disable"))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal=e}},{key:"setPushAudio",value:function(e){var t;this._audioExternal&&this._pushAudio!==e&&(this._pushAudio=e),this._pushAudio&&this.beginRecvFrame("audio","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.beginRecvFrame("audio","push")}},{key:"setExternalVideoSource",value:function(e){this._videoExternal=e}},{key:"setPushVideo",value:function(e){var t;this._videoExternal&&this._pushVideo!==e&&(this._pushVideo=e),this._pushVideo&&this.beginRecvFrame("video","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.beginRecvFrame("video","push")}},{key:"setPublishVideo",value:function(e){var t;this._publishVideo!==e&&(this._publishVideo=e),this._publishVideo&&this.beginRecvFrame("video","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unpublish")}},{key:"setPublishAudio",value:function(e){var t;this._publishAudio!==e&&(this._publishAudio=e),this._publishAudio&&this.beginRecvFrame("audio","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","unpublish")}},{key:"setAutoSubscribe",value:function(e){this._autoSubscribe=e}},{key:"setAutoSubscribeVideo",value:function(e){this._autoSubscribeVideo=e}},{key:"setAutoSubscribeAudio",value:function(e){this._autoSubscribeAudio=e}},{key:"setSubscribeAudio",value:function(e){var t,r;this._autoSubscribeAudio||this._subscribeAudio===e||(this._subscribe=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasAudio&&this.beginRecvFrame("audio","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","unsubscribe")}},{key:"setSubscribeVideo",value:function(e){var t,r;this._autoSubscribeVideo||this._subscribeVideo===e||(this._subscribeVideo=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&this.beginRecvFrame("video","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unsubscribe")}},{key:"setPushTrack",value:function(e){var t;this._pushTrack!==e&&(e&&!this._isScreen&&this.beginRecvFrame("audio","push_track"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","remove_track"))}},{key:"setMultiChatMode",value:function(e){this._multiChatMode=e}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"_watchForFirstVideoFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(Rm(Tm().mark((function n(){var i,o,a,s,c,u,d,l;return Tm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a||!a.getTrack()){n.next=12;break}return n.next=3,mL(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.videoTrack)||void 0===u?void 0:u.getTrack());case 3:if(d=n.sent,!(l=gE(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(l.framesReceived>t||l.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=l.framesReceived,r=l.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"_watchForFirstAudioFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(Rm(Tm().mark((function n(){var i,o,a,s,c,u,d,l;return Tm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a||!a.getOrgTrack()){n.next=12;break}return n.next=3,mL(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.getOrgTrack());case 3:if(d=n.sent,!(l=gE(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(l.totalSamplesReceived>t||l.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=l.totalSamplesReceived,r=l.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"getTransportDelay",value:(r=Rm(Tm().mark((function e(){var t=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelayIntl();case 2:window.clearInterval(this._transportDelayInterval),this._transportDelayInterval=window.setInterval(Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getTransportDelayIntl();case 2:case"end":return e.stop()}}),e)}))),2e3);case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getTransportDelayIntl",value:(t=Rm(Tm().mark((function e(){var t,r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc){e.next=7;break}return e.next=3,mL(null===(r=this._handler)||void 0===r?void 0:r.pc);case 3:n=e.sent,i=gE(n).call(n,(function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(o=gE(n).call(n,(function(e){return"candidate-pair"===e.type&&"succeeded"===e.state&&e.id===(null==i?void 0:i.selectedCandidatePairId)})))&&(this._transportDelay=Math.round(1e3*o.currentRoundTripTime/2));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"setDisconnect",value:function(){this.stopRecvFrame("audio","connection_lost"),this.stopRecvFrame("video","connection_lost"),this.reset()}},{key:"reset",value:function(){this._currentAudioRecv={startTime:0,eventSessionId:0,type:"login"},this._currentVideoRecv={startTime:0,eventSessionId:0,type:"login"},this._login=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._remoteUnmuteAudio=!1,this._remoteUnmuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoSubscribeVideo=!1,this._autoSubscribeAudio=!1,this._autoSubscribe=!1,this._subscribeAudio=!1,this._subscribeVideo=!1,this._subscribe=!1,this._pushTrack=!1,this._multiChatMode=!1,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._transportDelayInterval&&window.clearInterval(this._transportDelayInterval)}},{key:"audioFirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}},{key:"FirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}}]),a}(nM.exports.EventEmitter),oH=new Pw("SendFrameObserver",0),aH=function(){function e(t,r){Vl(this,e),Jd(this,"_audioEventSessionId",fD()),Jd(this,"_videoEventSessionId",fD()),Jd(this,"_pcSessionId",void 0),Jd(this,"_handler",void 0),Jd(this,"_firstAudioFrameTimer",void 0),Jd(this,"_firstVideoFrameTimer",void 0),Jd(this,"_stream",void 0),Jd(this,"_firstVideoFrameInterval",void 0),Jd(this,"_firstAudioFrameInterval",void 0),Jd(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:"login"}),Jd(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:"login"}),Jd(this,"_login",!1),Jd(this,"_publisher",!1),Jd(this,"_unMuteAudio",!1),Jd(this,"_enableAudio",!1),Jd(this,"_unMuteVideo",!1),Jd(this,"_enableVideo",!1),Jd(this,"_audioExternal",!1),Jd(this,"_pushAudio",!1),Jd(this,"_videoExternal",!1),Jd(this,"_pushVideo",!1),Jd(this,"_autoPublish",!1),Jd(this,"_publish",!1),Jd(this,"_timeout",1e4),Jd(this,"_audioFirstFrameState",0),Jd(this,"_videoFirstFrameState",0),Jd(this,"_monitor",void 0),this._stream=t,this._handler=r,this._monitor=VO(t.engineId)}var t,r;return Ul(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if("audio"===e){var n,i,o,a,s,c,u;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var d={event_type:"begin_send",media_type:e,is_screen:!(null===(n=this._stream)||void 0===n||!n.isScreen),type:t,start:this._currentAudioSend.startTime,event_session_id:this._audioEventSessionId,vendor_mode:(null===(i=this._stream)||void 0===i?void 0:i.vendorCode)||0,pc_session_id:(null===(o=this._stream)||void 0===o?void 0:o.pcSessionId)||(null===(a=this._handler)||void 0===a?void 0:a.peerConnectionId),capture_session_id:null===(s=this._stream)||void 0===s||null===(c=s.audioTrack)||void 0===c?void 0:c.captureSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){rH("audio",r._handler,r._stream,r._monitor),r.stopSendFrame("audio","timeout"),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),oH.info("rtcFirstFrameSend",Pm(d)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",d),this._watchForFirstAudioFrameSend(),this._audioFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteAudio=!0,this._pushAudio||(this._enableAudio=!0)}else if("video"===e){var l,h,p,v,f,_,m;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var y={event_type:"begin_send",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),type:t,start:this._currentVideoSend.startTime,event_session_id:this._videoEventSessionId,vendor_mode:(null===(h=this._stream)||void 0===h?void 0:h.vendorCode)||0,pc_session_id:(null===(p=this._stream)||void 0===p?void 0:p.pcSessionId)||(null===(v=this._handler)||void 0===v?void 0:v.peerConnectionId),capture_session_id:null===(f=this._stream)||void 0===f||null===(_=f.videoTrack)||void 0===_?void 0:_.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){rH("video",r._handler,r._stream,r._monitor),r.stopSendFrame("video","timeout"),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),oH.info("rtcFirstFrameSend",Pm(y)),null===(m=this._monitor)||void 0===m||m.report("rtc_first_frame",y),this._videoFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteVideo=!0,this._pushVideo||(this._enableVideo=!0)}}},{key:"stopSendFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c,u,d;if(1!==this._audioFirstFrameState)return;var l={event_type:"sent_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioSend)||void 0===n?void 0:n.startTime,reason:t,result:!1,event_session_id:this._audioEventSessionId,type:null===(i=this._currentAudioSend)||void 0===i?void 0:i.type,vendor_mode:(null===(o=this._stream)||void 0===o?void 0:o.vendorCode)||0,pc_session_id:(null===(a=this._stream)||void 0===a?void 0:a.pcSessionId)||(null===(s=this._handler)||void 0===s?void 0:s.peerConnectionId),capture_session_id:null===(c=this._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.captureSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,oH.info("rtcFirstFrameSend",Pm(l)),null===(d=this._monitor)||void 0===d||d.report("rtc_first_frame",l),this._audioFirstFrameState=2}else if("video"===e){var h,p,v,f,_,m,y,g,S;if(1!==this._videoFirstFrameState)return;var b={event_type:"sent_end",media_type:e,start:null===(h=this._currentVideoSend)||void 0===h?void 0:h.startTime,is_screen:!(null===(p=this._stream)||void 0===p||!p.isScreen),reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(v=this._currentVideoSend)||void 0===v?void 0:v.type,vendor_mode:(null===(f=this._stream)||void 0===f?void 0:f.vendorCode)||0,pc_session_id:(null===(_=this._stream)||void 0===_?void 0:_.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId),capture_session_id:null===(y=this._stream)||void 0===y||null===(g=y.videoTrack)||void 0===g?void 0:g.captureSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,oH.info("rtcFirstFrameSend",Pm(b)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",b),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if("audio"===e){var t,r,n,i,o,a,s;if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var c=this._currentAudioSend,u=c.type,d=c.startTime,l={event_type:"sent_end",media_type:e,is_screen:!(null===(t=this._stream)||void 0===t||!t.isScreen),start:d,result:!0,event_session_id:this._audioEventSessionId,type:u,vendor_mode:(null===(r=this._stream)||void 0===r?void 0:r.vendorCode)||0,pc_session_id:(null===(n=this._stream)||void 0===n?void 0:n.pcSessionId)||(null===(i=this._handler)||void 0===i?void 0:i.peerConnectionId),capture_session_id:null===(o=this._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a?void 0:a.captureSessionId};delete this._currentAudioSend,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),oH.info("rtcFirstFrameSend",Pm(l)),null===(s=this._monitor)||void 0===s||s.report("rtc_first_frame",l),this._audioFirstFrameState=3}else if("video"===e){var h,p,v,f,_,m,y;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var g=this._currentVideoSend,S=g.type,b=g.startTime,E={event_type:"sent_end",media_type:e,is_screen:!(null===(h=this._stream)||void 0===h||!h.isScreen),start:b,result:!0,event_session_id:this._videoEventSessionId,type:S,vendor_mode:(null===(p=this._stream)||void 0===p?void 0:p.vendorCode)||0,pc_session_id:(null===(v=this._stream)||void 0===v?void 0:v.pcSessionId)||(null===(f=this._handler)||void 0===f?void 0:f.peerConnectionId),capture_session_id:null===(_=this._stream)||void 0===_||null===(m=_.videoTrack)||void 0===m?void 0:m.captureSessionId};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),oH.info("rtcFirstFrameSend",Pm(E)),null===(y=this._monitor)||void 0===y||y.report("rtc_first_frame",E),this._videoFirstFrameState=3}}},{key:"setLogin",value:function(e){if(this._login!==e){var t,r;if(this._login=e,e)null!==(t=this._stream)&&void 0!==t&&t.videoTrack&&this.beginSendFrame("video","login"),null!==(r=this._stream)&&void 0!==r&&r.audioTrack&&this.beginSendFrame("audio","login");!e&&this._audioSending&&this.stopSendFrame("audio","leave_room"),!e&&this._videoSending&&this.stopSendFrame("video","leave_room")}}},{key:"setPublish",value:function(e){if(this._publish!==e){var t,r;if(this._publish=e,e)(null===(t=this._stream)||void 0===t?void 0:t.videoTrack)&&this._stream.pubVideo&&this.beginSendFrame("video","publish"),(null===(r=this._stream)||void 0===r?void 0:r.audioTrack)&&this._stream.pubAudio&&this.beginSendFrame("audio","publish");!e&&this._audioSending&&this.stopSendFrame("audio","unpublish"),!e&&this._videoSending&&this.stopSendFrame("video","unpublish")}}},{key:"setUnmuteAudio",value:function(e){var t;this._unMuteAudio!==e&&(this._unMuteAudio=e,null!==(t=this._stream)&&void 0!==t&&t.audioHasCapture&&(e&&this.beginSendFrame("audio","unmute"),!e&&this._audioSending&&this.stopSendFrame("audio","mute")))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubAudio&&(this._enableAudio=e,e&&this.beginSendFrame("audio","enable"),!e&&this._audioSending&&this.stopSendFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t;this._unMuteVideo!==e&&(this._unMuteVideo=e,null!==(t=this._stream)&&void 0!==t&&t.videoHasCapture&&(e&&this.beginSendFrame("video","unmute"),!e&&this._videoSending&&this.stopSendFrame("video","mute")))}},{key:"setEnableVideo",value:function(e){var t;this._enableVideo!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubVideo&&(this._enableVideo=e,e&&this.beginSendFrame("video","enable"),!e&&this._videoSending&&this.stopSendFrame("video","disable"))}},{key:"setPushAudio",value:function(e){this._pushAudio!==e&&(this._pushAudio=e,e&&this.beginSendFrame("audio","push"),!e&&this._audioSending&&this.stopSendFrame("audio","stop_push"))}},{key:"setPushVideo",value:function(e){this._pushVideo!==e&&(this._pushVideo=e,e&&this.beginSendFrame("video","push"),!e&&this._videoSending&&this.stopSendFrame("video","stop_push"))}},{key:"setAutoPublish",value:function(e){this._autoPublish=e}},{key:"setPublisher",value:function(e){this._publisher!==e&&(this._publisher=e,!e&&this._audioSending&&this.stopSendFrame("audio","audience"),!e&&this._videoSending&&this.stopSendFrame("video","audience"))}},{key:"setDisconnect",value:function(){this._audioSending&&this.stopSendFrame("audio","connection_lost"),this._videoSending&&this.stopSendFrame("video","connection_lost"),this.reset()}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"setPCSessionId",value:function(e){this._pcSessionId=e}},{key:"setHandler",value:function(e){this._handler=e}},{key:"_getFirstVideoFrameStats",value:(r=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.videoTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=6;break}return e.next=3,mL(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a?void 0:a.getTrack("preprocessing"));case 3:return s=e.sent,c=Gs(s).call(s,(function(e){return"outbound-rtp"===e.type})),e.abrupt("return",c);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.audioTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=5;break}return e.next=3,mL(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a?void 0:a.getTrack("preprocessing"));case 3:return s=e.sent,e.abrupt("return",gE(s).call(s,(function(e){return"outbound-rtp"===e.type})));case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_watchForFirstVideoFrameSend",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(Rm(Tm().mark((function n(){var i,o,a;return Tm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e._getFirstVideoFrameStats();case 2:if(i=n.sent,o=0,a=0,null==i||jm(i).call(i,(function(e){o+=e.framesSent,a+=e.packetsSent})),!(i&&i.length>0&&(o>t||a>r))){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=o,r=a,n.abrupt("return");case 10:e.sendFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),100)}},{key:"_watchForFirstAudioFrameSend",value:function(){var e=this,t=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(Rm(Tm().mark((function r(){var n;return Tm().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e._getFirstAudioFrameStats();case 2:if(!((n=r.sent)&&n.packetsSent>t)){r.next=9;break}if(-1!==t){r.next=7;break}return t=n.packetsSent,r.abrupt("return");case 7:e.sendFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 9:case"end":return r.stop()}}),r)}))),100)}},{key:"reset",value:function(){this._login=!1,this._publisher=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoPublish=!1,this._publish=!1,this._audioFirstFrameState=0,this._videoFirstFrameState=0,this._currentAudioSend={startTime:0,eventSessionId:0,type:"login"},this._currentVideoSend={startTime:0,eventSessionId:0,type:"login"},window.clearTimeout(this._firstAudioFrameTimer),window.clearTimeout(this._firstVideoFrameTimer),window.clearInterval(this._firstAudioFrameInterval),window.clearInterval(this._firstVideoFrameInterval)}},{key:"destroy",value:function(){this.reset(),delete this._stream,delete this._handler}},{key:"_audioSending",get:function(){return 1===this._audioFirstFrameState}},{key:"_videoSending",get:function(){return 1===this._videoFirstFrameState}}]),e}(),sH=(Jd(eH={},"audio",{delay:1200,stallRadio:.3}),Jd(eH,"video",{delay:1200,stallRadio:.6}),Jd(eH,"screen_audio",{delay:1600,stallRadio:.8}),Jd(eH,"screen_video",{delay:1600,stallRadio:.8}),eH),cH=function(){function e(){Vl(this,e),Jd(this,"_preUplinkStats",new $S),Jd(this,"_preDownlinkStats",new $S),Jd(this,"_timer",void 0),Jd(this,"_delayTimer",void 0),Jd(this,"_msc",void 0),Jd(this,"reportor",void 0)}return Ul(e,[{key:"updateUplinkStats",value:function(e){var t=e.audioStats,r=e.videoStats,n=e.isScreen;if(t.sendKBitrate>0&&t.rtt){var i,o,a=n?"screen_audio":"audio",s=t.rtt,c=t._fractionLost,u=t._retransmittedRate,d=this._getQosLevel(s,c||0,u||0),l=this._preUplinkStats.get(a)||[d];this._preUplinkStats.set(a,km(i=Om(o=[]).call(o,Jk(l),[d])).call(i,-2))}if(r.sentKBitrate>0&&r.rtt){var h,p,v=n?"screen_video":"video",f=r._fractionLost,_=r.rtt,m=r._sendBandWidth,y=r._retransmittedRate;0===m&&(f=Math.max(.65,f));var g=this._getQosLevel(_,f||0,y||0),S=this._preUplinkStats.get(v)||[g];this._preUplinkStats.set(v,km(h=Om(p=[]).call(p,Jk(S),[g])).call(h,-2))}this._startNetworkQualityReport()}},{key:"updateDownlinkStats",value:function(e,t){if(t){var r,n,i=this._getStreamActiveState(t),o=i.audioActive,a=i.videoActive,s=e.audioStats,c=e.videoStats,u=e.isScreen,d=e.userId;if(o)if(0===s.receivedKBitrate)r=gl.VBAD;else{var l=s.rtt,h=s.audioLossRate,p=s.stallDuration,v=s.statsInterval,f=s.e2eDelay,_=p/v,m=u?"screen_audio":"audio",y=this._getQosLevel(l,h||0,c._retransmittedRate||0),g=this._getDownlinkQoE(m,_,f);r=this._getNetworkQuality(y,g)}if(a)if(0===c.receivedKBitrate||0===c.rtt)n=gl.VBAD;else{var S=c.rtt,b=c.videoLossRate,E=c.stallDuration,k=c.statsInterval,T=c.e2eDelay,I=c._retransmittedRate,R=E/k,A=u?"screen_video":"video",w=this._getQosLevel(S,b||0,I||0),C=this._getDownlinkQoE(A,R,T);n=this._getNetworkQuality(w,C)}var x=r&&n?Math.ceil((r+n)/2):r||n;if(x){var O,D,N,M=Om(O="".concat(d)).call(O,u?"_screen":""),P=this._preDownlinkStats.get(M)||[x];this._preDownlinkStats.set(M,km(D=Om(N=[]).call(N,Jk(P),[x])).call(D,-2)),this._startNetworkQualityReport()}}}},{key:"setMSC",value:function(e){this._msc=e}},{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._delayTimer&&(window.clearTimeout(this._delayTimer),delete this._delayTimer),this._preUplinkStats.clear(),this._preDownlinkStats.clear()}},{key:"_startNetworkQualityReport",value:function(){var e=this;this._delayTimer||this._timer||(this._preUplinkStats.size>0||this._preDownlinkStats.size>0)&&(this._delayTimer=window.setTimeout((function(){delete e._delayTimer,e._reportNetworkQuality(),e._timer=window.setInterval((function(){e._reportNetworkQuality()}),2e3)}),300))}},{key:"_reportNetworkQuality",value:function(){var e,t,r,n,i,o=this;if(mk(e=["connected","connecting"]).call(e,null===(t=this._msc)||void 0===t||null===(r=t.handler)||void 0===r?void 0:r.getConnectionState())){var a,s,c,u=this._getBetterQualityAndRemoveOldest("audio","up"),d=this._getBetterQualityAndRemoveOldest("video","up");n=u&&d?Math.ceil((u+d)/2):u||d||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||gl.EXCELLENT;var l=Gs(a=jm(s=qk(sw(c=this._preDownlinkStats).call(c))).call(s,(function(e){return o._getBetterQualityAndRemoveOldest(e,"down")}))).call(a,(function(e){return e}));i=Math.ceil(pb(l).call(l,(function(e,t){return t+e}),0)/l.length)||gl.UNKNOWN}else n=i=gl.DOWN;navigator.onLine||(n=gl.DOWN,i=gl.DOWN),"function"==typeof this.reportor&&this.reportor(n,i)}},{key:"_getNetworkQuality",value:function(e,t){return 1===t?Math.max(e-2,1):2===t?e:Math.min(e+1,5)}},{key:"_getQosLevel",value:function(e,t,r){var n;return n=(!e||e<=250)&&t<=.15?1:(!e||e<=500)&&t<=.3?2:(!e||e<=750)&&t<=.45?3:(!e||e<=1e3)&&t<=.6?4:5,r>.5?n=Math.max(n,4):r>.35?n=Math.max(n,3):r>.15&&(n=Math.max(n,2)),n}},{key:"_getUplinkQoE",value:function(e,t){var r=0;switch(e){case"audio":case"video":r=t<.05?1:t<.1?2:3;break;case"screen_video":case"screen_audio":r=t<.04?1:t<.08?2:3}return r}},{key:"_getDownlinkQoE",value:function(e,t,r){var n=sH[e];return t>n.stallRadio||r>n.delay||t>n.stallRadio/2&&r>n.delay/2?3:(t>n.stallRadio/2||n.delay,2)}},{key:"_getBetterQualityAndRemoveOldest",value:function(e,t){var r=gl.UNKNOWN,n="up"===t?this._preUplinkStats:this._preDownlinkStats,i=n.get(e);if(i){var o=Gs(i).call(i,(function(e){return e}));o.length>0&&(r=Math.min.apply(Math,Jk(o))),i.shift(),0===i.length&&n.delete(e)}return r}},{key:"_getStreamActiveState",value:function(e){var t=e.subMediaType,r=e._attributes,n=e.subVideo;return{audioActive:e.subAudio&&wD(t)&&r.localaudio&&r.audiostream,videoActive:n&&CD(t)&&r.localvideo&&r.videostream}}}]),e}(),uH=function(){function e(t){Vl(this,e),Jd(this,"_timer",void 0),Jd(this,"_remoteVideoSizeCache",{}),Jd(this,"_remoteScreenSizeCache",{}),Jd(this,"onchange",void 0),this._room=t,this._start()}return Ul(e,[{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._remoteVideoSizeCache={},this._remoteScreenSizeCache={}}},{key:"_start",value:function(){var e=this;this._timer||(this._timer=window.setInterval((function(){var t={},r={};e._room.remoteStreams.forEach((function(n,i){n.forEach((function(n){var o,a=null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack();if(a){var s=n.isScreen?e._remoteScreenSizeCache:e._remoteVideoSizeCache,c=s[i]||{},u=c.width,d=void 0===u?0:u,l=c.height,h=void 0===l?0:l,p=a.getSettings(),v=p.width,f=void 0===v?0:v,_=p.height,m=void 0===_?0:_;h===m&&d===f||"function"==typeof e.onchange&&e.onchange(i,n.isScreen,f,m),delete s[i],(n.isScreen?r:t)[i]={width:f,height:m}}}))})),an(e._remoteVideoSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!1,0,0)})),an(e._remoteScreenSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),dH=qk((new TextEncoder).encode("subt")),lH={1:pA.SUBTITLE_ERR_POSTPROCESS,2:pA.SUBTITLE_ERR_CONNECTION_ERROR,3:pA.SUBTITLE_ERR_PROCESS_ERROR},hH=new Pw("SubtitleTool",1),pH=function(e){if(e.extraInfo)try{var t,r=JSON.parse(e.extraInfo);r.source_language&&xE(t=["zh","en","ja"]).call(t,r.source_language)}catch(a){}else{var n,i,o=(null===(n=navigator.language)||void 0===n?void 0:n.substring(0,2))||"";xE(i=["zh","en","ja"]).call(i,o)>-1&&(e.extraInfo=Pm({source_language:o}))}},vH=function(){function e(t){var r,n,i;Vl(this,e),Jd(this,"_taskId",void 0),Jd(this,"_appId",void 0),Jd(this,"_roomId",void 0),Jd(this,"_userId",void 0),Jd(this,"onEvent",void 0),Jd(this,"onMessage",void 0),Jd(this,"_preConfig",void 0),Jd(this,"_timer",void 0),this._room=t,this._appId=null===(r=this._room._roomInfo)||void 0===r?void 0:r.appId,this._roomId=null===(n=this._room._roomInfo)||void 0===n?void 0:n.roomId,this._userId=null===(i=this._room._roomInfo)||void 0===i?void 0:i.userInfo.userId}var t,r,n;return Ul(e,[{key:"start",value:(n=Rm(Tm().mark((function e(t){var r=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(hH.info("start","Invoke config: %o",t),VN(t.mode,"mode",[Rl.ASR_ONLY,Rl.ASR_AND_TRANSLATION]),t.mode!==Rl.ASR_AND_TRANSLATION||-1!==xE(_H).call(_H,t.targetLanguage||"")){e.next=4;break}throw new mA(pA.INVALID_PARAMS,"Invalid targetLanguage.");case 4:if(!this._taskId){e.next=6;break}throw new mA(pA.SUBTITLE_ALREADY_ON,"Already turned on subtitle");case 6:return this._preConfig=t,this._taskId=(Date.now().toString()+this._roomId+this._userId).substring(0,20),e.next=10,this._room.subtitleControlMessage(this._genSubtitleSignaling("started",t,this._taskId));case 10:this._preConfig=t,this._timer=self.setTimeout((function(){var e;null===(e=r.onEvent)||void 0===e||e.call(r,{event:Al.ERROR,errorCode:pA.TIME_OUT,errorMessage:"start subtitle timeout."}),delete r._timer,r.stop()}),3e4);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"update",value:(r=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(VN(t.mode,"mode",[Rl.ASR_ONLY,Rl.ASR_AND_TRANSLATION]),t.mode!==Rl.ASR_AND_TRANSLATION||-1!==xE(_H).call(_H,t.targetLanguage||"")){e.next=3;break}throw new mA(pA.INVALID_PARAMS,"Invalid targetLanguage.");case 3:if(!this._taskId){e.next=5;break}throw new mA(pA.SUBTITLE_ALREADY_ON,"Already started subtitle");case 5:if(this._taskId){e.next=7;break}throw new mA(pA.SUBTITLE_NOT_TURNED_ON,"Start subtitle first.");case 7:if((null===(r=this._preConfig)||void 0===r?void 0:r.mode)===t.mode&&this._preConfig.targetLanguage===t.targetLanguage){e.next=11;break}return this._preConfig=t,e.next=11,this._room.subtitleControlMessage(this._genSubtitleSignaling("update",t,this._taskId));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stop",value:function(){var e=this;hH.info("stop","Invoke"),this._taskId&&this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId}).finally((function(){var t;delete e._taskId,null===(t=e.onEvent)||void 0===t||t.call(e,{event:Al.STOPPED}),e._clearTimer()}))}},{key:"reconnect",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._taskId||!this._preConfig){e.next=5;break}return e.next=3,this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId});case 3:delete this._taskId,this.start(this._preConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getConfig",value:function(){return this._preConfig}},{key:"destroy",value:function(){hH.info("destroy","Invoke"),this.stop(),delete this._preConfig,delete this._taskId}},{key:"onResult",value:function(e){var t=e.body,r=t.error,n=t.errorMessage,i=t.eventType;if(0!==r){var o,a=new mA(lH[r]||pA.SUBTITLE_ERR_UNKNOWN,n||"");null===(o=this.onEvent)||void 0===o||o.call(this,{event:Al.ERROR,errorCode:a.code,errorMessage:a.message}),this._clearTimer()}else if("SubtitleStarted"===i){var s;null===(s=this.onEvent)||void 0===s||s.call(this,{event:Al.STARTED}),this._clearTimer()}}},{key:"onMessageRecv",value:function(e){if(this._taskId&&this._preConfig){var t=fH(e);if(t&&t.length>0){var r,n=this._preConfig,i=n.mode,o=n.targetLanguage,a=[];if(t.forEach((function(e){i===Rl.ASR_ONLY?e.mode===i&&a.push(e):i===Rl.ASR_AND_TRANSLATION&&(e.language!==o&&e.mode!==Rl.ASR_ONLY||a.push(e),e.mode===Rl.ASR_ONLY&&e.language===o&&a.push(Zd(Zd({},e),{},{mode:Rl.ASR_AND_TRANSLATION})))})),a.length>0)null===(r=this.onMessage)||void 0===r||r.call(this,a)}return!!t}return!1}},{key:"_genSubtitleSignaling",value:function(e,t,r){return{taskId:r,type:"subtitle",action:e,roomId:this._roomId,appId:this._appId,userId:this._userId,subtitleMeta:{subtitleConfig:{mode:t.mode,usersConfig:[{userId:this._userId,targetLanguages:[t.targetLanguage||""]}]},vendorConfig:{type:0}}}}},{key:"_clearTimer",value:function(){this._timer&&(self.clearTimeout(this._timer),delete this._timer)}}]),e}(),fH=function(e){var t=e.message;if(t instanceof ArrayBuffer&&t.byteLength>8)try{var r=new DataView(t,0),n=0;if(dH.every((function(e){return r.getUint8(n++)===e}))){var i=r.getUint32(n);if(n+=4,i===r.byteLength-8){var o=pD.ab2str(km(t).call(t,8)),a=JSON.parse(o),s=a.data;if("subtitle"===a.type)return s}}}catch(c){}return!1},_H=["zh","zh-Hant","tn","vi","iu","it","id","hi","en","ho","he","es","el","uk","ur","tk","tr","ti","ty","tl","to","th","ta","te","sl","sk","ss","eo","sm","sg","st","sv","ja","tw","qu","pt","pa","no","nb","nr","my","bn","mn","mh","mk","ml","mr","ms","lu","ro","lt","lv","lo","kj","hr","kn","ki","cs","ca","nl","ko","ht","gu","ka","kl","km","lg","kg","fi","fj","fr","ru","ng","de","tt","da","ts","cv","fa","bs","pl","bi","nd","ba","bg","az","ar","af","sq","ab","os","ee","et","ay","lzh","am","ckb","cy","gl","ha","hy","ig","kmr","ln","nso","ny","om","sn","so","sr","sw","xh","yo","zu"],mH=ad,yH=tc,gH=function(e,t,r,n){for(var i,o=n>1?void 0:n?yH(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&mH(t,r,o),o},SH=function(){function e(t){Vl(this,e),Jd(this,"_forwardDstRooms",new $S),Jd(this,"forwardStreamState","stopped"),Jd(this,"_monitor",void 0),this._room=t,this._monitor=VO(this._room.id)}var t,r,n,i,o,a;return Ul(e,[{key:"startForwardStream2Rooms",value:(a=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("running"!==this.forwardStreamState&&"paused"!==this.forwardStreamState){e.next=2;break}throw new mA(pA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke startForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("start",this._room.roomInfo.roomId,t);case 4:return r=e.sent,this._updateDstRooms(t,r),n=this._transformForwardStreamResult(r),this.forwardStreamState="running",e.abrupt("return",n);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(o=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new mA(pA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke updateForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:if(r=this._mockForwardStreamResult(t),"running"!==this.forwardStreamState){e.next=7;break}return e.next=6,this._sendForwardStreamSignaling("update",this._room._roomInfo.roomId,t);case 6:r=e.sent;case 7:return this._updateDstRooms(t,r),n=this._transformForwardStreamResult(r),e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(i=Rm(Tm().mark((function e(){var t,r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new mA(pA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke stopForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:if(r=this._mockForwardStreamResult([]),"running"!==this.forwardStreamState){e.next=7;break}return e.next=6,this._sendForwardStreamSignaling("stop",this._room._roomInfo.roomId);case 6:r=e.sent;case 7:if(this._updateDstRooms([],r),!(Jk(sw(t=this._forwardDstRooms).call(t)).length>0)){e.next=10;break}throw new mA(pA.UNEXPECTED_ERROR,"stopforwardstream failed: ".concat(Pm(r)));case 10:return n=this._transformForwardStreamResult(r),this.forwardStreamState="stopped",e.abrupt("return",n);case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"pauseForwardStream2AllRooms",value:(n=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("paused"!==this.forwardStreamState&&"stopped"!==this.forwardStreamState){e.next=2;break}throw new mA(pA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke pauseForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("stop",this._room._roomInfo.roomId);case 4:return t=e.sent,r=this._transformForwardStreamResult(t),this.forwardStreamState="paused",e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(r=Rm(Tm().mark((function e(){var t,r,n,i,o=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o.length>0&&void 0!==o[0]&&o[0]||!mk(t=["running","stopped"]).call(t,this.forwardStreamState)){e.next=3;break}throw new mA(pA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke resumeForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 3:return r=this._getDstRooms(),e.next=6,this._sendForwardStreamSignaling("start",this._room._roomInfo.roomId,r);case 6:return n=e.sent,this._updateDstRooms(r,n),i=this._transformForwardStreamResult(n),this.forwardStreamState="running",e.abrupt("return",i);case 11:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"resumeFromReconnect",value:function(){var e=this;"running"===this.forwardStreamState&&this.resumeForwardStream2AllRooms(!0).then((function(t){t.forEach((function(t){t.state===wl.FORWARD_STREAM_STATE_FAILURE&&e._room.safeEmit(_G.ON_FORWARD_STREAM_ERROR,t)}))}))}},{key:"onForwardDstRoomUserKick",value:function(e){var t=[{dstRoomId:e.dstRoomId,code:200,forwardStreamType:"stop"}];this._updateDstRooms([],t),this._room.safeEmit(_G.ON_FORWARD_STREAM_ERROR,{roomId:e.dstRoomId,state:wl.FORWARD_STREAM_STATE_FAILURE,error:Cl.FORWARD_STREAM_ERROR_REMOTE_KICKED})}},{key:"clear",value:function(){this._forwardDstRooms.clear(),this.forwardStreamState="stopped"}},{key:"_mockForwardStreamResult",value:function(e){var t=this,r=[];return this._forwardDstRooms.forEach((function(e,t){r.push({dstRoomId:t,forwardStreamType:"stop",code:200})})),e.forEach((function(e){var n,i=QR(r).call(r,(function(t){return t.dstRoomId===e.roomId}));-1===i?r.push({dstRoomId:e.roomId,forwardStreamType:"start",code:e.roomId===(null===(n=t._room.roomInfo)||void 0===n?void 0:n.roomId)?400:200}):r[i].forwardStreamType="update"})),r}},{key:"_transformForwardStreamResult",value:function(e){e||(e=[]);var t,r=[],n=$T(e);try{for(n.s();!(t=n.n()).done;){var i=t.value,o=i.dstRoomId,a=i.code,s={roomId:o,state:wl.FORWARD_STREAM_STATE_SUCCESS,error:Cl.FORWARD_STREAM_ERROR_OK};200===a||(400===a?(s.state=wl.FORWARD_STREAM_STATE_FAILURE,s.error=Cl.FORWARD_STREAM_ERROR_REMOTE_KICKED):a>=700&&a<800?(s.state=wl.FORWARD_STREAM_STATE_FAILURE,s.error=Cl.FORWARD_STREAM_ERROR_INVALID_TOKEN):(s.state=wl.FORWARD_STREAM_STATE_FAILURE,s.error=Cl.FORWARD_STREAM_ERROR_RESPONSE)),r.push(s)}}catch(c){n.e(c)}finally{n.f()}return r}},{key:"_updateDstRooms",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];0===(null==r?void 0:r.length)&&this._forwardDstRooms.clear(),r.forEach((function(r){var n=r.dstRoomId,i=r.code,o=r.forwardStreamType;if(200===i)if("stop"===o)t._forwardDstRooms.delete(n);else{var a,s=gE(e).call(e,(function(e){return e.roomId===n}));if(!s&&!t._forwardDstRooms.has(n))throw new mA(pA.UNEXPECTED_ERROR,"unknow roomid ".concat(n," in signaling return"));var c=null!==(a=t._forwardDstRooms.get(n))&&void 0!==a?a:{token:void 0};c=wb(c,s),t._forwardDstRooms.set(n,c)}else t._forwardDstRooms.has(n)&&t._forwardDstRooms.delete(n)}))}},{key:"_getDstRooms",value:function(){var e=[];return this._forwardDstRooms.forEach((function(t,r){e.push({roomId:r,token:t.token})})),e}},{key:"_sendForwardStreamSignaling",value:(t=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="".concat(fD()),"stop"!==t&&(a=jm(n).call(n,(function(e){return e.roomId})),null===(o=this._monitor)||void 0===o||o.report("rtc_forward_stream",{type:"begin",dst_rooms:"{ ".concat(jm(a).call(a,(function(e){return'"'.concat(e,'"')})).join(",")," }"),event_session_id:i})),e.next=4,this._room._mediaServerClient.sendForwardStreamSignal(t,r,n);case 4:if(s=e.sent,c=[],200===(null==s?void 0:s.code)){e.next=9;break}throw"stop"!==t&&(null==n||n.forEach((function(e){c.push({dst_room_id:e.roomId,result:"server error ".concat(null==s?void 0:s.code)})})),null===(u=this._monitor)||void 0===u||u.report("rtc_forward_stream",{type:"end",dst_rooms:Pm(c),event_session_id:i})),new mA(pA.UNEXPECTED_ERROR,"server side internal error, error code: ".concat(s));case 9:return"stop"!==t&&(null===(d=s.forwardStreamResults)||void 0===d||d.forEach((function(e){c.push({dst_room_id:e.dstRoomId,result:"dst room lost"})})),null===(l=s.forwardStreamResults)||void 0===l||l.forEach((function(e){var t=gE(c).call(c,(function(t){return t.dst_room_id===e.dstRoomId}));t&&(200===e.code?"update"===e.forwardStreamType?t.result="update":t.result="success":t.result="server error ".concat(e.code))})),null===(h=this._monitor)||void 0===h||h.report("rtc_forward_stream",{type:"end",dst_rooms:Pm(c),event_session_id:i})),e.abrupt("return",s.forwardStreamResults);case 11:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})}]),e}();function bH(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var r,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=this._room._roomInfo)||void 0===r||!r.roomId){e.next=7;break}for(i=s.length,o=new Array(i),a=0;a<i;a++)o[a]=s[a];return e.next=4,n.apply(this,o);case 4:return e.abrupt("return",e.sent);case 7:throw new mA(pA.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 8:case"end":return e.stop()}}),e,this)}))),r}gH([bH],SH.prototype,"startForwardStream2Rooms",1),gH([bH],SH.prototype,"updateForwardStream2Rooms",1),gH([bH],SH.prototype,"stopForwardStream2Rooms",1),gH([bH],SH.prototype,"pauseForwardStream2AllRooms",1),gH([bH],SH.prototype,"resumeForwardStream2AllRooms",1);var EH=new Pw("Room",1),kH={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1,publishTime:0},TH=function(e){NI(O,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x=QI(O);function O(e,t){var r;return Vl(this,O),Jd(tI(r=x.call(this)),"id",void 0),Jd(tI(r),"_mediaServerClient",void 0),Jd(tI(r),"_localStream",void 0),Jd(tI(r),"_localScreenStream",void 0),Jd(tI(r),"_remoteUsers",new $S),Jd(tI(r),"_remoteStreams",new $S),Jd(tI(r),"_remoteStreamStreamIdUserIdMap",{}),Jd(tI(r),"_virtualStreams",[]),Jd(tI(r),"_context",void 0),Jd(tI(r),"_sessionId",void 0),Jd(tI(r),"_connectionLostTimer",void 0),Jd(tI(r),"_serverConfig",void 0),Jd(tI(r),"_roomConfig",void 0),Jd(tI(r),"_roomInfo",void 0),Jd(tI(r),"_userDuplicateLoginTimerMap",new $S),Jd(tI(r),"_networkQualityManager",void 0),Jd(tI(r),"_videoSizeObserver",void 0),Jd(tI(r),"_hasPublished",!1),Jd(tI(r),"_subtitleTool",void 0),Jd(tI(r),"_csrcUserIdMap",void 0),Jd(tI(r),"_publishOnDemandItem",void 0),Jd(tI(r),"_onceTriggerBySignal",!1),Jd(tI(r),"_pubTransceiverReady",!1),Jd(tI(r),"_publishOnDemandBusy",!1),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_forwardStreamManager",void 0),EH.info("constructor","invoke"),r.id=t.id,r._roomConfig=e,r._mediaServerClient=new QG(t),r._networkQualityManager=new cH,r._networkQualityManager.reportor=r._reportNetworkQuality.bind(tI(r)),r._videoSizeObserver=new uH(tI(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(tI(r)),r._context=t,r._csrcUserIdMap={},r._monitor=VO(r.id),r._forwardStreamManager=new SH(tI(r)),r._addHandlerEventHandler(),r}return Ul(O,[{key:"hasScreenPublished",get:function(){var e;return null===(e=this._localScreenStream)||void 0===e?void 0:e.hasPublished}},{key:"hasPublished",get:function(){var e;return null===(e=this._localStream)||void 0===e?void 0:e.hasPublished}},{key:"connectionState",get:function(){return this._mediaServerClient.connectionState}},{key:"remoteUsers",get:function(){return this._remoteUsers}},{key:"remoteStreams",get:function(){return this._remoteStreams}},{key:"localStream",get:function(){return this._localStream}},{key:"localScreenStream",get:function(){return this._localScreenStream}},{key:"roomInfo",get:function(){return this._roomInfo}},{key:"roomConfig",set:function(e){this._roomConfig=e}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,D,N=this;null===(e=this._mediaServerClient)||void 0===e||e.on(cG.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on(cG.ON_ADD_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return N._onAddStream(e)}))})),null===(r=this._mediaServerClient)||void 0===r||r.on(cG.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(cG.ON_REMOVE_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return N._onRemoveStream(e)}))})),null===(i=this._mediaServerClient)||void 0===i||i.on(cG.USER_CONNECTION,this._onUserConnection.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(cG.USER_CONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return N._onUserConnection(e)}))})),null===(a=this._mediaServerClient)||void 0===a||a.on(cG.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(cG.USER_DISCONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return N._onUserDisconnection(e)}))})),null===(c=this._mediaServerClient)||void 0===c||c.on(cG.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(u=this._mediaServerClient)||void 0===u||u.on(cG.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(cG.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(cG.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(cG.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(cG.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(cG.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(cG.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(cG.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(cG.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(cG.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(cG.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(uG.RSCP,(function(e,t){!!gE(e).call(e,(function(e){var t,r,n;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:mk(t).call(t,null===(r=N._localStream)||void 0===r||null===(n=r.stream)||void 0===n?void 0:n.id)}))&&(t?N._pubTransceiverReady=!0:N._onceTriggerBySignal=!0,t&&N._onceTriggerBySignal||(N._publishOnDemandItem=e),N._pubTransceiverReady&&N._onPublishOnDemand())})),null===(b=this._mediaServerClient)||void 0===b||b.on(uG.RTT,this._onRTT.bind(this)),null===(E=this._mediaServerClient)||void 0===E||E.on(uG.SSC,this._onSSC.bind(this)),null===(k=this._mediaServerClient)||void 0===k||k.on(dG.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(T=this._mediaServerClient)||void 0===T||T.on(dG.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return N.emit(dG.ON_VENDOR_CONNECTION_STATE_CHANGE,e)})),null===(I=this._mediaServerClient)||void 0===I||I.on(cG.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),null===(R=this._mediaServerClient)||void 0===R||R.on("onRemoteStreamStats",(function(e){N._networkQualityManager.updateDownlinkStats(e,N._findRemoteStreamByScreen(e.userId,e.isScreen)),N.emit(_G.ON_REMOTE_STREAM_STATS,xD(e))})),null===(A=this._mediaServerClient)||void 0===A||A.on(_G.RESUBSCRIBE,(function(e){N.emit(_G.RESUBSCRIBE,e)})),null===(w=this._mediaServerClient)||void 0===w||w.on(_G.RECONNECT_FAILED,(function(){N.emit(_G.RECONNECT_FAILED)})),null===(C=this._mediaServerClient)||void 0===C||C.on("joinSuccess",this._onJoinSucc.bind(this)),null===(x=this._mediaServerClient)||void 0===x||x.on(cG.ON_FORWARD_DST_ROOM_USER_KICK,this._forwardStreamManager.onForwardDstRoomUserKick.bind(this._forwardStreamManager)),null===(O=this._mediaServerClient)||void 0===O||O.on(_G.ON_REJOIN_WITH_TCP,(function(){N.emit(_G.ON_REJOIN_WITH_TCP)})),null===(D=this._mediaServerClient)||void 0===D||D.on(_G.ON_ICE_CONNECT_WITH_TCP,(function(){N.emit(_G.ON_ICE_CONNECT_WITH_TCP)}))}},{key:"_onLocalStreamStats",value:function(e){this._networkQualityManager.updateUplinkStats(e),this.emit(_G.ON_LOCAL_STREAM_STATS,xD(e))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(C=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.connect();case 2:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"join",value:(w=Rm(Tm().mark((function e(t,r,n,i,o){var a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(a=this._monitor)||void 0===a||a.set({rtc_app_id:t,room_id:r,user_id:i.userId}),EH.info("join()"),this._mediaServerClient.setLiveControlMessage(o),this._roomInfo={appId:t,roomId:r,token:n,userInfo:i,roomProfile:this._roomConfig.roomProfileType},this.setSessionId(),e.prev=5,e.next=8,this._mediaServerClient.join(this._roomInfo);case 8:return c=e.sent,null!==(s=c.roomAttributes)&&void 0!==s&&s.multiChatMode&&this._handleFFAudioTrack(),this._initSubtitleTool(),e.abrupt("return",{users:c.clients,streams:c.streams});case 14:if(e.prev=14,e.t0=e.catch(5),e.t0.code===pA.OPERATION_CANCEL){e.next=18;break}throw e.t0;case 18:case"end":return e.stop()}}),e,this,[[5,14]])}))),function(e,t,r,n,i){return w.apply(this,arguments)})},{key:"publishScreen",value:(A=Rm(Tm().mark((function e(t,r,n,i,o){var a,s,c,u,d,l,h,p,v,f,_,m;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(EH.info("publishScreen()"),this._localScreenStream||(this._localScreenStream=new sF(this._context),null!==(a=this._mediaServerClient)&&void 0!==a&&null!==(s=a.vendorConfig)&&void 0!==s&&s.enableMultiVendor&&(this._localScreenStream.pcSessionId=_w()),this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new aH(this._localScreenStream,this._mediaServerClient.handler))),c=!1,u=!1,d=!1,l=!1,!this._localScreenStream.videoTrack&&r?(r instanceof fV&&(u=!0),c=!0):this._localScreenStream.videoTrack&&!r&&(c=!1),!this._localScreenStream.audioTrack&&n?(n instanceof _V&&(l=!0),d=!0):this._localScreenStream.audioTrack&&!n&&(d=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(wD(i)&&(this._localScreenStream.pubAudio=o===yG.PUB),CD(i)&&(this._localScreenStream.pubVideo=o===yG.PUB),EH.info("publishScreen mediaType","pubAudio: %o, pubVideo: %o",this._localScreenStream.pubAudio,this._localScreenStream.pubVideo)),this._localScreenStream.pubAudio||this._localScreenStream.pubVideo){e.next=18;break}if(null===(h=this._localScreenStream)||void 0===h||!h.hasPublished){e.next=17;break}return e.abrupt("return",this.unpublishScreen());case 17:return e.abrupt("return");case 18:if(this._localScreenStream.hasPublished){e.next=24;break}return null===(p=this._localScreenStream.observer)||void 0===p||p.setPublish(!0),e.next=22,this._mediaServerClient.publish(this._localScreenStream);case 22:e.next=28;break;case 24:return u?null===(v=this._localScreenStream.observer)||void 0===v||v.setPushVideo(c):null===(f=this._localScreenStream.observer)||void 0===f||f.setEnableVideo(c),l?null===(_=this._localScreenStream.observer)||void 0===_||_.setPushAudio(d):null===(m=this._localScreenStream.observer)||void 0===m||m.setEnableAudio(d),e.next=28,this.updatePubScreenTrack();case 28:this._localScreenStream.pubAudio||this._localScreenStream.pubVideo?this._localScreenStream.startReport(this._onLocalStreamStats.bind(this),this._mediaServerClient.handler):this._localScreenStream.stopReport("unpublish screen");case 29:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return A.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(R=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(EH.info("updatePubScreenTrack","Invoke updatePubScreenTrack"),!this._localScreenStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localScreenStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return R.apply(this,arguments)})},{key:"unpublishScreen",value:(I=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(EH.info("unpublish","Invoke unpublishScreen"),!this._localScreenStream){e.next=8;break}return null===(t=this._localScreenStream.observer)||void 0===t||t.setPublish(!1),e.next=5,this._mediaServerClient.unpublish(this._localScreenStream);case 5:this._localScreenStream.stopReport("unpublish screen"),this._localScreenStream.clean(),this._localScreenStream=void 0;case 8:case"end":return e.stop()}}),e,this)}))),function(){return I.apply(this,arguments)})},{key:"liveControlMessage",value:(T=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return EH.info("controlMessage","Invoke controlMessage"),null===(r=t.transcodeMeta)||void 0===r||r.layout.regions.forEach((function(e){n.roomInfo&&(e.roomID=n.roomInfo.roomId)})),e.next=4,this._mediaServerClient.controlMessage(t);case 4:this._mediaServerClient.setLiveControlMessage("stopped"===t.action?void 0:t);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(k=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"stopped"===t.action&&delete t.publicStreamMeta,e.next=3,this._mediaServerClient.controlMessage(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"subtitleControlMessage",value:(E=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.controlMessage(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"updateUserAttributes",value:(b=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return EH.info("updateUserAttributes","Invoke updateUserAttributes"),t.role&&this._roomInfo&&(this._roomInfo.userInfo.role=t.role),e.next=4,this._mediaServerClient.updateUserAttributes(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"publish",value:(S=Rm(Tm().mark((function e(t,r,n,i,o,a){var s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=E.length>6&&void 0!==E[6]&&E[6],EH.info("publish","Invoke publish"),c=!1,this._localStream||(this._localStream=new sF(this._context),null!==(u=this._mediaServerClient)&&void 0!==u&&null!==(d=u.vendorConfig)&&void 0!==d&&d.enableMultiVendor&&(this._localStream.pcSessionId=_w()),this._mediaServerClient.handler&&(this._localStream.observer=new aH(this._localStream,this._mediaServerClient.handler)),c=!0,this._localStream.vendorCode=(null===(l=this._mediaServerClient.vendorConfig)||void 0===l?void 0:l.vendorCode)||0),this._localStream.videoTrack=n,this._localStream.audioTrack=i,this._localStream.videoEncodeConfig=t,this._localStream.enableSimulcast=r,o&&(wD(o)&&(this._localStream.pubAudio=a===yG.PUB),CD(o)&&(this._localStream.pubVideo=a===yG.PUB),EH.info("publish mediaType","pubAudio: %o, pubVideo: %o",this._localStream.pubAudio,this._localStream.pubVideo)),this._localStream.hasPublished){e.next=26;break}if(this._localStream.pubAudio||this._localStream.pubVideo){e.next=12;break}return e.abrupt("return");case 12:return e.prev=12,s?null===(h=this._localStream.observer)||void 0===h||h.setLogin(!0):c&&(p=!!this._localStream.videoTrack,v=!!this._localStream.audioTrack,f=this._localStream.videoTrack instanceof fV,_=this._localStream.audioTrack instanceof _V,this._roomConfig.isAutoPublish&&!this._hasPublished?(p&&(f?null===(m=this._localStream.observer)||void 0===m||m.setPushVideo(!0):null===(y=this._localStream.observer)||void 0===y||y.setEnableVideo(!0)),v&&(_?null===(g=this._localStream.observer)||void 0===g||g.setPushAudio(!0):null===(S=this._localStream.observer)||void 0===S||S.setEnableAudio(!0))):null===(b=this._localStream.observer)||void 0===b||b.setPublish(!0)),e.next=16,this._mediaServerClient.publish(this._localStream);case 16:this._hasPublished=!0,this.emit(_G.ON_PUBLISH_RESULT,{isScreen:!1,state:ol.PUBLISH_SUCC}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(12),this.emit(_G.ON_PUBLISH_RESULT,{isScreen:!1,state:ol.PUBLISH_FAIL}),e.t0;case 24:e.next=28;break;case 26:return e.next=28,this.updatePubTrack();case 28:this._localStream.pubAudio||this._localStream.pubVideo?this._localStream.startReport(this._onLocalStreamStats.bind(this),this._mediaServerClient.handler):this._localStream.stopReport("unpublish");case 29:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e,t,r,n,i,o){return S.apply(this,arguments)})},{key:"updatePubTrack",value:(g=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(EH.info("updatePubTrack","Invoke updatePubTrack"),!this._localStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"unpublish",value:(y=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(EH.info("unpublish","Invoke unpublish"),!this._localStream){e.next=7;break}return e.next=4,this._mediaServerClient.unpublish(this._localStream);case 4:this._localStream.stopReport("unpublish"),this._localStream.clean(),this._localStream=void 0;case 7:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"subscribe",value:(m=Rm(Tm().mark((function e(t,r,n){var i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return EH.info("subscribe","remoteStream %o",t),i=void 0,n&&(i=this._getSubLayer(n,t)),e.next=5,this._mediaServerClient.subscribe(t,r,i);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return m.apply(this,arguments)})},{key:"updateSubTrack",value:(_=Rm(Tm().mark((function e(t,r,n,i){var o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(EH.info("updateSubTrack","Invoke updateSubTrack"),!i){e.next=4;break}return e.next=4,null===(a=this._mediaServerClient)||void 0===a?void 0:a.updateSubTrackLayer(t,i);case 4:return e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrack(t,r,n));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return _.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(f=Rm(Tm().mark((function e(t,r){var n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((a=this._findRemoteStreamByScreen(t,!1))&&a.hasSubscribed&&!((null==a||null===(n=a.attributes)||void 0===n||null===(i=n.videoDescriptions)||void 0===i?void 0:i.length)<=1)){e.next=3;break}return e.abrupt("return");case 3:return s=this._getSubLayer(r,a),a.originalStreamIndex=s.spatialLayer,e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrackLayer(a,s));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"_getSubLayer",value:function(e,t){for(var r,n,i,o,a,s=null==t?void 0:t.attributes,c=s.videoDescriptions,u=s.subVideoDescriptions,d=Array.isArray(u)?u:c,l=-1,h=e.width*e.height,p=0;p<(null==d?void 0:d.length);p++){var v,f;if(h>=(null===(v=d[p])||void 0===v?void 0:v.width)*(null===(f=d[p])||void 0===f?void 0:f.height)){l=p;break}}var _=d[0];if(-1===l)_=d[l=d.length-1];else if(0!==l){var m=d[l-1].width*d[l-1].height,y=(m-h)/(m-d[l].width*d[l].height);_=y<.1?d[l-1]:d[l],l=y<.1?l-1:l}return a=null!==(r=null===(n=_)||void 0===n?void 0:n.sub_index)&&void 0!==r?r:-1,{spatialLayer:null!==(i=null===(o=_)||void 0===o?void 0:o.video_index)&&void 0!==i?i:l,spatialSubLayer:a}}},{key:"unsubscribe",value:(v=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return EH.info("unsubscribe","Invoke unsubscribe"),e.next=3,this._mediaServerClient.unsubscribe(t,r);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"startSubtitle",value:(p=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subtitleTool){e.next=5;break}return e.next=3,this._subtitleTool.start(t);case 3:e.next=6;break;case 5:throw new mA(pA.INVOKED_BEFORE_JOIN_ROOM,"join first");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"stopSubtitle",value:(h=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(t=this._subtitleTool)||void 0===t||t.stop();case 1:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"startForwardStream2Rooms",value:(l=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.startForwardStream2Rooms(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(d=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.updateForwardStream2Rooms(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(u=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.stopForwardStream2Rooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"pauseForwardStream2AllRooms",value:(c=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.pauseForwardStream2AllRooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(s=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.resumeForwardStream2AllRooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"leave",value:(a=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=h.length>0&&void 0!==h[0]&&h[0],EH.info("leave","Invoke leave"),n=lD(),null===(t=this._subtitleTool)||void 0===t||t.destroy(),delete this._subtitleTool,e.prev=5,s=$T(oR(a=this._remoteStreams).call(a));try{for(s.s();!(c=s.n()).done;)u=c.value,Array.isArray(u)&&u.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setLogin(!1)}))}catch(p){s.e(p)}finally{s.f()}return this._localStream&&(null===(d=this._localStream.observer)||void 0===d||d.setLogin(!1)),e.next=11,this._mediaServerClient.leave().catch((function(){}));case 11:this.destroy(),null===(i=this._monitor)||void 0===i||i.report("rtc_leave_room",{error_code:0,message:"",elapse:lD()-n}),null===(o=this._monitor)||void 0===o||o.set({room_id:"",user_id:"",rtc_session_id:"",rtc_vid:""}),e.next=24;break;case 16:if(e.prev=16,e.t0=e.catch(5),!r){e.next=22;break}throw e.t0;case 22:this.destroy();case 23:e.t0 instanceof Error&&(null===(l=this._monitor)||void 0===l||l.report("rtc_leave_room",{error_code:-1,message:e.t0.message,elapse:lD()-n}));case 24:case"end":return e.stop()}}),e,this,[[5,16]])}))),function(){return a.apply(this,arguments)})},{key:"updateRemoteUserPriority",value:function(e){var t,r=this;null===(t=this.remoteStreams.get(e))||void 0===t||t.forEach((function(t){var n=(r._context||{}).userPriority;t.hasSubscribed&&n.has(e)&&r._mediaServerClient.updateSubPriority(t,n.get(e))}))}},{key:"destroy",value:function(){var e;EH.info("destroy","Invoke destroy"),jO(this.id,"room_destroy","".concat((new Error).stack)),null===(e=this._subtitleTool)||void 0===e||e.destroy(),delete this._subtitleTool,this._mediaServerClient.destroy(),this._removeHandlerEventHandler(),this._roomInfo=void 0,this._remoteUsers=new $S;var t,r,n,i=$T(this._remoteStreams);try{for(i.s();!(t=i.n()).done;){var o=eI(t.value,2)[1];Array.isArray(o)&&o.forEach((function(e){e&&e.destroy()}))}}catch(a){i.e(a)}finally{i.f()}(this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new $S,this._localStream)&&(null===(r=this._localStream)||void 0===r||r.clean(),this._localStream=void 0);this._localScreenStream&&(null===(n=this._localScreenStream)||void 0===n||n.clean(),this._localScreenStream=void 0);this._removeHandlerEventHandler(),clearTimeout(this._connectionLostTimer),this._userDuplicateLoginTimerMap.forEach((function(e){clearTimeout(e)})),this._userDuplicateLoginTimerMap.clear(),this._networkQualityManager.destroy(),this._videoSizeObserver.destroy(),this._csrcUserIdMap={},this._virtualStreams=[],this._remoteStreamStreamIdUserIdMap={},this._forwardStreamManager.clear()}},{key:"updateToken",value:(o=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return EH.info("updateToken","Invoke updateToken"),this._roomInfo&&(this._roomInfo.token=t),e.prev=2,e.next=5,this._mediaServerClient.updateToken(t);case 5:e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(2),this.safeEmit(_G.ON_ROOM_ERROR,{errorCode:pA.UPDATE_TOKEN_WITH_INVALID_TOKEN}),e.t0;case 11:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return o.apply(this,arguments)})},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._mediaServerClient)||void 0===r?void 0:r.sendUserMessage(e,t)}},{key:"setSessionId",value:function(){var e;this._sessionId=vw(),this._mediaServerClient._sessionId=this._sessionId,null===(e=this._monitor)||void 0===e||e.set({rtc_session_id:this._sessionId})}},{key:"sendRoomMessage",value:(i=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=s.length>1&&void 0!==s[1]&&s[1],a={clientId:null===(r=this._roomInfo)||void 0===r?void 0:r.userInfo.userId,binary:o,message:"",roomId:null===(n=this._roomInfo)||void 0===n?void 0:n.roomId},!o){e.next=8;break}return e.next=5,pD.ab2b64str(t);case 5:a.message=e.sent,e.next=9;break;case 8:a.message=t;case 9:return e.abrupt("return",null===(i=this._mediaServerClient)||void 0===i?void 0:i.sendRoomMessage(a));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"_onJoinSucc",value:function(e){var t,r,n,i=this,o=e.joinRes,a=e.reconnect;EH.info("_onJoinSucc()","invoke. ".concat(a?"[reconnect]":"")),this._serverConfig=o.config,this._mediaServerClient.roomAttributes=o.roomAttributes;var s=[],c=[],u=[],d=[],l=[];null===(t=o.clientsDetail)||void 0===t||t.forEach((function(e){if(e.attributes&&(e.attributes.serverMuteVideo&&i.safeEmit(_G.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&i.safeEmit(_G.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio})),e.clientId!==o.clientId){var t=i._remoteUsers.get(e.clientId);t?t._stillExist=!0:s.push(e)}}));var h,p=$T(oR(r=this._remoteUsers).call(r));try{for(p.s();!(h=p.n()).done;){var v=h.value;v._stillExist||c.push({clientId:v.userId}),delete v._stillExist}}catch(y){p.e(y)}finally{p.f()}o.streams.forEach((function(e){var t=i._findRemoteStreamByScreen(e.clientId,e.screen);t?(t.stillExist=!0,t.streamId=e.streamId,l.push(e)):d.push(e)}));var f,_=$T(oR(n=this._remoteStreams).call(n));try{for(_.s();!(f=_.n()).done;){var m=f.value;Array.isArray(m)&&m.forEach((function(e){e.stillExist?delete e.stillExist:u.push({clientId:e.userId,streamId:e.streamId,message:aG.clientDisconnected})}))}}catch(y){_.e(y)}finally{_.f()}c.forEach((function(e){return i._onUserDisconnection(e)})),s.forEach((function(e){return i._onUserConnection(e)})),u.forEach((function(e){return i._onRemoveStream(e)})),d.forEach((function(e){return i._onAddStream(e,{fromSignal:!1})})),l.forEach((function(e){return i._onUpdateStreamAttributes(e)})),a&&this._handleSendOrRecvStreamAfterReconnect()}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e,t,r,n,i,o=this;this._localStream&&(this._localStream.clean(),this._localStream.vendorCode=(null===(r=this._mediaServerClient.vendorConfig)||void 0===r?void 0:r.vendorCode)||0,null===(n=this._localStream.observer)||void 0===n||n.setLogin(!0),this._mediaServerClient.publish(this._localStream).catch((function(e){})));this._localScreenStream&&(this._localScreenStream.clean(),null===(i=this._localScreenStream.observer)||void 0===i||i.setLogin(!0),this._mediaServerClient.publish(this._localScreenStream).catch((function(e){})));var a,s=$T(oR(t=this._remoteStreams).call(t));try{for(s.s();!(a=s.n()).done;){var c=a.value;Array.isArray(c)&&c.forEach(function(){var e=Rm(Tm().mark((function e(t){var r,n,i,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasSubscribed){e.next=17;break}return t.resetHasSubscribed(),e.prev=2,EH.info(Om(r="start resubscribe ".concat(t.userId," with ")).call(r,t.subMediaType)),CD(t.subMediaType)&&(null===(n=t.observer)||void 0===n||n.setSubscribeVideo(!0)),wD(t.subMediaType)&&(null===(i=t.observer)||void 0===i||i.setSubscribeAudio(!0)),e.next=8,o._mediaServerClient.subscribe(t,t.subMediaType);case 8:EH.info(Om(a="success resubscribe ".concat(t.userId," with ")).call(a,t.subMediaType)),o.safeEmit(_G.RESUBSCRIBE,{stream:t}),e.next=17;break;case 12:e.prev=12,e.t0=e.catch(2),EH.error(Om(s=Om(c="failed resubscribe ".concat(t.userId," with ")).call(c,t.subMediaType,", error:")).call(s,e.t0)),t.clean(),null==t||t.resetHasSubscribed();case 17:case"end":return e.stop()}}),e,null,[[2,12]])})));return function(t){return e.apply(this,arguments)}}())}}catch(u){s.e(u)}finally{s.f()}null===(e=this._subtitleTool)||void 0===e||e.reconnect(),this._forwardStreamManager.resumeFromReconnect()}},{key:"_handleFFAudioTrack",value:function(){var e,t,r,n,i=null===(e=this._mediaServerClient)||void 0===e||null===(t=e.handler)||void 0===t?void 0:t.audioTrack4ff,o=null===(r=this._mediaServerClient)||void 0===r||null===(n=r.handler)||void 0===n?void 0:n.getTransceivers();if(i&&Array.isArray(o)){var a=gE(o).call(o,(function(e){var t;return(null==e||null===(t=e.receiver)||void 0===t?void 0:t.track)===i}));if(a){var s=new cF(this._context,"ff-stream","ff-stream",!1,!1,kH);s.virtual=!0,s.audioTransceiver=a,s.audioMid="0",s.audioTrack=OV(i),this._virtualStreams.push(s),this.safeEmit(_G.SUBSCRIBE_PUSH_TRACK,{stream:s})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?gE(r).call(r,(function(e){return e.streamId===t})):null}},{key:"_findRemoteStreamByScreen",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?gE(r).call(r,(function(e){return e.isScreen===t})):null}},{key:"_onAddStream",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.needEmit,i=void 0===n||n,o=r.fromSignal,a=void 0===o||o,s=r.virtual,c=void 0!==s&&s;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var u=this._roomConfig,d=u.isAutoSubscribeAudio,l=u.isAutoSubscribeVideo,h=this._findRemoteStreamByScreen(e.clientId,e.screen);if(h&&h.streamId!==e.streamId){var p,v=null===(p=this._remoteStreams.get(e.clientId))||void 0===p?void 0:Gs(p).call(p,(function(e){return e.streamId!==h.streamId}));h.clean(),this._remoteStreams.set(e.clientId,v||[])}var f=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,f)f.attributes=e.attributes;else if((f=new cF(this._context,e.clientId,e.streamId,e.screen,!1,e.attributes)).virtual=c,this._initStreamListeners(f),!c){var _=this._remoteStreams.get(e.clientId);_?_.push(f):this._remoteStreams.set(e.clientId,[f])}if(this._mediaServerClient.handler&&(f.observer=new iH(f,this._mediaServerClient.handler)),!f.isScreen&&l){var m,y,g,S,b,E,k,T;if(a&&f.hasVideo)if(f.attributes.extvideo)null===(m=f.observer)||void 0===m||m.setExternalVideoSource(!0),null===(y=f.observer)||void 0===y||y.setPushVideo(!0);else null===(g=f.observer)||void 0===g||g.setExternalVideoSource(!1),null===(S=f.observer)||void 0===S||S.setPublishVideo(!0);if(a&&f.hasAudio&&d&&!this._mediaServerClient.roomAttributes.multiChatMode)if(f.attributes.extaudio)null===(b=f.observer)||void 0===b||b.setExternalAudioSource(!0),null===(E=f.observer)||void 0===E||E.setPushAudio(!0);else null===(k=f.observer)||void 0===k||k.setExternalAudioSource(!1),null===(T=f.observer)||void 0===T||T.setPublishAudio(!0);if(i&&!a){var I,R=this._roomConfig,A=R.isAutoSubscribeAudio,w=R.isAutoSubscribeVideo;null===(I=f.observer)||void 0===I||I.setLogin(!0,{audio:!!A&&!this.multiChatMode,video:!!w})}}return i&&this.safeEmit(cG.ON_ADD_STREAM,{stream:f}),f}}},{key:"_onUserConnection",value:function(e){var t;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var r=this._userDuplicateLoginTimerMap.get(e.clientId);if("number"==typeof r)return this._userDuplicateLoginTimerMap.delete(e.clientId),void self.clearTimeout(r);var n={userId:e.clientId,extraInfo:e.attributes.extra_info};this._remoteUsers.set(e.clientId,Zd({},n)),this.safeEmit(cG.USER_CONNECTION,{userInfo:n}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(_G.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(_G.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}}},{key:"_onUserDisconnection",value:function(e){var t,r=this,n=e.clientId,i=e.tag,o=e.code;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var a=null;i===lG.kickedByAdmin?a=pA.KICKED_OUT:i===lG.onUserTokenDidExpire?a=pA.TOKEN_EXPIRED:i===lG.userDuplicateLogin&&(a=pA.DUPLICATE_LOGIN),o===hG.roomDismissByAdmin&&(a=pA.ROOM_DISMISS),a&&this.safeEmit(_G.ON_ROOM_ERROR,{errorCode:a})}else{var s=tl.DROPPED;i===lG.userLeave?s=tl.QUIT:i===lG.kickedByAdmin?s=tl.KICKED_BY_ADMIN:i===lG.roleChanged&&(s=tl.SWITCH_TO_INVISIBLE);var c=function(){var e;r._remoteUsers.delete(n),null===(e=r._remoteStreams.get(n))||void 0===e||e.forEach((function(e){r._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:aG.clientDisconnected})})),r._remoteStreams.delete(n),r.safeEmit(_G.ON_USER_LEAVE,{userInfo:{userId:n},reason:s})};if(i===lG.userDuplicateLogin){var u=this._userDuplicateLoginTimerMap.get(n);u&&self.clearTimeout(u);var d=self.setTimeout(c,5e3);this._userDuplicateLoginTimerMap.set(n,d)}else c()}}},{key:"_onRemoveStream",value:function(e){var t,r=this;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var n=this._remoteStreams.get(e.clientId);if(n){var i=gE(n).call(n,(function(t){return t.streamId===e.streamId}));if(i){var o,a,s;if(null===(o=this._mediaServerClient)||void 0===o||o.handleRemoveStream(i,e).then((function(){var t=r._remoteStreams.get(e.clientId);t&&(t=Gs(t).call(t,(function(t){return t.streamId!==e.streamId||(t.clean(),!1)})),r._remoteStreams.set(e.clientId,t))})).finally((function(){r.safeEmit(cG.ON_REMOVE_STREAM,{stream:i,reason:e.message,callback:function(){return i.destroy()}})})),i.hasVideo)null===(a=i.observer)||void 0===a||a.setPublishVideo(!1);if(i.hasAudio&&!this._mediaServerClient.roomAttributes.multiChatMode)null===(s=i.observer)||void 0===s||s.setPublishAudio(!1)}}}}},{key:"_onUpdateUserAttributes",value:function(e){e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(_G.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(_G.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){var t;e.roomAttributes&&(this._mediaServerClient.roomAttributes=Zd(Zd({},this._mediaServerClient.roomAttributes),e.roomAttributes)),null!==(t=e.roomAttributes)&&void 0!==t&&t.multiChatMode&&this._handleFFAudioTrack()}},{key:"_onUpdateStreamAttributes",value:function(e){var t=this._roomConfig,r=t.isAutoSubscribeAudio,n=t.isAutoSubscribeVideo,i=e.clientId,o=e.streamId,a=e.attributes,s=this._findRemoteStream(i,o);if(s){var c,u,d=s.attributes,l=Zd(Zd({},d),a),h=!1,p=l.localaudio!==d.localaudio,v=!1,f=!1,_=l.localvideo!==d.localvideo,m=!1,y=GV.NONE,g=GV.NONE;if(l.audiostream!==d.audiostream&&(h=l.localaudio,v=!!l.audiostream,l.audiostream?y|=ul.AUDIO:g|=ul.AUDIO),l.videostream!==d.videostream&&(f=l.localvideo,m=!!l.videostream,l.videostream?y|=ul.VIDEO:g|=ul.VIDEO),y&&this.safeEmit(_G.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:y,isScreen:s.isScreen,pubState:yG.PUB,remoteStream:s}),g&&this.safeEmit(_G.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:g,isScreen:s.isScreen,pubState:yG.UNPUB,remoteStream:s}),s.attributes=l,l.localaudio!==d.localaudio)if(l.localaudio){var S,b,E,k;if(r&&l.audiostream)if(l.extaudio)null===(S=s.observer)||void 0===S||S.setExternalAudioSource(!0),null===(b=s.observer)||void 0===b||b.setPushAudio(!0);else null===(E=s.observer)||void 0===E||E.setExternalAudioSource(!1),null===(k=s.observer)||void 0===k||k.setEnableAudio(!0);this.safeEmit(_G.ON_USER_START_AUDIO_CAPTURE,{userId:i},s)}else{var T,I,R,A;if(l.extaudio)null===(T=s.observer)||void 0===T||T.setExternalAudioSource(!0),null===(I=s.observer)||void 0===I||I.setPushAudio(!1);else null===(R=s.observer)||void 0===R||R.setExternalAudioSource(!1),null===(A=s.observer)||void 0===A||A.setEnableAudio(!1);!s.isScreen&&this.safeEmit(_G.ON_USER_STOP_AUDIO_CAPTURE,{userId:i})}if(l.localvideo!==d.localvideo)if(l.localvideo){var w,C,x,O;if(n&&l.videostream)if(l.extvideo)null===(w=s.observer)||void 0===w||w.setExternalVideoSource(!0),null===(C=s.observer)||void 0===C||C.setPushVideo(!0);else null===(x=s.observer)||void 0===x||x.setExternalVideoSource(!1),null===(O=s.observer)||void 0===O||O.setEnableVideo(!0);this.safeEmit(_G.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var D,N,M,P;if(l.extvideo)null===(D=s.observer)||void 0===D||D.setExternalVideoSource(!0),null===(N=s.observer)||void 0===N||N.setPushVideo(!1);else null===(M=s.observer)||void 0===M||M.setExternalVideoSource(!1),null===(P=s.observer)||void 0===P||P.setEnableVideo(!1);!s.isScreen&&this.safeEmit(_G.ON_USER_STOP_VIDEO_CAPTURE,{userId:i})}if(h&&!p)null===(c=s.observer)||void 0===c||c.setRemoteUnmuteAudio(v);if(f&&!_)null===(u=s.observer)||void 0===u||u.setRemoteUnmuteVideo(m)}}},{key:"_onPushTrack",value:function(e){var t,r=this;if(null!==(t=e.streamId)&&void 0!==t&&hA(t).call(t,"audio_mux")){var n=this._onAddStream(Zd(Zd({},e),{},{attributes:kH}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._mediaServerClient.subscribe4pushTrack(n,e).then((function(){r.safeEmit(_G.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){EH.error("subscribe","push track failed %o",e)}))}else{var i,o;null===(i=this._monitor)||void 0===i||i.report("rtc_error",{message:Om(o="onPushTrack, userId: ".concat(e.clientId,", ")).call(o,e.streamId),error_code:kG.TRACK_ERROR})}}},{key:"_onRemoveTrack",value:function(e){var t,r=e.clientId,n=e.streamId,i=e.message,o=e.trackType;EH.info("_onRemoveTrack","remove track: %o",r);var a=this._findRemoteStream(r,n);a&&(a.removeTrack=!0,null===(t=this._mediaServerClient)||void 0===t||t.unsubscribe4removeTrack(a,i,o),this.emit(_G.REMOVE_PUSH_TRACK,{stream:a,mediaType:o+1}))}},{key:"_onMeetingSpeakerChange",value:function(e){if(Array.isArray(null==e?void 0:e.speakerCsrcInfo)){var t={};null==e||e.speakerCsrcInfo.forEach((function(e){var r=e.csrc,n=e.userId;e.isScreen||(t[r]=n)})),this._csrcUserIdMap=t}Array.isArray(e.muxStreamInUse)&&this._virtualStreams.forEach((function(t){var r;null!==(r=e.muxStreamInUse)&&void 0!==r&&mk(r).call(r,t.streamId)?t.virtualOccupy=!0:t.virtualOccupy=!1}))}},{key:"getActiveSpeakerInMultiChatMode",value:function(){var e=this,t=[];return this._virtualStreams.forEach((function(r){var n,i=null===(n=r.audioTransceiver)||void 0===n?void 0:n.receiver;if(i){var o=eI(i.getContributingSources()||[],1)[0];if(o){var a=o.audioLevel,s=o.source;e._csrcUserIdMap[s]&&t.push({userId:e._csrcUserIdMap[s],audioLevel:a})}}})),t.length&&GR(t).call(t,(function(e,t){return e.audioLevel-t.audioLevel})),t}},{key:"_onReconnecting",value:function(){var e,t,r,n,i,o,a,s=this;if(this._roomInfo){var c,u=$T(oR(a=this._remoteStreams).call(a));try{for(u.s();!(c=u.n()).done;){var d=c.value;Array.isArray(d)&&d.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setDisconnect(),e.clean()}))}}catch(l){u.e(l)}finally{u.f()}this._virtualStreams.forEach((function(e){var t;s.emit(_G.REMOVE_PUSH_TRACK,{stream:e,mediaType:ul.AUDIO}),null===(t=e.observer)||void 0===t||t.setDisconnect(),e.clean()})),this._virtualStreams=[],null===(e=this.localStream)||void 0===e||null===(t=e.observer)||void 0===t||t.setDisconnect(),null===(r=this.localStream)||void 0===r||r.clean(),null===(n=this.localScreenStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setDisconnect(),null===(o=this.localScreenStream)||void 0===o||o.clean()}}},{key:"_onConnectionStateChange",value:function(e){var t,r=this;if(e.next===YG.DISCONNECTED)t=ll.CONNECTION_STATE_DISCONNECTED;else if(e.next===YG.CONNECTED)clearTimeout(this._connectionLostTimer),t=this._mediaServerClient.isReconnecting?ll.CONNECTION_STATE_RECONNECTED:ll.CONNECTION_STATE_CONNECTED;else{if(e.next!==YG.CONNECTING)return;this._mediaServerClient.isReconnecting?(t=ll.CONNECTION_STATE_RECONNECTING,this._onReconnecting()):t=ll.CONNECTION_STATE_CONNECTING}e.prev===YG.CONNECTED&&e.next===YG.DISCONNECTED&&(this._connectionLostTimer=window.setTimeout((function(){r.safeEmit(dG.ON_CONNECTION_STATE_CHANGE,{state:ll.CONNECTION_STATE_LOST})}),1e4)),this._networkQualityManager.setMSC(this._mediaServerClient),this.safeEmit(dG.ON_CONNECTION_STATE_CHANGE,{state:t})}},{key:"_initStreamListeners",value:function(e){var t=this;e.on("ontrack",(function(e){e.track})),e.on("onSEIMessage",(function(r){var n;t.emit(_G.ON_SEI_MESSAGED_RECEIVED,{sei:r,remoteStreamKey:{userId:e.userId,roomId:null===(n=t._roomInfo)||void 0===n?void 0:n.roomId,streamIndex:e.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){this.safeEmit(cG.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(cG.USER_MESSAGE_RECEIVED,{userId:e.from,message:e.msg})}},{key:"_onUserBinaryMessageReceived",value:function(e){var t,r={userId:e.from,message:e.msg};null!==(t=this._subtitleTool)&&void 0!==t&&t.onMessageRecv(r)||this.safeEmit(cG.USER_BINARY_MESSAGE_RECEIVED,r)}},{key:"_initSubtitleTool",value:function(){var e=this;this._subtitleTool=new vH(this),this._subtitleTool.onEvent=function(t){e.emit(_G.ON_SUBTITLE_STATE_CHANGED,t)},this._subtitleTool.onMessage=function(t){e.emit(_G.ON_SUBTITLE_MESSAGE_RECEIVED,t)}}},{key:"_onPostProcessingMessage",value:function(e){if(e.body)if("subtitleCallback"!==e.type){var t=e.body,r=t.error||0,n=mG.START,i=["success","parameter error","subscription timeout","ffmpeg error","cdn error","publish error"];if("2.0"===t.protocol){switch(t.eventType){case"TranscodeStarted":0!==t.error&&(n=mG.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?mG.START_FAILED:mG.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?mG.STOP_FAILED:mG.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?mG.UPDATE_FAILED:mG.UPDATE_SUCCESS}this.safeEmit(cG.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(cG.POST_PROCESSING_MESSAGE,{code:r,message:i[r],type:e.type})}else{var o;null===(o=this._subtitleTool)||void 0===o||o.onResult(e)}}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(cG.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onStreamFailed",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("publish"!==t.type){e.next=11;break}if(s=void 0,(null===(r=this.localStream)||void 0===r?void 0:r.streamId)===t.streamId?s=this.localStream:(null===(n=this.localScreenStream)||void 0===n?void 0:n.streamId)===t.streamId&&(s=this.localScreenStream),s){e.next=5;break}return e.abrupt("return");case 5:return null===(i=s)||void 0===i||i.clean(),e.next=8,null===(o=this._mediaServerClient)||void 0===o?void 0:o.unpublish(s).catch((function(){}));case 8:null===(a=this._mediaServerClient)||void 0===a||a.publish(s).catch((function(){})),e.next=20;break;case 11:if("subscribe"!==t.type){e.next=20;break}if(c=this._remoteStreamStreamIdUserIdMap[t.streamId],!(u=this._findRemoteStream(c,t.streamId))){e.next=20;break}return e.next=17,null===(d=this._mediaServerClient)||void 0===d?void 0:d.unsubscribe(u,ul.AUDIO_AND_VIDEO);case 17:return e.next=19,null===(l=this._mediaServerClient)||void 0===l?void 0:l.subscribe(u,u.subMediaType,u.subLayer);case 19:this.safeEmit(_G.RESUBSCRIBE,{stream:u});case 20:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_onStreamControlMessage",value:function(e){var t,r;e.type===sG.PushLimitWarn&&(null!==(t=this._localStream)&&void 0!==t&&t.pubAudio||null!==(r=this._localStream)&&void 0!==r&&r.pubVideo||this.unpublish())}},{key:"_onPublishOnDemand",value:(r=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publishOnDemandItem&&!this._publishOnDemandBusy&&!1!==(null===(t=this._serverConfig)||void 0===t||null===(r=t.engine_VPM)||void 0===r||null===(n=r.ondemand)||void 0===n?void 0:n.enable)){e.next=2;break}return e.abrupt("return");case 2:if(null===(i=this._localStream)||void 0===i||!i.enableSimulcast||null===(o=this._localStream)||void 0===o||!o.videoTransceiver){e.next=16;break}return this._publishOnDemandBusy=!0,u=this._publishOnDemandItem,this._publishOnDemandItem=void 0,d=[],l=null===(s=this._localStream)||void 0===s?void 0:s.stream.id,h=null===(c=this._localStream)||void 0===c?void 0:c.videoTransceiver.sender,p=h.getParameters(),Array.isArray(p.encodings)&&Array.isArray(u)&&(f={},EH.info("_onPublishOnDemand exec","usedDescriptions: %o",u),u.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&mk(t).call(t,l)){var r=null==e?void 0:e.Metadata.VideoIndex;f[r]=!0}})),p.encodings=jm(v=p.encodings).call(v,(function(e){if(e.rid){f[e.rid]?e.active=!0:e.active=!1;var t=Number(e.rid);d[t]=e.active}return e})),this._context&&(this._context.activeSimStreams=d)),e.next=13,h.setParameters(p);case 13:this._publishOnDemandBusy=!1,e.next=18;break;case 16:if(null!==(a=this._localStream)&&void 0!==a&&a.videoTransceiver){e.next=18;break}return e.abrupt("return");case 18:this._onPublishOnDemand();case 19:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_onRTT",value:function(e){var t=e.StreamIds,r=e.Metadata;if(t.length&&r){var n,i=t[0];null!==(n=this._context)&&void 0!==n&&n.streamRTT&&(this._context.streamRTT[i]={audio:r.audio_rtt,video:r.video_rtt})}}},{key:"_onSSC",value:function(e){var t=e.StreamIds,r=e.Metadata,n=t[0],i=this._remoteStreamStreamIdUserIdMap[n],o=this._findRemoteStream(i,n),a={userId:i,isScreen:!!o&&o.isScreen,beforeVideoIndex:r.ssc_items[0].prev_layer_id,afterVideoIndex:r.ssc_items[0].cur_layer_id,beforeEnable:0!==r.ssc_items[0].prev_video_open,afterEnable:0!==r.ssc_items[0].cur_video_open,reason:r.ssc_items[0].change_reason};this.emit(_G.ON_SIMULCAST_SUBSCRIBE_FALLBACK,a)}},{key:"_reportNetworkQuality",value:function(e,t){this.emit(_G.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){var i;this.emit(_G.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:null===(i=this.roomInfo)||void 0===i?void 0:i.roomId,userId:e,streamIndex:t?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN},{width:r,height:n})}},{key:"multiChatMode",get:function(){var e;return null===(e=this._mediaServerClient)||void 0===e?void 0:e.multiChatMode()}},{key:"setAudioEncodeMaxBitrate",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(n=t===cl.STREAM_INDEX_MAIN?this.localStream:this.localScreenStream)||!n.pubAudio){e.next=7;break}if(null==(o=null===(i=n.audioTransceiver)||void 0===i?void 0:i.sender.getParameters())||!o.encodings.length){e.next=7;break}return o.encodings[0].maxBitrate=1e3*r,e.next=7,null===(a=n.audioTransceiver)||void 0===a?void 0:a.sender.setParameters(o);case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),O}(aM),IH=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=document.createElement(e);return t.id&&(r.id=t.id),t.classList&&t.classList.forEach((function(e){r.classList.add(e)})),t.style&&wb(r.style,t.style),t.attributes&&RA(t.attributes).forEach((function(e){var t=eI(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},RH=new Pw("Player",0),AH=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],wH={playsinline:"","webkit-playsinline":""},CH={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},xH=function(e){NI(n,e);var t,r=QI(n);function n(e,t){var i;Vl(this,n),Jd(tI(i=r.call(this)),"_containerDom",void 0),Jd(tI(i),"_videoDom",void 0),Jd(tI(i),"__cumulativeTime",void 0),Jd(tI(i),"userId",void 0),Jd(tI(i),"renderMode",void 0),Jd(tI(i),"mirrorType",hl.MIRROR_TYPE_NONE),Jd(tI(i),"isScreen",void 0),Jd(tI(i),"isLocal",void 0),Jd(tI(i),"played",!1),Jd(tI(i),"_needLoad",!1),Jd(tI(i),"_emitPlayFailed",!1),Jd(tI(i),"_videoContainer",void 0),Jd(tI(i),"_safari15VideoTimer",void 0),Jd(tI(i),"_monitor",void 0),Jd(tI(i),"_onLocalTrackMute",void 0),Jd(tI(i),"_onInterruptionEnd",void 0),Jd(tI(i),"_needResume",!1),Jd(tI(i),"emitVideoEvent",(function(e){var t,r,n={type:"video",rawEvent:e,readyState:(null===(t=i._videoDom)||void 0===t?void 0:t.readyState)||0,userId:i.userId,eventName:e.type,currentTime:(null===(r=i._videoDom)||void 0===r?void 0:r.currentTime)||0,isScreen:i.isScreen};switch(i.emit("playback_event",n),e.type){case"canplay":case"loadeddata":i._internalPlay();break;case"playing":RH.info("VideoPlayerPlaying","[userId-".concat(i.userId,"] video element playing"));break;case"pause":RH.info("VideoPlayerPause","[userId-".concat(i.userId,"] video element pause")),i._needResume&&(RH.info("VideoPlayerPause","[userId-".concat(i.userId,"] video element resume")),i._internalPlay(),i._needResume=!1)}})),Jd(tI(i),"_internalPlay",(function(){var e;if(null!==(e=i._videoDom)&&void 0!==e&&e.paused){var t=i._videoDom.play();null!=t&&t.then&&t.then((function(){var e;i.isLocal&&WD&&!i._needLoad&&(null===(e=i._videoDom)||void 0===e||e.load(),i._needLoad=!0)})).catch((function(e){var t,r,n,o,a,s;i._emitPlayFailed||("AbortError"!==e.name?(i._emitPlayFailed=!0,null===(t=i._monitor)||void 0===t||t.report("rtc_error",{message:Om(r="video autoplay failed, userId: ".concat(i.userId,", ")).call(r,e.name),error_code:kG.AUTOPLAY_FAILED}),i.emit("playback_event",{type:"video",rawEvent:e,readyState:(null===(n=i._videoDom)||void 0===n?void 0:n.readyState)||0,userId:i.userId,eventName:"autoplay-error",currentTime:(null===(o=i._videoDom)||void 0===o?void 0:o.currentTime)||0,isScreen:i.isScreen})):null===(a=i._monitor)||void 0===a||a.report("rtc_error",{message:Om(s="video autoplay failed, userId: ".concat(i.userId,", ")).call(s,e.name),error_code:kG.AUTOPLAY_FAILED}))}))}})),i.engineId=e;var o=t.renderDom;i._monitor=VO(e);var a=t.userId,s=t.isScreen?sl.RENDER_MODE_FIT:sl.RENDER_MODE_HIDDEN;i.renderMode=void 0!==t.renderMode?t.renderMode:s;var c="string"==typeof o?document.getElementById(o):o;if(!c)throw new mA(pA.CANT_FIND_DOM,"can't find dom");return i._videoContainer=document.createElement("div"),i._videoContainer.style.width="100%",i._videoContainer.style.height="100%",i._videoContainer.style.position="relative",i._videoContainer.style.overflow="hidden",i._containerDom=c,i.userId=a,i.isLocal=!!t.isLocal,i.isScreen=!!t.isScreen,i._initVideo(),i}return Ul(n,[{key:"_initVideo",value:function(){var e,t=this;this._videoDom||(this._videoDom=IH("video",{style:{width:"100%",height:"100%"},attributes:CH}),this._videoDom.id=Om(e="".concat(this.userId,"_")).call(e,dD()),this.setRenderMode(this.renderMode),this.mirror(this.mirrorType===hl.MIRROR_TYPE_RENDER));this._videoContainer.appendChild(this._videoDom),this._containerDom.appendChild(this._videoContainer),this._initListeners(),this._onLocalTrackMute=function(){t._needResume=!0},this._onInterruptionEnd=function(){RH.warn("resume player after iOS interruption"),t._internalPlay()},JU.on(qU.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),JU.on(qU.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),JU.on(qU.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd)}},{key:"_initListeners",value:function(){var e=this;this._videoDom&&AH.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.addEventListener(t,e.emitVideoEvent)}))}},{key:"_removeListeners",value:function(){var e=this;this._videoDom&&AH.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.removeEventListener(t,e.emitVideoEvent)}))}},{key:"_recordFrame",value:function(e){var t=this,r=e.isScreen?1.5:.55;if(KD){var n;if(null===(n=this._videoDom)||void 0===n||!n.requestVideoFrameCallback)return;this._videoDom.requestVideoFrameCallback((function n(i,o){var a=o.presentationTime;if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t.__cumulativeTime){var s,c=(a-t.__cumulativeTime)%2e3,u=c>1e3*r;null===(s=e.recordedVideoFrames)||void 0===s||s.push({playTime:a,isStall:u,stallCount:u?1:0,stallDuration:c})}t.__cumulativeTime=a,t._videoDom.requestVideoFrameCallback(n)}))}else this.on("playback_event",(function(n){var i;if("timeupdate"===n.eventName){if(0===(null===(i=t._videoDom)||void 0===i?void 0:i.currentTime))return;if(void 0===t.__cumulativeTime)return void(t.__cumulativeTime=t._videoDom.currentTime);if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t._videoDom.currentTime>t.__cumulativeTime){var o=Math.floor(1e3*(t._videoDom.currentTime-t.__cumulativeTime)),a=t._videoDom.currentTime-t.__cumulativeTime>r;e.recordedVideoFrames.push({playTime:t._videoDom.currentTime,isStall:a,stallCount:a?1:0,stallDuration:o%2e3})}t.__cumulativeTime=t._videoDom.currentTime}}))}},{key:"_recordPause",value:function(e){var t=this;void 0===e.statsReport.isPaused&&this.on("playback_event",(function(r){if("pause"===r.eventName)e.statsReport.isPaused=!0,e.statsReport.pauseStart=lD();else if("timeupdate"===r.eventName){var n;if((null===(n=t._videoDom)||void 0===n||!n.paused)&&e.statsReport.isPaused){e.statsReport.isPaused=!1;var i=lD()-(e.statsReport.pauseStart||0);i>500&&(e.statsReport.pauseDuration+=i)}}}))}},{key:"setRenderMode",value:function(e){this.renderMode=e,this._videoDom&&(this.renderMode===sl.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this.renderMode===sl.RENDER_MODE_FILL?this._videoDom.style.objectFit="fill":this._videoDom.style.objectFit="cover")}},{key:"playVideo",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=this._videoDom,RH.info("playVideo","play video track: ".concat(this.userId)),!(o&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(n=t.getTrack())||void 0===n?void 0:n.id))){e.next=5;break}try{jO(this.engineId,"playVideo","play video repeatedly",0,this.userId)}catch(XW){}return e.abrupt("return");case 5:o||(this._initVideo(),o=this._videoDom),RH.info("playVideo","play video by dom: ".concat(null===(i=o)||void 0===i?void 0:i.id)),(a=new MediaStream).addTrack(t.getTrack("preprocessing")),o.srcObject=a,o&&!this._containerDom.contains(this._videoContainer)&&this._containerDom.appendChild(this._videoContainer),o&&!this._videoContainer.contains(o)&&this._videoContainer.appendChild(o),setTimeout((function(){return s._internalPlay()})),r&&CN.VIDEO_STALL&&(this._recordFrame(r),this._recordPause(r),r.statsReport.player=this),this.played=!0;case 15:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"updateSrcObject",value:function(e){var t=e.getTrack();if(t&&this._videoDom){var r=new MediaStream;r.addTrack(t),this._videoDom.srcObject=r}}},{key:"removeTrack",value:function(){var e,t=null===(e=this._videoDom)||void 0===e?void 0:e.srcObject;if(t){var r=t.getVideoTracks();null!=r&&r.length&&r.forEach((function(e){t.removeTrack(e)}))}}},{key:"manuallyPlay",value:function(){if(RH.info("Invoke VideoPlayer.manuallyPlay",this.userId,this.isScreen),this._emitPlayFailed=!1,!this._videoDom)throw new mA(pA.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||eN?this._videoDom.play():Y_.resolve()}},{key:"mirror",value:function(e){var t;RH.info("mirror",Om(t="".concat(this.userId," set mirror: ")).call(t,e)),this.mirrorType=e?hl.MIRROR_TYPE_RENDER:hl.MIRROR_TYPE_NONE,this._videoDom&&(this._videoDom.style.transform=e?"rotateY(180deg)":"")}},{key:"stop",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=this._containerDom;(RH.info("stop","stop video track: ".concat(this.userId)),this._videoDom)&&(t||(this._videoDom.srcObject=null),null!=r&&r.contains(this._videoContainer)&&r.removeChild(this._videoContainer),null!==(e=this._videoContainer)&&void 0!==e&&e.contains(this._videoDom)&&this._videoContainer.removeChild(this._videoDom));this.__cumulativeTime=void 0,this.played=!1}},{key:"destroy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];RH.info("destroy","video player: ".concat(this.userId)),this.stop(e),OI(CI(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),JU.off(qU.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),JU.off(qU.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),JU.off(qU.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd),this._videoDom&&delete this._videoDom,this._safari15VideoTimer&&(window.clearInterval(this._safari15VideoTimer),this._safari15VideoTimer=void 0)}},{key:"domElement",get:function(){return this._videoDom}}]),n}(nM.exports.EventEmitter),OH=function(e){NI(i,e);var t,r,n=QI(i);function i(e,t){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{divId:void 0,muted:!1,isScreen:!1},a=o.divId,s=o.muted,c=o.isScreen;if(Vl(this,i),Jd(tI(r=n.call(this)),"_containerDom",void 0),Jd(tI(r),"_audioDom",void 0),Jd(tI(r),"_fakeAudioDom",void 0),Jd(tI(r),"userId",void 0),Jd(tI(r),"muted",!1),Jd(tI(r),"_emitPlayFailed",!1),Jd(tI(r),"played",!1),Jd(tI(r),"isScreen",void 0),Jd(tI(r),"_wechatTimer",void 0),Jd(tI(r),"_edgeTimer",void 0),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_pasued",!0),Jd(tI(r),"emitAudioEvent",(function(e){var t,n,i={type:"audio",rawEvent:e,readyState:(null===(t=r._audioDom)||void 0===t?void 0:t.readyState)||0,userId:r.userId,eventName:e.type,currentTime:(null===(n=r._audioDom)||void 0===n?void 0:n.currentTime)||0};"playing"===e.type&&RH.info("AudioPlayerPlaying","[userId-".concat(r.userId,"] audio element playing")),"pause"===e.type&&(RH.info("AudioPlayerPause","[userId-".concat(r.userId,"] audio element pause")),r._pasued||r._internalPlay()),nN&&eN&&("canplay"===e.type?(clearTimeout(r._wechatTimer),r._wechatTimer=window.setTimeout((function(){r._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(r._wechatTimer)),tN&&QD&&"error"===e.type&&(clearTimeout(r._edgeTimer),r._edgeTimer=window.setTimeout((function(){var e;0===(null===(e=r._audioDom)||void 0===e?void 0:e.currentTime)&&r._autoPlayError("edge")}),500)),r.emit("playback_event",i)})),Jd(tI(r),"_internalPlay",(function(){var e,t;if(jO(r.engineId,"_internalPlay",{paused:null===(e=r._audioDom)||void 0===e?void 0:e.paused}),null!==(t=r._audioDom)&&void 0!==t&&t.paused)try{var n,i=r._audioDom.play(),o=eV.getAudioContextInstance();if("suspended"===o.state){var a=o.resume(),s=setTimeout((function(){var e;"suspended"===o.state&&(r._autoPlayError("AudioContext cannot resume"),null===(e=r._monitor)||void 0===e||e.report("rtc_error",{message:"audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - timeout"),error_code:-1e3}));clearTimeout(s)}));a.catch((function(e){var t,n,i;r._autoPlayError("AudioContext cannot resume"),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:Om(n=Om(i="audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - rejected by: [")).call(i,null==e?void 0:e.name,"]")).call(n,null==e?void 0:e.message),error_code:-1e3})})).finally((function(){clearTimeout(s)}))}null!==(n=i)&&void 0!==n&&n.then&&(nN&&tN&&(i=i.then((function(){return new Y_((function(e){setTimeout(Rm(Tm().mark((function t(){var n;return Tm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null===(n=r._audioDom)||void 0===n||n.pause(),r._audioDom.volume=1,t.next=4,r._audioDom.play();case 4:e();case 5:case"end":return t.stop()}}),t)}))),500)}))}))),i.then((function(){jO(r.engineId,"_internalPlay successfully",{userId:r.userId}),r._pasued=!1})).catch((function(e){var t,n,i;r._autoPlayError(e),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:Om(n=Om(i="audio autoplay failed, userId: ".concat(r.userId,": ")).call(i,e.message," ")).call(n,e.name),error_code:kG.AUTOPLAY_FAILED})})))}catch(l){var c,u,d;r._autoPlayError(l),null===(c=r._monitor)||void 0===c||c.report("rtc_error",{message:Om(u=Om(d="audio autoplay failed, userId: ".concat(r.userId,": ")).call(d,l.message," ")).call(u,l.name),error_code:kG.AUTOPLAY_FAILED})}})),r.engineId=e,a){var u=document.getElementById(a);if(!u)throw new mA(pA.CANT_FIND_DOM,"can't find dom");r._containerDom=u}else r._containerDom=document.body;return r.userId=t,r.muted=s,r.isScreen=c,r._monitor=VO(e),r._initAudio(),r}return Ul(i,[{key:"_initAudio",value:function(){var e;this._audioDom||(this._audioDom=IH("audio",{style:{display:"none"},attributes:wH}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id=Om(e="".concat(this.userId,"_")).call(e,dD()),this._containerDom.appendChild(this._audioDom));this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&AH.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.addEventListener(t,e.emitAudioEvent)}))}},{key:"_removeListeners",value:function(){var e=this;this._audioDom&&(AH.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.removeEventListener(t,e.emitAudioEvent)})),this._audioDom.removeEventListener("canplay",this._internalPlay),this._audioDom.removeEventListener("loadeddata",this._internalPlay))}},{key:"playAudio",value:(r=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(RH.info("playAudio","play audio track: ".concat(this.userId)),!((o=this._audioDom)&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(r=t.getTrack())||void 0===r?void 0:r.id))){e.next=4;break}return e.abrupt("return");case 4:o||(this._initAudio(),o=this._audioDom),a=new MediaStream,t instanceof jV?(this._fakeAudioDom=new Audio,this._fakeAudioDom.muted=!0,this._fakeAudioDom.srcObject=new MediaStream([t.getOrgTrack()]),a.addTrack(t.getTrack())):a.addTrack(t.getTrack("preprocessing")),nN&&tN&&(this._audioDom.volume=0),o.srcObject=a,null===(n=o)||void 0===n||n.addEventListener("canplay",this._internalPlay),null===(i=o)||void 0===i||i.addEventListener("loadeddata",this._internalPlay),setTimeout((function(){return s._internalPlay()})),this.played=!0;case 13:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_autoPlayError",value:function(e){var t,r;this._emitPlayFailed||(this._emitPlayFailed=!0,this.emit("playback_event",{type:"audio",rawEvent:e,readyState:(null===(t=this._audioDom)||void 0===t?void 0:t.readyState)||0,userId:this.userId,eventName:"autoplay-error",currentTime:(null===(r=this._audioDom)||void 0===r?void 0:r.currentTime)||0}))}},{key:"pause",value:function(){if(!this._audioDom)throw new mA(pA.INVALID_PARAMS,"Player not found");this._pasued=!0,this._audioDom.pause()}},{key:"manuallyPlay",value:function(){var e,t=this;if(RH.info("Invoke AudioPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._audioDom)throw new mA(pA.INVALID_PARAMS,"Player not found");if(!this.played)return Y_.resolve();this._audioDom.volume=1,this._audioDom.muted=!1,null===(e=this._fakeAudioDom)||void 0===e||e.play();var r=[],n=this._audioDom.play();null!=n&&n.then&&r.push(n);var i=eV.getAudioContextInstance();if("suspended"===i.state){var o=i.resume();null!=o&&o.then&&r.push(o)}(r.length>0?Y_.all(r):Y_.resolve(n)).then((function(){t._pasued=!1}))}},{key:"setPlaybackDevice",value:(t=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return RH.info("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,XU.enumerateAudioPlaybackDevices();case 3:if(r=e.sent,n=jm(r).call(r,(function(e){return e.deviceId})),mk(n).call(n,t)&&this._audioDom&&this._audioDom.setSinkId){e.next=7;break}return e.abrupt("return");case 7:return e.next=9,this._audioDom.setSinkId(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"stop",value:function(){var e=this._containerDom;RH.info("stopAudio","stop audio track: ".concat(this.userId)),this._audioDom&&(this._audioDom.srcObject=null,null!=e&&e.contains(this._audioDom)&&e.removeChild(this._audioDom)),this._fakeAudioDom&&(this._fakeAudioDom.srcObject=null,this._fakeAudioDom=void 0),this.played=!1}},{key:"domElement",get:function(){return this._audioDom}},{key:"destroy",value:function(){RH.info("destroy","audio player: ".concat(this.userId)),this.stop(),OI(CI(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(this._audioDom.srcObject=null,delete this._audioDom),this._edgeTimer&&clearTimeout(this._edgeTimer)}}]),i}(nM.exports.EventEmitter);function DH(e,t,r,n){var i=function(){var e=Rm(Tm().mark((function e(t,i){var o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null==n?void 0:n.get(i),Array.isArray(o)&&(o=null===(a=o)||void 0===a?void 0:gE(a).call(a,(function(e){return e.isScreen===r}))),!t){e.next=9;break}if(!t.played){e.next=8;break}return e.next=6,t.manuallyPlay();case 6:e.next=9;break;case 8:o&&(t instanceof xH&&o.videoTrack&&t.playVideo(o.videoTrack,o),t instanceof OH&&o.audioTrack&&t.playAudio(o.audioTrack));case 9:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();if(t)return i(e.get(t),t);var o=[];return e.forEach((function(e,t){return o.push(i(e,t))})),Y_.all(o)}var NH=i,MH=lt("iterator"),PH=!NH((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),!e.toJSON||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[MH]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==r||"x"!==new URL("http://x",void 0).host})),LH=Jt,UH=E,VH=2147483647,FH=/[^\0-\u007E]/,BH=/[.\u3002\uFF0E\uFF61]/g,jH="Overflow: input needs wider integers to process",GH=RangeError,HH=UH(BH.exec),zH=Math.floor,KH=String.fromCharCode,XH=UH("".charCodeAt),WH=UH([].join),qH=UH([].push),YH=UH("".replace),JH=UH("".split),QH=UH("".toLowerCase),ZH=function(e){return e+22+75*(e<26)},$H=function(e,t,r){var n=0;for(e=r?zH(e/700):e>>1,e+=zH(e/t);e>455;)e=zH(e/35),n+=36;return zH(n+36*e/(e+38))},ez=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=XH(e,r++);if(i>=55296&&i<=56319&&r<n){var o=XH(e,r++);56320==(64512&o)?qH(t,((1023&i)<<10)+(1023&o)+65536):(qH(t,i),r--)}else qH(t,i)}return t}(e);var r,n,i=e.length,o=128,a=0,s=72;for(r=0;r<e.length;r++)(n=e[r])<128&&qH(t,KH(n));var c=t.length,u=c;for(c&&qH(t,"-");u<i;){var d=VH;for(r=0;r<e.length;r++)(n=e[r])>=o&&n<d&&(d=n);var l=u+1;if(d-o>zH((VH-a)/l))throw GH(jH);for(a+=(d-o)*l,o=d,r=0;r<e.length;r++){if((n=e[r])<o&&++a>VH)throw GH(jH);if(n==o){for(var h=a,p=36;;){var v=p<=s?1:p>=s+26?26:p-s;if(h<v)break;var f=h-v,_=36-v;qH(t,KH(ZH(v+f%_))),h=zH(f/_),p+=36}qH(t,KH(ZH(h))),s=$H(a,l,u==c),a=0,u++}}a++,o++}return WH(t,"")},tz=Ar,rz=n,nz=O,iz=E,oz=w,az=PH,sz=li,cz=Qy,uz=Pi,dz=Mc,lz=Zi,hz=mp,pz=R,vz=Ye,fz=Yt,_z=fn,mz=tr,yz=$,gz=yn,Sz=Hn,bz=V,Ez=gh,kz=hh,Tz=wp,Iz=lR,Rz=lt("iterator"),Az="URLSearchParams",wz="URLSearchParamsIterator",Cz=lz.set,xz=lz.getterFor(Az),Oz=lz.getterFor(wz),Dz=Object.getOwnPropertyDescriptor,Nz=function(e){if(!oz)return rz[e];var t=Dz(rz,e);return t&&t.value},Mz=Nz("fetch"),Pz=Nz("Request"),Lz=Nz("Headers"),Uz=Pz&&Pz.prototype,Vz=Lz&&Lz.prototype,Fz=rz.RegExp,Bz=rz.TypeError,jz=rz.decodeURIComponent,Gz=rz.encodeURIComponent,Hz=iz("".charAt),zz=iz([].join),Kz=iz([].push),Xz=iz("".replace),Wz=iz([].shift),qz=iz([].splice),Yz=iz("".split),Jz=iz("".slice),Qz=/\+/g,Zz=Array(4),$z=function(e){return Zz[e-1]||(Zz[e-1]=Fz("((?:%[\\da-f]{2}){"+e+"})","gi"))},eK=function(e){try{return jz(e)}catch(XW){return e}},tK=function(e){var t=Xz(e,Qz," "),r=4;try{return jz(t)}catch(XW){for(;r;)t=Xz(t,$z(r--),eK);return t}},rK=/[!'()~]|%20/g,nK={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},iK=function(e){return nK[e]},oK=function(e){return Xz(Gz(e),rK,iK)},aK=dz((function(e,t){Cz(this,{type:wz,iterator:Ez(xz(e).entries),kind:t})}),"Iterator",(function(){var e=Oz(this),t=e.kind,r=e.iterator.next(),n=r.value;return r.done||(r.value="keys"===t?n.key:"values"===t?n.value:[n.key,n.value]),r}),!0),sK=function(e){this.entries=[],this.url=null,void 0!==e&&(yz(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===Hz(e,0)?Jz(e,1):e:gz(e)))};sK.prototype={type:Az,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,c=kz(e);if(c)for(r=(t=Ez(e,c)).next;!(n=nz(r,t)).done;){if(o=(i=Ez(mz(n.value))).next,(a=nz(o,i)).done||(s=nz(o,i)).done||!nz(o,i).done)throw Bz("Expected sequence with length 2");Kz(this.entries,{key:gz(a.value),value:gz(s.value)})}else for(var u in e)vz(e,u)&&Kz(this.entries,{key:u,value:gz(e[u])})},parseQuery:function(e){if(e)for(var t,r,n=Yz(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=Yz(t,"="),Kz(this.entries,{key:tK(Wz(r)),value:tK(zz(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],Kz(r,oK(e.key)+"="+oK(e.value));return zz(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var cK=function(){hz(this,uK);var e=arguments.length>0?arguments[0]:void 0;Cz(this,new sK(e))},uK=cK.prototype;if(cz(uK,{append:function(e,t){Tz(arguments.length,2);var r=xz(this);Kz(r.entries,{key:gz(e),value:gz(t)}),r.updateURL()},delete:function(e){Tz(arguments.length,1);for(var t=xz(this),r=t.entries,n=gz(e),i=0;i<r.length;)r[i].key===n?qz(r,i,1):i++;t.updateURL()},get:function(e){Tz(arguments.length,1);for(var t=xz(this).entries,r=gz(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){Tz(arguments.length,1);for(var t=xz(this).entries,r=gz(e),n=[],i=0;i<t.length;i++)t[i].key===r&&Kz(n,t[i].value);return n},has:function(e){Tz(arguments.length,1);for(var t=xz(this).entries,r=gz(e),n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){Tz(arguments.length,1);for(var r,n=xz(this),i=n.entries,o=!1,a=gz(e),s=gz(t),c=0;c<i.length;c++)(r=i[c]).key===a&&(o?qz(i,c--,1):(o=!0,r.value=s));o||Kz(i,{key:a,value:s}),n.updateURL()},sort:function(){var e=xz(this);Iz(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=xz(this).entries,n=fz(e,arguments.length>1?arguments[1]:void 0),i=0;i<r.length;)n((t=r[i++]).value,t.key,this)},keys:function(){return new aK(this,"keys")},values:function(){return new aK(this,"values")},entries:function(){return new aK(this,"entries")}},{enumerable:!0}),sz(uK,Rz,uK.entries,{name:"entries"}),sz(uK,"toString",(function(){return xz(this).serialize()}),{enumerable:!0}),uz(cK,Az),tz({global:!0,constructor:!0,forced:!az},{URLSearchParams:cK}),!az&&pz(Lz)){var dK=iz(Vz.has),lK=iz(Vz.set),hK=function(e){if(yz(e)){var t,r=e.body;if(_z(r)===Az)return t=e.headers?new Lz(e.headers):new Lz,dK(t,"content-type")||lK(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),Sz(e,{body:bz(0,gz(r)),headers:bz(0,t)})}return e};if(pz(Mz)&&tz({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return Mz(e,arguments.length>1?hK(arguments[1]):{})}}),pz(Pz)){var pK=function(e){return hz(this,Uz),new Pz(e,arguments.length>1?hK(arguments[1]):{})};Uz.constructor=pK,pK.prototype=Uz,tz({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:pK})}}var vK,fK=Ar,_K=w,mK=PH,yK=n,gK=Yt,SK=E,bK=li,EK=function(e,t,r){return LH.f(e,t,r)},kK=mp,TK=Ye,IK=Rb,RK=Xk,AK=ni,wK=Ud.codeAt,CK=function(e){var t,r,n=[],i=JH(YH(QH(e),BH,"."),".");for(t=0;t<i.length;t++)r=i[t],qH(n,HH(FH,r)?"xn--"+ez(r):r);return WH(n,".")},xK=yn,OK=Pi,DK=wp,NK={URLSearchParams:cK,getState:xz},MK=Zi,PK=MK.set,LK=MK.getterFor("URL"),UK=NK.URLSearchParams,VK=NK.getState,FK=yK.URL,BK=yK.TypeError,jK=yK.parseInt,GK=Math.floor,HK=Math.pow,zK=SK("".charAt),KK=SK(/./.exec),XK=SK([].join),WK=SK(1..toString),qK=SK([].pop),YK=SK([].push),JK=SK("".replace),QK=SK([].shift),ZK=SK("".split),$K=SK("".slice),eX=SK("".toLowerCase),tX=SK([].unshift),rX="Invalid scheme",nX="Invalid host",iX="Invalid port",oX=/[a-z]/i,aX=/[\d+-.a-z]/i,sX=/\d/,cX=/^0x/i,uX=/^[0-7]+$/,dX=/^\d+$/,lX=/^[\da-f]+$/i,hX=/[\0\t\n\r #%/:<>?@[\\\]^|]/,pX=/[\0\t\n\r #/:<>?@[\\\]^|]/,vX=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,fX=/[\t\n\r]/g,_X=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)tX(t,e%256),e=GK(e/256);return XK(t,".")}if("object"==typeof e){for(t="",n=function(e){for(var t=null,r=1,n=null,i=0,o=0;o<8;o++)0!==e[o]?(i>r&&(t=n,r=i),n=null,i=0):(null===n&&(n=o),++i);return i>r&&(t=n,r=i),t}(e),r=0;r<8;r++)i&&0===e[r]||(i&&(i=!1),n===r?(t+=r?":":"::",i=!0):(t+=WK(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},mX={},yX=IK({},mX,{" ":1,'"':1,"<":1,">":1,"`":1}),gX=IK({},yX,{"#":1,"?":1,"{":1,"}":1}),SX=IK({},gX,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),bX=function(e,t){var r=wK(e,0);return r>32&&r<127&&!TK(t,e)?e:encodeURIComponent(e)},EX={ftp:21,file:null,http:80,https:443,ws:80,wss:443},kX=function(e,t){var r;return 2==e.length&&KK(oX,zK(e,0))&&(":"==(r=zK(e,1))||!t&&"|"==r)},TX=function(e){var t;return e.length>1&&kX($K(e,0,2))&&(2==e.length||"/"===(t=zK(e,2))||"\\"===t||"?"===t||"#"===t)},IX=function(e){return"."===e||"%2e"===eX(e)},RX={},AX={},wX={},CX={},xX={},OX={},DX={},NX={},MX={},PX={},LX={},UX={},VX={},FX={},BX={},jX={},GX={},HX={},zX={},KX={},XX={},WX=function(e,t,r){var n,i,o,a=xK(e);if(t){if(i=this.parse(a))throw BK(i);this.searchParams=null}else{if(void 0!==r&&(n=new WX(r,!0)),i=this.parse(a,null,n))throw BK(i);(o=VK(new UK)).bindURL(this),this.searchParams=o}};WX.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,c=this,u=t||RX,d=0,l="",h=!1,p=!1,v=!1;for(e=xK(e),t||(c.scheme="",c.username="",c.password="",c.host=null,c.port=null,c.path=[],c.query=null,c.fragment=null,c.cannotBeABaseURL=!1,e=JK(e,vX,"")),e=JK(e,fX,""),n=RK(e);d<=n.length;){switch(i=n[d],u){case RX:if(!i||!KK(oX,i)){if(t)return rX;u=wX;continue}l+=eX(i),u=AX;break;case AX:if(i&&(KK(aX,i)||"+"==i||"-"==i||"."==i))l+=eX(i);else{if(":"!=i){if(t)return rX;l="",u=wX,d=0;continue}if(t&&(c.isSpecial()!=TK(EX,l)||"file"==l&&(c.includesCredentials()||null!==c.port)||"file"==c.scheme&&!c.host))return;if(c.scheme=l,t)return void(c.isSpecial()&&EX[c.scheme]==c.port&&(c.port=null));l="","file"==c.scheme?u=FX:c.isSpecial()&&r&&r.scheme==c.scheme?u=CX:c.isSpecial()?u=NX:"/"==n[d+1]?(u=xX,d++):(c.cannotBeABaseURL=!0,YK(c.path,""),u=zX)}break;case wX:if(!r||r.cannotBeABaseURL&&"#"!=i)return rX;if(r.cannotBeABaseURL&&"#"==i){c.scheme=r.scheme,c.path=AK(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,u=XX;break}u="file"==r.scheme?FX:OX;continue;case CX:if("/"!=i||"/"!=n[d+1]){u=OX;continue}u=MX,d++;break;case xX:if("/"==i){u=PX;break}u=HX;continue;case OX:if(c.scheme=r.scheme,i==vK)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=AK(r.path),c.query=r.query;else if("/"==i||"\\"==i&&c.isSpecial())u=DX;else if("?"==i)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=AK(r.path),c.query="",u=KX;else{if("#"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=AK(r.path),c.path.length--,u=HX;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=AK(r.path),c.query=r.query,c.fragment="",u=XX}break;case DX:if(!c.isSpecial()||"/"!=i&&"\\"!=i){if("/"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,u=HX;continue}u=PX}else u=MX;break;case NX:if(u=MX,"/"!=i||"/"!=zK(l,d+1))continue;d++;break;case MX:if("/"!=i&&"\\"!=i){u=PX;continue}break;case PX:if("@"==i){h&&(l="%40"+l),h=!0,o=RK(l);for(var f=0;f<o.length;f++){var _=o[f];if(":"!=_||v){var m=bX(_,SX);v?c.password+=m:c.username+=m}else v=!0}l=""}else if(i==vK||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(h&&""==l)return"Invalid authority";d-=RK(l).length+1,l="",u=LX}else l+=i;break;case LX:case UX:if(t&&"file"==c.scheme){u=jX;continue}if(":"!=i||p){if(i==vK||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(c.isSpecial()&&""==l)return nX;if(t&&""==l&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(l))return a;if(l="",u=GX,t)return;continue}"["==i?p=!0:"]"==i&&(p=!1),l+=i}else{if(""==l)return nX;if(a=c.parseHost(l))return a;if(l="",u=VX,t==UX)return}break;case VX:if(!KK(sX,i)){if(i==vK||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()||t){if(""!=l){var y=jK(l,10);if(y>65535)return iX;c.port=c.isSpecial()&&y===EX[c.scheme]?null:y,l=""}if(t)return;u=GX;continue}return iX}l+=i;break;case FX:if(c.scheme="file","/"==i||"\\"==i)u=BX;else{if(!r||"file"!=r.scheme){u=HX;continue}if(i==vK)c.host=r.host,c.path=AK(r.path),c.query=r.query;else if("?"==i)c.host=r.host,c.path=AK(r.path),c.query="",u=KX;else{if("#"!=i){TX(XK(AK(n,d),""))||(c.host=r.host,c.path=AK(r.path),c.shortenPath()),u=HX;continue}c.host=r.host,c.path=AK(r.path),c.query=r.query,c.fragment="",u=XX}}break;case BX:if("/"==i||"\\"==i){u=jX;break}r&&"file"==r.scheme&&!TX(XK(AK(n,d),""))&&(kX(r.path[0],!0)?YK(c.path,r.path[0]):c.host=r.host),u=HX;continue;case jX:if(i==vK||"/"==i||"\\"==i||"?"==i||"#"==i){if(!t&&kX(l))u=HX;else if(""==l){if(c.host="",t)return;u=GX}else{if(a=c.parseHost(l))return a;if("localhost"==c.host&&(c.host=""),t)return;l="",u=GX}continue}l+=i;break;case GX:if(c.isSpecial()){if(u=HX,"/"!=i&&"\\"!=i)continue}else if(t||"?"!=i)if(t||"#"!=i){if(i!=vK&&(u=HX,"/"!=i))continue}else c.fragment="",u=XX;else c.query="",u=KX;break;case HX:if(i==vK||"/"==i||"\\"==i&&c.isSpecial()||!t&&("?"==i||"#"==i)){if(".."===(s=eX(s=l))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"==i||"\\"==i&&c.isSpecial()||YK(c.path,"")):IX(l)?"/"==i||"\\"==i&&c.isSpecial()||YK(c.path,""):("file"==c.scheme&&!c.path.length&&kX(l)&&(c.host&&(c.host=""),l=zK(l,0)+":"),YK(c.path,l)),l="","file"==c.scheme&&(i==vK||"?"==i||"#"==i))for(;c.path.length>1&&""===c.path[0];)QK(c.path);"?"==i?(c.query="",u=KX):"#"==i&&(c.fragment="",u=XX)}else l+=bX(i,gX);break;case zX:"?"==i?(c.query="",u=KX):"#"==i?(c.fragment="",u=XX):i!=vK&&(c.path[0]+=bX(i,mX));break;case KX:t||"#"!=i?i!=vK&&("'"==i&&c.isSpecial()?c.query+="%27":c.query+="#"==i?"%23":bX(i,mX)):(c.fragment="",u=XX);break;case XX:i!=vK&&(c.fragment+=bX(i,yX))}d++}},parseHost:function(e){var t,r,n;if("["==zK(e,0)){if("]"!=zK(e,e.length-1))return nX;if(t=function(e){var t,r,n,i,o,a,s,c=[0,0,0,0,0,0,0,0],u=0,d=null,l=0,h=function(){return zK(e,l)};if(":"==h()){if(":"!=zK(e,1))return;l+=2,d=++u}for(;h();){if(8==u)return;if(":"!=h()){for(t=r=0;r<4&&KK(lX,h());)t=16*t+jK(h(),16),l++,r++;if("."==h()){if(0==r)return;if(l-=r,u>6)return;for(n=0;h();){if(i=null,n>0){if(!("."==h()&&n<4))return;l++}if(!KK(sX,h()))return;for(;KK(sX,h());){if(o=jK(h(),10),null===i)i=o;else{if(0==i)return;i=10*i+o}if(i>255)return;l++}c[u]=256*c[u]+i,2!=++n&&4!=n||u++}if(4!=n)return;break}if(":"==h()){if(l++,!h())return}else if(h())return;c[u++]=t}else{if(null!==d)return;l++,d=++u}}if(null!==d)for(a=u-d,u=7;0!=u&&a>0;)s=c[u],c[u--]=c[d+a-1],c[d+--a]=s;else if(8!=u)return;return c}($K(e,1,-1)),!t)return nX;this.host=t}else if(this.isSpecial()){if(e=CK(e),KK(hX,e))return nX;if(t=function(e){var t,r,n,i,o,a,s,c=ZK(e,".");if(c.length&&""==c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(r=[],n=0;n<t;n++){if(""==(i=c[n]))return e;if(o=10,i.length>1&&"0"==zK(i,0)&&(o=KK(cX,i)?16:8,i=$K(i,8==o?1:2)),""===i)a=0;else{if(!KK(10==o?dX:8==o?uX:lX,i))return e;a=jK(i,o)}YK(r,a)}for(n=0;n<t;n++)if(a=r[n],n==t-1){if(a>=HK(256,5-t))return null}else if(a>255)return null;for(s=qK(r),n=0;n<r.length;n++)s+=r[n]*HK(256,3-n);return s}(e),null===t)return nX;this.host=t}else{if(KK(pX,e))return nX;for(t="",r=RK(e),n=0;n<r.length;n++)t+=bX(r[n],mX);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return TK(EX,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&kX(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,n=e.password,i=e.host,o=e.port,a=e.path,s=e.query,c=e.fragment,u=t+":";return null!==i?(u+="//",e.includesCredentials()&&(u+=r+(n?":"+n:"")+"@"),u+=_X(i),null!==o&&(u+=":"+o)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+XK(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw BK(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new qX(e.path[0]).origin}catch(XW){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+_X(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(xK(e)+":",RX)},getUsername:function(){return this.username},setUsername:function(e){var t=RK(xK(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=bX(t[r],SX)}},getPassword:function(){return this.password},setPassword:function(e){var t=RK(xK(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=bX(t[r],SX)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?_X(e):_X(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,LX)},getHostname:function(){var e=this.host;return null===e?"":_X(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,UX)},getPort:function(){var e=this.port;return null===e?"":xK(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=xK(e))?this.port=null:this.parse(e,VX))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+XK(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,GX))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=xK(e))?this.query=null:("?"==zK(e,0)&&(e=$K(e,1)),this.query="",this.parse(e,KX)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=xK(e))?("#"==zK(e,0)&&(e=$K(e,1)),this.fragment="",this.parse(e,XX)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var qX=function(e){var t=kK(this,YX),r=DK(arguments.length,1)>1?arguments[1]:void 0,n=PK(t,new WX(e,!1,r));_K||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},YX=qX.prototype,JX=function(e,t){return{get:function(){return LK(this)[e]()},set:t&&function(e){return LK(this)[t](e)},configurable:!0,enumerable:!0}};if(_K&&(EK(YX,"href",JX("serialize","setHref")),EK(YX,"origin",JX("getOrigin")),EK(YX,"protocol",JX("getProtocol","setProtocol")),EK(YX,"username",JX("getUsername","setUsername")),EK(YX,"password",JX("getPassword","setPassword")),EK(YX,"host",JX("getHost","setHost")),EK(YX,"hostname",JX("getHostname","setHostname")),EK(YX,"port",JX("getPort","setPort")),EK(YX,"pathname",JX("getPathname","setPathname")),EK(YX,"search",JX("getSearch","setSearch")),EK(YX,"searchParams",JX("getSearchParams")),EK(YX,"hash",JX("getHash","setHash"))),bK(YX,"toJSON",(function(){return LK(this).serialize()}),{enumerable:!0}),bK(YX,"toString",(function(){return LK(this).serialize()}),{enumerable:!0}),FK){var QX=FK.createObjectURL,ZX=FK.revokeObjectURL;QX&&bK(qX,"createObjectURL",gK(QX,FK)),ZX&&bK(qX,"revokeObjectURL",gK(ZX,FK))}OK(qX,"URL"),fK({global:!0,constructor:!0,forced:!mK,sham:!_K},{URL:qX});var $X=ee.URL,eW=function(){var e=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio($X.createObjectURL(new Blob([t],r))),e.prev=1,n.muted=!0,e.next=5,n.play();case 5:return n.pause(),e.abrupt("return",!0);case 9:return e.prev=9,e.t0=e.catch(1),e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t,r){return e.apply(this,arguments)}}(),tW=ad,rW=tc,nW=function(e,t,r,n){for(var i,o=n>1?void 0:n?rW(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&tW(t,r,o),o},iW=function(){function e(t,r){Vl(this,e),Jd(this,"_sharedAudioContext",new AudioContext),Jd(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),Jd(this,"_localGainNode",this._sharedAudioContext.createGain()),Jd(this,"_bufferGainNode",this._sharedAudioContext.createGain()),Jd(this,"_audioBufferSource",void 0),Jd(this,"_localSource",void 0),Jd(this,"_context",void 0),Jd(this,"_failedAudioList",[]),Jd(this,"_startingIds",new $S),Jd(this,"_revokeURLs",new JP),Jd(this,"mixingMap",new $S),Jd(this,"resourcesCache",new $S),Jd(this,"volumeConfig",new $S),Jd(this,"cachedBuffer",[]),Jd(this,"id","AudioMixingManager"),this.engineId=r,this._context=t,this._localGainNode.gain.value=1}var t,r,n;return Ul(e,[{key:"mixMediaStream",value:function(e){this._localSource&&this._localSource.disconnect(this._localGainNode),this._localSource=this._sharedAudioContext.createMediaStreamSource(e),this._localSource.connect(this._localGainNode).connect(this._audioDestination)}},{key:"startAudioMixing",value:(n=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===this._startingIds.get(t)){e.next=3;break}return console.warn("AudioMixing task id: ".concat(t," is starting")),e.abrupt("return");case 3:if(this._startingIds.set(t,t),i=n.playCount,VN(o=n.type,"mixingType",Yj(Dl)),a=this._context.getLocalAudioTrack()){e.next=9;break}return e.abrupt("return");case 9:if((s=a.getTrack("preprocessing"))&&this.mixMediaStream(new MediaStream([s])),null!=(c=this.mixingMap.get(t))&&c.audioNode){c.audioNode.pause(),this._context.emitMessage({mixId:t,state:Nl.AUDIO_MIXING_STATE_STOPPED,error:vA.AUDIO_MIXING_ERROR_OK});try{c.gainNode.disconnect(this._audioDestination),c.audioSource.disconnect(c.gainNode)}catch(y){}}if(!(d=this.resourcesCache.get(t))||d.filePath!==r){e.next=18;break}u=d.getAudioNode(),e.next=31;break;case 18:return e.next=20,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw m._context.emitMessage({mixId:t,state:Nl.AUDIO_MIXING_STATE_FAILED,error:vA.AUDIO_MIXING_ERROR_START_FAILED}),new mA(pA.LOAD_RESOURCES_FAILED,e.statusText)}));case 20:return l=e.sent,Qb(r).call(r,"mp3")?h={type:"audio/mpeg"}:Qb(r).call(r,"aac")&&(h={type:"audio/aac"}),e.next=24,eW(l,h);case 24:if(e.sent){e.next=28;break}throw this._context.emitMessage({mixId:t,state:Nl.AUDIO_MIXING_STATE_FAILED,error:vA.AUDIO_MIXING_ERROR_START_FAILED}),new mA(pA.LOAD_RESOURCES_FAILED,"invalid audio resource");case 28:(u=new Audio).crossOrigin="anonymous",u.src=$X.createObjectURL(new Blob([l],h));case 31:return i<=0?u.loop=!0:i>0&&(p=i,u.onended=function(){--p>0?u.play():(m.mixingMap.delete(t),m._context.emitMessage({mixId:t,state:Nl.AUDIO_MIXING_STATE_FINISHED,error:vA.AUDIO_MIXING_ERROR_OK}))}),e.prev=32,e.next=35,u.play();case 35:e.next=42;break;case 37:e.prev=37,e.t0=e.catch(32),console.error(e.t0),this._failedAudioList.push(u),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:cl.STREAM_INDEX_MAIN,mediaType:ul.AUDIO});case 42:if(this._startingIds.delete(t),v=this._sharedAudioContext.createMediaElementSource(u),f=this._sharedAudioContext.createGain(),_=this.volumeConfig.get(t),f.gain.value=_?_/100:1,v.connect(f).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:v,audioNode:u,gainNode:f,type:"file"}),o===Dl.PUBLISH)try{f.disconnect(this._sharedAudioContext.destination)}catch(y){}else f.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:Nl.AUDIO_MIXING_STATE_PLAYING,error:vA.AUDIO_MIXING_ERROR_OK});case 52:case"end":return e.stop()}}),e,this,[[32,37]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"stopAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&"file"===t.type&&(this.mixingMap.delete(e),t.audioNode.pause(),t.audioSource.disconnect(t.gainNode),t.gainNode.disconnect(this._audioDestination),this._context.emitMessage({mixId:e,state:Nl.AUDIO_MIXING_STATE_STOPPED,error:vA.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Nl.AUDIO_MIXING_STATE_PAUSED,error:vA.AUDIO_MIXING_ERROR_OK}),t.audioNode.pause())}},{key:"resumeAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Nl.AUDIO_MIXING_STATE_PLAYING,error:vA.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=Rm(Tm().mark((function e(t,r){var n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.stopAudioMixing(t),e.next=3,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw new mA(pA.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(o._context.emitMessage({mixId:t,state:Nl.AUDIO_MIXING_STATE_FAILED,error:vA.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof mA)throw e;throw new mA(pA.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,Qb(r).call(r,"mp3")?i={type:"audio/mpeg"}:Qb(r).call(r,"aac")&&(i={type:"audio/aac"}),e.next=7,eW(n,i);case 7:if(e.sent){e.next=11;break}throw this._context.emitMessage({mixId:t,state:Nl.AUDIO_MIXING_STATE_FAILED,error:vA.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new mA(pA.LOAD_RESOURCES_FAILED,"Load resources failed");case 11:return this._context.emitMessage({mixId:t,state:Nl.AUDIO_MIXING_STATE_PRELOADED,error:vA.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){var e=$X.createObjectURL(new Blob([n],i));return o._revokeURLs.add(e),new Audio(e)},filePath:r,duration:0}),e.next=15,new Y_((function(e){var r=$X.createObjectURL(new Blob([n],i)),a=new Audio(r);a.addEventListener("durationchange",(function(){var n=o.resourcesCache.get(t);n&&(n.duration=a.duration,o.resourcesCache.set(t,n)),$X.revokeObjectURL(r),e(null)}))}));case 15:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"unloadAudioMixing",value:function(e){this.resourcesCache.has(e)&&this.resourcesCache.delete(e)}},{key:"getAudioMixingVolume",value:function(e){var t=this.mixingMap.get(e);return t?100*t.gainNode.gain.value:0}},{key:"setAudioMixingVolume",value:function(e,t){t<0?t=0:t>400&&(t=400),this.volumeConfig.set(e,t);var r=this.mixingMap.get(e);r&&(r.gainNode.gain.value=Number(t)/100)}},{key:"getAudioMixingDuration",value:function(e){var t=this.mixingMap.get(e),r=this.resourcesCache.get(e);return t||r?t?1e3*t.audioNode.duration:r?1e3*r.duration:0:0}},{key:"getAudioMixingCurrentPosition",value:function(e){var t=this.mixingMap.get(e);return t?1e3*t.audioNode.currentTime:0}},{key:"setAudioMixingPosition",value:function(e,t){var r=this.mixingMap.get(e);r&&(r.audioNode.currentTime=t/1e3,r.audioNode.play())}},{key:"enableAudioMixingBuffer",value:function(e){VN(e,"type",Yj(Dl));var t=this._context.getLocalAudioTrack();if(t){var r=t.getTrack("preprocessing");if(r&&this.mixMediaStream(new MediaStream([r])),e===Dl.PUBLISH)try{this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(n){}else this._bufferGainNode.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],e),this._bufferGainNode.connect(this._audioDestination),this._context.emitMessage({mixId:-1,state:Nl.AUDIO_MIXING_STATE_PCM_ENABLED,error:vA.AUDIO_MIXING_ERROR_OK})}}},{key:"disableAudioMixingBuffer",value:function(){if(this.cachedBuffer=[],this._audioBufferSource){try{this._audioBufferSource.disconnect(this._bufferGainNode),this._bufferGainNode.disconnect(this._audioDestination),this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(e){}finally{this._audioBufferSource=void 0}this._context.updateLocalAudioTrack(),this._context.emitMessage({mixId:-1,state:Nl.AUDIO_MIXING_STATE_PCM_DISABLED,error:vA.AUDIO_MIXING_ERROR_OK})}}},{key:"pushAudioMixingBuffer",value:function(e){var t=this;if(!(this._audioBufferSource&&(this.cachedBuffer.push(e),this.cachedBuffer.length>0))){this._audioBufferSource=this._sharedAudioContext.createBufferSource(),this._audioBufferSource.buffer=e,this._audioBufferSource.connect(this._bufferGainNode);try{this._audioBufferSource.start()}catch(r){this._failedAudioList.push(this._audioBufferSource)}this._audioBufferSource.onended=function(){var e;if(null===(e=t._audioBufferSource)||void 0===e||e.disconnect(t._bufferGainNode),t._audioBufferSource=void 0,t.cachedBuffer.length){var r=t.cachedBuffer.shift();r&&t.pushAudioMixingBuffer(r)}}}}},{key:"stopAll",value:function(){var e=this;if(this._localSource)try{this._localSource.disconnect(this._localGainNode),delete this._localSource}catch(t){}this.mixingMap.forEach((function(t,r){e.stopAudioMixing(r)}))}},{key:"mixTrack",get:function(){return this._audioDestination.stream.getAudioTracks()[0]}},{key:"sharedAudioContext",get:function(){return this._sharedAudioContext}},{key:"resumeLocalPlay",value:(t=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=$T(this._failedAudioList),e.prev=2,r.s();case 4:if((n=r.n()).done){e.next=24;break}if(i=n.value,e.prev=6,!(i instanceof HTMLAudioElement)){e.next=13;break}return i.muted=!1,e.next=11,i.play();case 11:e.next=14;break;case 13:i.start();case 14:e.next=22;break;case 16:return e.prev=16,e.t0=e.catch(6),t.push(i),console.error(e.t0),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:cl.STREAM_INDEX_MAIN,mediaType:ul.AUDIO}),e.abrupt("break",24);case 22:e.next=4;break;case 24:e.next=29;break;case 26:e.prev=26,e.t1=e.catch(2),r.e(e.t1);case 29:return e.prev=29,r.f(),e.finish(29);case 32:this._failedAudioList=t;case 33:case"end":return e.stop()}}),e,this,[[2,26,29,32],[6,16]])}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e=this._sharedAudioContext;"closed"!==e.state&&"function"==typeof e.close&&e.close(),this.cachedBuffer=[],this.mixingMap.clear(),this.resourcesCache.clear(),this.volumeConfig.clear(),this._startingIds=new $S,this._revokeURLs.forEach((function(e){$X.revokeObjectURL(e)}))}}]),e}();nW([FO("id","filePath","options")],iW.prototype,"startAudioMixing",1),nW([FO("id")],iW.prototype,"stopAudioMixing",1),nW([FO("id")],iW.prototype,"pauseAudioMixing",1),nW([FO("id")],iW.prototype,"resumeAudioMixing",1),nW([FO("id")],iW.prototype,"preloadAudioMixing",1),nW([FO("id")],iW.prototype,"unloadAudioMixing",1),nW([FO("id")],iW.prototype,"getAudioMixingVolume",1),nW([FO("id","volume")],iW.prototype,"setAudioMixingVolume",1),nW([FO("id")],iW.prototype,"getAudioMixingDuration",1),nW([FO("id")],iW.prototype,"getAudioMixingCurrentPosition",1),nW([FO("id","position")],iW.prototype,"setAudioMixingPosition",1),nW([FO("type")],iW.prototype,"enableAudioMixingBuffer",1),nW([FO()],iW.prototype,"disableAudioMixingBuffer",1),nW([FO("buffer")],iW.prototype,"pushAudioMixingBuffer",1);var oW=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(oW||{}),aW=new Pw("RTMClient",1),sW=function(e){NI(c,e);var t,r,n,i,o,a,s=QI(c);function c(e){var t;return Vl(this,c),Jd(tI(t=s.call(this)),"_dataChannelSignal",void 0),Jd(tI(t),"_handler",void 0),Jd(tI(t),"_dataChannelSignalState",YG.DISCONNECTED),Jd(tI(t),"_loginSessionId",null),Jd(tI(t),"_userId",null),Jd(tI(t),"_token",null),Jd(tI(t),"_loginResolveCallback",void 0),Jd(tI(t),"_loginRejectCallback",void 0),Jd(tI(t),"_wait_login_token",!1),Jd(tI(t),"_serverParamsCache",void 0),Jd(tI(t),"id",void 0),Jd(tI(t),"_connectionManager",void 0),Jd(tI(t),"isReconnecting",!1),t._ctx=e,t.id=e.id,t._connectionManager=new HG(e),t._addConnectHandler(),t}return Ul(c,[{key:"login",value:function(e,t){var r=this;return new Y_((function(n,i){var o;if(aW.info("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new mA(pA.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new mA(pA.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,null===(o=VO(r.id))||void 0===o||o.set({rtm_user_id:t}),r._loginResolveCallback=n,r._loginRejectCallback=i,r._dataChannelSignal?r._login():r.connect().then((function(){r._login()}))}))}},{key:"logout",value:(a=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mA(pA.NOT_LOGIN,"login first");case 2:return e.next=4,null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("logout",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId},{functionType:BG.C2RTM}).catch((function(){}));case 4:this._clearState();case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"updateLoginToken",value:(o=Rm(Tm().mark((function e(t){var r=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new Y_((function(e,t){r._wait_login_token?(r._loginResolveCallback=e,r._loginRejectCallback=t,r._login()):e()})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(i=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mA(pA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.next=5,this._dataChannelSignal.sendSignaling("getPeerOnlineStatus",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,peerUserId:t},{functionType:BG.C2RTM});case 5:return r=e.sent,e.abrupt("return",null==r?void 0:r.status);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(n=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mA(pA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:t,room:"",msg:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"setServerParams",value:(r=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,UN(t,"signature"),UN(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new mA(pA.NOT_LOGIN,"login first");case 5:return this._checkDataChannelSignal(),e.next=8,this._dataChannelSignal.sendSignaling("setServerParams",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,signature:t,url:r},{functionType:BG.C2RTM}).catch((function(e){throw new mA(pA.UNEXPECTED_ERROR,e.msg)}));case 8:this._serverParamsCache={signature:t,url:r},this.emit("onServerParamsSetResult"),e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(0),this.emit("onServerParamsSetResult",e.t0),e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,12]])}))),function(e,t){return r.apply(this,arguments)})},{key:"sendServerMessage",value:(t=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new mA(pA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:"",room:"",type:MG.BUSINESS_SERVER,msg:t}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e;aW.info("destroy","invoke."),OI(CI(c.prototype),"removeAllListeners",this).call(this),this._loginResolveCallback&&this._loginRejectCallback&&(this._loginRejectCallback(new mA(pA.LOGIN_FAILED,"logout")),delete this._loginResolveCallback,delete this._loginRejectCallback),null===(e=this._dataChannelSignal)||void 0===e||e.destroy(),delete this._dataChannelSignal,this._clearState(),this._connectionManager.destroy(),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=dD();this._checkDataChannelSignal(),this._dataChannelSignal.sendSignaling("login",{Token:pD.token2auth(this._ctx.appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:CN.VERSION,deviceId:EN.getDeviceId(),appId:this._ctx.appId,userId:this._userId},accessParams:Pm({requireICEUfragV2:!0})},{functionType:BG.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,wO.setRtsSessionId(e.id,t),e._wait_login_token=!1,e._serverParamsCache&&e.setServerParams(e._serverParamsCache.signature,e._serverParamsCache.url)})).catch((function(t){var r,n,i=t||{},o=i.code,a=i.message;e._wait_login_token=!1,o>=700&&o<800?708===o?(r=pA.INVALID_PARAMS,n="Invalid userId"):(r=pA.INVALID_TOKEN,n="Invalid token",e._wait_login_token=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=pA.LOGIN_FAILED,n="login failed"),"function"==typeof e._loginRejectCallback&&e._loginRejectCallback(new mA(r,a||n))})).finally((function(){delete e._loginResolveCallback,delete e._loginRejectCallback}))}}},{key:"connect",value:function(){var e=this;return new Y_((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"_checkDataChannelSignal",value:function(){if(!this._dataChannelSignal||this._dataChannelSignalState!==YG.CONNECTED)throw new mA(pA.NOT_CONNECTED_YET,"datachannel not connect")}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n;e._dataChannelSignalState=YG.CONNECTED,aW.info("connectStateChange","connected"),null===(r=e._handler)||void 0===r||r.destroy(),null===(n=e._dataChannelSignal)||void 0===n||n.destroy(),e._handler=oG(e._ctx,t.pc),e._dataChannelSignal=t.signaling,e._addSignalEventHandler(),e.isReconnecting&&e._login()})),this._connectionManager.on("disconnected",(function(t){e._dataChannelSignalState=YG.DISCONNECTED,aW.warn("connectStateChange","disconnected. %o",t),e.isReconnecting&&(e.emit("onUserDisconnection"),e._clearState())})),this._connectionManager.on("connecting",(function(){var t;e.isReconnecting=!1,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e._dataChannelSignalState=YG.CONNECTING,aW.info("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(){var t;e.isReconnecting=!0,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e._dataChannelSignalState=YG.CONNECTING,aW.warn("connectStateChange","reconnecting")}))}},{key:"_addSignalEventHandler",value:function(){var e,t,r,n=this;null===(e=this._dataChannelSignal)||void 0===e||e.on(cG.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){n.emit("onUserMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),null===(t=this._dataChannelSignal)||void 0===t||t.on(cG.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){n.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),null===(r=this._dataChannelSignal)||void 0===r||r.on(cG.USER_DISCONNECTION,(function(){n.emit("onUserDisconnection"),n._clearState()}))}},{key:"_clearState",value:function(){this._userId=null,this._token=null,this._loginSessionId=null,wO.setRtsSessionId(this.id,"")}}]),c}(nM.exports.EventEmitter),cW=function(){function e(t){Vl(this,e),Jd(this,"_roomId",void 0),Jd(this,"_constraints",{}),Jd(this,"_profile",void 0),Jd(this,"_customMaxBitrate",0),this._appId=t}return Ul(e,[{key:"setRoomId",value:function(e){this._roomId=e}},{key:"setAudioProfile",value:function(e){this._profile=e,this._customMaxBitrate=0}},{key:"customMaxBitrate",get:function(){return this._customMaxBitrate}},{key:"setCustomMaxBitrate",value:function(e){var t=EN.getEngineWebConfig(this._appId,this._roomId||"").audio_encode;this._customMaxBitrate=null!=t&&t.bitrate?0:1e3*e}},{key:"getOpusConfigStr",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=EN.getEngineWebConfig(this._appId,this._roomId||""),n=r.audio_encode,i=this.getConstraints(),o=i.sampleRate,a=i.channelCount,s="number"==typeof o?o:null==o?void 0:o.exact,c="number"==typeof a?a:null==a?void 0:a.exact,u={};t.split(";").forEach((function(e){var t=eI(e.split("="),2),r=t[0],n=t[1];r&&n&&(u[r]=n)}));var d=(null==n?void 0:n.bitrate)||this._customMaxBitrate||this._getConfigByAudioProfile().bitrate;d&&(u.maxaveragebitrate=d);var l=(null==n?void 0:n.enc_sample_rate)||s;l&&(u["sprop-maxcapturerate"]=l);var h=(null==n?void 0:n.playback_rate)||s;return h&&(u.maxplaybackrate=h),(c&&c>1||null!=n&&n.stereo)&&(u["sprop-stereo"]=1,u.stereo=1),null!=n&&n.dtx&&(u.usedtx=1),jm(e=an(u)).call(e,(function(e){var t;return Om(t="".concat(e,"=")).call(t,u[e])})).join(";")}},{key:"updateConstraints",value:function(e){this._constraints=Zd(Zd({},this._constraints),e)}},{key:"getConstraints",value:function(){var e=Zd({},this._constraints),t=EN.getEngineWebConfig(this._appId,this._roomId||"").audio_capture;ND(null==t?void 0:t.sample_rate)||(e.sampleRate=t.sample_rate),ND(null==t?void 0:t.channel)||(e.channelCount=t.channel),ND(null==t?void 0:t.agc)||(e.autoGainControl=t.agc),ND(null==t?void 0:t.ans)||(e.noiseSuppression=t.ans),ND(null==t?void 0:t.aec)||(e.echoCancellation=t.aec);var r=this._getConfigByAudioProfile(),n=r.sampleRate,i=r.channel;return ND(e.sampleRate)&&!ND(n)&&(e.sampleRate=n),ND(e.channelCount)&&!ND(i)&&(e.channelCount=i),e}},{key:"_getConfigByAudioProfile",value:function(){var e={};switch(this._profile){case El.fluent:e.sampleRate=16e3,e.bitrate=24e3;break;case El.standard:e.sampleRate=48e3,e.bitrate=48e3;break;case El.hd:e.sampleRate=48e3,e.bitrate=128e3,e.channel=2;break;case El.standardStereo:e.sampleRate=48e3,e.bitrate=8e4,e.channel=2;break;case El.hdMono:e.sampleRate=48e3,e.bitrate=128e3}return e}}]),e}(),uW=function(e){NI(o,e);var t,r,n,i=QI(o);function o(e,t,r){var n,a=r.businessId;return Vl(this,o),Jd(tI(n=i.call(this)),"_mediaServerClient",void 0),Jd(tI(n),"_appId",void 0),Jd(tI(n),"remoteStreams",void 0),Jd(tI(n),"_businessId",void 0),Jd(tI(n),"_ctx",void 0),n.id=e,n._appId=t,n.remoteStreams=new $S,n._businessId=a,n._ctx={id:n.id,appId:n._appId,avSync:!0,audioProfileManager:new cW(n._appId),useCloudProxy:!1,userPriority:new $S,joinRoomConfig:new TN(n.id),enableFallbackHandler:CW(t)},n}return Ul(o,[{key:"connect",value:(n=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._mediaServerClient=new QG(this._ctx),this._businessId&&(this._mediaServerClient.businessId=this._businessId),this._bindEvents(),e.next=5,this._mediaServerClient.connect();case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startPlayPublicStream",value:(r=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.remoteStreams.get(t)){e.next=2;break}throw new mA(pA.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new cF(this._ctx,t,t,!1,!0,{audiostream:!0,localaudio:!0,videostream:!0,localvideo:!0,extaudio:!1,extvideo:!1,videoDescriptions:[]})).on("onSEIMessage",(function(e){if(e instanceof Uint8Array)for(var t=OD(e),i=0;i<t.seiCount;i++)n.emit(_G.ON_SEI_MESSAGED_RECEIVED,{sei:t.seis[i],publicStreamId:r.streamId})})),e.next=6,this._mediaServerClient.subscribePublicStream(r);case 6:return this.remoteStreams.set(t,r),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stopPlayPublicStream",value:function(e){var t=this.remoteStreams.get(e);if(t)return this.remoteStreams.delete(e),this._mediaServerClient.unsubscribePublicStream(t)}},{key:"destroy",value:function(){var e;this.remoteStreams.forEach((function(e){e.clean()})),this.remoteStreams=new $S,null===(e=this._mediaServerClient)||void 0===e||e.destroy(),this.removeAllListeners()}},{key:"_handleReconnected",value:(t=Rm(Tm().mark((function e(){var t,r,n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=$T(this.remoteStreams);try{for(n=function(){var e=eI(r.value,1)[0];i.remoteStreams.delete(e),i.startPlayPublicStream(e).then((function(){var t=i.remoteStreams.get(e);i.safeEmit(_G.RESUBSCRIBE,{stream:t})}))},t.s();!(r=t.n()).done;)n()}catch(o){t.e(o)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_bindEvents",value:function(){var e,t,r=this;null===(e=this._mediaServerClient)||void 0===e||e.on("joinSuccess",(function(e){e.reconnect&&r._handleReconnected()})),null===(t=this._mediaServerClient)||void 0===t||t.on("onRemoteStreamStats",(function(e){r.emit("onRemoteStreamStats",e)}))}}]),o}(aM),dW=new Pw("AudioDeviceManager",1),lW=function(e){NI(c,e);var t,r,n,i,o,a,s=QI(c);function c(e){var t;return Vl(this,c),Jd(tI(t=s.call(this)),"_audioLevelFetcher",void 0),Jd(tI(t),"_playbackDeviceTestTimer",void 0),Jd(tI(t),"_audioElement",void 0),Jd(tI(t),"_audioTrack",void 0),Jd(tI(t),"_mediaRecorder",void 0),Jd(tI(t),"_recoderTimer",void 0),Jd(tI(t),"_isAudioPlaybackDeviceTesting",!1),Jd(tI(t),"_isAudioDeviceRecordTesting",!1),Jd(tI(t),"_audioCaptureAndRecoderResolve",void 0),Jd(tI(t),"_onAutoplayFailed",void 0),Jd(tI(t),"_audioPlaybackDeviceId",void 0),t._extensionManager=e,t}return Ul(c,[{key:"audioTrack",get:function(){return this._audioTrack}},{key:"startAudioPlaybackDeviceTest",value:(a=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new mA(pA.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,dW.info("startAudioPlaybackDeviceTest()","Invoke"),e.prev=4,e.next=7,this._playAudioFile(t,{loop:!0});case 7:e.next=14;break;case 9:throw e.prev=9,e.t0=e.catch(4),dW.error("startAudioPlaybackDeviceTest()","error",e.t0),this.stopAudioPlaybackDeviceTest(),e.t0;case 14:this._startEmitAudioPlaybackDeviceTestVolume(r);case 15:case"end":return e.stop()}}),e,this,[[4,9]])}))),function(e,t){return a.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this._isAudioPlaybackDeviceTesting&&(dW.info("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(o=Rm(Tm().mark((function e(t,r,n){var i,o=this,a=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=a.length>3&&void 0!==a[3]?a[3]:3e4,window.MediaRecorder){e.next=3;break}throw new mA(pA.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 3:if(!this._isAudioDeviceRecordTesting&&!this._isAudioPlaybackDeviceTesting){e.next=5;break}throw new mA(pA.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 5:return this._isAudioDeviceRecordTesting=!0,dW.info("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){dW.info("startAudioDeviceRecordTest()","".concat(i,'ms automatic call method "stopAudioDeviceRecordAndPlayTest"')),o._stopAudioCaptureAndRecoder()}),i),e.prev=8,this._onAutoplayFailed=r,e.next=12,this._startAudioCaptureAndRecoder(t,null!=n?n:100);case 12:e.next=19;break;case 14:throw e.prev=14,e.t0=e.catch(8),this._isAudioDeviceRecordTesting=!1,delete this._onAutoplayFailed,e.t0;case 19:delete this._audioCaptureAndRecoderResolve;case 20:case"end":return e.stop()}}),e,this,[[8,14]])}))),function(e,t,r){return o.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){dW.info("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(dW.info("stopAudioDevicePlayTest()","Invoke"),this._isAudioDeviceRecordTesting=!1,this.stopAudioDeviceRecordAndPlayTest(),this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement()),delete this._onAutoplayFailed}},{key:"getRecordTrack",value:function(){return this._audioTrack}},{key:"setSinkId",value:(i=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(dW.info("setSinkId()","Invoke"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=3;break}throw new mA(pA.NOT_SUPPORTED,"setSinkId not supported by current browser");case 3:return e.next=5,XU.getDeviceById(t);case 5:if(r=e.sent){e.next=8;break}throw new mA(pA.INVALID_DEVICE_ID,"audio playback device id ".concat(t," is invalid"));case 8:return this._audioPlaybackDeviceId=t,this._setAudioCtxSinkId(),e.abrupt("return",r);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getSinkId",value:function(){return this._audioPlaybackDeviceId}},{key:"destroy",value:function(){dW.info("destroy()","Invoke"),OI(CI(c.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:(n=Rm(Tm().mark((function e(t,r){var n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dW.info("_playAudioFile()",Om(n="Invoke url=".concat(t,"; loop=")).call(n,r.loop)),e.abrupt("return",new Y_((function(e,n){var o=IH("audio",{attributes:{src:t,crossOrigin:"anonymous"}});i._audioElement=o,o.loop=r.loop,i._audioLevelFetcher=new $U(o),o.onplaying=function(){o.onplaying=null,dW.info("_playAudioFile()","onplaying"),e()},o.onerror=function(){var e=Rm(Tm().mark((function e(t){var r,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:dW.error("_playAudioFile()","onerror",t),i=t.message||(null==o||null===(r=o.error)||void 0===r?void 0:r.message),n(new mA(pA.LOAD_RESOURCES_FAILED,"Failed to play recorded audio".concat(i?", reason: ".concat(i):".")));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),i._setAudioCtxSinkId().then((function(){var e,t;return null===(e=o.play())||void 0===e||null===(t=e.catch)||void 0===t?void 0:t.call(e,(function(e){var t;dW.warn("_playAudioFile()","autoplay error",e);var r=Om(t="Failed to play recorded audio, ".concat(e.name,": ")).call(t,e.message);"NotAllowedError"===e.name&&i._onAutoplayFailed?i._onAutoplayFailed((function(){var e;return Y_.all([null===(e=i._audioLevelFetcher)||void 0===e?void 0:e.resume(),o.play()])})):n(new mA(pA.LOAD_RESOURCES_FAILED,r))}))}))})));case 2:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"_destroyAudioElement",value:function(){this._audioElement&&(dW.info("_destroyAudioElement()","Invoke"),this._audioElement.onplaying=null,this._audioElement.onerror=null,this._audioElement.src="",delete this._audioElement,"function"==typeof this._audioCaptureAndRecoderResolve&&this._audioCaptureAndRecoderResolve())}},{key:"_startEmitAudioPlaybackDeviceTestVolume",value:function(e){var t=this;e=Math.max(e,100),this._audioElement&&(dW.info("_startEmitAudioPlaybackDeviceTestVolume()","start timer(".concat(e,"ms)")),this._playbackDeviceTestTimer=self.setInterval((function(){t._audioLevelFetcher&&t.emit("onAudioPlaybackDeviceTestVolume",t._audioLevelFetcher.getAudioLevel())}),e))}},{key:"_stopEmitAudioPlaybackDeviceTestVolume",value:function(){var e;void 0!==this._playbackDeviceTestTimer&&(dW.info("_stopEmitAudioPlaybackDeviceTestVolume()","stop timer"),self.clearInterval(this._playbackDeviceTestTimer),delete this._playbackDeviceTestTimer),null===(e=this._audioLevelFetcher)||void 0===e||e.destroy(),delete this._audioLevelFetcher}},{key:"_startAudioCaptureAndRecoder",value:(r=Rm(Tm().mark((function e(t,r){var n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,AV({},this._extensionManager);case 2:return this._audioTrack=e.sent,this._audioTrack.setVolume(r),n=new MediaStream([this._audioTrack.getTrack("preprocessing")]),dW.info("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new Y_((function(e,r){var o,a;"function"==typeof MediaRecorder.isTypeSupported&&(o=gE(a=["audio/webm","audio/mp4"]).call(a,(function(e){return MediaRecorder.isTypeSupported(e)})),dW.info("startAudioDeviceRecordTest()","use mimeType: ".concat(o))),i._mediaRecorder=new MediaRecorder(n,o?{mimeType:o}:void 0);var s=i._mediaRecorder.mimeType;i._mediaRecorder.ondataavailable=function(){var n=Rm(Tm().mark((function n(o){var a,c;return Tm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!i._isAudioDeviceRecordTesting){n.next=16;break}return dW.info("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),c=new Blob([o.data],{type:s}),n.prev=3,n.next=6,i._playAudioFile($X.createObjectURL(c),{loop:!1});case 6:n.next=11;break;case 8:return n.prev=8,n.t0=n.catch(3),n.abrupt("return",r(n.t0));case 11:i._startEmitAudioPlaybackDeviceTestVolume(t),null===(a=i._audioElement)||void 0===a||a.addEventListener("ended",(function(){i.stopAudioDevicePlayTest(),e()})),i._audioCaptureAndRecoderResolve=e,n.next=17;break;case 16:e();case 17:case"end":return n.stop()}}),n,null,[[3,8]])})));return function(e){return n.apply(this,arguments)}}(),i._mediaRecorder.onerror=function(e){r(new mA(pA.AUDIO_DEVICE_TEST_FAILED,e.message||"mediaRecorder error"))},i._audioCaptureAndRecoderResolve=e,i._mediaRecorder.start()})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_stopAudioCaptureAndRecoder",value:function(){var e;this._mediaRecorder&&("recording"===this._mediaRecorder.state&&this._mediaRecorder.stop(),delete this._mediaRecorder),null===(e=this._audioTrack)||void 0===e||e.close(),delete this._audioTrack}},{key:"_setAudioCtxSinkId",value:(t=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._audioPlaybackDeviceId){"default"===t&&(t="");try{null===(r=eV.getAudioContextInstance())||void 0===r||null===(n=r.setSinkId)||void 0===n||n.call(r,t),dW.info("setSinkId","ctx.sinkId=".concat(t))}catch(o){dW.error("setSinkId",Om(i="failed, ".concat(o.name," - ")).call(i,o.message))}}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),c}(nM.exports.EventEmitter),hW=new Pw("VideoSnapshot",1),pW=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},vW=function(){var e=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=document.createElement("canvas"),o=i.getContext("2d")){e.next=4;break}throw new Error("canvas.getContext error");case 4:if(a=function(e,t,n){return t=t||e.width,n=n||e.height,i.width=t,i.height=n,r?o.setTransform(-1,0,0,1,t,0):o.setTransform(1,0,0,1,0,0),o.drawImage(e,0,0,t,n),o.getImageData(0,0,t,n)},s=Date.now(),!(c=pW(n))){e.next=16;break}return hW.info("takeSnapshot","VideoPlayer already set."),e.next=11,a(c,c.videoWidth,c.videoHeight);case 11:return u=e.sent,hW.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",u);case 16:if(!window.ImageCapture){e.next=29;break}if("live"!==(d=new window.ImageCapture(t)).track.readyState||!d.track.enabled||d.track.muted){e.next=29;break}return hW.info("takeSnapshot","use ImageCapture"),e.t0=a,e.next=23,d.grabFrame();case 23:return e.t1=e.sent,e.next=26,(0,e.t0)(e.t1);case 26:return l=e.sent,hW.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",l);case 29:return hW.info("takeSnapshot","use temp video"),e.abrupt("return",new Y_((function(e,r){var n=new MediaStream([t]),i=document.createElement("video");i.setAttribute("playsinline",""),i.muted=!0,document.body.appendChild(i),i.onplaying=function(){var r=a(i,i.videoWidth,i.videoHeight);hW.info("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e(r),n.removeTrack(t),i.srcObject=null,i.load()},i.onerror=r,i.srcObject=n,i.play()})));case 31:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),fW=function(){return{url:"",video:{codec:Il.H264,width:640,height:360,fps:15,gop:2,kBitRate:_W(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:Tl.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function _W(e,t,r){return e*t<=288e3?r<=15?800:1200:e*t<=864e3?r<=15?1200:1800:e*t<=1152e3?r<=15?1600:2400:e*t<=2592e3?r<=15?2500:3750:r<=15?3300:5e3}function mW(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new mA(pA.INVALID_PARAMS,"Invalid rtmp address")}function yW(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new mA(pA.INVALID_PARAMS,"regions should not be empty.");var t,r=$T(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new mA(pA.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if("boolean"!=typeof n.isScreenStream)throw new mA(pA.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(i){r.e(i)}finally{r.f()}}function gW(e,t){var r,n,i,o=function(e,r){var n=pb(e).call(e,(function(e,t){return null==e?void 0:e[t]}),t),i=pb(e).call(e,(function(e,t){return null==e?void 0:e[t]}),fW());return n&&r(n)?n:i},a=function(e){return e%2==0?e:e+1},s=a(o(["video","width"],(function(e){return e>=2&&e<=1920}))),c=a(o(["video","height"],(function(e){return e>=2&&e<=1920}))),u=o(["video","fps"],(function(e){return e>=1&&e<=60})),d=(null===(r=t.video)||void 0===r?void 0:r.kBitRate)||0,l=o(["audio","sampleRate"],(function(e){var t;return!!gE(t=[32e3,44100,48e3]).call(t,(function(t){return t===e||t/1e3===e}))}));return{type:"transcode",action:e,transcodeMeta:{transcode:{url:t.url},control:{protocol:"2.0"},audio:{codec:o(["audio","codec"],(function(e){return"AAC"===e})),bitRate:1e3*o(["audio","kBitRate"],(function(e){return e>=32&&e<=192})),sampleRate:l<100?1e3*l:l,channels:o(["audio","channels"],(function(e){var t;return mk(t=[1,2]).call(t,e)})),profile:o(["audio","AACProfile"],(function(e){var t;return mk(t=[Tl.LC,Tl.HEv1,Tl.HEv2]).call(t,e)}))},video:{codec:o(["video","codec"],(function(e){var t;return mk(t=["H264","H265"]).call(t,e)})),fps:u,gop:o(["video","gop"],(function(e){return e>=1&&e<=5}))*u,bitRate:1e3*(d>=16&&d<=1e4?d:_W(s,c,u)),width:s,height:c},layout:{canvas:{bgnd:o(["layout","backgroundColor"],(function(e){return/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(e)}))},regions:(null===(n=t.layout)||void 0===n||null===(i=n.regions)||void 0===i?void 0:jm(i).call(i,(function(e){var t,r;return{alpha:!e.alpha||Number(e.alpha)>1||Number(e.alpha)<=0?1:Number(e.alpha),uid:e.userId,zorder:!e.zorder||Number(e.zorder)<0||Number(e.zorder)>100?0:Number(e.zorder),x:!e.x||Number(e.x)>=1||Number(e.x)<0?0:Number(e.x),y:!e.y||Number(e.y)>=1||Number(e.y)<0?0:Number(e.y),w:!e.w||Number(e.w)>1||Number(e.w)<=0?1:Number(e.w),h:!e.h||Number(e.h)>1||Number(e.h)<=0?1:Number(e.h),renderMode:e.renderMode&&mk(t=[1,2,3]).call(t,e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&mk(r=[0,1,2]).call(r,e.contentControl)?e.contentControl:0,screen:!!e.isScreenStream}})))||[],app_data:o(["layout","appData"],(function(e){return"string"==typeof e}))}}}}var SW,bW={getDefaultValue:fW,checkStartParams:function(e){var t;mW(e.url),yW(null===(t=e.layout)||void 0===t?void 0:t.regions)},checckUpdateParams:function(e){var t;e.url&&mW(e.url),yW(null===(t=e.layout)||void 0===t?void 0:t.regions)},getStartParams:function(e){return gW("started",e)},getUpdateParams:function(e){return gW("layoutChanged",e)}},EW=ad,kW=tc,TW=function(e,t,r,n){for(var i,o=n>1?void 0:n?kW(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&EW(t,r,o),o},IW=new Pw("Engine",0),RW=function(e){NI(ke,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,D,N,M,P,L,U,V,F,B,j,G,H,z,K,X,W,q,Y,J,Q,Z,$,ee,te,re,ne,ie,oe,ae,se,ce,ue,de,le,he,pe,ve,fe,_e,me,ye,ge,Se,be,Ee=QI(ke);function ke(e,t,r){var n;return Vl(this,ke),Jd(tI(n=Ee.call(this)),"monitor",void 0),Jd(tI(n),"_room",void 0),Jd(tI(n),"_publicStreamManager",void 0),Jd(tI(n),"_appId",void 0),Jd(tI(n),"_businessId",void 0),Jd(tI(n),"_visibility",!0),Jd(tI(n),"_localVideoTrack",void 0),Jd(tI(n),"_localAudioTrack",void 0),Jd(tI(n),"_localImgVideoTrack",void 0),Jd(tI(n),"_localImgScreenTrack",void 0),Jd(tI(n),"_localScreenVideoTrack",void 0),Jd(tI(n),"_localScreenAudioTrack",void 0),Jd(tI(n),"_tempMixingAudioTrack",void 0),Jd(tI(n),"_localAudioVolume",100),Jd(tI(n),"_localScreenAudioVolume",100),Jd(tI(n),"_remoteAudioVolume",new $S),Jd(tI(n),"_remoteScreenAudioVolume",new $S),Jd(tI(n),"_publicAudioVolume",new $S),Jd(tI(n),"_videoPlayer",void 0),Jd(tI(n),"_screenPlayer",void 0),Jd(tI(n),"_remoteVideoPlayer",new $S),Jd(tI(n),"_remoteScreenPlayer",new $S),Jd(tI(n),"_remoteAudioPlayer",new $S),Jd(tI(n),"_remoteScreenAudioPlayer",new $S),Jd(tI(n),"_publicStreamAudioPlayer",new $S),Jd(tI(n),"_publicStreamVideoPlayer",new $S),Jd(tI(n),"_publicStreamIds",new $S),Jd(tI(n),"_roomConfig",void 0),Jd(tI(n),"_videoStreamConstraints",NN),Jd(tI(n),"_audioStreamConstraints",{}),Jd(tI(n),"_enableSimulcast",!1),Jd(tI(n),"_videoStreamEncodeConfig",[NN]),Jd(tI(n),"_screenStreamEncodeConfig",[MN]),Jd(tI(n),"_dummyMainImage",void 0),Jd(tI(n),"_dummyScreenImage",void 0),Jd(tI(n),"_trackSourceType",void 0),Jd(tI(n),"_liveTranscodeConfig",void 0),Jd(tI(n),"_startCloudProxyTimestamp",void 0),Jd(tI(n),"_localVideoDeviceId",void 0),Jd(tI(n),"_localAudioDeviceId",void 0),Jd(tI(n),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeStreamIds:{}}),Jd(tI(n),"_audioVolumeIndicationTimer",void 0),Jd(tI(n),"_dummyMainTimer",void 0),Jd(tI(n),"_dummyScreenTimer",void 0),Jd(tI(n),"_audioPropertiesReportTimer",null),Jd(tI(n),"_mirrorType",hl.MIRROR_TYPE_RENDER),Jd(tI(n),"_audioMixingManager",void 0),Jd(tI(n),"_pubLock",void 0),Jd(tI(n),"_rtmClient",void 0),Jd(tI(n),"_messageStatisticsObserver",void 0),Jd(tI(n),"_tempRoomInfo",void 0),Jd(tI(n),"_originIceConfigRequestUrls",void 0),Jd(tI(n),"_originConfigServerUrls",void 0),Jd(tI(n),"_originLogServerUrl",void 0),Jd(tI(n),"_extensionManager",void 0),Jd(tI(n),"_audioDeviceManager",void 0),Jd(tI(n),"_remoteVideoConfig",new $S),Jd(tI(n),"_cameraCapturing",!1),Jd(tI(n),"_interruptCameraCapture",!1),Jd(tI(n),"_micCapturing",!1),Jd(tI(n),"_interruptMicCapture",!1),Jd(tI(n),"_config",void 0),Jd(tI(n),"_needClosePreTrack",!1),Jd(tI(n),"_ctx",void 0),Jd(tI(n),"_updateMixAudioTrack",function(){var e=Rm(Tm().mark((function e(t){var r,i,o=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.length>1&&void 0!==o[1]?o[1]:Dl.PLAYOUT_AND_PUBLISH,IW.info("_updateMixAudioTrack()"),n._localAudioTrack){e.next=5;break}return t&&(n._tempMixingAudioTrack={track:t,type:i}),e.abrupt("return");case 5:if(t?(n._localAudioTrack.mixType=i,n._localAudioTrack.mixedAudioTrack=t):(delete n._localAudioTrack.mixType,delete n._localAudioTrack.mixedAudioTrack),null===(r=n._room)||void 0===r||!r.hasPublished){e.next=9;break}return e.next=9,n._updatePublish();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),Jd(tI(n),"_onAudioMixingMessage",(function(e){n.safeEmit(Pl.onAudioMixingStateChanged,e)})),Jd(tI(n),"_onAudioMixingAutoplayFailed",(function(e){n.safeEmit(Pl.onAutoplayFailed,e)})),n.id=t,n._appId=e,n._pubLock=new fG("pubLock"),n._addDeviceEventHandler(),n._extensionManager=new rV(t),n._audioDeviceManager=new lW(n._extensionManager),n._audioMixingManager=new iW({getLocalAudioTrack:function(){return n._localAudioTrack},updateLocalAudioTrack:n._updateMixAudioTrack,emitMessage:n._onAudioMixingMessage,onAutoPlayFailed:n._onAudioMixingAutoplayFailed},t),n._ctx={id:t,appId:e,avSync:!0,streamRTT:{},useCloudProxy:!1,audioProfileManager:new cW(e),userPriority:new $S,expectedIDC:null==r?void 0:r.expectedIDC,joinRoomConfig:new TN(t),enableFallbackHandler:CW(e)},window.__rtc_engine__=tI(n),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=tI(n),n._trackSourceType={video:$d.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:$d.VIDEO_SOURCE_TYPE_INTERNAL,audio:el.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:el.AUDIO_SOURCE_TYPE_INTERNAL},n._config=r,n._rtmClient=new sW(n._ctx),n._handleRTMClient(n._rtmClient),n._handleAudioDeviceManager(),n._messageStatisticsObserver=new CO(t),n.monitor=VO(t),wO.createRTSMsgReportor(n.id),n._getServerConfig(),n}return Ul(ke,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(be=Rm(Tm().mark((function e(t){var r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("updateToken()","token: %s",t),UN(t,"token"),!this.waitForNewToken||!this._tempRoomInfo){e.next=8;break}return n=this._tempRoomInfo,i=n.config,o=n.userInfo,a=n.roomId,delete this._tempRoomInfo,e.next=7,this.joinRoom(t,a,o,i);case 7:return e.abrupt("return",e.sent);case 8:if(this._room){e.next=10;break}throw new mA(pA.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 10:return e.next=12,null===(r=this._room)||void 0===r?void 0:r.updateToken(t);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return be.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(Se=Rm(Tm().mark((function e(t){var r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("setVideoCaptureDevice()","deviceId: %s",t),UN(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:return r=zB({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete r.deviceId,r.facingMode=t):r.deviceId={exact:t},nN&&XD&&pN>=85&&pN<=91&&(null===(n=this._videoPlayer)||void 0===n||n.removeTrack()),this._needClosePreTrack=this._needClosePreTrack||nN&&XD,this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),delete this._localVideoTrack),IW.info("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=13,IV(r,this._extensionManager).catch((function(e){if(o._localVideoTrack&&!o._localVideoTrack.dummy)return IW.warn("setVideoCaptureDevice()","createCameraVideoTrack failed, stop pre VideoTrack."),o._removeLocalTrackEvents(o._localVideoTrack),o._localVideoTrack.close(),delete o._localVideoTrack,IV(r,o._extensionManager).then((function(e){return o._needClosePreTrack=!0,e})).catch(Rm(Tm().mark((function t(){var r;return Tm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return IW.error("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,IV(o._videoStreamConstraints,o._extensionManager);case 3:throw r=t.sent,o._switchTrack(r),e;case 6:case"end":return t.stop()}}),t)}))));throw e}));case 13:return i=e.sent,IW.success("setVideoCaptureDevice()","createCameraVideoTrack success."),this._videoStreamConstraints=r,this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),e.next=19,this._switchTrack(i);case 19:case"end":return e.stop()}}),e,this)}))),function(e){return Se.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(ge=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("setAudioCaptureDevice()","deviceId: %s",t),UN(t,"deviceId"),this._localAudioDeviceId=t,this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._localAudioTrack.close(),this._removeLocalTrackEvents(this._localAudioTrack),e.prev=8,this._micCapturing=!0,e.next=12,AV(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 12:if(i=e.sent,!this._interruptMicCapture){e.next=18;break}return this._interruptMicCapture=!1,i.close(),this._localAudioTrack=void 0,e.abrupt("return");case 18:if(this._initLocalTrackEvents(i),this._localAudioTrack=i,this._localAudioTrack.setVolume(this._localAudioVolume),this._room){e.next=23;break}return e.abrupt("return");case 23:if(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n||!n.pubAudio){e.next=26;break}return e.next=26,this._updatePublish();case 26:return e.prev=26,this._micCapturing=!1,e.finish(26);case 29:case"end":return e.stop()}}),e,this,[[8,,26,29]])}))),function(e){return ge.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){XU.on(Pl.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),XU.on(Pl.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,D,N,M,P=this;null===(e=this._room)||void 0===e||e.on(cG.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(cG.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(cG.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(_G.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(_G.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(_G.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(cG.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(cG.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(cG.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(cG.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(d=this._room)||void 0===d||d.on(cG.POST_PROCESSING_MESSAGE,(function(e){"2.0"===e.protocol?P._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?P._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&P._onLiveTranscodingResult(e)})),null===(l=this._room)||void 0===l||l.on(dG.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(h=this._room)||void 0===h||h.on(dG.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return P.safeEmit(Pl.onVendorConnectionStateChanged,e)})),null===(p=this._room)||void 0===p||p.on(_G.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(v=this._room)||void 0===v||v.on(_G.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(f=this._room)||void 0===f||f.on(_G.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(_=this._room)||void 0===_||_.on(_G.ON_PUBLISH_RESULT,(function(e){var t;null!==(t=P._room)&&void 0!==t&&t._roomConfig.isAutoPublish&&P.safeEmit(Pl.onAutoPublishResult,e)})),null===(m=this._room)||void 0===m||m.on(_G.ON_REMOTE_STREAM_STATS,(function(e){P.safeEmit(Pl.onRemoteStreamStats,e)})),null===(y=this._room)||void 0===y||y.on(_G.ON_LOCAL_STREAM_STATS,(function(e){P.safeEmit(Pl.onLocalStreamStats,e)})),null===(g=this._room)||void 0===g||g.on(_G.ON_SUBTITLE_STATE_CHANGED,(function(e){P.safeEmit(Pl.onSubtitleStateChanged,e)})),null===(S=this._room)||void 0===S||S.on(_G.ON_SUBTITLE_MESSAGE_RECEIVED,(function(e){P.safeEmit(Pl.onSubtitleMessageReceived,e)})),null===(b=this._room)||void 0===b||b.on(_G.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(E=this._room)||void 0===E||E.on(_G.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;P._updateAudioPlayerState(t),P.safeEmit(Pl.onUserStartAudioCapture,{userId:r})})),null===(k=this._room)||void 0===k||k.on(_G.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(Pl.onUserStopAudioCapture,{userId:t})})),null===(T=this._room)||void 0===T||T.on(_G.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(Pl.onUserStartVideoCapture,{userId:t})})),null===(I=this._room)||void 0===I||I.on(_G.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(Pl.onUserStopVideoCapture,{userId:t})})),null===(R=this._room)||void 0===R||R.on(_G.ON_SEI_MESSAGED_RECEIVED,(function(e){P.safeEmit(Pl.onSEIMessageReceived,e)})),null===(A=this._room)||void 0===A||A.on(_G.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){P.safeEmit(Pl.onRemoteVideoSizeChanged,e,t)})),null===(w=this._room)||void 0===w||w.on(_G.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return P.safeEmit(Pl.onSimulcastSubscribeFallback,e)})),null===(C=this._room)||void 0===C||C.on(_G.RECONNECT_FAILED,(function(){P.safeEmit(Pl.onError,{errorCode:pA.RECONNECT_FAILED})})),null===(x=this._room)||void 0===x||x.on(_G.ON_VIDEO_STREAM_BANNED,(function(e){P.safeEmit(Pl.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(O=this._room)||void 0===O||O.on(_G.ON_AUDIO_STREAM_BANNED,(function(e){P.safeEmit(Pl.onAudioStreamBanned,{uid:e.uid,banned:e.banned})})),null===(D=this._room)||void 0===D||D.on(_G.ON_FORWARD_STREAM_ERROR,(function(e){P.safeEmit(Pl.onForwardStreamError,e)})),null===(N=this._room)||void 0===N||N.on(_G.ON_REJOIN_WITH_TCP,(function(){P.safeEmit(Pl.onRejoinWithTcp)})),null===(M=this._room)||void 0===M||M.on(_G.ON_ICE_CONNECT_WITH_TCP,(function(){P.safeEmit(Pl.onIceConnectWithTcp)}))}},{key:"safeEmit",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return ZN(e)&&BO(this.id,e,i),(t=OI(CI(ke.prototype),"safeEmit",this)).call.apply(t,Om(r=[this,e]).call(r,i))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(ye=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._room){e.next=2;break}return e.abrupt("return",!1);case 2:return this._room=new TH({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:bl.communication},this._ctx),this._addHandlerEventHandler(),e.next=6,this._room.connect(this._appId);case 6:case"end":return e.stop()}}),e,this)}))),function(){return ye.apply(this,arguments)})},{key:"joinRoom",value:(me=Rm(Tm().mark((function e(t,r,n,i){var o,a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("joinRoom()","token: %o roomId: %o, userInfo: %o, roomConfig: %o",t,r,n,i),zN(t)||UN(t,"token"),KN(r),qN(n),YN(i=zB({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:bl.communication},i)),(null===(o=this._room)||void 0===o?void 0:o.connectionState)!==YG.CONNECTED){e.next=8;break}throw new mA(pA.REPEAT_JOIN,"Already joined");case 8:return this._room||(this._room=new TH(i,this._ctx),this._addHandlerEventHandler()),this._room.roomConfig=i,a=this._liveTranscodeConfig&&bW.getStartParams(this._liveTranscodeConfig),s=Zd(Zd({},n),{},{businessId:this._businessId,role:this._visibility?oW.NORMAL_USER:oW.SILENT_USER}),e.prev=12,this._ctx.useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),pH(s),e.next=17,this._room.join(this._appId,r,t,s,a);case 17:return u=e.sent,this._roomConfig=i,this._ctx.audioProfileManager.setRoomId(r),this._tempRoomInfo&&delete this._tempRoomInfo,null!==(c=i)&&void 0!==c&&c.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:ul.AUDIO_AND_VIDEO}):this.safeEmit(Pl.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),wO.setRoomId(this.id,r),wO.setUserId(this.id,n.userId),e.abrupt("return",u);case 27:throw e.prev=27,e.t0=e.catch(12),e.t0.code===pA.INVALID_TOKEN&&(this._tempRoomInfo={config:i,roomId:r,userInfo:s}),null===(d=this._room)||void 0===d||d.destroy(),delete this._room,e.t0;case 33:case"end":return e.stop()}}),e,this,[[12,27]])}))),function(e,t,r,n){return me.apply(this,arguments)})},{key:"leaveRoom",value:(_e=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],IW.info("leaveRoom()"),!t){e.next=7;break}return e.next=5,null===(r=this._room)||void 0===r?void 0:r.leave(t);case 5:e.next=8;break;case 7:null===(n=this._room)||void 0===n||n.leave(t).catch();case 8:this._removeHandlerEventHandler(),this._ctx.audioProfileManager.setRoomId(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new $S,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new $S,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new $S,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new $S,this._roomConfig=void 0,this._publicStreamIds=new $S,wO.setRoomId(this.id,""),wO.setUserId(this.id,"");case 24:case"end":return e.stop()}}),e,this)}))),function(){return _e.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;IW.info("destroy()"),this.removeAllListeners(),this._removeHandlerEventHandler(),null===(e=this._room)||void 0===e||e.destroy(),this._room=void 0,null===(t=this._videoPlayer)||void 0===t||t.destroy(),this._videoPlayer=void 0,this._screenPlayer=void 0,this._videoStreamConstraints={},this._videoStreamEncodeConfig=[NN],this._screenStreamEncodeConfig=[MN],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeStreamIds:{}},this._messageStatisticsObserver.destroy(),this.monitor.destroy(),wO.destroyRTSMsgReportor(this.id),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyMainTimer),clearInterval(this._dummyScreenTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close(),this._localAudioTrack=void 0),this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localVideoTrack=void 0),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close(),this._localScreenAudioTrack=void 0),this._localScreenVideoTrack&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localScreenVideoTrack=void 0),this._localImgVideoTrack&&(this._localImgVideoTrack.stop(),this._localImgVideoTrack=void 0),this._localImgScreenTrack&&(this._localImgScreenTrack.stop(),this._localImgScreenTrack=void 0),this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new $S,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new $S,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new $S,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new $S,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new $S,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new $S,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._publicStreamManager)||void 0===r||r.destroy(),this._publicStreamIds=new $S,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new $S,this._ctx.userPriority.clear(),this._extensionManager.destroy(),this._cameraCapturing=!1,this._micCapturing=!1,this._interruptCameraCapture=!1,this._interruptMicCapture=!1,this._ctx.avSync=!0,this._localAudioVolume=100,this._localScreenAudioVolume=100,this._remoteAudioVolume.clear(),this._remoteScreenAudioVolume.clear(),this._publicAudioVolume.clear()}},{key:"publishStream",value:(fe=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!CD(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,bV(this._localImgVideoTrack,this._extensionManager);case 6:this._localVideoTrack=e.sent;case 7:return e.next=9,this._updatePublish({mediaType:t});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return fe.apply(this,arguments)})},{key:"unpublishStream",value:(ve=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("unpublishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!r){e.next=5;break}return e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.unpublish());case 5:return e.next=7,this._updatePublish({mediaType:t,pubState:yG.UNPUB});case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return ve.apply(this,arguments)})},{key:"publishScreen",value:(pe=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("publishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.prev=3,!CD(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,kV(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:yG.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof mA)){e.next=18;break}throw e.t0;case 18:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return pe.apply(this,arguments)})},{key:"unpublishScreen",value:(he=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IW.info("unpublishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.next=5,this._updateScreenPublish({mediaType:t,pubState:yG.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return he.apply(this,arguments)})},{key:"subscribeStream",value:(le=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IW.info("subscribeStream()","userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!1,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return le.apply(this,arguments)})},{key:"_subscribe",value:(de=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._checkMediaType(n),this._assertNotInRoom(),n!==ul.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){e.next=5;break}return IW.warn("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 5:if(u=this._room.remoteStreams.get(r),d=null==u?void 0:gE(u).call(u,(function(e){return e.isScreen===t}))){e.next=9;break}throw new mA(pA.STREAM_NOT_EXIST,"stream not exist");case 9:return l=this._pauseAllSubscribeState.audio,h=this._pauseAllSubscribeState.video,this._pauseAllSubscribeState.audio&&(n-=n&ul.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&ul.VIDEO),IW.warn("subscribeStream()","due to pauseAll mediaType: %o",n),p=d.hasSubscribed,v=this._remoteVideoConfig.get(r)||(null===(o=this._roomConfig)||void 0===o?void 0:o.remoteVideoConfig),d.originalMediaType=n,e.next=19,this._room.subscribe(d,n,v);case 19:wD(n)&&this._updateAudioPlayerState(d),CD(n)&&this._updateVideoPlayerState(d),f=0,_=0,l!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?f|=ul.AUDIO:_|=ul.AUDIO),h!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?f|=ul.VIDEO:_|=ul.VIDEO),f&&this.pauseAllSubscribedStream(f),_&&this.resumeAllSubscribedStream(_),this._pauseAllSubscribeState.resumeStreamIds[d.streamId]=d.streamId,!t&&(null!==(a=this._roomConfig)&&void 0!==a&&a.isAutoSubscribeAudio||null!==(s=this._roomConfig)&&void 0!==s&&s.isAutoSubscribeVideo)&&(d.audioTrack||d.videoTrack)&&(m={userId:r,isScreen:!1,state:il.SUBSCRIBE_SUCC},this.safeEmit(Pl.onAutoSubscribeResult,m)),null!==(c=this._room)&&void 0!==c&&c.multiChatMode||p||!wD(n)||!d.hasAudio||null===(y=d.observer)||void 0===y||y.setSubscribeAudio(!0),!p&&CD(n)&&d.hasVideo&&(null===(g=d.observer)||void 0===g||g.setSubscribeVideo(!0));case 31:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return de.apply(this,arguments)})},{key:"unsubscribeStream",value:(ue=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:IW.info("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this._unsubscribe(!1,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ue.apply(this,arguments)})},{key:"subscribeScreen",value:(ce=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IW.info("subscribeScreen() userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!0,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ce.apply(this,arguments)})},{key:"unsubscribeScreen",value:(se=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:IW.info("unsubscribeScreen() userId: %o, mediaType: %o",t,r),this._unsubscribe(!0,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return se.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(this._checkMediaType(r),this._assertNotInRoom(),r!==ul.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){var a,s=this._room.remoteStreams.get(t),c=null==s?void 0:gE(s).call(s,(function(t){return t.isScreen===e}));if(null==c||!c.hasSubscribed)throw new mA(pA.STREAM_NOT_EXIST,"stream not exist");if(nN&&pN&&pN>=85&&pN<=91&&r!==ul.AUDIO)null===(a=e?this._remoteScreenPlayer.get(t):this._remoteVideoPlayer.get(t))||void 0===a||a.stop();return this._room.unsubscribe(c,r).then((function(){n||delete o._pauseAllSubscribeState.resumeStreamIds[c.streamId]}))}IW.warn("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(ae=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IW.info("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),XN(t),$N(r),this._remoteVideoConfig.set(t,r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.updateSubVideoConfig(t,r).then((function(){})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return ae.apply(this,arguments)})},{key:"startVideoCapture",value:(oe=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("startVideoCapture()","deviceId: %s",t),zN(t)||UN(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,this._trackSourceType.video!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(!(this._cameraCapturing||this._localVideoTrack&&!this._localVideoTrack.dummy)){e.next=8;break}throw new mA(pA.REPEAT_CAPTURE,"Has already capture");case 8:return a=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?a.facingMode=t:a.deviceId={exact:t},this._videoStreamConstraints=a),s={},e.prev=11,this._cameraCapturing=!0,e.next=15,IV(a,this._extensionManager);case 15:if(u=e.sent,!this._interruptCameraCapture){e.next=22;break}throw this._interruptCameraCapture=!1,this._removeLocalTrackEvents(u),this._localVideoTrack=void 0,u.close(),new mA(pA.INTERRUPT,"interrupt by stopVideoCapture");case 22:if(this._initLocalTrackEvents(u),this._localVideoTrack=u,null===(c=this._videoPlayer)||void 0===c||c.playVideo(u),(d=null==u?void 0:u.getTrack())&&(s=d.getSettings(),l={width:s.width,height:s.height},this._localVideoTrack.resolution=l,setTimeout((function(){return p.safeEmit(Pl.onLocalVideoSizeChanged,{streamIndex:cl.STREAM_INDEX_MAIN,info:l})}))),this._room){e.next=29;break}return e.abrupt("return",s);case 29:return e.prev=29,this._cameraCapturing=!1,e.finish(29);case 32:return h=this._room._roomConfig.isAutoPublish,(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localStream)&&void 0!==n&&n.pubVideo||h)&&(this._visibility?this._updatePublish():this.safeEmit(Pl.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),null===(i=this._room.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableVideo(!0),e.abrupt("return",s);case 36:case"end":return e.stop()}}),e,this,[[11,,29,32]])}))),function(e){return oe.apply(this,arguments)})},{key:"stopVideoCapture",value:(ie=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("stopVideoCapture()"),!this._cameraCapturing){e.next=5;break}return this._interruptCameraCapture=!0,IW.warn("stopVideoCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.video!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 7:if(null===(t=this._videoPlayer)||void 0===t||t.stop(),this._localVideoTrack&&(this._localVideoTrack.dummy||((s=this._extensionManager.getPluginByName(tV.PRE_PROCESSING,"RTCBeautyExtension"))&&s.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localImgVideoTrack?(null===(c=this._localVideoTrack)||void 0===c||c.setTrack(this._localImgVideoTrack,this._extensionManager),this._localVideoTrack.dummy=!0):this._localVideoTrack=void 0)),this._room){e.next=11;break}return e.abrupt("return");case 11:if(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n||!n.pubVideo){e.next=14;break}return e.next=14,this._updatePublish();case 14:null===(i=this._room)||void 0===i||null===(o=i.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setEnableVideo(!1);case 15:case"end":return e.stop()}}),e,this)}))),function(){return ie.apply(this,arguments)})},{key:"startAudioCapture",value:(ne=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("startAudioCapture()","deviceId: $o",t),zN(t)||UN(t,"deviceId"),t=t||this._localAudioDeviceId,this._localAudioDeviceId=t,this._trackSourceType.audio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 6:if(!this._micCapturing&&!this._localAudioTrack){e.next=8;break}throw new mA(pA.REPEAT_CAPTURE,"Has already capture");case 8:return t&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),a={},e.prev=10,this._micCapturing=!0,e.next=14,AV(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 14:if(s=e.sent,!this._interruptMicCapture){e.next=21;break}throw this._interruptMicCapture=!1,this._removeLocalTrackEvents(s),s.close(),this._localAudioTrack=void 0,new mA(pA.INTERRUPT,"interrupt by stopAudioCapture");case 21:if(this._initLocalTrackEvents(s),this._localAudioTrack=s,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),s.getOrgTrack()&&(a=s.getOrgTrack().getSettings()),this._room){e.next=28;break}return e.abrupt("return",a);case 28:return e.prev=28,this._micCapturing=!1,e.finish(28);case 31:return c=this._room._roomConfig.isAutoPublish,(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localStream)&&void 0!==n&&n.pubAudio||c)&&(this._visibility?this._updatePublish():this.safeEmit(Pl.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),null===(i=this._room.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableAudio(!0),e.abrupt("return",a);case 35:case"end":return e.stop()}}),e,this,[[10,,28,31]])}))),function(e){return ne.apply(this,arguments)})},{key:"stopAudioCapture",value:(re=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("stopAudioCapture()"),!this._micCapturing){e.next=5;break}return this._interruptMicCapture=!0,IW.warn("stopAudioCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.audio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:if(this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,this._audioMixingManager.stopAll(),this._room){e.next=12;break}return e.abrupt("return");case 12:if(null===(t=this._room)||void 0===t||null===(r=t.localStream)||void 0===r||!r.pubAudio){e.next=15;break}return e.next=15,this._updatePublish();case 15:null===(n=this._room.localStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setEnableAudio(!1);case 16:case"end":return e.stop()}}),e,this)}))),function(){return re.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return IW.info("getAudioMixingManager()","invoke"),this._audioMixingManager}},{key:"startScreenCapture",value:(te=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m=this,y=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=y.length>0&&void 0!==y[0]?y[0]:{},IW.info("startScreenCapture()","config: %o",c),u=c.enableAudio,d=void 0!==u&&u,this._trackSourceType.screenVideo!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 5:if(this._trackSourceType.screenAudio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:return e.next=9,CV(d,this._extensionManager,this._screenStreamEncodeConfig[0]);case 9:if(l=e.sent,h=eI(l,2),p=h[0],null==(v=h[1])||v.setVolume(this._localScreenAudioVolume),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(t=this._localScreenAudioTrack)||void 0===t||t.close(),delete this._localScreenAudioTrack,this._localScreenVideoTrack=p,null!==(r=this._screenStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&p.setContentHint(null===(f=this._screenStreamEncodeConfig[0])||void 0===f?void 0:f.contentHint),(_=null==p?void 0:p.getTrack())&&setTimeout((function(){var e=_.getSettings(),t={width:e.width,height:e.height};p.resolution=t,m.safeEmit(Pl.onLocalVideoSizeChanged,{streamIndex:cl.STREAM_INDEX_SCREEN,info:{width:e.width,height:e.height}})}),500),v&&(this._localScreenAudioTrack=v,this._initLocalTrackEvents(v)),null===(n=this._screenPlayer)||void 0===n||n.playVideo(this._localScreenVideoTrack),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),!(null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubAudio||null!==(a=this._room)&&void 0!==a&&null!==(s=a.localScreenStream)&&void 0!==s&&s.pubVideo)){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(){return te.apply(this,arguments)})},{key:"stopScreenCapture",value:(ee=Rm(Tm().mark((function e(){var t,r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("stopScreenCapture()"),null===(t=this._screenPlayer)||void 0===t||t.stop(),this._localScreenVideoTrack&&(this._localScreenVideoTrack.dummy||(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localImgScreenTrack&&(null===(a=this._localScreenVideoTrack)||void 0===a||a.setTrack(this._localImgScreenTrack,this._extensionManager),this._localScreenVideoTrack.dummy=!0))),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,!(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localScreenStream)&&void 0!==n&&n.pubAudio||null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubVideo)){e.next=8;break}return e.next=8,this._updateScreenPublish();case 8:case"end":return e.stop()}}),e,this)}))),function(){return ee.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){if(IW.info("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),VN(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),t&&t.renderDom){var r,n,i,o,a=Zd(Zd({userId:this._getUserId()},t),{},{isLocal:!0});if(JN(a),e===cl.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new xH(this.id,a),this._initPlayerEvents(this._videoPlayer,!1,e),this._videoPlayer.mirror(!!this._mirrorType),this._localVideoTrack&&!this._localVideoTrack.dummy&&(null===(r=this._config)||void 0===r?void 0:r.autoPlayPolicy)!==kl.PLAY_MANUALLY&&this._videoPlayer.playVideo(this._localVideoTrack),(null===(n=this._room)||void 0===n?void 0:n.localStream)&&(this._room.localStream.videoDom=this._videoPlayer.domElement),this._videoPlayer.domElement;if(e===cl.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new xH(this.id,Zd(Zd({},a),{},{isScreen:!0,isLocal:!0})),this._initPlayerEvents(this._screenPlayer,!1,e),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy)!==kl.PLAY_MANUALLY&&this._screenPlayer.playVideo(this._localScreenVideoTrack),(null===(o=this._room)||void 0===o?void 0:o.localScreenStream)&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),this._screenPlayer.domElement;if(t&&void 0!==t.renderMode){var s=e===cl.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer;null==s||s.setRenderMode(t.renderMode)}}else{var c,u;e===cl.STREAM_INDEX_MAIN?(null===(c=this._videoPlayer)||void 0===c||c.destroy(!0),delete this._videoPlayer):(null===(u=this._screenPlayer)||void 0===u||u.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:($=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("startLiveTranscoding()","transcode: %o",t),bW.checkStartParams(t),this._liveTranscodeConfig=t,!((n=null===(r=this._room)||void 0===r?void 0:r.roomInfo)&&n.roomId.length+n.userInfo.userId.length>126)){e.next=6;break}throw new mA(pA.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(Pl.onStreamMixingEvent,{event:mG.START,error:0,message:""}),!this._room||this._room.connectionState!==YG.CONNECTED){e.next=11;break}return e.next=11,null===(i=this._room)||void 0===i?void 0:i.liveControlMessage(bW.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof mA)){e.next=19;break}throw e.t0;case 19:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return $.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(Z=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("updateLiveTranscoding()","transcode: %o",t),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete(i=zB({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,bW.checckUpdateParams(i),this._liveTranscodeConfig=zB(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(Pl.onStreamMixingEvent,{event:mG.UPDATE,error:0,message:""}),e.next=13,null===(o=this._room)||void 0===o?void 0:o.liveControlMessage(bW.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(e.t0 instanceof mA)){e.next=21;break}throw e.t0;case 21:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return Z.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(Q=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("stopLiveTranscoding()"),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete this._liveTranscodeConfig,e.prev=4,this.safeEmit(Pl.onStreamMixingEvent,{event:mG.STOP,error:0,message:""}),e.next=8,null===(t=this._room)||void 0===t?void 0:t.liveControlMessage({action:"stopped",type:"transcode"});case 8:e.next=17;break;case 10:if(e.prev=10,e.t0=e.catch(4),!(e.t0 instanceof mA)){e.next=16;break}throw e.t0;case 16:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return Q.apply(this,arguments)})},{key:"startSubtitle",value:(J=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IW.info("startSubtitle()","config: %o",t),this._assertNotInRoom(),e.next=4,null===(r=this._room)||void 0===r?void 0:r.startSubtitle(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return J.apply(this,arguments)})},{key:"stopSubtitle",value:function(){var e;IW.info("stopSubtitle()","invoke"),null===(e=this._room)||void 0===e||e.stopSubtitle()}},{key:"setBusinessId",value:function(e){return IW.info("setBusinessId()","businessId: %s",e),!function(e){return"string"!=typeof e}(e)&&!this._room&&(this.monitor.set({rtc_business_id:e}),this._businessId=e,!0)}},{key:"setUserVisibility",value:(Y=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("setUserVisibility()","enable: %o",t),t=!!t,this._visibility!==t){e.next=4;break}return e.abrupt("return");case 4:if(this._room){e.next=7;break}return this._visibility=t,e.abrupt("return");case 7:if(this._assertNotInRoom(),this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),e.t0=!t,!e.t0){e.next=13;break}return e.next=13,this._room.unpublish();case 13:return e.next=15,this._room.updateUserAttributes({role:t?oW.NORMAL_USER:oW.SILENT_USER});case 15:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:ul.AUDIO_AND_VIDEO});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return Y.apply(this,arguments)})},{key:"_initPlayerEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:cl.STREAM_INDEX_MAIN,i=n===cl.STREAM_INDEX_SCREEN;e.on("playback_event",(function(n){switch(n.eventName){case"timeupdate":return;case"loadeddata":if("audio"===n.type){var o,a,s=e.userId.replace("_screen",""),c=null===(o=t._room)||void 0===o||null===(a=o.remoteStreams.get(s))||void 0===a?void 0:gE(a).call(a,(function(e){return e.isScreen===i})),u=function(){r?t.safeEmit(Pl.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:s}):(t.safeEmit(Pl.onAudioFirstFrameDecoded,{userId:s,isScreen:i}),t.safeEmit(Pl.onRemoteAudioFirstFrame,{userId:s,isScreen:i})),t.monitor.report("first_remote_audio_render",{stream_id:"",stream_user_id:s||""},{isScreen:i})};c&&c.observer&&!c.observer.audioFirstFrameReceived?c.observer.once("recvAudioFirstFrame",u):u()}else{var d,l,h={userId:e.userId,height:(null===(d=e.domElement)||void 0===d?void 0:d.videoHeight)||0,width:(null===(l=e.domElement)||void 0===l?void 0:l.videoWidth)||0,isScreen:i};r?(h.publicStreamId=h.userId,delete h.userId,delete h.isScreen,t.safeEmit(Pl.onFirstPublicStreamVideoFrameRendered,h),t.safeEmit(Pl.onFirstPublicStreamVideoFrameDecoded,h)):e.isLocal||(t.safeEmit(Pl.onVideoFirstFrameRendered,h),t.safeEmit(Pl.onVideoFirstFrameDecoded,h),t.safeEmit(Pl.onRemoteVideoFirstFrame,h)),t.monitor.report("first_remote_video_render",{stream_id:"",stream_user_id:n.userId||""},{isScreen:i})}break;case"autoplay-error":return r&&(n.publicStreamId=n.userId),jO(t.id,"autoplay-error",e instanceof xH?"video":"audio",0,n.userId||""),void t.safeEmit(Pl.onAutoplayFailed,{userId:n.userId,kind:e instanceof xH?"video":"audio",mediaType:e instanceof xH?ul.VIDEO:ul.AUDIO,streamIndex:e.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN})}t.safeEmit(Pl.onPlayerEvent,n)}))}},{key:"_initLocalTrackEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];["track-ended","track-mute","track-unmute"].forEach((function(r){e.on(r,function(){var e=Rm(Tm().mark((function e(n){var i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.monitor.report("rtc_error",{message:Om(i="track-".concat(r," mediaType: ")).call(i,n.getTrack().kind),error_code:kG.TRACK_ERROR,capture_session_id:n.captureSessionId,media_type:r,reason:r}),o=!1,n!==t._localScreenAudioTrack&&n!==t._localScreenVideoTrack||(o=!0),a=n.getTrack(),s=a.kind,t.safeEmit({"track-ended":Pl.onTrackEnded,"track-mute":Pl.onTrackMute,"track-unmute":Pl.onTrackUnmute}[r],{kind:s,isScreen:o}),!rN&&!ZD){e.next=13;break}if("track-mute"!==r){e.next=12;break}if(JU.emit(qU.ON_IOS_LOCAL_TRACK_MUTE,s),"audio"!==s){e.next=12;break}return e.next=11,t.stopAudioCapture();case 11:t.startAudioCapture();case 12:"track-unmute"===r&&JU.emit(qU.ON_IOS_LOCAL_TRACK_UNMUTE,s);case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())})),e.on("resolution-change",(function(e){t._extensionManager.getPluginsByType(tV.PRE_PROCESSING).forEach((function(t){var r;null==t||null===(r=t.applyConstraints)||void 0===r||r.call(t,e)})),t.safeEmit(Pl.onLocalVideoSizeChanged,{streamIndex:r?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN,info:e})}))}},{key:"_removeLocalTrackEvents",value:function(e){e.removeAllListeners("track-ended"),e.removeAllListeners("track-mute"),e.removeAllListeners("track-unmute"),e.removeAllListeners("resolution-change")}},{key:"setRemoteVideoPlayer",value:function(e,t){IW.info("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),VN(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),JN(t);var r,n,i,o=t.userId;if(e===cl.STREAM_INDEX_MAIN){var a,s,c;if(null===(a=this._remoteVideoPlayer.get(o))||void 0===a||a.destroy(),!t.renderDom)return;var u=new xH(this.id,t);this._initPlayerEvents(u,!1,e),this._remoteVideoPlayer.set(o,u);var d=null===(s=this._room)||void 0===s||null===(c=s.remoteStreams.get(o))||void 0===c?void 0:gE(c).call(c,(function(e){return!e.isScreen}));return d&&(this._updateVideoPlayerState(d),d.videoDom=u.domElement),u.domElement}if(null===(r=this._remoteScreenPlayer.get(o))||void 0===r||r.destroy(),t.renderDom){var l=new xH(this.id,Zd(Zd({},t),{},{isScreen:!0}));this._remoteScreenPlayer.set(o,l),this._initPlayerEvents(l,!1,e);var h=null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(o))||void 0===i?void 0:gE(i).call(i,(function(e){return e.isScreen}));return h&&(this._updateVideoPlayerState(h),h.videoDom=l.domElement),l.domElement}}},{key:"setLocalVideoMirrorType",value:function(e){IW.info("setLocalVideoMirrorType()","mirrorType: %o",e),VN(e,"mirrorType",[hl.MIRROR_TYPE_NONE,hl.MIRROR_TYPE_RENDER]),this._mirrorType=e,this._videoPlayer&&this._videoPlayer.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(q=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IW.info("setAudioPlaybackDevice()","deviceId: %s",t),UN(t,"deviceId"),e.next=4,this._audioDeviceManager.setSinkId(t);case 4:r=e.sent,this._remoteAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this._remoteScreenAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this.safeEmit(Pl.onAudioPlaybackDeviceChanged,r),this.monitor.report("rtc_audio_device",{audio_event:"playout_device_switch",message:Pm(r),error_code:0});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return q.apply(this,arguments)})},{key:"play",value:(W=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=y.length>1&&void 0!==y[1]?y[1]:ul.AUDIO_AND_VIDEO,a=y.length>2?y[2]:void 0,IW.info("play()","userId: %s, mediaType: %s, streamIndex: %s",t,o,a),s=!t||t===this._getUserId()||"local_user"===t,c=void 0===a||a===cl.STREAM_INDEX_MAIN,u=void 0===a||a===cl.STREAM_INDEX_SCREEN,d=o!==ul.VIDEO,l=o!==ul.AUDIO,h=[],s&&l&&(c&&this._localVideoTrack&&(null===(p=this._videoPlayer)||void 0===p||p.mirror(!!this._mirrorType),h.push(null===(v=this._videoPlayer)||void 0===v?void 0:v.manuallyPlay())),u&&this._localScreenVideoTrack&&h.push(null===(f=this._screenPlayer)||void 0===f?void 0:f.manuallyPlay())),t===(null===(r=this._audioMixingManager)||void 0===r?void 0:r.id)&&h.push(this._audioMixingManager.resumeLocalPlay()),_=null===(n=this._room)||void 0===n?void 0:n.remoteStreams,l&&c&&h.push(DH(this._remoteVideoPlayer,t,!1,_)),l&&u&&h.push(DH(this._remoteScreenPlayer,t,!0,_)),d&&c&&h.push(DH(this._remoteAudioPlayer,t,!1,_)),l&&u&&h.push(DH(this._remoteScreenAudioPlayer,t,!0,_)),m=null===(i=this._publicStreamManager)||void 0===i?void 0:i.remoteStreams,d&&h.push(DH(this._publicStreamVideoPlayer,t,!1,m)),l&&h.push(DH(this._publicStreamAudioPlayer,t,!1,m)),e.abrupt("return",Y_.all(h).then((function(){})));case 20:case"end":return e.stop()}}),e,this)}))),function(e){return W.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(X=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),wD(t)&&(s._pauseAllSubscribeState.audio=!0),CD(t)&&(s._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",Y_.resolve());case 6:n=[],i=$T(oR(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(e.hasSubscribed){s._pauseAllSubscribeState.resumeStreamIds[e.streamId]=e.streamId;var r=s._unsubscribe(e.isScreen,e.userId,t,!0);r&&n.push(r)}}))}catch(c){i.e(c)}finally{i.f()}return e.abrupt("return",Y_.all(n).then((function(){})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return X.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(K=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.info("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),wD(t)&&(s._pauseAllSubscribeState.audio=!1),CD(t)&&(s._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",Y_.resolve());case 6:n=[],i=$T(oR(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(s._pauseAllSubscribeState.resumeStreamIds[e.streamId]){delete s._pauseAllSubscribeState.resumeStreamIds[e.streamId];var r=s._subscribe(e.isScreen,e.userId,t);r&&n.push(r)}}))}catch(c){i.e(c)}finally{i.f()}return e.abrupt("return",Y_.all(n).then((function(){var e,t;null===(e=s._room)||void 0===e||null===(t=e.remoteStreams)||void 0===t||t.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){s._updateAudioPlayerState(e),s._updateVideoPlayerState(e)}))}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return K.apply(this,arguments)})},{key:"sendUserMessage",value:(z=Rm(Tm().mark((function e(t,r){var n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XN(t),QN(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!1,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!1,o,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return z.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(H=Rm(Tm().mark((function e(t,r){var n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XN(t),jN(r,"message"),QN(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!0,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!0,o,e),e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return H.apply(this,arguments)})},{key:"sendRoomMessage",value:(G=Rm(Tm().mark((function e(t){var r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return QN(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return G.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(j=Rm(Tm().mark((function e(t){var r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return QN(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t,!0))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return j.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(B=Rm(Tm().mark((function e(){var t,r=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.length>0&&void 0!==r[0]?r[0]:{},IW.info("setAudioCaptureConfig()","config: %o",t),delete t.deviceId,GN(t),this._shouldUpdateAudioConf("setAudioCaptureConfig")&&this._ctx.audioProfileManager.updateConstraints(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return B.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(F=Rm(Tm().mark((function e(){var t,r=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},IW.info("setVideoCaptureConfig()","config: %o",t),e.abrupt("return",this._setVideoCaptureConfig(t));case 3:case"end":return e.stop()}}),e,this)}))),function(){return F.apply(this,arguments)})},{key:"_setVideoCaptureConfig",value:(V=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(delete(r=i.length>0&&void 0!==i[0]?i[0]:{}).deviceId,GN(r),n=Zd(Zd({},r),{},{deviceId:this._videoStreamConstraints.deviceId}),!this._localVideoTrack){e.next=7;break}return e.next=7,this._localVideoTrack.updateVideoCaptureConfig(n);case 7:return this._videoStreamConstraints=n,e.abrupt("return",(null===(t=this._localVideoTrack)||void 0===t?void 0:t.getTrack().getSettings())||{});case 9:case"end":return e.stop()}}),e,this)}))),function(){return V.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){var t;return IW.info("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,14!==(null==dN?void 0:dN[0])&&(null!==(t=this._room)&&void 0!==t&&t.hasPublished&&PD("You must call this API before publishing the video streams"),!0)}},{key:"setVideoEncoderConfig",value:(U=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(IW.info("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),tM(t=Gs(t).call(t,(function(e){return!!e}))),t.length>3&&(PD("setVideoEncoderConfig: You can set parameters for up to 3 streams"),t=km(t).call(t,0,3)),n=1;n<t.length;n++)i=LD(t[0].width)/LD(t[n].width)||1,Math.floor(i)!==i&&PD("setVideoEncoderConfig: The resolution setting needs to be an integer multiple");GR(t).call(t,(function(e,t){return t.maxKbps-e.maxKbps})),this._setVideoCaptureConfig(Zd({},t[0])),this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(cl.STREAM_INDEX_MAIN),null!==(r=this._room)&&void 0!==r&&r.hasPublished&&this._updatePublish();case 11:case"end":return e.stop()}}),e,this)}))),function(e){return U.apply(this,arguments)})},{key:"setScreenEncoderConfig",value:(L=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:IW.info("setScreenEncoderConfig()","description: %o",t),this._screenStreamEncodeConfig=[t],this._localScreenVideoTrack&&(this._localScreenVideoTrack.updateVideoCaptureConfig(t),t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint)),this._updateDummyCaptureImage(cl.STREAM_INDEX_SCREEN),null!==(r=this._room)&&void 0!==r&&r.hasScreenPublished&&this._updateScreenPublish();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return L.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(IW.info("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!lL())throw new mA(pA.NOT_SUPPORTED,"Browser does not support sending SEI");VN(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),LN(r,"repeatCount",0,30);var n="string"==typeof t?new Uint8Array(pD.str2ab(t)):t;if(t.length){var i;if(e===cl.STREAM_INDEX_MAIN){var o,a,s;if(null===(o=this._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.hasPublished)return;i=null===(s=this._room)||void 0===s?void 0:s.localStream}else{var c,u,d;if(null===(c=this._room)||void 0===c||null===(u=c.localScreenStream)||void 0===u||!u.hasPublished)return;i=null===(d=this._room)||void 0===d?void 0:d.localScreenStream}if(n.byteLength>4096)IW.warn("sei size must not bigger than 4KB");else{var l=dD();i.seiList.push({content:n,uuid:l,repeatCount:r}),setTimeout((function(){var e;if(i){var t,r=QR(e=i.seiList).call(e,(function(e){return e.uuid===l}));if(r)rk(t=i.seiList).call(t,r,1)}}),2e3)}}else IW.warn("sei message must not be empty")}},{key:"setAudioVolumeIndicationInterval",value:function(e){var t=this;IW.info("setAudioVolumeIndicationInterval()","interval %o: ",e),("number"!=typeof e||e<200)&&(e=200);var r=[];this._audioVolumeIndicationTimer&&clearInterval(this._audioVolumeIndicationTimer),this._audioVolumeIndicationTimer=setInterval((function(){var e,n;r=[],null===(e=t._room)||void 0===e||e.remoteStreams.forEach((function(e,t){var n;if(0!==e.length){var i=gE(e).call(e,(function(e){return!e.isScreen})),o=null==i||null===(n=i.audioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t,volume:o||0})}}));var i=null===(n=t._localAudioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t._getUserId(),volume:i||0}),t.safeEmit(Pl.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n=e[0],i=pb(t).call(t,(function(e,t){return e&&e.audioPropertiesInfo.nonlinearVolume>t.audioPropertiesInfo.nonlinearVolume?e:t}),void 0);if((r=n?i?n.audioPropertiesInfo.nonlinearVolume>i.audioPropertiesInfo.nonlinearVolume?n:i:n:i)&&r.audioPropertiesInfo.nonlinearVolume>-35){var o,a;if(r.streamKey)o=this._room.remoteUsers.get(r.streamKey.userId);else o=null===(a=this._room._roomInfo)||void 0===a?void 0:a.userInfo;o&&this.safeEmit(Pl.onActiveSpeaker,{userId:o.userId,extraInfo:o.extraInfo})}}}},{key:"enableAudioPropertiesReport",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};IW.info("enableAudioPropertiesReport()","config %o: ",t);var r=t.enableInBackground,n=void 0===r||r,i=t.interval,o=void 0===i?100:i;this._stopAudioPropertiesReport(),o<=0||(o=Math.max(100,o),this._audioPropertiesReportTimer=self.setInterval((function(){if(n||"hidden"!==document.visibilityState){var t=[],r=e._audioDeviceManager.getRecordTrack()||e._localAudioTrack;if(r){var i=r.getAudioLevel();t.push({streamIndex:cl.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:i,nonlinearVolume:AD(i)}})}if(e._localScreenAudioTrack){var o=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:cl.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:o,nonlinearVolume:AD(o)}})}if(e.safeEmit(Pl.onLocalAudioPropertiesReport,t),e._room){var a,s=[];if(null!==(a=e._room)&&void 0!==a&&a.multiChatMode)e._room.getActiveSpeakerInMultiChatMode().forEach((function(t){var r,n,i=255*t.audioLevel;s.push({streamKey:{userId:t.userId,streamIndex:cl.STREAM_INDEX_MAIN,roomId:null===(r=e._room)||void 0===r||null===(n=r._roomInfo)||void 0===n?void 0:n.roomId},audioPropertiesInfo:{linearVolume:i,nonlinearVolume:AD(i)}})}));else e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o=t.audioTrack.getAudioLevel();s.push({streamKey:{userId:r,streamIndex:t.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN,roomId:null===(n=e._room)||void 0===n||null===(i=n.roomInfo)||void 0===i?void 0:i.roomId},audioPropertiesInfo:{linearVolume:o,nonlinearVolume:AD(o)}})}}))}));e.safeEmit(Pl.onRemoteAudioPropertiesReport,s),e._sendActiveSpeaker(t,Gs(s).call(s,(function(e){return e.streamKey.streamIndex!==cl.STREAM_INDEX_SCREEN})))}}}),o))}},{key:"setVideoSourceType",value:(P=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T,I,R,A;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),VN(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),VN(r,"VideoSourceType",[$d.VIDEO_SOURCE_TYPE_EXTERNAL,$d.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===cl.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,IW.print("setVideoSourceType",Om(i="set ".concat(n," source type to ")).call(i,r)),!this._localVideoTrack||t!==cl.STREAM_INDEX_MAIN){e.next=17;break}if(u=!1,r===$d.VIDEO_SOURCE_TYPE_EXTERNAL&&(u=!0,(d=this._extensionManager.getPluginByName(tV.PRE_PROCESSING,"RTCBeautyExtension"))&&d.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null===(o=this._videoPlayer)||void 0===o||o.stop(),this._localVideoTrack=void 0,l=null===(a=this._room)||void 0===a?void 0:a._roomConfig.isAutoPublish,u?null===(h=this._room)||void 0===h||null===(p=h.localStream)||void 0===p||null===(v=p.observer)||void 0===v||v.setEnableVideo(!1):null===(f=this._room)||void 0===f||null===(_=f.localStream)||void 0===_||null===(m=_.observer)||void 0===m||m.setPushVideo(!1),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubVideo||l)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(!this._localScreenVideoTrack||t!==cl.STREAM_INDEX_SCREEN){e.next=26;break}if(b=!1,r===$d.VIDEO_SOURCE_TYPE_EXTERNAL&&(b=!0,this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(y=this._screenPlayer)||void 0===y||y.stop(),this._localScreenVideoTrack=void 0,b?null===(E=this._room)||void 0===E||null===(k=E.localScreenStream)||void 0===k||null===(T=k.observer)||void 0===T||T.setEnableVideo(!1):null===(I=this._room)||void 0===I||null===(R=I.localScreenStream)||void 0===R||null===(A=R.observer)||void 0===A||A.setPushVideo(!1),null===(g=this._room)||void 0===g||null===(S=g.localScreenStream)||void 0===S||!S.pubVideo){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return P.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(M=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.print("setExternalVideoTrack()","index: %o, track: %o",t,r),VN(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),FN(r),t!==cl.STREAM_INDEX_MAIN){e.next=15;break}if(this._trackSourceType.video===$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,DV(r,this._extensionManager);case 8:if(this._localVideoTrack=e.sent,this._initLocalTrackEvents(this._localVideoTrack),null===(n=this._videoPlayer)||void 0===n||n.playVideo(this._localVideoTrack),s=null===(i=this._room)||void 0===i?void 0:i._roomConfig.isAutoPublish,!(null!==(o=this._room)&&void 0!==o&&null!==(a=o.localStream)&&void 0!==a&&a.pubVideo||s)){e.next=15;break}return e.next=15,this._updatePublish();case 15:if(t!==cl.STREAM_INDEX_SCREEN){e.next=27;break}if(this._trackSourceType.screenVideo===$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=18;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 18:return e.next=20,LV(r,this._extensionManager);case 20:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(c=this._screenPlayer)||void 0===c||c.playVideo(this._localScreenVideoTrack),null===(u=this._room)||void 0===u||null===(d=u.localScreenStream)||void 0===d||null===(l=d.observer)||void 0===l||l.setPushVideo(!0),null===(h=this._room)||void 0===h||null===(p=h.localScreenStream)||void 0===p||!p.pubVideo){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(e,t){return M.apply(this,arguments)})},{key:"setAudioSourceType",value:(N=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,f,_,m,y,g,S,b,E,k,T;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),VN(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),VN(r,"audioSourceType",[el.AUDIO_SOURCE_TYPE_EXTERNAL,el.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===cl.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,IW.print("setVideoSourceType",Om(i="set ".concat(n," source type to ")).call(i,r)),!this._localAudioTrack||t!==cl.STREAM_INDEX_MAIN){e.next=16;break}if(c=!1,this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL&&(c=!0,this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,u=null===(o=this._room)||void 0===o?void 0:o._roomConfig.isAutoPublish,c?null===(d=this._room)||void 0===d||null===(l=d.localStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setEnableAudio(!1):null===(p=this._room)||void 0===p||null===(v=p.localStream)||void 0===v||null===(f=v.observer)||void 0===f||f.setPushAudio(!1),!(null!==(a=this._room)&&void 0!==a&&null!==(s=a.localStream)&&void 0!==s&&s.pubAudio||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(!this._localScreenAudioTrack||t!==cl.STREAM_INDEX_SCREEN){e.next=24;break}if(y=!1,this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL&&(y=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,y?null===(g=this._room)||void 0===g||null===(S=g.localScreenStream)||void 0===S||null===(b=S.observer)||void 0===b||b.setEnableAudio(!1):null===(E=this._room)||void 0===E||null===(k=E.localScreenStream)||void 0===k||null===(T=k.observer)||void 0===T||T.setPushAudio(!1),null===(_=this._room)||void 0===_||null===(m=_.localScreenStream)||void 0===m||!m.pubAudio){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return N.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(D=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.print("setExternalAudioTrack()","index: %o, track: %o",t,r),VN(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),FN(r),t!==cl.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,MV(r,this._extensionManager);case 8:if(this._localAudioTrack=e.sent,this._localAudioTrack.setVolume(this._localAudioVolume),this._initLocalTrackEvents(this._localAudioTrack),u=null===(n=this._room)||void 0===n?void 0:n._roomConfig.isAutoPublish,null===(i=this._room)||void 0===i||null===(o=i.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setPushAudio(!0),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubAudio||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(t!==cl.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenAudio===el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new mA(pA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 19:return e.next=21,VV(r,this._extensionManager);case 21:if(this._localScreenAudioTrack=e.sent,this._localScreenAudioTrack.setVolume(this._localScreenAudioVolume),this._initLocalTrackEvents(this._localScreenAudioTrack),null===(d=this._room)||void 0===d||null===(l=d.localScreenStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setPushAudio(!0),null===(p=this._room)||void 0===p||null===(v=p.localScreenStream)||void 0===v||!v.pubAudio){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return D.apply(this,arguments)})},{key:"login",value:(O=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IW.info("login()","token: %o, userInfo: %o",t,r),zN(t)||UN(t,"token"),XN(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return O.apply(this,arguments)})},{key:"logout",value:(x=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IW.info("logout()"),e.abrupt("return",this._rtmClient.logout());case 2:case"end":return e.stop()}}),e,this)}))),function(){return x.apply(this,arguments)})},{key:"updateLoginToken",value:(C=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IW.info("updateLoginToken()","token: %o",t),zN(t)||UN(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(w=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IW.info("getPeerOnlineStatus()","userId: %o",t),XN(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(A=Rm(Tm().mark((function e(t,r){var n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XN(t),QN(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!1,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!1,n,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return A.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(R=Rm(Tm().mark((function e(t,r){var n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XN(t),jN(r,"message"),QN(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!0,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!0,n,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"setServerParams",value:(I=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IW.info("setServerParams()","signature: %o, url: %0",t,r),e.abrupt("return",this._rtmClient.setServerParams(t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return I.apply(this,arguments)})},{key:"sendServerMessage",value:(T=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return UN(t,"message"),QN(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!1,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!1,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(k=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jN(t,"message"),QN(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!0,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!0,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new mA(pA.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");IW.info("startCloudProxy()",e),UN(e.logProxy,"logProxy"),UN(e.accessProxy,"accessProxy"),UN(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=ON("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=ON("LOG_SERVER_URL"),this._originConfigServerUrls=ON("CONFIG_REQUEST_DOMAINS"),xN("ICE_CONFIG_REQUEST_URLS",e.accessProxy),xN("LOG_SERVER_URL",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://".concat(e)),"".concat(e,"/video/v1/webrtc_log/")}(e.logProxy)),xN("CONFIG_REQUEST_DOMAINS",[e.configProxy]),EN.clearAccessNode(this._appId),EN.clearAccessUrls(),this._ctx.useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){var e;if(this._room)throw new mA(pA.STOP_CLOUD_PROXY_BEFORE_LEAVE,"[stopCloudProxy] should be invoke after leave room ");IW.info("stopCloudProxy()"),xN("ICE_CONFIG_REQUEST_URLS",null===(e=this._originIceConfigRequestUrls)||void 0===e?void 0:jm(e).call(e,(function(e){return e.replace("https://","").replace("/dispatch/v1/AccessInfo?Action=GetAccessInfo","")}))),xN("LOG_SERVER_URL",this._originLogServerUrl),xN("CONFIG_REQUEST_DOMAINS",this._originConfigServerUrls),EN.clearAccessNode(this._appId),EN.clearAccessUrls(),this._ctx.useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(E=Rm(Tm().mark((function e(t,r){var n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),WN(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new mA(pA.REPEAT_PUSH,"repeat push public media stream");case 5:return o=DN(t,"started",r),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.publicStreamControlMessage(o))||void 0===i?void 0:i.then((function(){a._publicStreamIds.set(t,t)})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return E.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(b=Rm(Tm().mark((function e(t,r){var n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IW.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),WN(t),this._assertNotInRoom(),i=DN(t,"layoutChanged",r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.publicStreamControlMessage(i));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return b.apply(this,arguments)})},{key:"stopPushPublicStream",value:(S=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IW.print("startPushPublicStream()","publicStreamId: %o",t),WN(t),this._assertNotInRoom(),e.abrupt("return",null===(r=this._room)||void 0===r?void 0:r.publicStreamControlMessage({type:"publicstream",action:"stopped",publicStreamID:t}).then((function(){n._publicStreamIds.delete(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"startPlayPublicStream",value:(g=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(WN(t),this._publicStreamManager){e.next=8;break}return this._publicStreamManager=new uW(this.id,this._appId,{businessId:this._businessId}),this._publicStreamManager.on(_G.RESUBSCRIBE,(function(e){var t=e.stream;if(t){var r,n=c._publicStreamAudioPlayer.get(t.streamId);n&&t.audioTrack&&(n.stop(),n.playAudio(null===(r=e.stream)||void 0===r?void 0:r.audioTrack));var i,o=c._publicStreamVideoPlayer.get(t.streamId);o&&t.videoTrack&&o.playVideo(null===(i=e.stream)||void 0===i?void 0:i.videoTrack)}})),null===(r=this._publicStreamManager)||void 0===r||r.on("onRemoteStreamStats",(function(e){e.publicStreamId=e.userId,delete e.userId,delete e.isScreen,c.safeEmit(Pl.onPublicStreamStats,e)})),null===(n=this._publicStreamManager)||void 0===n||n.on(_G.ON_SEI_MESSAGED_RECEIVED,(function(e){c.safeEmit(Pl.onPublicStreamSEIMessageReceived,e)})),e.next=8,this._publicStreamManager.connect();case 8:return e.next=10,this._publicStreamManager.startPlayPublicStream(t);case 10:i=e.sent,(o=this._publicStreamVideoPlayer.get(t))&&null!=i&&i.videoTrack&&o.playVideo(i.videoTrack,i),!(a=this._publicStreamAudioPlayer.get(t))&&null!=i&&i.audioTrack&&(a=new OH(this.id,t,{muted:(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)===kl.VIDEO_ONLY,isScreen:!1}),this._initPlayerEvents(a,!0),a.playAudio(i.audioTrack),this._publicStreamAudioPlayer.set(t,a));case 15:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(y=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publicStreamManager){e.next=2;break}return e.abrupt("return");case 2:this._publicStreamManager.stopPlayPublicStream(t),(r=this._publicStreamAudioPlayer.get(t))&&(r.destroy(),this._publicStreamAudioPlayer.delete(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"setAudioProfile",value:(m=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:IW.info("setAudioProfile()","profile: %o",t),this._shouldUpdateAudioConf("setAudioProfile")&&this._ctx.audioProfileManager.setAudioProfile(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"setAudioEncodeMaxBitrate",value:(_=Rm(Tm().mark((function e(t){var r,n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.print("setAudioEncodeMaxBitrate()",t),LN(t,"maxBitrate",6,256),this._ctx.audioProfileManager.setCustomMaxBitrate(t),!this._ctx.audioProfileManager.customMaxBitrate){e.next=10;break}if(!zD||!(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localStream)&&void 0!==n&&n.pubAudio||null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubAudio)){e.next=6;break}throw new mA(pA.NOT_SUPPORTED,"Your browser does not support set audio encode maxBitrate dynamically.");case 6:return e.next=8,null===(a=this._room)||void 0===a?void 0:a.setAudioEncodeMaxBitrate(cl.STREAM_INDEX_MAIN,t);case 8:return e.next=10,null===(s=this._room)||void 0===s?void 0:s.setAudioEncodeMaxBitrate(cl.STREAM_INDEX_SCREEN,t);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,i,o;IW.print("setPublicStreamVideoPlayer()","publicStreamId: %o, videoPlayerOption: %o",e,t);var a=this._publicStreamVideoPlayer.get(e);if(null===(r=a)||void 0===r||r.destroy(),null!=t&&t.renderDom){a=new xH(this.id,Zd(Zd({},t),{},{userId:e})),this._initPlayerEvents(a,!0),this._publicStreamVideoPlayer.set(e,a);var s=null===(n=this._publicStreamManager)||void 0===n||null===(i=n.remoteStreams)||void 0===i?void 0:i.get(e);null!=s&&s.videoTrack&&(null===(o=this._config)||void 0===o?void 0:o.autoPlayPolicy)!==kl.PLAY_MANUALLY&&a.playVideo(s.videoTrack,s)}else this._publicStreamVideoPlayer.delete(e)}},{key:"setDummyCaptureImagePath",value:(f=Rm(Tm().mark((function e(t,r){var n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Y_((function(e,i){UN(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){t===cl.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),e()}catch(r){i(new mA(pA.UNEXPECTED_ERROR,r.message))}},o.onerror=function(){i(new mA(pA.UNEXPECTED_ERROR,"Load image error"))}})));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return f.apply(this,arguments)})},{key:"_updateDummyCaptureImage",value:function(e){var t,r;if(e===cl.STREAM_INDEX_MAIN?(t=this._dummyMainImage,r=this._videoStreamEncodeConfig[0]):(t=this._dummyScreenImage,r=this._screenStreamEncodeConfig[0]),t){var n,i,o=document.createElement("canvas"),a=o.getContext("2d"),s=LD(r.width),c=LD(r.height);if(!a)throw new mA(pA.UNEXPECTED_ERROR,"Not support canvas");!s||!c||t.width<=s&&t.height<=c?(n=t.width,i=t.height):(n=Math.min(s,t.width*c/t.height),i=Math.min(c,t.height*s/t.width)),o.width=n,o.height=i,a.drawImage(t,0,0,t.width,t.height,0,0,n,i);var u=window.setInterval((function(){t&&a.drawImage(t,0,0,t.width,t.height,0,0,n,i)}),200);e===cl.STREAM_INDEX_MAIN?(clearInterval(this._dummyMainTimer),this._dummyMainTimer=u):(clearInterval(this._dummyScreenTimer),this._dummyScreenTimer=u);var d,l,h,p,v=o.captureStream(5).getVideoTracks()[0];if(e===cl.STREAM_INDEX_MAIN){if(this._localImgVideoTrack=v,null!==(d=this._localVideoTrack)&&void 0!==d&&d.dummy)null===(l=this._localVideoTrack)||void 0===l||l.setTrack(this._localImgVideoTrack,this._extensionManager)}else if(this._localImgScreenTrack=v,null!==(h=this._localScreenVideoTrack)&&void 0!==h&&h.dummy)null===(p=this._localScreenVideoTrack)||void 0===p||p.setTrack(this._localImgScreenTrack,this._extensionManager)}}},{key:"_addListenExtensionEvent",value:function(e){var t=this;e.on("re-capture-audio",(function(){t._localAudioTrack&&t.stopAudioCapture().then((function(){t.startAudioCapture()}))})),e.on("re-capture-video",(function(){t._localVideoTrack&&!t._localVideoTrack.dummy&&t.stopVideoCapture().then((function(){t.startVideoCapture()}))})),e.on("reset-video-effect",function(){var e=Rm(Tm().mark((function e(r,n){var i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t._localVideoTrack||t._localVideoTrack.dummy){e.next=17;break}return t._localVideoTrack&&t._removeLocalTrackEvents(t._localVideoTrack),e.prev=2,e.next=5,t._localVideoTrack.generatePreProcessingTrack(t._extensionManager);case 5:e.next=10;break;case 7:e.prev=7,e.t0=e.catch(2),n(e.t0);case 10:if(t._initLocalTrackEvents(t._localVideoTrack),null!==(i=t._videoPlayer)&&void 0!==i&&i.played&&(t._videoPlayer.stop(),t._videoPlayer.playVideo(t._localVideoTrack),t._videoPlayer.mirror(!!t._mirrorType)),t.safeEmit(Pl.onLocalStreamTrackChangedByExtension,{streamIndex:cl.STREAM_INDEX_MAIN,type:"video"}),r(),null===(o=t._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.pubVideo){e.next=17;break}return e.next=17,t._updatePublish();case 17:r();case 18:case"end":return e.stop()}}),e,null,[[2,7]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"registerExtension",value:(v=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.monitor=this.monitor,e.prev=1,e.next=4,t.isSupported();case 4:if(e.sent){e.next=7;break}throw new Error("This extension is not supported.");case 7:e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(1),new Error("This extension is not supported.");case 12:return e.next=14,t.init({videoCaptureConfig:this._videoStreamConstraints});case 14:this._extensionManager.register(t),this._addListenExtensionEvent(t);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return v.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(Pm(bW.getDefaultValue()))}},{key:"_updatePublish",value:(p=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},IW.info("_updatePublish()","config: %o",t),r={mediaType:void 0,invokeByJoinRoom:!1,pubState:yG.PUB},t=Zd(Zd({},r),t),this._visibility){e.next=6;break}throw new mA(pA.NO_PUBLISH_PERMISSION,"no publish permission");case 6:return e.next=8,this._pubLock.lock();case 8:if(n=e.sent,this._room&&this._room.connectionState===YG.CONNECTED){e.next=12;break}return n(),e.abrupt("return");case 12:return e.prev=12,e.next=15,this._room.publish(this._videoStreamEncodeConfig,this._enableSimulcast,this._localVideoTrack,this._localAudioTrack,t.mediaType,t.pubState,t.invokeByJoinRoom);case 15:this._videoPlayer&&this._room.localStream&&(this._room.localStream.videoDom=this._videoPlayer.domElement),e.next=25;break;case 18:if(e.prev=18,e.t0=e.catch(12),!(e.t0 instanceof mA)){e.next=24;break}throw e.t0;case 24:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 25:return e.prev=25,n(),e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[12,18,25,28]])}))),function(){return p.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(h=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IW.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),UN(t,"filePath"),LN(r,"indicationInterval"),e.next=5,this._audioDeviceManager.startAudioPlaybackDeviceTest(t,r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){IW.info("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(l=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IW.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),LN(t,"indicationInterval"),e.next=4,this._audioDeviceManager.startAudioDeviceRecordTest(t,r,this._localAudioVolume);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){IW.info("stopAudioDeviceRecordAndPlayTest()"),this._audioDeviceManager.stopAudioDeviceRecordAndPlayTest()}},{key:"stopAudioDevicePlayTest",value:function(){IW.info("stopAudioDevicePlayTest()"),this._audioDeviceManager.stopAudioDevicePlayTest()}},{key:"setRemoteUserPriority",value:function(e,t){var r;IW.print("setRemoteUserPriority()","userId: %o, priority: %o",e,t);try{XN(e),VN(t,"priority",[yl.HIGH,yl.MEDIUM,yl.LOW])}catch(n){return console.warn(n),!1}return this._ctx.userPriority.set(e,t),null===(r=this._room)||void 0===r||r.updateRemoteUserPriority(e),!0}},{key:"takeLocalSnapshot",value:(d=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.print("takeLocalSnapshot()","streamIndex: %o",t),VN(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),r=t===cl.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new mA(pA.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return n=t===cl.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer,e.abrupt("return",vW(r.getTrack("preprocessing"),(null==n?void 0:n.mirrorType)===hl.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(u=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(IW.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),UN(t,"id"),VN(r,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),c=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=gE(i).call(i,(function(e){return e.isScreen===(r===cl.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.videoTrack)||(null===(a=this._publicStreamManager)||void 0===a||null===(s=a.remoteStreams.get(t))||void 0===s?void 0:s.videoTrack)){e.next=6;break}throw new mA(pA.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",vW(c.getTrack(),!1,r===cl.STREAM_INDEX_MAIN?this._remoteVideoPlayer.get(t):this._remoteScreenPlayer.get(t)));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){IW.info("setSubscribeFallbackOption()","option: %o",e);try{VN(e,"option",[ml.DISABLE,ml.VIDEO_STREAM_LOW,ml.AUDIO_ONLY])}catch(t){return console.warn(t),!1}return!this._room&&(this._ctx.subscribeFallbackOption=e,!0)}},{key:"getLocalStreamTrack",value:function(e,t){var r,n,i,o=this;if(e===cl.STREAM_INDEX_MAIN?(n="video"===t?this.localVideoTrack:this.localAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localStream}):(n="video"===t?this.localScreenVideoTrack:this.localScreenAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localScreenStream}),n){var a=n instanceof BV&&n.mixedAudioTrack?n.mixedAudioTrack:n.getTrack("preprocessing");if(a){var s=i();return this._reportMsTrackEvent(a,(null==s||null===(r=s.stream)||void 0===r?void 0:r.id)||"local"),a}}}},{key:"getRemoteStreamTrack",value:function(e,t,r){var n,i,o=(null===(n=this._room)||void 0===n?void 0:n.remoteStreams.get(e))||[];if(o&&o.length){var a,s,c,u,d;if(t===cl.STREAM_INDEX_MAIN)a=gE(o).call(o,(function(e){return!e.isScreen})),i="video"===r?null===(s=a)||void 0===s?void 0:s.videoTrack:null===(c=a)||void 0===c?void 0:c.audioTrack;else a=gE(o).call(o,(function(e){return e.isScreen})),i="video"===r?null===(u=a)||void 0===u?void 0:u.videoTrack:null===(d=a)||void 0===d?void 0:d.audioTrack;if(i){var l=i.getTrack();if(l&&a){var h=a.streamId;return this._reportMsTrackEvent(l,h),l}}}}},{key:"getPublicStreamTrack",value:function(e,t){if(this._publicStreamManager&&this._publicStreamManager.remoteStreams){var r=this._publicStreamManager.remoteStreams.get(e);if(r){var n="video"===t?r.videoTrack:r.audioTrack;if(n){var i=n.getTrack();if(i){var o=r.streamId;return this._reportMsTrackEvent(i,o),i}}}}}},{key:"setRemoteStreamRenderSync",value:function(e){return!this._room&&(this._ctx.avSync=!!e,!0)}},{key:"setCaptureVolume",value:function(e,t){var r,n,i;(VN(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),t=rM(t,"volume",0,400),e===cl.STREAM_INDEX_SCREEN)?(null===(r=this._localScreenAudioTrack)||void 0===r||r.setVolume(t),this._localScreenAudioVolume=t):(null===(n=this._localAudioTrack)||void 0===n||n.setVolume(t),null===(i=this._audioDeviceManager.audioTrack)||void 0===i||i.setVolume(t),this._localAudioVolume=t)}},{key:"setPlaybackVolume",value:function(e,t,r){var n,i,o;if(XN(e),VN(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),r=rM(r,"volume",0,400),null!==(n=this._room)&&void 0!==n&&n.multiChatMode)PD("setPlaybackVolume is not supported in Conference mode");else{var a=t===cl.STREAM_INDEX_SCREEN;a?this._remoteScreenAudioVolume.set(e,r):this._remoteAudioVolume.set(e,r),null===(i=this._room)||void 0===i||null===(o=i.remoteStreams.get(e))||void 0===o||o.forEach((function(e){var t;e.isScreen===a&&(null===(t=e.audioTrack)||void 0===t||t.setVolume(r))}))}}},{key:"setPublicStreamVolume",value:function(e,t){var r,n,i;UN(e,"publicStreamId"),t=rM(t,"volume",0,400),this._publicAudioVolume.set(e,t),null===(r=this._publicStreamManager)||void 0===r||null===(n=r.remoteStreams.get(e))||void 0===n||null===(i=n.audioTrack)||void 0===i||i.setVolume(t)}},{key:"startForwardStreamToRooms",value:(c=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){KN(e.roomId)})),this._assertNotInRoom(),e.next=4,this._room.startForwardStream2Rooms(t);case 4:return r=e.sent,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"updateForwardStreamToRooms",value:(s=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){KN(e.roomId)})),this._assertNotInRoom(),e.next=4,this._room.updateForwardStream2Rooms(t);case 4:return r=e.sent,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"stopForwardStreamToRooms",value:(a=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.stopForwardStream2Rooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"pauseForwardStreamToAllRooms",value:(o=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.pauseForwardStream2AllRooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"resumeForwardStreamToAllRooms",value:(i=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.resumeForwardStream2AllRooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_reportMsTrackEvent",value:function(e,t){var r=this;if(!e.hookStop){e.hookStop=!0;var n=e.stop;e.stop=function(){jO(r.id,"stop",t,0,t),n.call(e)}}}},{key:"_updateScreenPublish",value:(n=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:{},IW.info("_updateScreenPublish()"),r={mediaType:void 0,pubState:yG.PUB},t=Zd(Zd({},r),t),e.next=6,this._pubLock.lock();case 6:if(n=e.sent,this._room&&this._room.connectionState===YG.CONNECTED){e.next=10;break}return n(),e.abrupt("return");case 10:return e.prev=10,e.next=13,this._room.publishScreen(this._screenStreamEncodeConfig,this._localScreenVideoTrack,this._localScreenAudioTrack,t.mediaType,t.pubState);case 13:this._screenPlayer&&this._room.localScreenStream&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),e.next=23;break;case 16:if(e.prev=16,e.t0=e.catch(10),!(e.t0 instanceof mA)){e.next=22;break}throw e.t0;case 22:throw new mA(pA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 23:return e.prev=23,n(),e.finish(23);case 26:case"end":return e.stop()}}),e,this,[[10,16,23,26]])}))),function(){return n.apply(this,arguments)})},{key:"_updateAudioPlayerState",value:function(e){IW.info("_updateAudioPlayerState()");var t,r=e.userId,n=e.isScreen,i=n?this._remoteScreenAudioPlayer:this._remoteAudioPlayer,o=i.get(r);if(e.audioTrack&&e.attributes.audiostream&&e.subAudio){var a,s,c,u=n?null!==(a=this._remoteScreenAudioVolume.get(r))&&void 0!==a?a:100:null!==(s=this._remoteAudioVolume.get(r))&&void 0!==s?s:100;if(e.audioTrack.setVolume(u),!o){var d;o=new OH(this.id,r,{muted:(null===(d=this._config)||void 0===d?void 0:d.autoPlayPolicy)===kl.VIDEO_ONLY,isScreen:n}),this._initPlayerEvents(o,!1,n?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN),i.set(r,o);var l=this._audioDeviceManager.getSinkId();l&&o.setPlaybackDevice(l)}(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)!==kl.PLAY_MANUALLY&&o.playAudio(e.audioTrack),KD&&ZD&&(t=this._remoteAudioPlayer,SW&&clearTimeout(SW),SW=setTimeout((function(){var e,r=$T(t);try{for(r.s();!(e=r.n()).done;){var n=eI(e.value,2),i=n[0],o=n[1];null!=i&&hA(i).call(i,"mux")&&o.pause()}}catch(l){r.e(l)}finally{r.f()}var a,s=$T(t);try{for(s.s();!(a=s.n()).done;){var c=eI(a.value,2),u=c[0],d=c[1];null!=u&&hA(u).call(u,"mux")&&d.manuallyPlay()}}catch(l){s.e(l)}finally{s.f()}}),2e3))}else{var h;null===(h=o)||void 0===h||h.stop()}}},{key:"_updateVideoPlayerState",value:function(e){var t;IW.info("_updateVideoPlayerState()");var r,n,i=e.userId;if(r=e.isScreen?this._remoteScreenPlayer.get(i):this._remoteVideoPlayer.get(i),e.videoTrack)r&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==kl.PLAY_MANUALLY&&r.playVideo(e.videoTrack,e);else if(null!==(t=r)&&void 0!==t&&t.played){var o;null===(o=r)||void 0===o||o.stop()}}},{key:"_onAddStream",value:(r=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=t.stream).videoDom=null===(r=this._remoteVideoPlayer.get(n.userId))||void 0===r?void 0:r.domElement,i=null==n?void 0:n.attributes,o=i.localaudio,a=i.audiostream,s=i.localvideo,c=i.videostream,u=GV.NONE,a&&(u|=ul.AUDIO),c&&(u|=ul.VIDEO),!u){e.next=12;break}return e.next=9,new Y_((function(e){return setTimeout(e)}));case 9:null!=n&&n.isScreen?this.safeEmit(Pl.onUserPublishScreen,{userId:n.userId,mediaType:u}):(this.safeEmit(Pl.onUserPublishStream,{userId:n.userId,mediaType:u,videoStreamDescriptions:null==n||null===(d=n.attributes)||void 0===d?void 0:d.videoDescriptions}),this._handleAutoSubscribe(n,!0)),this.safeEmit("onAddStream",{userId:n.userId,mediaType:u,isScreen:!(null==n||!n.isScreen)}),null!=n&&n.isScreen||(o&&this.safeEmit(Pl.onUserStartAudioCapture,{userId:n.userId}),s&&this.safeEmit(Pl.onUserStartVideoCapture,{userId:n.userId}));case 12:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_handleAutoSubscribe",value:function(e,t){var r,n,i=GV.NONE;if(null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoSubscribeAudio&&(i|=ul.AUDIO),null!==(n=this._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo&&(i|=ul.VIDEO),i){var o,a;if(t&&wD(i))null===(o=e.observer)||void 0===o||o.setAutoSubscribeAudio(!0);if(t&&CD(i))null===(a=e.observer)||void 0===a||a.setAutoSubscribeVideo(!0);this._subscribe(!1,e.userId,i)}}},{key:"_onRemoveStream",value:function(e){var t,r=this,n=e.stream,i=null!==(t=wW[e.reason])&&void 0!==t?t:dl.STREAM_REMOVE_REASON_OTHER,o=n.isScreen?Pl.onUserUnpublishScreen:Pl.onUserUnpublishStream,a=GV.NONE;n.attributes.audiostream&&(a|=ul.AUDIO),n.attributes.videostream&&(a|=ul.VIDEO),a!==GV.NONE&&(this.safeEmit(o,{userId:n.userId,mediaType:a,reason:i}),this.safeEmit("onRemoveStream",{userId:n.userId,isScreen:n.isScreen})),"function"==typeof e.callback&&e.callback(),this._getRemotePlayer(n.userId,n.isScreen).forEach((function(e){n.isScreen?(r._remoteScreenPlayer.delete(n.userId),r._remoteScreenAudioPlayer.delete(n.userId)):(r._remoteAudioPlayer.delete(n.userId),r._remoteVideoPlayer.delete(n.userId)),null==e||e.destroy()}))}},{key:"_onUserConnection",value:function(e){var t=this;setTimeout((function(){return t.safeEmit(Pl.onUserJoined,e)}))}},{key:"_onUserLeave",value:function(e){var t=this,r=e.userInfo;this._getRemotePlayer(r.userId,!0).forEach((function(e){t._remoteScreenAudioPlayer.delete(r.userId),t._remoteScreenPlayer.delete(r.userId),null==e||e.destroy()})),this._getRemotePlayer(r.userId,!1).forEach((function(e){t._remoteAudioPlayer.delete(r.userId),t._remoteVideoPlayer.delete(r.userId),null==e||e.destroy()})),this.safeEmit(Pl.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(Pl.onError,e),null===(t=this._room)||void 0===t||t.destroy(),this._room=void 0}},{key:"_onNetworkQuality",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this.safeEmit.apply(this,Om(e=[Pl.onNetworkQuality]).call(e,r))}},{key:"_onConnectionStateChange",value:function(e){if(void 0!==this._startCloudProxyTimestamp&&this._ctx.useCloudProxy&&e.state===ll.CONNECTION_STATE_CONNECTED&&this.safeEmit(Pl.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),this.safeEmit(Pl.onConnectionStateChanged,e),e.state===ll.CONNECTION_STATE_RECONNECTING){var t,r=$T(this._remoteAudioPlayer);try{for(r.s();!(t=r.n()).done;){var n=eI(t.value,2),i=n[0],o=n[1];null!=i&&hA(i).call(i,"mux")&&o.stop()}}catch(a){r.e(a)}finally{r.f()}}}},{key:"_getRemotePlayer",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ul.AUDIO_AND_VIDEO,n=(t?this._remoteScreenAudioPlayer:this._remoteAudioPlayer).get(e),i=(t?this._remoteScreenPlayer:this._remoteVideoPlayer).get(e),o=[];return r&ul.AUDIO&&o.push(n),r&ul.VIDEO&&o.push(i),o}},{key:"_stopAudioPropertiesReport",value:function(){null!==this._audioPropertiesReportTimer&&(clearInterval(this._audioPropertiesReportTimer),this._audioPropertiesReportTimer=null)}},{key:"_onResubscribe",value:function(e){e.stream&&(this._getRemotePlayer(e.stream.userId,e.stream.isScreen).forEach((function(e){return null==e?void 0:e.stop()})),this._updateAudioPlayerState(e.stream),this._updateVideoPlayerState(e.stream))}},{key:"_onSubscribePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onRemovePushTrack",value:function(e){var t=this;if(e.stream){this._updateAudioPlayerState(e.stream);var r=e.stream;this._getRemotePlayer(r.userId,r.isScreen,e.mediaType).forEach((function(n){e.mediaType&ul.AUDIO&&(r.isScreen?t._remoteScreenAudioPlayer.delete(r.userId):t._remoteAudioPlayer.delete(r.userId)),r.isScreen?e.mediaType&ul.VIDEO&&t._remoteScreenPlayer.delete(r.userId):e.mediaType&ul.VIDEO&&t._remoteVideoPlayer.delete(r.userId),null==n||n.destroy()}))}}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(Pl.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(Pl.onAudioDeviceStateChanged,e)}},{key:"_onUserPublishStateChange",value:function(e){var t,r=this,n=e.userId,i=e.isScreen,o=e.mediaType,a=e.pubState,s=e.remoteStream,c={userId:n,mediaType:o};(o&ul.AUDIO&&setTimeout((function(){r._updateAudioPlayerState(s)})),i)?a===yG.PUB?this.safeEmit(Pl.onUserPublishScreen,c):this.safeEmit(Pl.onUserUnpublishScreen,Zd(Zd({},c),{},{reason:dl.STREAM_REMOVE_REASON_UNPUBLISH})):a===yG.PUB?(c.videoStreamDescriptions=null==s||null===(t=s.attributes)||void 0===t?void 0:t.videoDescriptions,this.safeEmit(Pl.onUserPublishStream,c),this._handleAutoSubscribe(s,!0)):this.safeEmit(Pl.onUserUnpublishStream,Zd(Zd({},c),{},{reason:dl.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(Pl.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(Pl.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Pl.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Pl.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(Pl.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(Pl.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(Pl.onTokenWillExpire)}},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(Pl.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Pl.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Pl.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(Pl.onError,{errorCode:pA.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(Pl.onError,{errorCode:pA.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(Pl.onServerParamsSetResult,null==e?void 0:e.code)}))}},{key:"waitForNewToken",get:function(){return!!this._tempRoomInfo}},{key:"localAudioTrack",get:function(){return this._localAudioTrack}},{key:"localVideoTrack",get:function(){return this._localVideoTrack}},{key:"localScreenAudioTrack",get:function(){return this._localScreenAudioTrack}},{key:"localScreenVideoTrack",get:function(){return this._localScreenVideoTrack}},{key:"remoteStreams",get:function(){var e,t,r=[];null!==(e=this._room)&&void 0!==e&&e.remoteStreams&&(null===(t=this._room)||void 0===t||t.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){r.push({userId:e.userId,isScreen:e.isScreen,hasVideo:e.hasVideo,hasAudio:e.hasAudio,videoStreamDescriptions:e.attributes.videoDescriptions})}))})));return r}},{key:"iceState",get:function(){var e,t,r,n;return null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient)||void 0===t||null===(r=t.handler)||void 0===r||null===(n=r._peerConnection)||void 0===n?void 0:n.iceConnectionState}},{key:"remoteUsers",get:function(){var e,t,r=[];null!==(e=this._room)&&void 0!==e&&e.remoteUsers&&(null===(t=this._room)||void 0===t||t.remoteUsers.forEach((function(e){r.push({userId:e.userId})})));return r}},{key:"multiChatMode",get:function(){var e,t;return!(null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient)||void 0===t||!t.roomAttributes.multiChatMode)}},{key:"_handleAudioDeviceManager",value:function(){var e=this;this._audioDeviceManager.on("onAudioPlaybackDeviceTestVolume",(function(t){e.safeEmit(Pl.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||this._room.connectionState!==YG.CONNECTED)throw new mA(pA.NOT_CONNECTED_YET,"server not connected")}},{key:"_checkMediaType",value:function(e){VN(e,"mediaType",[ul.AUDIO,ul.VIDEO,ul.AUDIO_AND_VIDEO])}},{key:"_getUserId",value:function(){var e,t;return(null===(e=this._room)||void 0===e||null===(t=e.roomInfo)||void 0===t?void 0:t.userInfo.userId)||"local_user"}},{key:"_switchTrack",value:(t=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._initLocalTrackEvents(t),this._localVideoTrack=t,null!==(r=this._videoPlayer)&&void 0!==r&&r.played&&(this._videoPlayer.stop(),this._videoPlayer.playVideo(t),this._videoPlayer.mirror(!!this._mirrorType)),null===(n=this._room)||void 0===n||null===(i=n.localStream)||void 0===i||!i.pubVideo){e.next=6;break}return e.next=6,this._updatePublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_shouldUpdateAudioConf",value:function(e){var t,r,n,i=(null===(t=this._room)||void 0===t?void 0:t.hasPublished)||(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n?void 0:n.pubAudio)||this._localAudioTrack&&this._localAudioTrack.sourceType===nV.INTERNAL;if(i){var o="engine.".concat(e," should be called before publishing or capturing.");console.warn("[RTC WebSDK]: ".concat(o)),jO(this.id,e,o)}return!i}},{key:"_getServerConfig",value:function(){var e=this,t=EN.getServerConfig(this.appId);t.rts_report&&wO.setConfig(t.rts_report),this._ctx.joinRoomConfig.setServerConfig(t.web_join_room),HO({engineId:this.id,appId:this.appId,sdkVersion:ON("VERSION"),requestDomains:ON("CONFIG_REQUEST_DOMAINS"),keys:["rts_report","web_join_room","web_rtc_config"],deviceId:ON("DEVICE_ID")}).then((function(t){EN.setServerConfig(e.appId,t)}))}}]),ke}(aM);TW([FO()],RW.prototype,"updateToken",1),TW([FO()],RW.prototype,"setVideoCaptureDevice",1),TW([FO()],RW.prototype,"setAudioCaptureDevice",1),TW([function(e,t,r){if("function"==typeof r.value){var n=r.value;r.value=function(){for(var e,t=VO(this.id),r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return null==t||t.set({room_id:i[1],user_id:null===(e=i[2])||void 0===e?void 0:e.userId}),n.apply(this,i)}}},FO()],RW.prototype,"connect",1),TW([FO()],RW.prototype,"joinRoom",1),TW([FO()],RW.prototype,"leaveRoom",1),TW([FO()],RW.prototype,"destroy",1),TW([FO()],RW.prototype,"publishStream",1),TW([FO()],RW.prototype,"unpublishStream",1),TW([FO()],RW.prototype,"publishScreen",1),TW([FO()],RW.prototype,"unpublishScreen",1),TW([FO()],RW.prototype,"subscribeStream",1),TW([FO()],RW.prototype,"unsubscribeStream",1),TW([FO()],RW.prototype,"subscribeScreen",1),TW([FO()],RW.prototype,"unsubscribeScreen",1),TW([FO()],RW.prototype,"setRemoteVideoConfig",1),TW([FO()],RW.prototype,"startVideoCapture",1),TW([FO()],RW.prototype,"stopVideoCapture",1),TW([FO()],RW.prototype,"startAudioCapture",1),TW([FO()],RW.prototype,"stopAudioCapture",1),TW([FO()],RW.prototype,"getAudioMixingManager",1),TW([FO()],RW.prototype,"startScreenCapture",1),TW([FO()],RW.prototype,"stopScreenCapture",1),TW([FO()],RW.prototype,"setLocalVideoPlayer",1),TW([FO()],RW.prototype,"startLiveTranscoding",1),TW([FO()],RW.prototype,"updateLiveTranscoding",1),TW([FO()],RW.prototype,"stopLiveTranscoding",1),TW([FO()],RW.prototype,"startSubtitle",1),TW([FO()],RW.prototype,"stopSubtitle",1),TW([FO()],RW.prototype,"setBusinessId",1),TW([FO()],RW.prototype,"setUserVisibility",1),TW([FO()],RW.prototype,"setRemoteVideoPlayer",1),TW([FO()],RW.prototype,"setLocalVideoMirrorType",1),TW([FO()],RW.prototype,"setAudioPlaybackDevice",1),TW([FO()],RW.prototype,"play",1),TW([FO()],RW.prototype,"pauseAllSubscribedStream",1),TW([FO()],RW.prototype,"resumeAllSubscribedStream",1),TW([FO()],RW.prototype,"sendUserMessage",1),TW([FO()],RW.prototype,"sendUserBinaryMessage",1),TW([FO()],RW.prototype,"sendRoomMessage",1),TW([FO()],RW.prototype,"sendRoomBinaryMessage",1),TW([FO()],RW.prototype,"setAudioCaptureConfig",1),TW([MD("4.51"),FO()],RW.prototype,"setVideoCaptureConfig",1),TW([FO()],RW.prototype,"enableSimulcastMode",1),TW([FO()],RW.prototype,"setVideoEncoderConfig",1),TW([FO()],RW.prototype,"setScreenEncoderConfig",1),TW([FO()],RW.prototype,"sendSEIMessage",1),TW([MD("4.42"),FO()],RW.prototype,"setAudioVolumeIndicationInterval",1),TW([FO()],RW.prototype,"enableAudioPropertiesReport",1),TW([FO()],RW.prototype,"setVideoSourceType",1),TW([FO()],RW.prototype,"setExternalVideoTrack",1),TW([FO()],RW.prototype,"setAudioSourceType",1),TW([FO()],RW.prototype,"setExternalAudioTrack",1),TW([FO()],RW.prototype,"login",1),TW([FO()],RW.prototype,"logout",1),TW([FO()],RW.prototype,"updateLoginToken",1),TW([FO()],RW.prototype,"getPeerOnlineStatus",1),TW([FO()],RW.prototype,"sendUserMessageOutsideRoom",1),TW([FO()],RW.prototype,"sendUserBinaryMessageOutsideRoom",1),TW([FO()],RW.prototype,"setServerParams",1),TW([FO()],RW.prototype,"sendServerMessage",1),TW([FO()],RW.prototype,"sendServerBinaryMessage",1),TW([FO()],RW.prototype,"startCloudProxy",1),TW([FO()],RW.prototype,"stopCloudProxy",1),TW([FO()],RW.prototype,"startPushPublicStream",1),TW([FO()],RW.prototype,"updatePublicStreamParam",1),TW([FO()],RW.prototype,"stopPushPublicStream",1),TW([FO("streamId")],RW.prototype,"startPlayPublicStream",1),TW([FO("streamId")],RW.prototype,"stopPlayPublicStream",1),TW([FO()],RW.prototype,"setAudioProfile",1),TW([FO()],RW.prototype,"setAudioEncodeMaxBitrate",1),TW([FO()],RW.prototype,"setPublicStreamVideoPlayer",1),TW([FO()],RW.prototype,"setDummyCaptureImagePath",1),TW([FO()],RW.prototype,"registerExtension",1),TW([FO()],RW.prototype,"startAudioPlaybackDeviceTest",1),TW([FO()],RW.prototype,"stopAudioPlaybackDeviceTest",1),TW([FO()],RW.prototype,"startAudioDeviceRecordTest",1),TW([FO()],RW.prototype,"stopAudioDeviceRecordAndPlayTest",1),TW([FO()],RW.prototype,"stopAudioDevicePlayTest",1),TW([FO()],RW.prototype,"setRemoteUserPriority",1),TW([FO()],RW.prototype,"takeLocalSnapshot",1),TW([FO()],RW.prototype,"takeRemoteSnapshot",1),TW([FO()],RW.prototype,"setSubscribeFallbackOption",1),TW([FO()],RW.prototype,"getLocalStreamTrack",1),TW([FO()],RW.prototype,"getRemoteStreamTrack",1),TW([FO()],RW.prototype,"getPublicStreamTrack",1),TW([FO()],RW.prototype,"setRemoteStreamRenderSync",1),TW([FO()],RW.prototype,"startForwardStreamToRooms",1),TW([FO()],RW.prototype,"updateForwardStreamToRooms",1),TW([FO()],RW.prototype,"stopForwardStreamToRooms",1),TW([FO()],RW.prototype,"pauseForwardStreamToAllRooms",1),TW([FO()],RW.prototype,"resumeForwardStreamToAllRooms",1);var AW,wW={"client unpublished":dl.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":dl.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":dl.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":dl.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":dl.STREAM_REMOVE_REASON_REPUBLISH};function CW(e){var t=EN.getServerConfig(e).web_rtc_config;return!(null==t||!t.fallback)||!!ON("ENABLE_FALLBACK_HANDLER")}var xW=new Pw("VERTC",0);Ew.storeKey=Om(AW="".concat(Date.now(),"-")).call(AW,EN.getDeviceId()),xO({rtc_sdk_version:CN.VERSION,device_id:EN.getDeviceId(),log_cache_key:Ew.storeKey}),OO(CN.LOG_SERVER_URL);var OW=1,DW=function(e,t){xW.info("createEngine","Invoke VERTC.createEngine"),UN(e,"appId");var r=(OW++).toString();return function(e,t){var r=new TO(e);r.set(Zd(Zd({},t),{},{engine_session_id:_w()})),r.report("sdk_init_engine",{start:Date.now(),type:"begin"}),UO.set(e,r)}(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new RW(e,r,t)},NW=function(e){if(xW.info("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof RW))throw new mA(pA.INVALID_ENGINE,"Invalid engine object");var t;e.destroy(),(t=e.monitor).report("sdk_init_engine",{start:Date.now(),type:"end"}),UO.delete(t.id)},MW=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",XU.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),PW=function(){var e=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:{video:!0,audio:!0},r=t.video,n=t.audio,i={video:!1,audio:!1},!r){e.next=14;break}return e.prev=4,e.next=7,XU.getPermissions({video:!0,force:!0});case 7:o=e.sent,i.video=o.video,o.video||(i.videoExceptionError=o.reason),e.next=14;break;case 12:e.prev=12,e.t0=e.catch(4);case 14:if(!n){e.next=25;break}return e.prev=15,e.next=18,XU.getPermissions({audio:!0,force:!0});case 18:a=e.sent,i.audio=a.audio,a.audio||(i.audioExceptionError=a.reason),e.next=25;break;case 23:e.prev=23,e.t1=e.catch(15);case 25:return e.abrupt("return",i);case 26:case"end":return e.stop()}}),e,null,[[4,12],[15,23]])})));return function(){return e.apply(this,arguments)}}(),LW=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",XU.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),UW=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",XU.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),VW=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",XU.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),FW=function(){return CN.VERSION},BW=function(){return NO("isSupported",0,""),QP()},jW=function(){return NO("getSupportedCodecs",0,""),eL()},GW=function(e){var t=e.logLevel,r=e.LogfileSize;t&&(Ew.logLevel=t),r&&(Ew.LogfileSize=r)},HW=function(e){Ew.download(e)};function zW(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Pm(jm(t).call(t,(function(e){return e instanceof RW?"[ENGINE]":e})))}function KW(e,t){return function(){NO(t,0,zW.apply(void 0,arguments));var r=e.apply(void 0,arguments);return"function"==typeof(null==r?void 0:r.then)?r.then((function(e){return MO(t,0,zW(e)),e})).catch((function(e){throw MO(t,e.code,e.message),e})):(MO(t,0,zW(r)),r)}}return Zd(Zd(Zd(Zd({},new(Ul((function e(){Vl(this,e),Jd(this,"getSdkVersion",KW(FW,"getSdkVersion")),Jd(this,"createEngine",KW(DW,"createEngine")),Jd(this,"destroyEngine",KW(NW,"destroyEngine")),Jd(this,"enumerateDevices",KW(MW,"enumerateDevices")),Jd(this,"enableDevices",KW(PW,"enableDevices")),Jd(this,"enumerateAudioCaptureDevices",KW(LW,"enumerateAudioCaptureDevices")),Jd(this,"enumerateVideoCaptureDevices",KW(UW,"enumerateVideoCaptureDevices")),Jd(this,"enumerateAudioPlaybackDevices",KW(VW,"enumerateAudioPlaybackDevices")),Jd(this,"getParameter",ON),Jd(this,"setParameter",xN),Jd(this,"isSupported",KW(BW,"isSupported")),Jd(this,"getSupportedCodecs",KW(jW,"getSupportedCodecs")),Jd(this,"events",Pl),Jd(this,"ErrorCode",pA),Jd(this,"platform","BytePlus"),Jd(this,"commitInfo","release_455<1ae233e*>"),Jd(this,"downloadLog",KW(HW,"downloadLog")),Jd(this,"setLogConfig",KW(GW,"setLogConfig"))})))),xl),Ml),{},{events:Pl})}));
|