@byteplus/rtc 4.52.4 → 4.52.5

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.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.52.4
4
+ * version: 4.52.5
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,u=s.apply,c=s.call,d="object"==typeof Reflect&&Reflect.apply||(a?c.bind(u):function(){return c.apply(u,arguments)}),l=o,h=Function.prototype,v=h.call,p=l&&h.bind.bind(v,v),f=l?p:function(e){return function(){return v.apply(e,arguments)}},_=f,m=_({}.toString),g=_("".slice),y=function(e){return g(m(e),8,-1)},S=y,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,A=T.IS_HTMLDDA?function(e){return"function"==typeof e||e===I}:function(e){return"function"==typeof e},R={},w=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),C=o,x=Function.prototype.call,P=C?x.bind(x):function(){return x.apply(x,arguments)},O={},D={}.propertyIsEnumerable,M=Object.getOwnPropertyDescriptor,N=M&&!D.call({1:2},1);O.f=N?function(e){var t=M(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),z=F((function(){return!j("z").propertyIsEnumerable(0)}))?function(e){return"String"==B(e)?G(e,""):j(e)}:j,H=function(e){return null==e},X=H,K=TypeError,q=function(e){if(X(e))throw K("Can't call method on "+e);return e},Y=z,W=q,Q=function(e){return Y(W(e))},J=A,Z=T.all,$=T.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:J(e)||e===Z}:function(e){return"object"==typeof e?null!==e:J(e)},ee={},te=ee,re=n,ne=A,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")||"",ue=n,ce=se,de=ue.process,le=ue.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&&ce&&(!(L=ce.match(/Edge\/(\d+)/))||L[1]>=74)&&(L=ce.match(/Chrome\/(\d+)/))&&(U=+L[1]);var pe=U,fe=pe,_e=i,me=!!Object.getOwnPropertySymbols&&!_e((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&fe&&fe<41})),ge=me&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ye=oe,Se=A,be=ae,Ee=Object,ke=ge?function(e){return"symbol"==typeof e}:function(e){var t=ye("Symbol");return Se(t)&&be(t.prototype,Ee(e))},Te=String,Ie=function(e){try{return Te(e)}catch(t){return"Object"}},Ae=A,Re=Ie,we=TypeError,Ce=function(e){if(Ae(e))return e;throw we(Re(e)+" is not a function")},xe=Ce,Pe=H,Oe=function(e,t){var r=e[t];return Pe(r)?void 0:xe(r)},De=P,Me=A,Ne=$,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,{}),ze=Ge;(Ue.exports=function(e,t){return ze[e]||(ze[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 He=q,Xe=Object,Ke=function(e){return Xe(He(e))},qe=Ke,Ye=E({}.hasOwnProperty),We=Object.hasOwn||function(e,t){return Ye(qe(e),t)},Qe=E,Je=0,Ze=Math.random(),$e=Qe(1..toString),et=function(e){return"Symbol("+(void 0===e?"":e)+")_"+$e(++Je+Ze,36)},tt=n,rt=Ue.exports,nt=We,it=et,ot=me,at=ge,st=rt("wks"),ut=tt.Symbol,ct=ut&&ut.for,dt=at?ut:ut&&ut.withoutSetter||it,lt=function(e){if(!nt(st,e)||!ot&&"string"!=typeof st[e]){var t="Symbol."+e;ot&&nt(ut,e)?st[e]=ut[e]:st[e]=at&&ct?ct(t):dt(t)}return st[e]},ht=P,vt=$,pt=ke,ft=Oe,_t=function(e,t){var r,n;if("string"===t&&Me(r=e.toString)&&!Ne(n=De(r,e)))return n;if(Me(r=e.valueOf)&&!Ne(n=De(r,e)))return n;if("string"!==t&&Me(r=e.toString)&&!Ne(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)||pt(e))return e;var r,n=ft(e,gt);if(n){if(void 0===t&&(t="default"),r=ht(n,e,t),!vt(r)||pt(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=yt(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):{}},At=It,Rt=!w&&!i((function(){return 7!=Object.defineProperty(At("div"),"a",{get:function(){return 7}}).a})),wt=w,Ct=P,xt=O,Pt=V,Ot=Q,Dt=bt,Mt=We,Nt=Rt,Lt=Object.getOwnPropertyDescriptor;R.f=wt?Lt:function(e,t){if(e=Ot(e),t=Dt(t),Nt)try{return Lt(e,t)}catch(r){}if(Mt(e,t))return Pt(!Ct(xt.f,e,t),e[t])};var Ut=i,Vt=A,Ft=/#|\.prototype\./,Bt=function(e,t){var r=Gt[jt(e)];return r==Ht||r!=zt&&(Vt(t)?Ut(t):!!t)},jt=Bt.normalize=function(e){return String(e).replace(Ft,".").toLowerCase()},Gt=Bt.data={},zt=Bt.NATIVE="N",Ht=Bt.POLYFILL="P",Xt=Bt,Kt=Ce,qt=o,Yt=E(E.bind),Wt=function(e,t){return Kt(e),void 0===t?e:qt?Yt(e,t):function(){return e.apply(t,arguments)}},Qt={},Jt=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=Rt,ir=Jt,or=tr,ar=bt,sr=TypeError,ur=Object.defineProperty,cr=Object.getOwnPropertyDescriptor,dr="enumerable",lr="configurable",hr="writable";Qt.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=cr(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 ur(e,t,r)}:ur:function(e,t,r){if(or(e),t=ar(t),or(r),nr)try{return ur(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=Qt,pr=V,fr=w?function(e,t,r){return vr.f(e,t,pr(1,r))}:function(e,t,r){return e[t]=r,e},_r=n,mr=d,gr=E,yr=A,Sr=R.f,br=Xt,Er=ee,kr=Wt,Tr=fr,Ir=We,Ar=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},Rr=function(e,t){var r,n,i,o,a,s,u,c,d=e.target,l=e.global,h=e.stat,v=e.proto,p=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)&&p&&Ir(p,i),a=f[i],r&&(s=e.dontCallGetSet?(c=Sr(p,i))&&c.value:p[i]),o=r&&s?s:t[i],r&&typeof a==typeof o||(u=e.bind&&r?kr(o,_r):e.wrap&&r?Ar(o):v&&yr(o)?gr(o):o,(e.sham||o&&o.sham||a&&a.sham)&&Tr(u,"sham",!0),Tr(f,i,u),v&&(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)},Pr=function(e){var t=+e;return t!=t||0===t?0:xr(t)},Or=Pr,Dr=Math.max,Mr=Math.min,Nr=function(e,t){var r=Or(e);return r<0?Dr(r+t,0):Mr(r,t)},Lr=Pr,Ur=Math.min,Vr=function(e){return e>0?Ur(Lr(e),9007199254740991):0},Fr=Vr,Br=function(e){return Fr(e.length)},jr=Q,Gr=Nr,zr=Br,Hr=function(e){return function(t,r,n){var i,o=jr(t),a=zr(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}},Xr={includes:Hr(!0),indexOf:Hr(!1)},Kr={},qr=We,Yr=Q,Wr=Xr.indexOf,Qr=Kr,Jr=E([].push),Zr=function(e,t){var r,n=Yr(e),i=0,o=[];for(r in n)!qr(Qr,r)&&qr(n,r)&&Jr(o,r);for(;t.length>i;)qr(n,r=t[i++])&&(~Wr(o,r)||Jr(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=Ke,on=rn;Rr({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 un="[object z]"===String(sn),cn=un,dn=A,ln=y,hn=lt("toStringTag"),vn=Object,pn="Arguments"==ln(function(){return arguments}()),fn=cn?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:pn?ln(t):"Object"==(n=ln(t))&&dn(t.callee)?"Arguments":n},_n=fn,mn=String,gn=function(e){if("Symbol"===_n(e))throw TypeError("Cannot convert a Symbol value to a string");return mn(e)},yn={},Sn=w,bn=Jt,En=Qt,kn=tr,Tn=Q,In=rn;yn.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 An,Rn=oe("document","documentElement"),wn=Ue.exports,Cn=et,xn=wn("keys"),Pn=function(e){return xn[e]||(xn[e]=Cn(e))},On=tr,Dn=yn,Mn=$r,Nn=Kr,Ln=Rn,Un=It,Vn=Pn("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{An=new ActiveXObject("htmlfile")}catch(n){}var e,t;Gn="undefined"!=typeof document?document.domain&&An?jn(An):((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(An);for(var r=Mn.length;r--;)delete Gn.prototype[Mn[r]];return Gn()};Nn[Vn]=!0;var zn=Object.create||function(e,t){var r;return null!==e?(Fn.prototype=On(e),r=new Fn,Fn.prototype=null,r[Vn]=e):r=Gn(),void 0===t?r:Dn.f(r,t)},Hn={},Xn=Zr,Kn=$r.concat("length","prototype");Hn.f=Object.getOwnPropertyNames||function(e){return Xn(e,Kn)};var qn={},Yn=bt,Wn=Qt,Qn=V,Jn=function(e,t,r){var n=Yn(t);n in e?Wn.f(e,n,Qn(0,r)):e[n]=r},Zn=Nr,$n=Br,ei=Jn,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=Q,ai=Hn.f,si=ni,ui="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];qn.f=function(e){return ui&&"Window"==ii(e)?function(e){try{return ai(e)}catch(t){return si(ui)}}(e):ai(oi(e))};var ci={};ci.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={},vi=lt;hi.f=vi;var pi,fi,_i,mi=ee,gi=We,yi=hi,Si=Qt.f,bi=function(e){var t=mi.Symbol||(mi.Symbol={});gi(t,e)||Si(t,e,{value:yi.f(e)})},Ei=P,ki=oe,Ti=lt,Ii=li,Ai=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})},Ri=fn,wi=un?{}.toString:function(){return"[object "+Ri(this)+"]"},Ci=un,xi=Qt.f,Pi=fr,Oi=We,Di=wi,Mi=lt("toStringTag"),Ni=function(e,t,r,n){if(e){var i=r?e:e.prototype;Oi(i,Mi)||xi(i,Mi,{configurable:!0,value:t}),n&&!Ci&&Pi(i,"toString",Di)}},Li=A,Ui=n.WeakMap,Vi=Li(Ui)&&/native code/.test(String(Ui)),Fi=Vi,Bi=n,ji=$,Gi=fr,zi=We,Hi=Ge,Xi=Pn,Ki=Kr,qi="Object already initialized",Yi=Bi.TypeError,Wi=Bi.WeakMap;if(Fi||Hi.state){var Qi=Hi.state||(Hi.state=new Wi);Qi.get=Qi.get,Qi.has=Qi.has,Qi.set=Qi.set,pi=function(e,t){if(Qi.has(e))throw Yi(qi);return t.facade=e,Qi.set(e,t),t},fi=function(e){return Qi.get(e)||{}},_i=function(e){return Qi.has(e)}}else{var Ji=Xi("state");Ki[Ji]=!0,pi=function(e,t){if(zi(e,Ji))throw Yi(qi);return t.facade=e,Gi(e,Ji,t),t},fi=function(e){return zi(e,Ji)?e[Ji]:{}},_i=function(e){return zi(e,Ji)}}var Zi={set:pi,get:fi,has:_i,enforce:function(e){return _i(e)?fi(e):pi(e,{})},getterFor:function(e){return function(t){var r;if(!ji(t)||(r=fi(t)).type!==e)throw Yi("Incompatible receiver, "+e+" required");return r}}},$i=y,eo=Array.isArray||function(e){return"Array"==$i(e)},to=A,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=A,uo=fn,co=io,lo=function(){},ho=[],vo=oe("Reflect","construct"),po=/^\s*(?:class|function)\b/,fo=oo(po.exec),_o=!po.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(uo(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return _o||!!fo(po,co(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=$,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},Ao=function(e,t){return new(Io(e))(0===t?0:t)},Ro=Wt,wo=z,Co=Ke,xo=Br,Po=Ao,Oo=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(u,c,d,l){for(var h,v,p=Co(u),f=wo(p),_=Ro(c,d),m=xo(f),g=0,y=l||Po,S=t?y(u,m):r||a?y(u,0):void 0;m>g;g++)if((s||g in f)&&(v=_(h=f[g],g,p),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:Oo(S,h)}else switch(e){case 4:return!1;case 7:Oo(S,h)}return o?-1:n||i?i:S}},Mo={forEach:Do(0),map:Do(1),filter:Do(2),some:Do(3),every:Do(4),find:Do(5),findIndex:Do(6),filterReject:Do(7)},No=Rr,Lo=n,Uo=P,Vo=E,Fo=w,Bo=me,jo=i,Go=We,zo=ae,Ho=tr,Xo=Q,Ko=bt,qo=gn,Yo=V,Wo=zn,Qo=rn,Jo=Hn,Zo=qn,$o=ci,ea=R,ta=Qt,ra=yn,na=O,ia=li,oa=Ue.exports,aa=Kr,sa=et,ua=lt,ca=hi,da=bi,la=Ai,ha=Ni,va=Zi,pa=Mo.forEach,fa=Pn("hidden"),_a="Symbol",ma=va.set,ga=va.getterFor(_a),ya=Object.prototype,Sa=Lo.Symbol,ba=Sa&&Sa.prototype,Ea=Lo.TypeError,ka=Lo.QObject,Ta=ea.f,Ia=ta.f,Aa=Zo.f,Ra=na.f,wa=Vo([].push),Ca=oa("symbols"),xa=oa("op-symbols"),Pa=oa("wks"),Oa=!ka||!ka.prototype||!ka.prototype.findChild,Da=Fo&&jo((function(){return 7!=Wo(Ia({},"a",{get:function(){return Ia(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=Ta(ya,t);n&&delete ya[t],Ia(e,t,r),n&&e!==ya&&Ia(ya,t,n)}:Ia,Ma=function(e,t){var r=Ca[e]=Wo(ba);return ma(r,{type:_a,tag:e,description:t}),Fo||(r.description=t),r},Na=function(e,t,r){e===ya&&Na(xa,t,r),Ho(e);var n=Ko(t);return Ho(r),Go(Ca,n)?(r.enumerable?(Go(e,fa)&&e[fa][n]&&(e[fa][n]=!1),r=Wo(r,{enumerable:Yo(0,!1)})):(Go(e,fa)||Ia(e,fa,Yo(1,{})),e[fa][n]=!0),Da(e,n,r)):Ia(e,n,r)},La=function(e,t){Ho(e);var r=Xo(t),n=Qo(r).concat(Ba(r));return pa(n,(function(t){Fo&&!Uo(Ua,r,t)||Na(e,t,r[t])})),e},Ua=function(e){var t=Ko(e),r=Uo(Ra,this,t);return!(this===ya&&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=Xo(e),n=Ko(t);if(r!==ya||!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=Aa(Xo(e)),r=[];return pa(t,(function(e){Go(Ca,e)||Go(aa,e)||wa(r,e)})),r},Ba=function(e){var t=e===ya,r=Aa(t?xa:Xo(e)),n=[];return pa(r,(function(e){!Go(Ca,e)||t&&!Go(ya,e)||wa(n,Ca[e])})),n};Bo||(Sa=function(){if(zo(ba,this))throw Ea("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?qo(arguments[0]):void 0,t=sa(e),r=function(e){this===ya&&Uo(r,xa,e),Go(this,fa)&&Go(this[fa],t)&&(this[fa][t]=!1),Da(this,t,Yo(1,e))};return Fo&&Oa&&Da(ya,t,{configurable:!0,set:r}),Ma(t,e)},ia(ba=Sa.prototype,"toString",(function(){return ga(this).tag})),ia(Sa,"withoutSetter",(function(e){return Ma(sa(e),e)})),na.f=Ua,ta.f=Na,ra.f=La,ea.f=Va,Jo.f=Zo.f=Fa,$o.f=Ba,ca.f=function(e){return Ma(ua(e),e)},Fo&&Ia(ba,"description",{configurable:!0,get:function(){return ga(this).description}})),No({global:!0,constructor:!0,wrap:!0,forced:!Bo,sham:!Bo},{Symbol:Sa}),pa(Qo(Pa),(function(e){da(e)})),No({target:_a,stat:!0,forced:!Bo},{useSetter:function(){Oa=!0},useSimple:function(){Oa=!1}}),No({target:"Object",stat:!0,forced:!Bo,sham:!Fo},{create:function(e,t){return void 0===t?Wo(e):La(Wo(e),t)},defineProperty:Na,defineProperties:La,getOwnPropertyDescriptor:Va}),No({target:"Object",stat:!0,forced:!Bo},{getOwnPropertyNames:Fa}),la(),ha(Sa,_a),aa[fa]=!0;var ja=me&&!!Symbol.for&&!!Symbol.keyFor,Ga=Rr,za=oe,Ha=We,Xa=gn,Ka=Ue.exports,qa=ja,Ya=Ka("string-to-symbol-registry"),Wa=Ka("symbol-to-string-registry");Ga({target:"Symbol",stat:!0,forced:!qa},{for:function(e){var t=Xa(e);if(Ha(Ya,t))return Ya[t];var r=za("Symbol")(t);return Ya[t]=r,Wa[r]=t,r}});var Qa=Rr,Ja=We,Za=ke,$a=Ie,es=ja,ts=(0,Ue.exports)("symbol-to-string-registry");Qa({target:"Symbol",stat:!0,forced:!es},{keyFor:function(e){if(!Za(e))throw TypeError($a(e)+" is not a symbol");if(Ja(ts,e))return ts[e]}});var rs=E([].slice),ns=Rr,is=oe,os=d,as=P,ss=E,us=i,cs=eo,ds=A,ls=$,hs=ke,vs=rs,ps=me,fs=is("JSON","stringify"),_s=ss(/./.exec),ms=ss("".charAt),gs=ss("".charCodeAt),ys=ss("".replace),Ss=ss(1..toString),bs=/[\uD800-\uDFFF]/g,Es=/^[\uD800-\uDBFF]$/,ks=/^[\uDC00-\uDFFF]$/,Ts=!ps||us((function(){var e=is("Symbol")();return"[null]"!=fs([e])||"{}"!=fs({a:e})||"{}"!=fs(Object(e))})),Is=us((function(){return'"\\udf06\\ud834"'!==fs("\udf06\ud834")||'"\\udead"'!==fs("\udead")})),As=function(e,t){var r=vs(arguments),n=t;if((ls(t)||void 0!==e)&&!hs(e))return cs(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)},Rs=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(gs(e,0),16):e};fs&&ns({target:"JSON",stat:!0,arity:3,forced:Ts||Is},{stringify:function(e,t,r){var n=vs(arguments),i=os(Ts?As:fs,null,n);return Is&&"string"==typeof i?ys(i,bs,Rs):i}});var ws=ci,Cs=Ke;Rr({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,Ps=i,Os=pe,Ds=lt("species"),Ms=function(e){return Os>=51||!Ps((function(){var t=[];return(t.constructor={})[Ds]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Ns=Mo.filter;Rr({target:"Array",proto:!0,forced:!Ms("filter")},{filter:function(e){return Ns(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},zs={exports:{}},Hs=Rr,Xs=i,Ks=Q,qs=R.f,Ys=w,Ws=Xs((function(){qs(1)}));Hs({target:"Object",stat:!0,forced:!Ys||Ws,sham:!Ys},{getOwnPropertyDescriptor:function(e,t){return qs(Ks(e),t)}});var Qs=ee.Object,Js=zs.exports=function(e,t){return Qs.getOwnPropertyDescriptor(e,t)};Qs.getOwnPropertyDescriptor.sham&&(Js.sham=!0);var Zs,$s,eu,tu=zs.exports,ru={},nu=w,iu=We,ou=Function.prototype,au=nu&&Object.getOwnPropertyDescriptor,su=iu(ou,"name"),uu={EXISTS:su,PROPER:su&&"something"===function(){}.name,CONFIGURABLE:su&&(!nu||nu&&au(ou,"name").configurable)},cu=!i((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),du=We,lu=A,hu=Ke,vu=cu,pu=Pn("IE_PROTO"),fu=Object,_u=fu.prototype,mu=vu?fu.getPrototypeOf:function(e){var t=hu(e);if(du(t,pu))return t[pu];var r=t.constructor;return lu(r)&&t instanceof r?r.prototype:t instanceof fu?_u:null},gu=i,yu=A,Su=$,bu=zn,Eu=mu,ku=li,Tu=lt("iterator"),Iu=!1;[].keys&&("next"in(eu=[].keys())?($s=Eu(Eu(eu)))!==Object.prototype&&(Zs=$s):Iu=!0);var Au=!Su(Zs)||gu((function(){var e={};return Zs[Tu].call(e)!==e}));yu((Zs=Au?{}:bu(Zs))[Tu])||ku(Zs,Tu,(function(){return this}));var Ru={IteratorPrototype:Zs,BUGGY_SAFARI_ITERATORS:Iu},wu=Ru.IteratorPrototype,Cu=zn,xu=V,Pu=Ni,Ou=ru,Du=function(){return this},Mu=function(e,t,r,n){var i=t+" Iterator";return e.prototype=Cu(wu,{next:xu(+!n,r)}),Pu(e,i,!1,!0),Ou[i]=Du,e},Nu=A,Lu=String,Uu=TypeError,Vu=E,Fu=tr,Bu=function(e){if("object"==typeof e||Nu(e))return e;throw Uu("Can't set "+Lu(e)+" as a prototype")},ju=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=Vu(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),t=r instanceof Array}catch(n){}return function(r,n){return Fu(r),Bu(n),t?e(r,n):r.__proto__=n,r}}():void 0),Gu=Rr,zu=P,Hu=uu,Xu=Mu,Ku=mu,qu=Ni,Yu=li,Wu=ru,Qu=Ru,Ju=Hu.PROPER,Zu=Qu.BUGGY_SAFARI_ITERATORS,$u=lt("iterator"),ec="keys",tc="values",rc="entries",nc=function(){return this},ic=function(e,t,r,n,i,o,a){Xu(r,t,n);var s,u,c,d=function(e){if(e===i&&f)return f;if(!Zu&&e in v)return v[e];switch(e){case ec:case tc:case rc:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,v=e.prototype,p=v[$u]||v["@@iterator"]||i&&v[i],f=!Zu&&p||d(i),_="Array"==t&&v.entries||p;if(_&&(s=Ku(_.call(new e)))!==Object.prototype&&s.next&&(qu(s,l,!0,!0),Wu[l]=nc),Ju&&i==tc&&p&&p.name!==tc&&(h=!0,f=function(){return zu(p,this)}),i)if(u={values:d(tc),keys:o?f:d(ec),entries:d(rc)},a)for(c in u)(Zu||h||!(c in v))&&Yu(v,c,u[c]);else Gu({target:t,proto:!0,forced:Zu||h},u);return a&&v[$u]!==f&&Yu(v,$u,f,{name:i}),Wu[t]=f,u},oc=function(e,t){return{value:e,done:t}},ac=Q,sc=function(){},uc=ru,cc=Zi,dc=(Qt.f,ic),lc=oc,hc="Array Iterator",vc=cc.set,pc=cc.getterFor(hc);dc(Array,"Array",(function(e,t){vc(this,{type:hc,target:ac(e),index:0,kind:t})}),(function(){var e=pc(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,lc(void 0,!0)):lc("keys"==r?n:"values"==r?t[n]:[n,t[n]],!1)}),"values");uc.Arguments=uc.Array;sc(),sc(),sc();var fc={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},_c=n,mc=fn,gc=fr,yc=ru,Sc=lt("toStringTag");for(var bc in fc){var Ec=_c[bc],kc=Ec&&Ec.prototype;kc&&mc(kc)!==Sc&&gc(kc,Sc,bc),yc[bc]=yc.Array}var Tc=i,Ic=function(e,t){var r=[][e];return!!r&&Tc((function(){r.call(null,t||function(){return 1},1)}))},Ac=Mo.forEach,Rc=Ic("forEach")?[].forEach:function(e){return Ac(this,e,arguments.length>1?arguments[1]:void 0)};Rr({target:"Array",proto:!0,forced:[].forEach!=Rc},{forEach:Rc});var wc=Us("Array").forEach,Cc=fn,xc=We,Pc=ae,Oc=wc,Dc=Array.prototype,Mc={DOMTokenList:!0,NodeList:!0},Nc=function(e){var t=e.forEach;return e===Dc||Pc(Dc,e)&&t===Dc.forEach||xc(Mc,Cc(e))?Oc:t},Lc=oe,Uc=Hn,Vc=ci,Fc=tr,Bc=E([].concat),jc=Lc("Reflect","ownKeys")||function(e){var t=Uc.f(Fc(e)),r=Vc.f;return r?Bc(t,r(e)):t},Gc=jc,zc=Q,Hc=R,Xc=Jn;Rr({target:"Object",stat:!0,sham:!w},{getOwnPropertyDescriptors:function(e){for(var t,r,n=zc(e),i=Hc.f,o=Gc(n),a={},s=0;o.length>s;)void 0!==(r=i(n,t=o[s++]))&&Xc(a,t,r);return a}});var Kc=ee.Object.getOwnPropertyDescriptors,qc={exports:{}},Yc=Rr,Wc=w,Qc=yn.f;Yc({target:"Object",stat:!0,forced:Object.defineProperties!==Qc,sham:!Wc},{defineProperties:Qc});var Jc=ee.Object,Zc=qc.exports=function(e,t){return Jc.defineProperties(e,t)};Jc.defineProperties.sham&&(Zc.sham=!0);var $c=qc.exports,ed={exports:{}},td=Rr,rd=w,nd=Qt.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;function sd(e,t,r){return t in e?ad(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ud(e,t){var r=an(e);if(xs){var n=xs(e);t&&(n=Gs(n).call(n,(function(t){return tu(e,t).enumerable}))),r.push.apply(r,n)}return r}function cd(e){for(var t=1;t<arguments.length;t++){var r,n,i=null!=arguments[t]?arguments[t]:{};t%2?Nc(r=ud(Object(i),!0)).call(r,(function(t){sd(e,t,i[t])})):Kc?$c(e,Kc(i)):Nc(n=ud(Object(i))).call(n,(function(t){ad(e,t,tu(i,t))}))}return e}var dd=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}(dd||{}),ld=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}(ld||{}),hd=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}(hd||{}),vd=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(vd||{}),pd=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(pd||{}),fd=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(fd||{}),_d=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(_d||{}),md=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(md||{}),gd=function(e){return e[e.RENDER_MODE_HIDDEN=0]="RENDER_MODE_HIDDEN",e[e.RENDER_MODE_FIT=1]="RENDER_MODE_FIT",e}(gd||{}),yd=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(yd||{}),Sd=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(Sd||{}),bd=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}(bd||{}),Ed=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}(Ed||{}),kd=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(kd||{}),Td=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(Td||{}),Id=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(Id||{}),Ad=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}(Ad||{}),Rd=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(Rd||{}),wd=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}(wd||{}),Cd=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(Cd||{}),xd=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}(xd||{}),Pd=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(Pd||{}),Od=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}(Od||{}),Dd=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}(Dd||{}),Md=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}(Md||{}),Nd=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(Nd||{}),Ld=function(e){return e.H264="H264",e.H265="H265",e}(Ld||{}),Ud=function(e){return e[e.ASR_ONLY=0]="ASR_ONLY",e[e.ASR_AND_TRANSLATION=1]="ASR_AND_TRANSLATION",e}(Ud||{}),Vd=function(e){return e[e.STARTED=0]="STARTED",e[e.STOPPED=1]="STOPPED",e[e.ERROR=2]="ERROR",e}(Vd||{}),Fd=Object.freeze(Object.defineProperty({__proto__:null,VideoSourceType:dd,AudioSourceType:ld,UserOfflineReason:hd,ChannelProfile:vd,SubscribeMode:pd,SubscribeState:fd,PublishState:_d,MirrorMode:md,VideoRenderMode:gd,StreamIndex:yd,MediaType:Sd,StreamRemoveReason:bd,ConnectionState:Ed,MirrorType:kd,LogChannel:Td,USER_ONLINE_STATUS:Id,PublicStreamType:Ad,PublicInterpolationMode:Rd,SubscribeFallbackOption:wd,RemoteUserPriority:Cd,NetworkQuality:xd,FallbackOrRecoverReason:Pd,RoomProfileType:Od,AudioProfileType:Dd,RTCAutoPlayPolicy:Md,AAC_PROFILE:Nd,TRANSCODING_VIDEO_CODEC:Ld,SUBTITLE_MODE:Ud,SubtitleEventType:Vd},Symbol.toStringTag,{value:"Module"})),Bd=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}(Bd||{}),jd=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(jd||{}),Gd=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}(Gd||{}),zd=Object.freeze(Object.defineProperty({__proto__:null,AudioMixingDualMonoMode:Bd,AudioMixingType:jd,AudioMixingState:Gd},Symbol.toStringTag,{value:"Module"})),Hd=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}(Hd||{});function Xd(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,n.key,n)}}function Kd(e,t,r){return t&&Xd(e.prototype,t),r&&Xd(e,r),ad(e,"prototype",{writable:!1}),e}function qd(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Yd=TypeError,Wd=function(e){if(e>9007199254740991)throw Yd("Maximum allowed index exceeded");return e},Qd=Rr,Jd=i,Zd=eo,$d=$,el=Ke,tl=Br,rl=Wd,nl=Jn,il=Ao,ol=Ms,al=pe,sl=lt("isConcatSpreadable"),ul=al>=51||!Jd((function(){var e=[];return e[sl]=!1,e.concat()[0]!==e})),cl=ol("concat"),dl=function(e){if(!$d(e))return!1;var t=e[sl];return void 0!==t?!!t:Zd(e)};Qd({target:"Array",proto:!0,arity:1,forced:!ul||!cl},{concat:function(e){var t,r,n,i,o,a=el(this),s=il(a,0),u=0;for(t=-1,n=arguments.length;t<n;t++)if(dl(o=-1===t?a:arguments[t]))for(i=tl(o),rl(u+i),r=0;r<i;r++,u++)r in o&&nl(s,u,o[r]);else rl(u+1),nl(s,u++,o);return s.length=u,s}}),bi("asyncIterator"),bi("hasInstance"),bi("isConcatSpreadable"),bi("iterator"),bi("match"),bi("matchAll"),bi("replace"),bi("search"),bi("species"),bi("split");var ll=Ai;bi("toPrimitive"),ll();var hl=oe,vl=Ni;bi("toStringTag"),vl(hl("Symbol"),"Symbol"),bi("unscopables"),Ni(n.JSON,"JSON",!0);var pl=ee.Symbol;bi("asyncDispose"),bi("dispose"),bi("matcher"),bi("metadataKey"),bi("observable"),bi("metadata"),bi("patternMatch"),bi("replaceAll");var fl=pl,_l=E,ml=Pr,gl=gn,yl=q,Sl=_l("".charAt),bl=_l("".charCodeAt),El=_l("".slice),kl=function(e){return function(t,r){var n,i,o=gl(yl(t)),a=ml(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=bl(o,a))<55296||n>56319||a+1===s||(i=bl(o,a+1))<56320||i>57343?e?Sl(o,a):n:e?El(o,a,a+2):i-56320+(n-55296<<10)+65536}},Tl={codeAt:kl(!1),charAt:kl(!0)},Il=Tl.charAt,Al=gn,Rl=Zi,wl=ic,Cl=oc,xl="String Iterator",Pl=Rl.set,Ol=Rl.getterFor(xl);wl(String,"String",(function(e){Pl(this,{type:xl,string:Al(e),index:0})}),(function(){var e,t=Ol(this),r=t.string,n=t.index;return n>=r.length?Cl(void 0,!0):(e=Il(r,n),t.index+=e.length,Cl(e,!1))}));var Dl=hi.f("iterator");function Ml(e){return(Ml="function"==typeof fl&&"symbol"==typeof Dl?function(e){return typeof e}:function(e){return e&&"function"==typeof fl&&e.constructor===fl&&e!==fl.prototype?"symbol":typeof e})(e)}Rr({target:"Object",stat:!0,sham:!w},{create:zn});var Nl=ee.Object,Ll=function(e,t){return Nl.create(e,t)},Ul=Ke,Vl=mu,Fl=cu;Rr({target:"Object",stat:!0,forced:i((function(){Vl(1)})),sham:!Fl},{getPrototypeOf:function(e){return Vl(Ul(e))}});var Bl=ee.Object.getPrototypeOf;Rr({target:"Object",stat:!0},{setPrototypeOf:ju});var jl=ee.Object.setPrototypeOf,Gl=We,zl=jc,Hl=R,Xl=Qt,Kl=Error,ql=E("".replace),Yl=String(Kl("zxcasd").stack),Wl=/\n\s*at [^:]*:[^\n]*/,Ql=Wl.test(Yl),Jl=$,Zl=fr,$l=ru,eh=lt("iterator"),th=Array.prototype,rh=function(e){return void 0!==e&&($l.Array===e||th[eh]===e)},nh=fn,ih=Oe,oh=H,ah=ru,sh=lt("iterator"),uh=function(e){if(!oh(e))return ih(e,sh)||ih(e,"@@iterator")||ah[nh(e)]},ch=P,dh=Ce,lh=tr,hh=Ie,vh=uh,ph=TypeError,fh=function(e,t){var r=arguments.length<2?vh(e):t;if(dh(r))return lh(ch(r,e));throw ph(hh(e)+" is not iterable")},_h=P,mh=tr,gh=Oe,yh=function(e,t,r){var n,i;mh(e);try{if(!(n=gh(e,"return"))){if("throw"===t)throw r;return r}n=_h(n,e)}catch(o){i=!0,n=o}if("throw"===t)throw r;if(i)throw n;return mh(n),r},Sh=Wt,bh=P,Eh=tr,kh=Ie,Th=rh,Ih=Br,Ah=ae,Rh=fh,wh=uh,Ch=yh,xh=TypeError,Ph=function(e,t){this.stopped=e,this.result=t},Oh=Ph.prototype,Dh=function(e,t,r){var n,i,o,a,s,u,c,d=r&&r.that,l=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),v=!(!r||!r.IS_ITERATOR),p=!(!r||!r.INTERRUPTED),f=Sh(t,d),_=function(e){return n&&Ch(n,"normal",e),new Ph(!0,e)},m=function(e){return l?(Eh(e),p?f(e[0],e[1],_):f(e[0],e[1])):p?f(e,_):f(e)};if(h)n=e.iterator;else if(v)n=e;else{if(!(i=wh(e)))throw xh(kh(e)+" is not iterable");if(Th(i)){for(o=0,a=Ih(e);a>o;o++)if((s=m(e[o]))&&Ah(Oh,s))return s;return new Ph(!1)}n=Rh(e,i)}for(u=h?e.next:n.next;!(c=bh(u,n)).done;){try{s=m(c.value)}catch(g){Ch(n,"throw",g)}if("object"==typeof s&&s&&Ah(Oh,s))return s}return new Ph(!1)},Mh=gn,Nh=V,Lh=!i((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",Nh(1,7)),7!==e.stack)})),Uh=Rr,Vh=ae,Fh=mu,Bh=ju,jh=function(e,t,r){for(var n=zl(t),i=Xl.f,o=Hl.f,a=0;a<n.length;a++){var s=n[a];Gl(e,s)||r&&Gl(r,s)||i(e,s,o(t,s))}},Gh=zn,zh=fr,Hh=V,Xh=function(e,t){if(Ql&&"string"==typeof e&&!Kl.prepareStackTrace)for(;t--;)e=ql(e,Wl,"");return e},Kh=function(e,t){Jl(t)&&"cause"in t&&Zl(e,"cause",t.cause)},qh=Dh,Yh=function(e,t){return void 0===e?arguments.length<2?"":t:Mh(e)},Wh=Lh,Qh=lt("toStringTag"),Jh=Error,Zh=[].push,$h=function(e,t){var r,n=arguments.length>2?arguments[2]:void 0,i=Vh(ev,this);Bh?r=Bh(Jh(),i?Fh(this):ev):(r=i?this:Gh(ev),zh(r,Qh,"Error")),void 0!==t&&zh(r,"message",Yh(t)),Wh&&zh(r,"stack",Xh(r.stack,1)),Kh(r,n);var o=[];return qh(e,Zh,{that:o}),zh(r,"errors",o),r};Bh?Bh($h,Jh):jh($h,Jh,{name:!0});var ev=$h.prototype=Gh(Jh.prototype,{constructor:Hh(1,$h),message:Hh(1,""),name:Hh(1,"AggregateError")});Uh({global:!0,constructor:!0,arity:2},{AggregateError:$h});var tv,rv,nv,iv,ov="process"==y(n.process),av=oe,sv=Qt,uv=w,cv=lt("species"),dv=function(e){var t=av(e),r=sv.f;uv&&t&&!t[cv]&&r(t,cv,{configurable:!0,get:function(){return this}})},lv=ae,hv=TypeError,vv=function(e,t){if(lv(t,e))return e;throw hv("Incorrect invocation")},pv=yo,fv=Ie,_v=TypeError,mv=function(e){if(pv(e))return e;throw _v(fv(e)+" is not a constructor")},gv=tr,yv=mv,Sv=H,bv=lt("species"),Ev=function(e,t){var r,n=gv(e).constructor;return void 0===n||Sv(r=gv(n)[bv])?t:yv(r)},kv=TypeError,Tv=function(e,t){if(e<t)throw kv("Not enough arguments");return e},Iv=/(?:ipad|iphone|ipod).*applewebkit/i.test(se),Av=n,Rv=d,wv=Wt,Cv=A,xv=We,Pv=i,Ov=Rn,Dv=rs,Mv=It,Nv=Tv,Lv=Iv,Uv=ov,Vv=Av.setImmediate,Fv=Av.clearImmediate,Bv=Av.process,jv=Av.Dispatch,Gv=Av.Function,zv=Av.MessageChannel,Hv=Av.String,Xv=0,Kv={},qv="onreadystatechange";try{tv=Av.location}catch(ZH){}var Yv=function(e){if(xv(Kv,e)){var t=Kv[e];delete Kv[e],t()}},Wv=function(e){return function(){Yv(e)}},Qv=function(e){Yv(e.data)},Jv=function(e){Av.postMessage(Hv(e),tv.protocol+"//"+tv.host)};Vv&&Fv||(Vv=function(e){Nv(arguments.length,1);var t=Cv(e)?e:Gv(e),r=Dv(arguments,1);return Kv[++Xv]=function(){Rv(t,void 0,r)},rv(Xv),Xv},Fv=function(e){delete Kv[e]},Uv?rv=function(e){Bv.nextTick(Wv(e))}:jv&&jv.now?rv=function(e){jv.now(Wv(e))}:zv&&!Lv?(iv=(nv=new zv).port2,nv.port1.onmessage=Qv,rv=wv(iv.postMessage,iv)):Av.addEventListener&&Cv(Av.postMessage)&&!Av.importScripts&&tv&&"file:"!==tv.protocol&&!Pv(Jv)?(rv=Jv,Av.addEventListener("message",Qv,!1)):rv=qv in Mv("script")?function(e){Ov.appendChild(Mv("script")).onreadystatechange=function(){Ov.removeChild(this),Yv(e)}}:function(e){setTimeout(Wv(e),0)});var Zv,$v,ep,tp,rp,np,ip,op,ap={set:Vv,clear:Fv},sp=n,up=/ipad|iphone|ipod/i.test(se)&&void 0!==sp.Pebble,cp=/web0s(?!.*chrome)/i.test(se),dp=n,lp=Wt,hp=R.f,vp=ap.set,pp=Iv,fp=up,_p=cp,mp=ov,gp=dp.MutationObserver||dp.WebKitMutationObserver,yp=dp.document,Sp=dp.process,bp=dp.Promise,Ep=hp(dp,"queueMicrotask"),kp=Ep&&Ep.value;kp||(Zv=function(){var e,t;for(mp&&(e=Sp.domain)&&e.exit();$v;){t=$v.fn,$v=$v.next;try{t()}catch(ZH){throw $v?tp():ep=void 0,ZH}}ep=void 0,e&&e.enter()},pp||mp||_p||!gp||!yp?!fp&&bp&&bp.resolve?((ip=bp.resolve(void 0)).constructor=bp,op=lp(ip.then,ip),tp=function(){op(Zv)}):mp?tp=function(){Sp.nextTick(Zv)}:(vp=lp(vp,dp),tp=function(){vp(Zv)}):(rp=!0,np=yp.createTextNode(""),new gp(Zv).observe(np,{characterData:!0}),tp=function(){np.data=rp=!rp}));var Tp=kp||function(e){var t={fn:e,next:void 0};ep&&(ep.next=t),$v||($v=t,tp()),ep=t},Ip=n,Ap=function(e){try{return{error:!1,value:e()}}catch(ZH){return{error:!0,value:ZH}}},Rp=function(){this.head=null,this.tail=null};Rp.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 wp=Rp,Cp=n.Promise,xp="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Pp=!xp&&!ov&&"object"==typeof window&&"object"==typeof document,Op=n,Dp=Cp,Mp=A,Np=Xt,Lp=io,Up=lt,Vp=Pp,Fp=xp,Bp=pe,jp=Dp&&Dp.prototype,Gp=Up("species"),zp=!1,Hp=Mp(Op.PromiseRejectionEvent),Xp={CONSTRUCTOR:Np("Promise",(function(){var e=Lp(Dp),t=e!==String(Dp);if(!t&&66===Bp)return!0;if(!jp.catch||!jp.finally)return!0;if(!Bp||Bp<51||!/native code/.test(e)){var r=new Dp((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[Gp]=n,!(zp=r.then((function(){}))instanceof n))return!0}return!t&&(Vp||Fp)&&!Hp})),REJECTION_EVENT:Hp,SUBCLASSING:zp},Kp={},qp=Ce,Yp=TypeError,Wp=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw Yp("Bad Promise constructor");t=e,r=n})),this.resolve=qp(t),this.reject=qp(r)};Kp.f=function(e){return new Wp(e)};var Qp,Jp,Zp=Rr,$p=ov,ef=n,tf=P,rf=li,nf=Ni,of=dv,af=Ce,sf=A,uf=$,cf=vv,df=Ev,lf=ap.set,hf=Tp,vf=function(e,t){var r=Ip.console;r&&r.error&&(1==arguments.length?r.error(e):r.error(e,t))},pf=Ap,ff=wp,_f=Zi,mf=Cp,gf=Xp,yf=Kp,Sf="Promise",bf=gf.CONSTRUCTOR,Ef=gf.REJECTION_EVENT,kf=_f.getterFor(Sf),Tf=_f.set,If=mf&&mf.prototype,Af=mf,Rf=If,wf=ef.TypeError,Cf=ef.document,xf=ef.process,Pf=yf.f,Of=Pf,Df=!!(Cf&&Cf.createEvent&&ef.dispatchEvent),Mf="unhandledrejection",Nf=function(e){var t;return!(!uf(e)||!sf(t=e.then))&&t},Lf=function(e,t){var r,n,i,o=t.value,a=1==t.state,s=a?e.ok:e.fail,u=e.resolve,c=e.reject,d=e.domain;try{s?(a||(2===t.rejection&&jf(t),t.rejection=1),!0===s?r=o:(d&&d.enter(),r=s(o),d&&(d.exit(),i=!0)),r===e.promise?c(wf("Promise-chain cycle")):(n=Nf(r))?tf(n,r,u,c):u(r)):c(o)}catch(ZH){d&&!i&&d.exit(),c(ZH)}},Uf=function(e,t){e.notified||(e.notified=!0,hf((function(){for(var r,n=e.reactions;r=n.get();)Lf(r,e);e.notified=!1,t&&!e.rejection&&Ff(e)})))},Vf=function(e,t,r){var n,i;Df?((n=Cf.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),ef.dispatchEvent(n)):n={promise:t,reason:r},!Ef&&(i=ef["on"+e])?i(n):e===Mf&&vf("Unhandled promise rejection",r)},Ff=function(e){tf(lf,ef,(function(){var t,r=e.facade,n=e.value;if(Bf(e)&&(t=pf((function(){$p?xf.emit("unhandledRejection",n,r):Vf(Mf,r,n)})),e.rejection=$p||Bf(e)?2:1,t.error))throw t.value}))},Bf=function(e){return 1!==e.rejection&&!e.parent},jf=function(e){tf(lf,ef,(function(){var t=e.facade;$p?xf.emit("rejectionHandled",t):Vf("rejectionhandled",t,e.value)}))},Gf=function(e,t,r){return function(n){e(t,n,r)}},zf=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,Uf(e,!0))},Hf=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw wf("Promise can't be resolved itself");var n=Nf(t);n?hf((function(){var r={done:!1};try{tf(n,t,Gf(Hf,r,e),Gf(zf,r,e))}catch(ZH){zf(r,ZH,e)}})):(e.value=t,e.state=1,Uf(e,!1))}catch(ZH){zf({done:!1},ZH,e)}}};bf&&(Rf=(Af=function(e){cf(this,Rf),af(e),tf(Qp,this);var t=kf(this);try{e(Gf(Hf,t),Gf(zf,t))}catch(ZH){zf(t,ZH)}}).prototype,(Qp=function(e){Tf(this,{type:Sf,done:!1,notified:!1,parent:!1,reactions:new ff,rejection:!1,state:0,value:void 0})}).prototype=rf(Rf,"then",(function(e,t){var r=kf(this),n=Pf(df(this,Af));return r.parent=!0,n.ok=!sf(e)||e,n.fail=sf(t)&&t,n.domain=$p?xf.domain:void 0,0==r.state?r.reactions.add(n):hf((function(){Lf(n,r)})),n.promise})),Jp=function(){var e=new Qp,t=kf(e);this.promise=e,this.resolve=Gf(Hf,t),this.reject=Gf(zf,t)},yf.f=Pf=function(e){return e===Af||undefined===e?new Jp(e):Of(e)}),Zp({global:!0,constructor:!0,wrap:!0,forced:bf},{Promise:Af}),nf(Af,Sf,!1,!0),of(Sf);var Xf=lt("iterator"),Kf=!1;try{var qf=0,Yf={next:function(){return{done:!!qf++}},return:function(){Kf=!0}};Yf[Xf]=function(){return this},Array.from(Yf,(function(){throw 2}))}catch(ZH){}var Wf=function(e,t){if(!t&&!Kf)return!1;var r=!1;try{var n={};n[Xf]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(ZH){}return r},Qf=Cp,Jf=Xp.CONSTRUCTOR||!Wf((function(e){Qf.all(e).then(void 0,(function(){}))})),Zf=P,$f=Ce,e_=Kp,t_=Ap,r_=Dh;Rr({target:"Promise",stat:!0,forced:Jf},{all:function(e){var t=this,r=e_.f(t),n=r.resolve,i=r.reject,o=t_((function(){var r=$f(t.resolve),o=[],a=0,s=1;r_(e,(function(e){var u=a++,c=!1;s++,Zf(r,t,e).then((function(e){c||(c=!0,o[u]=e,--s||n(o))}),i)})),--s||n(o)}));return o.error&&i(o.value),r.promise}});var n_=Rr,i_=Xp.CONSTRUCTOR;Cp&&Cp.prototype,n_({target:"Promise",proto:!0,forced:i_,real:!0},{catch:function(e){return this.then(void 0,e)}});var o_=P,a_=Ce,s_=Kp,u_=Ap,c_=Dh;Rr({target:"Promise",stat:!0,forced:Jf},{race:function(e){var t=this,r=s_.f(t),n=r.reject,i=u_((function(){var i=a_(t.resolve);c_(e,(function(e){o_(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var d_=P,l_=Kp;Rr({target:"Promise",stat:!0,forced:Xp.CONSTRUCTOR},{reject:function(e){var t=l_.f(this);return d_(t.reject,void 0,e),t.promise}});var h_=tr,v_=$,p_=Kp,f_=function(e,t){if(h_(e),v_(t)&&t.constructor===e)return t;var r=p_.f(e);return(0,r.resolve)(t),r.promise},__=Rr,m_=Cp,g_=Xp.CONSTRUCTOR,y_=f_,S_=oe("Promise"),b_=!g_;__({target:"Promise",stat:!0,forced:true},{resolve:function(e){return y_(b_&&this===S_?m_:this,e)}});var E_=P,k_=Ce,T_=Kp,I_=Ap,A_=Dh;Rr({target:"Promise",stat:!0},{allSettled:function(e){var t=this,r=T_.f(t),n=r.resolve,i=r.reject,o=I_((function(){var r=k_(t.resolve),i=[],o=0,a=1;A_(e,(function(e){var s=o++,u=!1;a++,E_(r,t,e).then((function(e){u||(u=!0,i[s]={status:"fulfilled",value:e},--a||n(i))}),(function(e){u||(u=!0,i[s]={status:"rejected",reason:e},--a||n(i))}))})),--a||n(i)}));return o.error&&i(o.value),r.promise}});var R_=P,w_=Ce,C_=oe,x_=Kp,P_=Ap,O_=Dh,D_="No one promise resolved";Rr({target:"Promise",stat:!0},{any:function(e){var t=this,r=C_("AggregateError"),n=x_.f(t),i=n.resolve,o=n.reject,a=P_((function(){var n=w_(t.resolve),a=[],s=0,u=1,c=!1;O_(e,(function(e){var d=s++,l=!1;u++,R_(n,t,e).then((function(e){l||c||(c=!0,i(e))}),(function(e){l||c||(l=!0,a[d]=e,--u||o(new r(a,D_)))}))})),--u||o(new r(a,D_))}));return a.error&&o(a.value),n.promise}});var M_=Rr,N_=Cp,L_=i,U_=oe,V_=A,F_=Ev,B_=f_,j_=N_&&N_.prototype;M_({target:"Promise",proto:!0,real:!0,forced:!!N_&&L_((function(){j_.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=F_(this,U_("Promise")),r=V_(e);return this.then(r?function(r){return B_(t,e()).then((function(){return r}))}:e,r?function(r){return B_(t,e()).then((function(){throw r}))}:e)}});var G_=ee.Promise,z_=Kp,H_=Ap;Rr({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=z_.f(this),r=H_(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var X_=G_,K_=Rr,q_=eo,Y_=E([].reverse),W_=[1,2];K_({target:"Array",proto:!0,forced:String(W_)===String(W_.reverse())},{reverse:function(){return q_(this)&&(this.length=this.length),Y_(this)}});var Q_=Us("Array").reverse,J_=ae,Z_=Q_,$_=Array.prototype,em=function(e){var t=e.reverse;return e===$_||J_($_,e)&&t===$_.reverse?Z_:t},tm=Rr,rm=eo,nm=yo,im=$,om=Nr,am=Br,sm=Q,um=Jn,cm=lt,dm=rs,lm=Ms("slice"),hm=cm("species"),vm=Array,pm=Math.max;tm({target:"Array",proto:!0,forced:!lm},{slice:function(e,t){var r,n,i,o=sm(this),a=am(o),s=om(e,a),u=om(void 0===t?a:t,a);if(rm(o)&&(r=o.constructor,(nm(r)&&(r===vm||rm(r.prototype))||im(r)&&null===(r=r[hm]))&&(r=void 0),r===vm||void 0===r))return dm(o,s,u);for(n=new(void 0===r?vm:r)(pm(u-s,0)),i=0;s<u;s++,i++)s in o&&um(n,i,o[s]);return n.length=i,n}});var fm=Us("Array").slice,_m=ae,mm=fm,gm=Array.prototype,ym=function(e){var t=e.slice;return e===gm||_m(gm,e)&&t===gm.slice?mm:t};function Sm(){Sm=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=ad||function(e,t,r){e[t]=r.value},i="function"==typeof fl?fl:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return ad(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(R){u=function(e,t,r){return e[t]=r}}function c(e,t,r,i){var o=t&&t.prototype instanceof h?t:h,a=Ll(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(R){return{type:"throw",arg:R}}}e.wrap=c;var l={};function h(){}function v(){}function p(){}var f={};u(f,o,(function(){return this}));var _=Bl&&Bl(Bl(I([])));_&&_!==t&&r.call(_,o)&&(f=_);var m=p.prototype=h.prototype=Ll(f);function g(e){var t;Nc(t=["next","throw","return"]).call(t,(function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){function i(n,o,a,s){var u=d(e[n],e,o);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==Ml(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){c.value=e,a(c)}),(function(e){return i("throw",e,a,s)}))}s(u.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 u=d(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function b(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=d(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(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"}],Nc(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:A}}function A(){return{value:void 0,done:!0}}return v.prototype=p,n(m,"constructor",{value:p,configurable:!0}),n(p,"constructor",{value:v,configurable:!0}),v.displayName=u(p,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 jl?jl(e,p):(e.__proto__=p,u(e,s,"GeneratorFunction")),e.prototype=Ll(m),e},e.awrap=function(e){return{__await:e}},g(y.prototype),u(y.prototype,a,(function(){return this})),e.AsyncIterator=y,e.async=function(t,r,n,i,o){void 0===o&&(o=X_);var a=new y(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),u(m,s,"Generator"),u(m,o,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return em(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,Nc(t=this.tryEntries).call(t,k),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+ym(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"),u=r.call(o,"finallyLoc");if(s&&u){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(!u)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 bm(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(ZH){return void r(ZH)}s.done?t(u):X_.resolve(u).then(n,i)}function Em(e){return function(){var t=this,r=arguments;return new X_((function(n,i){var o=e.apply(t,r);function a(e){bm(o,n,i,a,s,"next",e)}function s(e){bm(o,n,i,a,s,"throw",e)}a(void 0)}))}}var km=Us("Array").concat,Tm=ae,Im=km,Am=Array.prototype,Rm=function(e){var t=e.concat;return e===Am||Tm(Am,e)&&t===Am.concat?Im:t},wm="\t\n\v\f\r                 \u2028\u2029\ufeff",Cm=q,xm=gn,Pm=E("".replace),Om="[\t\n\v\f\r                 \u2028\u2029\ufeff]",Dm=RegExp("^"+Om+Om+"*"),Mm=RegExp(Om+Om+"*$"),Nm=function(e){return function(t){var r=xm(Cm(t));return 1&e&&(r=Pm(r,Dm,"")),2&e&&(r=Pm(r,Mm,"")),r}},Lm={start:Nm(1),end:Nm(2),trim:Nm(3)},Um=n,Vm=i,Fm=E,Bm=gn,jm=Lm.trim,Gm=wm,zm=Um.parseInt,Hm=Um.Symbol,Xm=Hm&&Hm.iterator,Km=/^[+-]?0x/i,qm=Fm(Km.exec),Ym=8!==zm(Gm+"08")||22!==zm(Gm+"0x16")||Xm&&!Vm((function(){zm(Object(Xm))}))?function(e,t){var r=jm(Bm(e));return zm(r,t>>>0||(qm(Km,r)?16:10))}:zm;Rr({global:!0,forced:parseInt!=Ym},{parseInt:Ym});var Wm=ee.parseInt,Qm={exports:{}},Jm=i((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),Zm=i,$m=$,eg=y,tg=Jm,rg=Object.isExtensible,ng=Zm((function(){rg(1)}))||tg?function(e){return!!$m(e)&&((!tg||"ArrayBuffer"!=eg(e))&&(!rg||rg(e)))}:rg,ig=!i((function(){return Object.isExtensible(Object.preventExtensions({}))})),og=Rr,ag=E,sg=Kr,ug=$,cg=We,dg=Qt.f,lg=Hn,hg=qn,vg=ng,pg=ig,fg=!1,_g=et("meta"),mg=0,gg=function(e){dg(e,_g,{value:{objectID:"O"+mg++,weakData:{}}})},yg=Qm.exports={enable:function(){yg.enable=function(){},fg=!0;var e=lg.f,t=ag([].splice),r={};r[_g]=1,e(r).length&&(lg.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===_g){t(n,i,1);break}return n},og({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:hg.f}))},fastKey:function(e,t){if(!ug(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!cg(e,_g)){if(!vg(e))return"F";if(!t)return"E";gg(e)}return e[_g].objectID},getWeakData:function(e,t){if(!cg(e,_g)){if(!vg(e))return!0;if(!t)return!1;gg(e)}return e[_g].weakData},onFreeze:function(e){return pg&&fg&&vg(e)&&!cg(e,_g)&&gg(e),e}};sg[_g]=!0;var Sg=Rr,bg=n,Eg=Qm.exports,kg=i,Tg=fr,Ig=Dh,Ag=vv,Rg=A,wg=$,Cg=Ni,xg=Qt.f,Pg=Mo.forEach,Og=w,Dg=Zi.set,Mg=Zi.getterFor,Ng=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=bg[e],u=s&&s.prototype,c={};if(Og&&Rg(s)&&(o||u.forEach&&!kg((function(){(new s).entries().next()})))){var d=(n=t((function(t,r){Dg(Ag(t,d),{type:e,collection:new s}),null!=r&&Ig(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,l=Mg(e);Pg(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in u)||o&&"clear"==e||Tg(d,e,(function(r,n){var i=l(this).collection;if(!t&&o&&!wg(r))return"get"==e&&void 0;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||xg(d,"size",{configurable:!0,get:function(){return l(this).collection.size}})}else n=r.getConstructor(t,e,i,a),Eg.enable();return Cg(n,e,!1,!0),c[e]=n,Sg({global:!0,forced:!0},c),o||r.setStrong(n,e,i),n},Lg=li,Ug=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:Lg(e,n,t[n],r);return e},Vg=Qt.f,Fg=zn,Bg=Ug,jg=Wt,Gg=vv,zg=H,Hg=Dh,Xg=ic,Kg=oc,qg=dv,Yg=w,Wg=Qm.exports.fastKey,Qg=Zi.set,Jg=Zi.getterFor,Zg={getConstructor:function(e,t,r,n){var i=e((function(e,i){Gg(e,o),Qg(e,{type:t,index:Fg(null),first:void 0,last:void 0,size:0}),Yg||(e.size=0),zg(i)||Hg(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=Jg(t),s=function(e,t,r){var n,i,o=a(e),s=u(e,t);return s?s.value=r:(o.last=s={index:i=Wg(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),Yg?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},u=function(e,t){var r,n=a(e),i=Wg(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key==t)return r};return Bg(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,Yg?e.size=0:this.size=0},delete:function(e){var t=this,r=a(t),n=u(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),Yg?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=jg(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!!u(this,e)}}),Bg(o,r?{get:function(e){var t=u(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)}}),Yg&&Vg(o,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=Jg(t),o=Jg(n);Xg(e,t,(function(e,t){Qg(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)?Kg("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,Kg(void 0,!0))}),r?"entries":"values",!r,!0),qg(t)}};Ng("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Zg);var $g=ee.Map,ey=Wt,ty=P,ry=Ce,ny=mv,iy=H,oy=Dh,ay=[].push,sy=function(e){var t,r,n,i,o=arguments.length,a=o>1?arguments[1]:void 0;return ny(this),(t=void 0!==a)&&ry(a),iy(e)?new this:(r=[],t?(n=0,i=ey(a,o>2?arguments[2]:void 0),oy(e,(function(e){ty(ay,r,i(e,n++))}))):oy(e,ay,{that:r}),new this(r))};Rr({target:"Map",stat:!0,forced:!0},{from:sy});var uy=rs,cy=function(){return new this(uy(arguments))};Rr({target:"Map",stat:!0,forced:!0},{of:cy});var dy=P,ly=Ce,hy=tr,vy=function(){for(var e,t=hy(this),r=ly(t.delete),n=!0,i=0,o=arguments.length;i<o;i++)e=dy(r,t,arguments[i]),n=n&&e;return!!n};Rr({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:vy});var py=P,fy=Ce,_y=tr,my=function(e,t){var r,n,i=_y(this),o=fy(i.get),a=fy(i.has),s=fy(i.set);return py(a,i,e)?(r=py(o,i,e),"update"in t&&(r=t.update(r,e,i),py(s,i,e,r)),r):(n=t.insert(e,i),py(s,i,e,n),n)};Rr({target:"Map",proto:!0,real:!0,forced:!0},{emplace:my});var gy=fh,yy=tr,Sy=Wt,by=gy,Ey=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=yy(this),r=by(t),n=Sy(e,arguments.length>1?arguments[1]:void 0);return!Ey(r,(function(e,r,i){if(!n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var ky=oe,Ty=Wt,Iy=P,Ay=Ce,Ry=tr,wy=Ev,Cy=gy,xy=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=Ry(this),r=Cy(t),n=Ty(e,arguments.length>1?arguments[1]:void 0),i=new(wy(t,ky("Map"))),o=Ay(i.set);return xy(r,(function(e,r){n(r,e,t)&&Iy(o,i,e,r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var Py=tr,Oy=Wt,Dy=gy,My=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=Py(this),r=Dy(t),n=Oy(e,arguments.length>1?arguments[1]:void 0);return My(r,(function(e,r,i){if(n(r,e,t))return i(r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var Ny=tr,Ly=Wt,Uy=gy,Vy=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=Ny(this),r=Uy(t),n=Ly(e,arguments.length>1?arguments[1]:void 0);return Vy(r,(function(e,r,i){if(n(r,e,t))return i(e)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var Fy=Rr,By=P,jy=Ce,Gy=fh,zy=Dh,Hy=E([].push);Fy({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){jy(t);var r=Gy(e),n=new this,i=jy(n.has),o=jy(n.get),a=jy(n.set);return zy(r,(function(e){var r=t(e);By(i,n,r)?Hy(By(o,n,r),e):By(a,n,r,[e])}),{IS_ITERATOR:!0}),n}});var Xy=tr,Ky=gy,qy=function(e,t){return e===t||e!=e&&t!=t},Yy=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return Yy(Ky(Xy(this)),(function(t,r,n){if(qy(r,e))return n()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var Wy=P,Qy=Dh,Jy=Ce;Rr({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new this;Jy(t);var n=Jy(r.set);return Qy(e,(function(e){Wy(n,r,t(e),e)})),r}});var Zy=tr,$y=gy,eS=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){return eS($y(Zy(this)),(function(t,r,n){if(r===e)return n(t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var tS=oe,rS=Wt,nS=P,iS=Ce,oS=tr,aS=Ev,sS=gy,uS=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=oS(this),r=sS(t),n=rS(e,arguments.length>1?arguments[1]:void 0),i=new(aS(t,tS("Map"))),o=iS(i.set);return uS(r,(function(e,r){nS(o,i,n(r,e,t),r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var cS=oe,dS=Wt,lS=P,hS=Ce,vS=tr,pS=Ev,fS=gy,_S=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=vS(this),r=fS(t),n=dS(e,arguments.length>1?arguments[1]:void 0),i=new(pS(t,cS("Map"))),o=hS(i.set);return _S(r,(function(e,r){lS(o,i,e,n(r,e,t))}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var mS=Ce,gS=tr,yS=Dh;Rr({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=gS(this),r=mS(t.set),n=arguments.length,i=0;i<n;)yS(arguments[i++],r,{that:t,AS_ENTRIES:!0});return t}});var SS=tr,bS=Ce,ES=gy,kS=Dh,TS=TypeError;Rr({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=SS(this),r=ES(t),n=arguments.length<2,i=n?void 0:arguments[1];if(bS(e),kS(r,(function(r,o){n?(n=!1,i=o):i=e(i,o,r,t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),n)throw TS("Reduce of empty map with no initial value");return i}});var IS=tr,AS=Wt,RS=gy,wS=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=IS(this),r=RS(t),n=AS(e,arguments.length>1?arguments[1]:void 0);return wS(r,(function(e,r,i){if(n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var CS=P,xS=tr,PS=Ce,OS=TypeError;Rr({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=xS(this),n=PS(r.get),i=PS(r.has),o=PS(r.set),a=arguments.length;PS(t);var s=CS(i,r,e);if(!s&&a<3)throw OS("Updating absent value");var u=s?CS(n,r,e):PS(a>2?arguments[2]:void 0)(e,r);return CS(o,r,e,t(u,e,r)),r}});var DS=P,MS=Ce,NS=A,LS=tr,US=TypeError,VS=function(e,t){var r,n=LS(this),i=MS(n.get),o=MS(n.has),a=MS(n.set),s=arguments.length>2?arguments[2]:void 0;if(!NS(t)&&!NS(s))throw US("At least one callback required");return DS(o,n,e)?(r=DS(i,n,e),NS(t)&&(r=t(r),DS(a,n,e,r))):NS(s)&&(r=s(),DS(a,n,e,r)),r};Rr({target:"Map",proto:!0,real:!0,forced:!0},{upsert:VS}),Rr({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:VS});var FS=$g,BS=Ce,jS=Ke,GS=z,zS=Br,HS=TypeError,XS=function(e){return function(t,r,n,i){BS(r);var o=jS(t),a=GS(o),s=zS(o),u=e?s-1:0,c=e?-1:1;if(n<2)for(;;){if(u in a){i=a[u],u+=c;break}if(u+=c,e?u<0:s<=u)throw HS("Reduce of empty array with no initial value")}for(;e?u>=0:s>u;u+=c)u in a&&(i=r(i,a[u],u,o));return i}},KS={left:XS(!1),right:XS(!0)}.left,qS=pe,YS=ov;Rr({target:"Array",proto:!0,forced:!Ic("reduce")||!YS&&qS>79&&qS<83},{reduce:function(e){var t=arguments.length;return KS(this,e,t,t>1?arguments[1]:void 0)}});var WS=Us("Array").reduce,QS=ae,JS=WS,ZS=Array.prototype,$S=function(e){var t=e.reduce;return e===ZS||QS(ZS,e)&&t===ZS.reduce?JS:t},eb=w,tb=E,rb=P,nb=i,ib=rn,ob=ci,ab=O,sb=Ke,ub=z,cb=Object.assign,db=Object.defineProperty,lb=tb([].concat),hb=!cb||nb((function(){if(eb&&1!==cb({b:1},cb(db({},"a",{enumerable:!0,get:function(){db(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!=cb({},e)[r]||ib(cb({},t)).join("")!=n}))?function(e,t){for(var r=sb(e),n=arguments.length,i=1,o=ob.f,a=ab.f;n>i;)for(var s,u=ub(arguments[i++]),c=o?lb(ib(u),o(u)):ib(u),d=c.length,l=0;d>l;)s=c[l++],eb&&!rb(a,u,s)||(r[s]=u[s]);return r}:cb,vb=hb;Rr({target:"Object",stat:!0,arity:2,forced:Object.assign!==vb},{assign:vb});var pb=ee.Object.assign,fb=$,_b=y,mb=lt("match"),gb=function(e){var t;return fb(e)&&(void 0!==(t=e[mb])?!!t:"RegExp"==_b(e))},yb=TypeError,Sb=function(e){if(gb(e))throw yb("The method doesn't accept regular expressions");return e},bb=lt("match"),Eb=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[bb]=!1,"/./"[e](t)}catch(n){}}return!1},kb=Rr,Tb=E;R.f;var Ib=Vr,Ab=gn,Rb=Sb,wb=q,Cb=Eb,xb=Tb("".endsWith),Pb=Tb("".slice),Ob=Math.min;kb({target:"String",proto:!0,forced:!Cb("endsWith")},{endsWith:function(e){var t=Ab(wb(this));Rb(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:Ob(Ib(r),n),o=Ab(e);return xb?xb(t,o,i):Pb(t,i-o.length,i)===o}});var Db=Us("String").endsWith,Mb=ae,Nb=Db,Lb=String.prototype,Ub=function(e){var t=e.endsWith;return"string"==typeof e||e===Lb||Mb(Lb,e)&&t===Lb.endsWith?Nb:t},Vb=!0,Fb=!0;function Bb(e,t,r){var n=e.match(t);return n&&n.length>=r&&Wm(n[r],10)}function jb(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 FS),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 Gb(e){return"boolean"!=typeof e?new Error("Argument type: "+Ml(e)+". Please use a boolean."):(Vb=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function zb(e){return"boolean"!=typeof e?new Error("Argument type: "+Ml(e)+". Please use a boolean."):(Fb=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function Hb(){if("object"===("undefined"==typeof window?"undefined":Ml(window))){if(Vb)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function Xb(e,t){Fb&&console.warn(e+" is deprecated, please use "+t+" instead.")}function Kb(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=Bb(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=Bb(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=Bb(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}function qb(e){return"[object Object]"===Object.prototype.toString.call(e)}function Yb(e){var t;return qb(e)?$S(t=an(e)).call(t,(function(t,r){var n=qb(e[r]),i=n?Yb(e[r]):e[r],o=n&&!an(i).length;return void 0===i||o?t:pb(t,sd({},r,i))}),{}):e}function Wb(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),an(t).forEach((function(n){Ub(n).call(n,"Id")?Wb(e,e.get(t[n]),r):Ub(n).call(n,"Ids")&&t[n].forEach((function(t){Wb(e,e.get(t),r)}))})))}function Qb(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new FS;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&&Wb(e,r,i)}))})),i}var Jb=Rr,Zb=Mo.find,$b="find",eE=!0;$b in[]&&Array(1).find((function(){eE=!1})),Jb({target:"Array",proto:!0,forced:eE},{find:function(e){return Zb(this,e,arguments.length>1?arguments[1]:void 0)}});var tE=Us("Array").find,rE=ae,nE=tE,iE=Array.prototype,oE=function(e){var t=e.find;return e===iE||rE(iE,e)&&t===iE.find?nE:t},aE=Rr,sE=Xr.indexOf,uE=Ic,cE=E([].indexOf),dE=!!cE&&1/cE([1],1,-0)<0,lE=uE("indexOf");aE({target:"Array",proto:!0,forced:dE||!lE},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return dE?cE(this,e,t)||0:sE(this,e,t)}});var hE=Us("Array").indexOf,vE=ae,pE=hE,fE=Array.prototype,_E=function(e){var t=e.indexOf;return e===fE||vE(fE,e)&&t===fE.indexOf?pE:t},mE=w,gE=eo,yE=TypeError,SE=Object.getOwnPropertyDescriptor,bE=mE&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(ZH){return ZH instanceof TypeError}}(),EE=Ie,kE=TypeError,TE=function(e,t){if(!delete e[t])throw kE("Cannot delete property "+EE(t)+" of "+EE(e))},IE=Rr,AE=Ke,RE=Nr,wE=Pr,CE=Br,xE=bE?function(e,t){if(gE(e)&&!SE(e,"length").writable)throw yE("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},PE=Wd,OE=Ao,DE=Jn,ME=TE,NE=Ms("splice"),LE=Math.max,UE=Math.min;IE({target:"Array",proto:!0,forced:!NE},{splice:function(e,t){var r,n,i,o,a,s,u=AE(this),c=CE(u),d=RE(e,c),l=arguments.length;for(0===l?r=n=0:1===l?(r=0,n=c-d):(r=l-2,n=UE(LE(wE(t),0),c-d)),PE(c+r-n),i=OE(u,n),o=0;o<n;o++)(a=d+o)in u&&DE(i,o,u[a]);if(i.length=n,r<n){for(o=d;o<c-n;o++)s=o+r,(a=o+n)in u?u[s]=u[a]:ME(u,s);for(o=c;o>c-n+r;o--)ME(u,o-1)}else if(r>n)for(o=c-n;o>d;o--)s=o+r-1,(a=o+n-1)in u?u[s]=u[a]:ME(u,s);for(o=0;o<r;o++)u[o+d]=arguments[o+2];return xE(u,c-n+r),i}});var VE=Us("Array").splice,FE=ae,BE=VE,jE=Array.prototype,GE=function(e){var t=e.splice;return e===jE||FE(jE,e)&&t===jE.splice?BE:t},zE=Mo.map;Rr({target:"Array",proto:!0,forced:!Ms("map")},{map:function(e){return zE(this,e,arguments.length>1?arguments[1]:void 0)}});var HE=Us("Array").map,XE=ae,KE=HE,qE=Array.prototype,YE=function(e){var t=e.map;return e===qE||XE(qE,e)&&t===qE.map?KE:t},WE=ee,QE=d;WE.JSON||(WE.JSON={stringify:JSON.stringify});var JE=function(e,t,r){return QE(WE.JSON.stringify,null,arguments)},ZE=JE,$E=Xr.includes;Rr({target:"Array",proto:!0,forced:i((function(){return!Array(1).includes()}))},{includes:function(e){return $E(this,e,arguments.length>1?arguments[1]:void 0)}});var ek=Us("Array").includes,tk=Rr,rk=Sb,nk=q,ik=gn,ok=Eb,ak=E("".indexOf);tk({target:"String",proto:!0,forced:!ok("includes")},{includes:function(e){return!!~ak(ik(nk(this)),ik(rk(e)),arguments.length>1?arguments[1]:void 0)}});var sk=Us("String").includes,uk=ae,ck=ek,dk=sk,lk=Array.prototype,hk=String.prototype,vk=function(e){var t=e.includes;return e===lk||uk(lk,e)&&t===lk.includes?ck:"string"==typeof e||e===hk||uk(hk,e)&&t===hk.includes?dk:t},pk=Hb;function fk(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==Ml(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"===Ml(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()+ym(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=Rm(t=r.optional||[]).call(t,e.advanced));return r},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(ZE(e)))&&"object"===Ml(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(ZE(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===Ml(e.video)){var a=e.video.facingMode;a=a&&("object"===Ml(a)?a:{ideal:a});var s,u=t.version<66;if(a&&("user"===a.exact||"environment"===a.exact||"user"===a.ideal||"environment"===a.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||u))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=oE(t).call(t,(function(e){return s.some((function(t){var r;return vk(r=e.label.toLowerCase()).call(r,t)}))}));return!r&&t.length&&vk(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),pk("chrome: "+ZE(e)),i(e)}));e.video=n(e.video)}return pk("chrome: "+ZE(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 X_.reject(o(e))}))}))}}}}function _k(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function mk(e){if("object"===Ml(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=oE(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=oE(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 jb(e,"track",(function(e){return e.transceiver||ad(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function gk(e){if("object"===Ml(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||[],ym(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=_E(t=this._senders).call(t,e);-1!==i&&GE(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=oE(r=t._senders).call(r,(function(t){return t.track===e}));o&&GE(n=t._senders).call(n,_E(i=t._senders).call(i,o),1)}))}}else if("object"===Ml(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 yk(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=ym(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 FS(YE(t=an(e)).call(t,(function(t){return[t,e[t]]})))};if(arguments.length>=2){var u=function(e){i(s(a(e)))};return t.apply(this,[u,n])}return new X_((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function Sk(e){if("object"===Ml(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 Qb(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}),jb(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 Qb(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?X_.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():X_.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function bk(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e,t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},YE(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===_E(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(oE(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===_E(o).call(o,e)}));this._shimmedLocalStreams[e.id]=Rm(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=_E(n=t._shimmedLocalStreams[r]).call(n,e);-1!==o&&GE(i=t._shimmedLocalStreams[r]).call(i,o,1);1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function Ek(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return bk(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},YE(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(oE(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=ym([]).call(arguments,1);if(1!==s.length||!oE(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 u=oE(i=this.getSenders()).call(i,(function(e){return e.track===t}));if(u)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var c=this._streams[r.id];if(c)c.addTrack(t),X_.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 oE(o=this.getSenders()).call(o,(function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=sd({},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]=u(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};var a=tu(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;oE(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 u(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 kk(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=sd({},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 Tk(e,t){jb(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 Ik=Object.freeze(Object.defineProperty({__proto__:null,shimMediaStream:_k,shimOnTrack:mk,shimGetSendersWithDtmf:gk,shimGetStats:yk,shimSenderReceiverGetStats:Sk,shimAddTrackRemoveTrackWithNative:bk,shimAddTrackRemoveTrack:Ek,shimPeerConnection:kk,fixNegotiationNeeded:Tk,shimGetUserMedia:fk,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"}));Rr({target:"Array",stat:!0},{isArray:eo});var Ak=ee.Array.isArray;function Rk(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 wk=uh,Ck=tr,xk=yh,Pk=Wt,Ok=P,Dk=Ke,Mk=function(e,t,r,n){try{return n?t(Ck(r)[0],r[1]):t(r)}catch(ZH){xk(e,"throw",ZH)}},Nk=rh,Lk=yo,Uk=Br,Vk=Jn,Fk=fh,Bk=uh,jk=Array,Gk=function(e){var t=Dk(e),r=Lk(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,u,c,d,l,h=Bk(t),v=0;if(!h||this===jk&&Nk(h))for(a=Uk(t),s=r?new this(a):jk(a);a>v;v++)l=o?i(t[v],v):t[v],Vk(s,v,l);else for(d=(c=Fk(t,h)).next,s=r?new this:[];!(u=Ok(d,c)).done;v++)l=o?Mk(c,i,[u.value,v],!0):u.value,Vk(s,v,l);return s.length=v,s},zk=Gk;Rr({target:"Array",stat:!0,forced:!Wf((function(e){Array.from(e)}))},{from:zk});var Hk=ee.Array.from;function Xk(e,t){var r;if(e){if("string"==typeof e)return Rk(e,t);var n=ym(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Hk(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Rk(e,t):void 0}}function Kk(e){return function(e){if(Ak(e))return Rk(e)}(e)||function(e){if(void 0!==fl&&null!=wk(e)||null!=e["@@iterator"])return Hk(e)}(e)||Xk(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,Yk=i,Wk=gn,Qk=Lm.trim,Jk=E("".charAt),Zk=qk.parseFloat,$k=qk.Symbol,eT=$k&&$k.iterator,tT=1/Zk("\t\n\v\f\r                 \u2028\u2029\ufeff-0")!=-1/0||eT&&!Yk((function(){Zk(Object(eT))}))?function(e){var t=Qk(Wk(e)),r=Zk(t);return 0===r&&"-"==Jk(t,0)?-0:r}:Zk;Rr({global:!0,forced:parseFloat!=tT},{parseFloat:tT});var rT=ee.parseFloat;function nT(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){Xb("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"===Ml(e)&&"object"===Ml(e.audio)&&(e=JSON.parse(ZE(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"===Ml(e)&&(e=JSON.parse(ZE(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function iT(e){"object"===Ml(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 oT(e,t){if("object"===Ml(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=sd({},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=ym(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,pb({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function aT(e){if("object"===Ml(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):X_.resolve(new FS)}}}function sT(e){if("object"===Ml(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}),jb(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function uT(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;Xb("removeStream","removeTrack"),this.getSenders().forEach((function(r){var n;r.track&&vk(n=e.getTracks()).call(n,r.track)&&t.removeTrack(r)}))})}function cT(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function dT(e){if("object"===Ml(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=Kk(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&&!(rT(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(rT(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 lT(e){if("object"===Ml(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=Rm(e=[]).call(e,this.sendEncodings||[{}]));return r})}}function hT(e){if("object"===Ml(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?X_.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function vT(e){if("object"===Ml(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?X_.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var pT=Object.freeze(Object.defineProperty({__proto__:null,shimOnTrack:iT,shimPeerConnection:oT,shimSenderGetStats:aT,shimReceiverGetStats:sT,shimRemoveStream:uT,shimRTCDataChannel:cT,shimAddTransceiver:dT,shimGetParameters:lT,shimCreateOffer:hT,shimCreateAnswer:vT,shimGetUserMedia:nT,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,X_.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}},Symbol.toStringTag,{value:"Module"}));function fT(e){if("object"===Ml(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=[]),vk(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?vk(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=_E(t=this._localStreams).call(t,e);if(-1!==i){GE(r=this._localStreams).call(r,i,1);var o=e.getTracks();this.getSenders().forEach((function(e){vk(o).call(o,e.track)&&n.removeTrack(e)}))}})}}function _T(e){if("object"===Ml(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=[]),!vk(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=[]),!(_E(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 mT(e){if("object"===Ml(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),X_.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),X_.resolve()):i};var s=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),X_.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),X_.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),X_.resolve()):n},t.addIceCandidate=s}}function gT(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(yT(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function yT(e){return e&&void 0!==e.video?pb({},e,{video:Yb(e.video)}):e}function ST(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")?(Xb("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(ZE(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 bT(e){"object"===Ml(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 ET(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=oE(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=oE(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 kT(e){"object"!==Ml(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var TT=Object.freeze(Object.defineProperty({__proto__:null,shimLocalStreamsAPI:fT,shimRemoteStreamsAPI:_T,shimCallbacksAPI:mT,shimGetUserMedia:gT,shimConstraints:yT,shimRTCIceServerUrls:ST,shimTrackEventTransceiver:bT,shimCreateOfferLegacy:ET,shimAudioContext:kT},Symbol.toStringTag,{value:"Module"})),IT=uu.PROPER,AT=i,RT=wm,wT=Lm.trim;Rr({target:"String",proto:!0,forced:function(e){return AT((function(){return!!RT[e]()||"​…᠎"!=="​…᠎"[e]()||IT&&RT[e].name!==e}))}("trim")},{trim:function(){return wT(this)}});var CT,xT,PT=Us("String").trim,OT=ae,DT=PT,MT=String.prototype,NT=function(e){var t=e.trim;return"string"==typeof e||e===MT||OT(MT,e)&&t===MT.trim?DT:t},LT={exports:{}};CT=LT,(xT={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}}).localCName=xT.generateIdentifier(),xT.splitLines=function(e){var t;return YE(t=NT(e).call(e).split("\n")).call(t,(function(e){return NT(e).call(e)}))},xT.splitSections=function(e){var t=e.split("\nm=");return YE(t).call(t,(function(e,t){var r;return NT(r=t>0?"m="+e:e).call(r)+"\r\n"}))},xT.getDescription=function(e){var t=xT.splitSections(e);return t&&t[0]},xT.getMediaSections=function(e){var t=xT.splitSections(e);return t.shift(),t},xT.matchPrefix=function(e,t){var r;return Gs(r=xT.splitLines(e)).call(r,(function(e){return 0===_E(e).call(e,t)}))},xT.parseCandidate=function(e){for(var t,r={foundation:(t=0===_E(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:Wm(t[3],10),ip:t[4],address:t[4],port:Wm(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=Wm(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},xT.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(" ")},xT.parseIceOptions=function(e){return e.substr(14).split(" ")},xT.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:Wm(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=Wm(t[1],10),r.channels=3===t.length?Wm(t[2],10):1,r.numChannels=r.channels,r},xT.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"},xT.parseExtmap=function(e){var t,r=e.substr(9).split(" ");return{id:Wm(r[0],10),direction:_E(t=r[0]).call(t,"/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},xT.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},xT.parseFmtp=function(e){for(var t,r={},n=e.substr(_E(e).call(e," ")+1).split(";"),i=0;i<n.length;i++){var o,a;t=NT(o=n[i]).call(o).split("="),r[NT(a=t[0]).call(a)]=t[1]}return r},xT.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},xT.parseRtcpFb=function(e){var t=e.substr(_E(e).call(e," ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},xT.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},xT.parseSsrcMedia=function(e){var t=_E(e).call(e," "),r={ssrc:Wm(e.substr(7,t-7),10)},n=_E(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},xT.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:YE(t).call(t,(function(e){return Wm(e,10)}))}},xT.getMid=function(e){var t=xT.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},xT.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},xT.getDtlsParameters=function(e,t){var r=xT.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:YE(r).call(r,xT.parseFingerprint)}},xT.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},xT.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:Wm(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:ym(t).call(t,3)}},xT.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===Ml(e.keyParams)?xT.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},xT.parseCryptoKeyParams=function(e){if(0!==_E(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}},xT.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},xT.getCryptoParameters=function(e,t){var r=xT.matchPrefix(e+t,"a=crypto:");return YE(r).call(r,xT.parseCryptoLine)},xT.getIceParameters=function(e,t){var r=xT.matchPrefix(e+t,"a=ice-ufrag:")[0],n=xT.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},xT.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},xT.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=xT.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],o=xT.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(o){var a,s=xT.parseRtpMap(o),u=xT.matchPrefix(e,"a=fmtp:"+i+" ");switch(s.parameters=u.length?xT.parseFmtp(u[0]):{},s.rtcpFeedback=YE(a=xT.matchPrefix(e,"a=rtcp-fb:"+i+" ")).call(a,xT.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return xT.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(xT.parseExtmap(e))})),t},xT.writeRtpDescription=function(e,t){var r,n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=YE(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+=xT.writeRtpMap(e),n+=xT.writeFmtp(e),n+=xT.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+=xT.writeExtmap(e)})),n},xT.parseRtpEncodingParameters=function(e){var t,r,n,i,o,a,s=[],u=xT.parseRtpParameters(e),c=-1!==_E(t=u.fecMechanisms).call(t,"RED"),d=-1!==_E(r=u.fecMechanisms).call(r,"ULPFEC"),l=Gs(n=YE(i=xT.matchPrefix(e,"a=ssrc:")).call(i,(function(e){return xT.parseSsrcMedia(e)}))).call(n,(function(e){return"cname"===e.attribute})),h=l.length>0&&l[0].ssrc,v=YE(o=xT.matchPrefix(e,"a=ssrc-group:FID")).call(o,(function(e){var t=e.substr(17).split(" ");return YE(t).call(t,(function(e){return Wm(e,10)}))}));v.length>0&&v[0].length>1&&v[0][0]===h&&(a=v[0][1]),u.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:h,codecPayloadType:Wm(e.parameters.apt,10)};h&&a&&(t.rtx={ssrc:a}),s.push(t),c&&((t=JSON.parse(ZE(t))).fec={ssrc:h,mechanism:d?"red+ulpfec":"red"},s.push(t))}})),0===s.length&&h&&s.push({ssrc:h});var p,f,_=xT.matchPrefix(e,"b=");return _.length&&(_=0===_E(p=_[0]).call(p,"b=TIAS:")?Wm(_[0].substr(7),10):0===_E(f=_[0]).call(f,"b=AS:")?1e3*Wm(_[0].substr(5),10)*.95-16e3:void 0,s.forEach((function(e){e.maxBitrate=_}))),s},xT.parseRtcpParameters=function(e){var t,r,n={},i=Gs(t=YE(r=xT.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return xT.parseSsrcMedia(e)}))).call(t,(function(e){return"cname"===e.attribute}))[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);var o=xT.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=o.length>0,n.compound=0===o.length;var a=xT.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},xT.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},xT.parseMsid=function(e){var t,r,n,i=xT.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(n=i[0].substr(7).split(" "))[0],track:n[1]};var o=Gs(t=YE(r=xT.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return xT.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},xT.parseSctpDescription=function(e){var t,r=xT.parseMLine(e),n=xT.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=Wm(n[0].substr(19),10)),isNaN(t)&&(t=65536);var i=xT.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:Wm(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};var o=xT.matchPrefix(e,"a=sctpmap:");if(o.length>0){var a=o[0].substr(10).split(" ");return{port:Wm(a[0],10),protocol:a[1],maxMessageSize:t}}},xT.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("")},xT.generateSessionId=function(){return Math.random().toString().substr(2,21)},xT.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||xT.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},xT.getDirection=function(e,t){for(var r=xT.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?xT.getDirection(t):"sendrecv"},xT.getKind=function(e){return xT.splitLines(e)[0].split(" ")[0].substr(2)},xT.isRejected=function(e){return"0"===e.split(" ",2)[1]},xT.parseMLine=function(e){var t=xT.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:Wm(t[1],10),protocol:t[2],fmt:ym(t).call(t,3).join(" ")}},xT.parseOLine=function(e){var t=xT.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:Wm(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},xT.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=xT.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},CT.exports=xT;var UT=LT.exports,VT=e({__proto__:null,default:UT},[LT.exports]);function FT(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){var r;if("object"===Ml(e)&&e.candidate&&0===_E(r=e.candidate).call(r,"a=")&&((e=JSON.parse(ZE(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=UT.parseCandidate(e.candidate),o=pb(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,jb(e,"icecandidate",(function(t){return t.candidate&&ad(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function BT(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||jb(e,"icecandidate",(function(e){if(e.candidate){var t=UT.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function jT(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=UT.splitSections(e.sdp);return t.shift(),t.some((function(e){var t,r=UT.parseMLine(e);return r&&"application"===r.kind&&-1!==_E(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=Wm(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=UT.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=Wm(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 u,c=n(arguments[0]),d=i(c),l=o(arguments[0],c);u=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 u}}),this._sctp=h}return a.apply(this,arguments)}}}function GT(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,this),e},jb(e,"datachannel",(function(e){return r(e.channel,e.target),e}))}function r(e,t){var r=e.send;e.send=function(){var n=arguments[0],i=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}}function zT(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 HT(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!==_E(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"!==NT(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 XT(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?X_.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),X_.resolve())})}}function KT(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"!==Ml(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:FT,shimRTCIceCandidateRelayProtocol:BT,shimMaxMessageSize:jT,shimSendThrowTypeError:GT,shimConnectionState:zT,removeExtmapAllowMixed:HT,shimAddIceCandidateNullOrEmpty:XT,shimParameterlessSetLocalDescription:KT},Symbol.toStringTag,{value:"Module"}));function YT(e,t){var r=void 0!==fl&&wk(e)||e["@@iterator"];if(!r){if(Ak(e)||(r=Xk(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 WT(e,t){return function(e){if(Ak(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==fl&&wk(e)||e["@@iterator"];if(null!=r){var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(u){s=!0,i=u}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}}(e,t)||Xk(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 QT(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}!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=Hb,i=Kb(t),o={browserDetails:i,commonShim:qT,extractVersion:Bb,disableLog:Gb,disableWarnings:zb,sdp:VT};switch(i.browser){case"chrome":if(!Ik||!kk||!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=Ik,XT(t,i),KT(t),fk(t,i),_k(t),kk(t,i),mk(t),Ek(t,i),gk(t),yk(t),Sk(t),Tk(t,i),FT(t),BT(t),zT(t),jT(t,i),GT(t),HT(t,i);break;case"firefox":if(!pT||!oT||!r.shimFirefox)return n("Firefox shim is not included in this adapter release."),o;n("adapter.js shimming firefox."),o.browserShim=pT,XT(t,i),KT(t),nT(t,i),oT(t,i),iT(t),uT(t),aT(t),sT(t),cT(t),dT(t),lT(t),hT(t),vT(t),FT(t),zT(t),jT(t,i),GT(t);break;case"safari":if(!TT||!r.shimSafari)return n("Safari shim is not included in this adapter release."),o;n("adapter.js shimming safari."),o.browserShim=TT,XT(t,i),KT(t),ST(t),ET(t),mT(t),fT(t),_T(t),bT(t),gT(t),kT(t),FT(t),BT(t),jT(t,i),GT(t),HT(t,i);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window});var JT=We,ZT=function(e){return void 0!==e&&(JT(e,"value")||JT(e,"writable"))},$T=P,eI=$,tI=tr,rI=ZT,nI=R,iI=mu;Rr({target:"Reflect",stat:!0},{get:function e(t,r){var n,i,o=arguments.length<3?t:arguments[2];return tI(t)===o?t[r]:(n=nI.f(t,r))?rI(n)?n.value:void 0===n.get?void 0:$T(n.get,o):eI(i=iI(t))?e(i,r,o):void 0}});var oI=ee.Reflect.get,aI=E,sI=Ce,uI=$,cI=We,dI=rs,lI=o,hI=Function,vI=aI([].concat),pI=aI([].join),fI={},_I=function(e,t,r){if(!cI(fI,t)){for(var n=[],i=0;i<t;i++)n[i]="a["+i+"]";fI[t]=hI("C,a","return new C("+pI(n,",")+")")}return fI[t](e,r)},mI=lI?hI.bind:function(e){var t=sI(this),r=t.prototype,n=dI(arguments,1),i=function(){var r=vI(n,dI(arguments));return this instanceof i?_I(t,r.length,r):t.apply(e,r)};return uI(r)&&(i.prototype=r),i},gI=mI;Rr({target:"Function",proto:!0,forced:Function.bind!==gI},{bind:gI});var yI=Us("Function").bind,SI=ae,bI=yI,EI=Function.prototype,kI=function(e){var t=e.bind;return e===EI||SI(EI,e)&&t===EI.bind?bI:t};function TI(e){var t;return(TI=jl?kI(t=Bl).call(t):function(e){return e.__proto__||Bl(e)})(e)}function II(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=TI(e)););return e}function AI(){var e;"undefined"!=typeof Reflect&&oI?AI=kI(e=oI).call(e):AI=function(e,t,r){var n=II(e,t);if(n){var i=tu(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}};return AI.apply(this,arguments)}function RI(e,t){var r;return(RI=jl?kI(r=jl).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function wI(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Ll(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),ad(e,"prototype",{writable:!1}),t&&RI(e,t)}var CI=Rr,xI=d,PI=mI,OI=mv,DI=tr,MI=$,NI=zn,LI=i,UI=oe("Reflect","construct"),VI=Object.prototype,FI=[].push,BI=LI((function(){function e(){}return!(UI((function(){}),[],e)instanceof e)})),jI=!LI((function(){UI((function(){}))})),GI=BI||jI;CI({target:"Reflect",stat:!0,forced:GI,sham:GI},{construct:function(e,t){OI(e),DI(t);var r=arguments.length<3?e:OI(arguments[2]);if(jI&&!BI)return UI(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 xI(FI,n,t),new(xI(PI,e,n))}var i=r.prototype,o=NI(MI(i)?i:VI),a=xI(e,o,t);return MI(a)?a:o}});var zI=ee.Reflect.construct;function HI(e,t){if(t&&("object"===Ml(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return QT(e)}function XI(e){var t=function(){if("undefined"==typeof Reflect||!zI)return!1;if(zI.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(zI(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=TI(e);if(t){var i=TI(this).constructor;r=zI(n,arguments,i)}else r=n.apply(this,arguments);return HI(this,r)}}var KI=Us("Array").values,qI=fn,YI=We,WI=ae,QI=KI,JI=Array.prototype,ZI={DOMTokenList:!0,NodeList:!0},$I=function(e){var t=e.values;return e===JI||WI(JI,e)&&t===JI.values||YI(ZI,qI(e))?QI:t},eA=ni,tA=Math.floor,rA=function(e,t){var r=e.length,n=tA(r/2);return r<8?nA(e,t):iA(e,rA(eA(e,0,n),t),rA(eA(e,n),t),t)},nA=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},iA=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},oA=rA,aA=se.match(/firefox\/(\d+)/i),sA=!!aA&&+aA[1],uA=/MSIE|Trident/.test(se),cA=se.match(/AppleWebKit\/(\d+)\./),dA=!!cA&&+cA[1],lA=Rr,hA=E,vA=Ce,pA=Ke,fA=Br,_A=TE,mA=gn,gA=i,yA=oA,SA=Ic,bA=sA,EA=uA,kA=pe,TA=dA,IA=[],AA=hA(IA.sort),RA=hA(IA.push),wA=gA((function(){IA.sort(void 0)})),CA=gA((function(){IA.sort(null)})),xA=SA("sort"),PA=!gA((function(){if(kA)return kA<70;if(!(bA&&bA>3)){if(EA)return!0;if(TA)return TA<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++)IA.push({k:t+n,v:r})}for(IA.sort((function(e,t){return t.v-e.v})),n=0;n<IA.length;n++)t=IA[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));lA({target:"Array",proto:!0,forced:wA||!CA||!xA||!PA},{sort:function(e){void 0!==e&&vA(e);var t=pA(this);if(PA)return void 0===e?AA(t):AA(t,e);var r,n,i=[],o=fA(t);for(n=0;n<o;n++)n in t&&RA(i,t[n]);for(yA(i,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:mA(t)>mA(r)?1:-1}}(e)),r=fA(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)_A(t,n++);return t}});var OA=Us("Array").sort,DA=ae,MA=OA,NA=Array.prototype,LA=function(e){var t=e.sort;return e===NA||DA(NA,e)&&t===NA.sort?MA:t},UA=Rr,VA=Mo.findIndex,FA="findIndex",BA=!0;FA in[]&&Array(1).findIndex((function(){BA=!1})),UA({target:"Array",proto:!0,forced:BA},{findIndex:function(e){return VA(this,e,arguments.length>1?arguments[1]:void 0)}});var jA=Us("Array").findIndex,GA=ae,zA=jA,HA=Array.prototype,XA=function(e){var t=e.findIndex;return e===HA||GA(HA,e)&&t===HA.findIndex?zA:t},KA=Rr,qA=E;R.f;var YA=Vr,WA=gn,QA=Sb,JA=q,ZA=Eb,$A=qA("".startsWith),eR=qA("".slice),tR=Math.min;KA({target:"String",proto:!0,forced:!ZA("startsWith")},{startsWith:function(e){var t=WA(JA(this));QA(e);var r=YA(tR(arguments.length>1?arguments[1]:void 0,t.length)),n=WA(e);return $A?$A(t,n,r):eR(t,r,r+n.length)===n}});var rR=Us("String").startsWith,nR=ae,iR=rR,oR=String.prototype,aR=function(e){var t=e.startsWith;return"string"==typeof e||e===oR||nR(oR,e)&&t===oR.startsWith?iR:t},sR=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.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.ROOM_FORBIDDEN="ROOM_FORBIDDEN",e.USER_FORBIDDEN="USER_FORBIDDEN",e}(sR||{}),uR=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}(uR||{}),cR=Kd((function e(t,r,n){qd(this,e),sd(this,"code",void 0),sd(this,"message",void 0),sd(this,"error",void 0),this.code=t,this.message=r,this.error=n})),dR=w,lR=E,hR=rn,vR=Q,pR=lR(O.f),fR=lR([].push),_R=function(e){return function(t){for(var r,n=vR(t),i=hR(n),o=i.length,a=0,s=[];o>a;)r=i[a++],dR&&!pR(n,r)||fR(s,e?[r,n[r]]:n[r]);return s}},mR={entries:_R(!0),values:_R(!1)}.entries;Rr({target:"Object",stat:!0},{entries:function(e){return mR(e)}});var gR=ee.Object.entries,yR=Pr,SR=gn,bR=q,ER=RangeError,kR=E,TR=Vr,IR=gn,AR=function(e){var t=SR(bR(this)),r="",n=yR(e);if(n<0||n==1/0)throw ER("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},RR=q,wR=kR(AR),CR=kR("".slice),xR=Math.ceil,PR=function(e){return function(t,r,n){var i,o,a=IR(RR(t)),s=TR(r),u=a.length,c=void 0===n?" ":IR(n);return s<=u||""==c?a:((o=wR(c,xR((i=s-u)/c.length))).length>i&&(o=CR(o,0,i)),e?a+o:o+a)}},OR={start:PR(!1),end:PR(!0)},DR=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(se),MR=OR.end;Rr({target:"String",proto:!0,forced:DR},{padEnd:function(e){return MR(this,e,arguments.length>1?arguments[1]:void 0)}});var NR=Us("String").padEnd,LR=ae,UR=NR,VR=String.prototype,FR=function(e){var t=e.padEnd;return"string"==typeof e||e===VR||LR(VR,e)&&t===VR.padEnd?UR:t},BR=Ym;Rr({target:"Number",stat:!0,forced:Number.parseInt!=BR},{parseInt:BR});var jR=ee.Number.parseInt,GR=Math.log,zR=Math.LOG10E;Rr({target:"Math",stat:!0},{log10:Math.log10||function(e){return GR(e)*zR}});var HR,XR=ee.Math.log10,KR=new Uint8Array(16);function qR(){if(!HR&&!(HR="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 HR(KR)}var YR=/^(?:[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 WR(e){return"string"==typeof e&&YR.test(e)}for(var QR=[],JR=0;JR<256;++JR)QR.push((JR+256).toString(16).substr(1));function ZR(e,t,r){var n=(e=e||{}).random||(e.rng||qR)();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=(QR[e[t+0]]+QR[e[t+1]]+QR[e[t+2]]+QR[e[t+3]]+"-"+QR[e[t+4]]+QR[e[t+5]]+"-"+QR[e[t+6]]+QR[e[t+7]]+"-"+QR[e[t+8]]+QR[e[t+9]]+"-"+QR[e[t+10]]+QR[e[t+11]]+QR[e[t+12]]+QR[e[t+13]]+QR[e[t+14]]+QR[e[t+15]]).toLowerCase();if(!WR(r))throw TypeError("Stringified UUID is invalid");return r}(n)}var $R=function(){return"undefined"==typeof window},ew={};!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=ym(Array.prototype).call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==Ml(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 Rm([]).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)}(ew);var tw={},rw={},nw={},iw=ew;function ow(e){for(var t=e.length;--t>=0;)e[t]=0}var aw=256,sw=286,uw=30,cw=15,dw=[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],lw=[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],hw=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],vw=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],pw=new Array(576);ow(pw);var fw=new Array(60);ow(fw);var _w=new Array(512);ow(_w);var mw=new Array(256);ow(mw);var gw=new Array(29);ow(gw);var yw,Sw,bw,Ew=new Array(uw);function kw(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 Tw(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Iw(e){return e<256?_w[e]:_w[256+(e>>>7)]}function Aw(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function Rw(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,Aw(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 ww(e,t,r){Rw(e,r[2*t],r[2*t+1])}function Cw(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function xw(e,t,r){var n,i,o=new Array(16),a=0;for(n=1;n<=cw;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]=Cw(o[s]++,s))}}function Pw(e){var t;for(t=0;t<sw;t++)e.dyn_ltree[2*t]=0;for(t=0;t<uw;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 Ow(e){e.bi_valid>8?Aw(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 Dw(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 Mw(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&Dw(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!Dw(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function Nw(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?ww(e,i,t):(ww(e,(o=mw[i])+aw+1,t),0!==(a=dw[o])&&Rw(e,i-=gw[o],a),ww(e,o=Iw(--n),r),0!==(a=lw[o])&&Rw(e,n-=Ew[o],a))}while(s<e.last_lit);ww(e,256,t)}function Lw(e,t){var r,n,i,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,u=t.stat_desc.elems,c=-1;for(e.heap_len=0,e.heap_max=573,r=0;r<u;r++)0!==o[2*r]?(e.heap[++e.heap_len]=c=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=c<2?++c:0)]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=a[2*i+1]);for(t.max_code=c,r=e.heap_len>>1;r>=1;r--)Mw(e,o,r);i=u;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Mw(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++,Mw(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,u=t.dyn_tree,c=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,p=t.stat_desc.max_length,f=0;for(o=0;o<=cw;o++)e.bl_count[o]=0;for(u[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)(o=u[2*u[2*(n=e.heap[r])+1]+1]+1)>p&&(o=p,f++),u[2*n+1]=o,n>c||(e.bl_count[o]++,a=0,n>=v&&(a=h[n-v]),s=u[2*n],e.opt_len+=s*(o+a),l&&(e.static_len+=s*(d[2*n+1]+a)));if(0!==f){do{for(o=p-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[p]--,f-=2}while(f>0);for(o=p;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>c||(u[2*i+1]!==o&&(e.opt_len+=(o-u[2*i+1])*u[2*i],u[2*i+1]=o),n--)}}(e,t),xw(o,c,e.bl_count)}function Uw(e,t,r){var n,i,o=-1,a=t[1],s=0,u=7,c=4;for(0===a&&(u=138,c=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++s<u&&i===a||(s<c?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?(u=138,c=3):i===a?(u=6,c=3):(u=7,c=4))}function Vw(e,t,r){var n,i,o=-1,a=t[1],s=0,u=7,c=4;for(0===a&&(u=138,c=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++s<u&&i===a)){if(s<c)do{ww(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(ww(e,i,e.bl_tree),s--),ww(e,16,e.bl_tree),Rw(e,s-3,2)):s<=10?(ww(e,17,e.bl_tree),Rw(e,s-3,3)):(ww(e,18,e.bl_tree),Rw(e,s-11,7));s=0,o=i,0===a?(u=138,c=3):i===a?(u=6,c=3):(u=7,c=4)}}ow(Ew);var Fw=!1;function Bw(e,t,r,n){Rw(e,0+(n?1:0),3),function(e,t,r,n){Ow(e),n&&(Aw(e,r),Aw(e,~r)),iw.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}nw._tr_init=function(e){Fw||(!function(){var e,t,r,n,i,o=new Array(16);for(r=0,n=0;n<28;n++)for(gw[n]=r,e=0;e<1<<dw[n];e++)mw[r++]=n;for(mw[r-1]=n,i=0,n=0;n<16;n++)for(Ew[n]=i,e=0;e<1<<lw[n];e++)_w[i++]=n;for(i>>=7;n<uw;n++)for(Ew[n]=i<<7,e=0;e<1<<lw[n]-7;e++)_w[256+i++]=n;for(t=0;t<=cw;t++)o[t]=0;for(e=0;e<=143;)pw[2*e+1]=8,e++,o[8]++;for(;e<=255;)pw[2*e+1]=9,e++,o[9]++;for(;e<=279;)pw[2*e+1]=7,e++,o[7]++;for(;e<=287;)pw[2*e+1]=8,e++,o[8]++;for(xw(pw,287,o),e=0;e<uw;e++)fw[2*e+1]=5,fw[2*e]=Cw(e,5);yw=new kw(pw,dw,257,sw,cw),Sw=new kw(fw,lw,0,uw,cw),bw=new kw(new Array(0),hw,0,19,7)}(),Fw=!0),e.l_desc=new Tw(e.dyn_ltree,yw),e.d_desc=new Tw(e.dyn_dtree,Sw),e.bl_desc=new Tw(e.bl_tree,bw),e.bi_buf=0,e.bi_valid=0,Pw(e)},nw._tr_stored_block=Bw,nw._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<aw;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),Lw(e,e.l_desc),Lw(e,e.d_desc),a=function(e){var t;for(Uw(e,e.dyn_ltree,e.l_desc.max_code),Uw(e,e.dyn_dtree,e.d_desc.max_code),Lw(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*vw[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?Bw(e,t,r,n):4===e.strategy||o===i?(Rw(e,2+(n?1:0),3),Nw(e,pw,fw)):(Rw(e,4+(n?1:0),3),function(e,t,r,n){var i;for(Rw(e,t-257,5),Rw(e,r-1,5),Rw(e,n-4,4),i=0;i<n;i++)Rw(e,e.bl_tree[2*vw[i]+1],3);Vw(e,e.dyn_ltree,t-1),Vw(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),Nw(e,e.dyn_ltree,e.dyn_dtree)),Pw(e),n&&Ow(e)},nw._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*(mw[r]+aw+1)]++,e.dyn_dtree[2*Iw(t)]++),e.last_lit===e.lit_bufsize-1},nw._tr_align=function(e){Rw(e,2,3),ww(e,256,pw),function(e){16===e.bi_valid?(Aw(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 jw=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 Gw=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 zw,Hw=function(e,t,r,n){var i=Gw,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},Xw={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"},Kw=ew,qw=nw,Yw=jw,Ww=Hw,Qw=Xw,Jw=-2,Zw=258,$w=262,eC=103,tC=113,rC=666;function nC(e,t){return e.msg=Qw[t],t}function iC(e){return(e<<1)-(e>4?9:0)}function oC(e){for(var t=e.length;--t>=0;)e[t]=0}function aC(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(Kw.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 sC(e,t){qw._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,aC(e.strm)}function uC(e,t){e.pending_buf[e.pending++]=t}function cC(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function dC(e,t){var r,n,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,u=e.strstart>e.w_size-$w?e.strstart-(e.w_size-$w):0,c=e.window,d=e.w_mask,l=e.prev,h=e.strstart+Zw,v=c[o+a-1],p=c[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(c[(r=t)+a]===p&&c[r+a-1]===v&&c[r]===c[o]&&c[++r]===c[o+1]){o+=2,r++;do{}while(c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&o<h);if(n=Zw-(h-o),o=h-Zw,n>a){if(e.match_start=t,a=n,n>=s)break;v=c[o+a-1],p=c[o+a]}}}while((t=l[t&d])>u&&0!=--i);return a<=e.lookahead?a:e.lookahead}function lC(e){var t,r,n,i,o,a,s,u,c,d,l=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=l+(l-$w)){Kw.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,u=e.strstart+e.lookahead,c=i,d=void 0,(d=a.avail_in)>c&&(d=c),r=0===d?0:(a.avail_in-=d,Kw.arraySet(s,a.input,a.next_in,d,u),1===a.state.wrap?a.adler=Yw(a.adler,s,d,u):2===a.state.wrap&&(a.adler=Ww(a.adler,s,d,u)),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<$w&&0!==e.strm.avail_in)}function hC(e,t){for(var r,n;;){if(e.lookahead<$w){if(lC(e),e.lookahead<$w&&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-$w&&(e.match_length=dC(e,r)),e.match_length>=3)if(n=qw._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=qw._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(sC(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(sC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(sC(e,!1),0===e.strm.avail_out)?1:2}function vC(e,t){for(var r,n,i;;){if(e.lookahead<$w){if(lC(e),e.lookahead<$w&&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-$w&&(e.match_length=dC(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=qw._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&&(sC(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=qw._tr_tally(e,0,e.window[e.strstart-1]))&&sC(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=qw._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(sC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(sC(e,!1),0===e.strm.avail_out)?1:2}function pC(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 fC(){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 Kw.Buf16(1146),this.dyn_dtree=new Kw.Buf16(122),this.bl_tree=new Kw.Buf16(78),oC(this.dyn_ltree),oC(this.dyn_dtree),oC(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Kw.Buf16(16),this.heap=new Kw.Buf16(573),oC(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Kw.Buf16(573),oC(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:tC,e.adler=2===t.wrap?0:1,t.last_flush=0,qw._tr_init(t),0):nC(e,Jw)}function mC(e){var t,r=_C(e);return 0===r&&((t=e.state).window_size=2*t.w_size,oC(t.head),t.max_lazy_match=zw[t.level].max_lazy,t.good_match=zw[t.level].good_length,t.nice_match=zw[t.level].nice_length,t.max_chain_length=zw[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 gC(e,t,r,n,i,o){if(!e)return Jw;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 nC(e,Jw);8===n&&(n=9);var s=new fC;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 Kw.Buf8(2*s.w_size),s.head=new Kw.Buf16(s.hash_size),s.prev=new Kw.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new Kw.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,mC(e)}zw=[new pC(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(lC(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,sC(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-$w&&(sC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(sC(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(sC(e,!1),e.strm.avail_out),1)})),new pC(4,4,8,4,hC),new pC(4,5,16,8,hC),new pC(4,6,32,32,hC),new pC(4,4,16,16,vC),new pC(8,16,32,32,vC),new pC(8,16,128,128,vC),new pC(8,32,128,256,vC),new pC(32,128,258,1024,vC),new pC(32,258,258,4096,vC)],rw.deflateInit=function(e,t){return gC(e,t,8,15,8,0)},rw.deflateInit2=gC,rw.deflateReset=mC,rw.deflateResetKeep=_C,rw.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?Jw:(e.state.gzhead=t,0):Jw},rw.deflate=function(e,t){var r,n,i,o;if(!e||!e.state||t>5||t<0)return e?nC(e,Jw):Jw;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===rC&&4!==t)return nC(e,0===e.avail_out?-5:Jw);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,uC(n,31),uC(n,139),uC(n,8),n.gzhead?(uC(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)),uC(n,255&n.gzhead.time),uC(n,n.gzhead.time>>8&255),uC(n,n.gzhead.time>>16&255),uC(n,n.gzhead.time>>24&255),uC(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),uC(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(uC(n,255&n.gzhead.extra.length),uC(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Ww(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(uC(n,0),uC(n,0),uC(n,0),uC(n,0),uC(n,0),uC(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),uC(n,3),n.status=tC);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=tC,cC(n,a),0!==n.strstart&&(cC(n,e.adler>>>16),cC(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=Ww(e.adler,n.pending_buf,n.pending-i,i)),aC(e),i=n.pending,n.pending!==n.pending_buf_size));)uC(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=Ww(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=Ww(e.adler,n.pending_buf,n.pending-i,i)),aC(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,uC(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=Ww(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=Ww(e.adler,n.pending_buf,n.pending-i,i)),aC(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,uC(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=Ww(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=eC)}else n.status=eC;if(n.status===eC&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&aC(e),n.pending+2<=n.pending_buf_size&&(uC(n,255&e.adler),uC(n,e.adler>>8&255),e.adler=0,n.status=tC)):n.status=tC),0!==n.pending){if(aC(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&iC(t)<=iC(r)&&4!==t)return nC(e,-5);if(n.status===rC&&0!==e.avail_in)return nC(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&n.status!==rC){var s=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(lC(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=qw._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(sC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(sC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(sC(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<=Zw){if(lC(e),e.lookahead<=Zw&&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+Zw;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=Zw-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=qw._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=qw._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(sC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(sC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(sC(e,!1),0===e.strm.avail_out)?1:2}(n,t):zw[n.level].func(n,t);if(3!==s&&4!==s||(n.status=rC),1===s||3===s)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===s&&(1===t?qw._tr_align(n):5!==t&&(qw._tr_stored_block(n,0,0,!1),3===t&&(oC(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),aC(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(uC(n,255&e.adler),uC(n,e.adler>>8&255),uC(n,e.adler>>16&255),uC(n,e.adler>>24&255),uC(n,255&e.total_in),uC(n,e.total_in>>8&255),uC(n,e.total_in>>16&255),uC(n,e.total_in>>24&255)):(cC(n,e.adler>>>16),cC(n,65535&e.adler)),aC(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)},rw.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==eC&&t!==tC&&t!==rC?nC(e,Jw):(e.state=null,t===tC?nC(e,-3):0):Jw},rw.deflateSetDictionary=function(e,t){var r,n,i,o,a,s,u,c,d=t.length;if(!e||!e.state)return Jw;if(2===(o=(r=e.state).wrap)||1===o&&42!==r.status||r.lookahead)return Jw;for(1===o&&(e.adler=Yw(e.adler,t,d,0)),r.wrap=0,d>=r.w_size&&(0===o&&(oC(r.head),r.strstart=0,r.block_start=0,r.insert=0),c=new Kw.Buf8(r.w_size),Kw.arraySet(c,t,d-r.w_size,r.w_size,0),t=c,d=r.w_size),a=e.avail_in,s=e.next_in,u=e.input,e.avail_in=d,e.next_in=0,e.input=t,lC(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,lC(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=u,e.avail_in=a,r.wrap=o,0},rw.deflateInfo="pako deflate (from Nodeca project)";var yC={},SC=ew,bC=!0,EC=!0;try{String.fromCharCode.apply(null,[0])}catch($H){bC=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch($H){EC=!1}for(var kC=new SC.Buf8(256),TC=0;TC<256;TC++)kC[TC]=TC>=252?6:TC>=248?5:TC>=240?4:TC>=224?3:TC>=192?2:1;function IC(e,t){if(t<65534&&(e.subarray&&EC||!e.subarray&&bC))return String.fromCharCode.apply(null,SC.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}kC[254]=kC[254]=1,yC.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 SC.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},yC.buf2binstring=function(e){return IC(e,e.length)},yC.binstring2buf=function(e){for(var t=new SC.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},yC.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=kC[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 IC(s,n)},yC.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+kC[e[r]]>t?r:t};var AC=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},RC=rw,wC=ew,CC=yC,xC=Xw,PC=AC,OC=Object.prototype.toString;function DC(e){if(!(this instanceof DC))return new DC(e);this.options=wC.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 PC,this.strm.avail_out=0;var r=RC.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==r)throw new Error(xC[r]);if(t.header&&RC.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?CC.string2buf(t.dictionary):"[object ArrayBuffer]"===OC.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(r=RC.deflateSetDictionary(this.strm,n)))throw new Error(xC[r]);this._dict_set=!0}}function MC(e,t){var r=new DC(t);if(r.push(e,!0),r.err)throw r.msg||xC[r.err];return r.result}DC.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=CC.string2buf(e):"[object ArrayBuffer]"===OC.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 wC.Buf8(o),i.next_out=0,i.avail_out=o),1!==(r=RC.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(CC.buf2binstring(wC.shrinkBuf(i.output,i.next_out))):this.onData(wC.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=RC.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==n||(this.onEnd(0),i.avail_out=0,!0)},DC.prototype.onData=function(e){this.chunks.push(e)},DC.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=wC.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},tw.Deflate=DC,tw.deflate=MC,tw.deflateRaw=function(e,t){return(t=t||{}).raw=!0,MC(e,t)},tw.gzip=function(e,t){return(t=t||{}).gzip=!0,MC(e,t)};var NC={},LC=tr,UC=P,VC=We,FC=ae,BC=function(){var e=LC(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},jC=RegExp.prototype,GC=ae,zC=function(e){var t=e.flags;return void 0!==t||"flags"in jC||VC(e,"flags")||!FC(jC,e)?t:UC(BC,e)},HC=RegExp.prototype,XC=function(e){return e===HC||GC(HC,e)?zC(e):e.flags},KC={},qC=ew,YC=15,WC=[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],QC=[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],JC=[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],ZC=[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],$C=ew,ex=jw,tx=Hw,rx=function(e,t){var r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A;r=e.state,n=e.next_in,I=e.input,i=n+(e.avail_in-5),o=e.next_out,A=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),u=r.dmax,c=r.wsize,d=r.whave,l=r.wnext,h=r.window,v=r.hold,p=r.bits,f=r.lencode,_=r.distcode,m=(1<<r.lenbits)-1,g=(1<<r.distbits)-1;e:do{p<15&&(v+=I[n++]<<p,p+=8,v+=I[n++]<<p,p+=8),y=f[v&m];t:for(;;){if(v>>>=S=y>>>24,p-=S,0===(S=y>>>16&255))A[o++]=65535&y;else{if(!(16&S)){if(0==(64&S)){y=f[(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)&&(p<S&&(v+=I[n++]<<p,p+=8),b+=v&(1<<S)-1,v>>>=S,p-=S),p<15&&(v+=I[n++]<<p,p+=8,v+=I[n++]<<p,p+=8),y=_[v&g];r:for(;;){if(v>>>=S=y>>>24,p-=S,!(16&(S=y>>>16&255))){if(0==(64&S)){y=_[(65535&y)+(v&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(E=65535&y,p<(S&=15)&&(v+=I[n++]<<p,(p+=8)<S&&(v+=I[n++]<<p,p+=8)),(E+=v&(1<<S)-1)>u){e.msg="invalid distance too far back",r.mode=30;break e}if(v>>>=S,p-=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+=c-S,S<b){b-=S;do{A[o++]=h[k++]}while(--S);k=o-E,T=A}}else if(l<S){if(k+=c+l-S,(S-=l)<b){b-=S;do{A[o++]=h[k++]}while(--S);if(k=0,l<b){b-=S=l;do{A[o++]=h[k++]}while(--S);k=o-E,T=A}}}else if(k+=l-S,S<b){b-=S;do{A[o++]=h[k++]}while(--S);k=o-E,T=A}for(;b>2;)A[o++]=T[k++],A[o++]=T[k++],A[o++]=T[k++],b-=3;b&&(A[o++]=T[k++],b>1&&(A[o++]=T[k++]))}else{k=o-E;do{A[o++]=A[k++],A[o++]=A[k++],A[o++]=A[k++],b-=3}while(b>2);b&&(A[o++]=A[k++],b>1&&(A[o++]=A[k++]))}break}}break}}while(n<i&&o<s);n-=b=p>>3,v&=(1<<(p-=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=p},nx=function(e,t,r,n,i,o,a,s){var u,c,d,l,h,v,p,f,_,m=s.bits,g=0,y=0,S=0,b=0,E=0,k=0,T=0,I=0,A=0,R=0,w=null,C=0,x=new qC.Buf16(16),P=new qC.Buf16(16),O=null,D=0;for(g=0;g<=YC;g++)x[g]=0;for(y=0;y<n;y++)x[t[r+y]]++;for(E=m,b=YC;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<=YC;g++)if(I<<=1,(I-=x[g])<0)return-1;if(I>0&&(0===e||1!==b))return-1;for(P[1]=0,g=1;g<YC;g++)P[g+1]=P[g]+x[g];for(y=0;y<n;y++)0!==t[r+y]&&(a[P[t[r+y]]++]=y);if(0===e?(w=O=a,v=19):1===e?(w=WC,C-=257,O=QC,D-=257,v=256):(w=JC,O=ZC,v=-1),R=0,y=0,g=S,h=o,k=E,T=0,d=-1,l=(A=1<<E)-1,1===e&&A>852||2===e&&A>592)return 1;for(;;){p=g-T,a[y]<v?(f=0,_=a[y]):a[y]>v?(f=O[D+a[y]],_=w[C+a[y]]):(f=96,_=0),u=1<<g-T,S=c=1<<k;do{i[h+(R>>T)+(c-=u)]=p<<24|f<<16|_|0}while(0!==c);for(u=1<<g-1;R&u;)u>>=1;if(0!==u?(R&=u-1,R+=u):R=0,y++,0==--x[g]){if(g===b)break;g=t[r+a[y]]}if(g>E&&(R&l)!==d){for(0===T&&(T=E),h+=S,I=1<<(k=g-T);k+T<b&&!((I-=x[k+T])<=0);)k++,I<<=1;if(A+=1<<k,1===e&&A>852||2===e&&A>592)return 1;i[d=R&l]=E<<24|k<<16|h-o|0}}return 0!==R&&(i[h+R]=g-T<<24|64<<16|0),s.bits=E,0},ix=-2,ox=12,ax=30;function sx(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function ux(){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 $C.Buf16(320),this.work=new $C.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function cx(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 $C.Buf32(852),t.distcode=t.distdyn=new $C.Buf32(592),t.sane=1,t.back=-1,0):ix}function dx(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,cx(e)):ix}function lx(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)?ix:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,dx(e))):ix}function hx(e,t){var r,n;return e?(n=new ux,e.state=n,n.window=null,0!==(r=lx(e,t))&&(e.state=null),r):ix}var vx,px,fx=!0;function _x(e){if(fx){var t;for(vx=new $C.Buf32(512),px=new $C.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(nx(1,e.lens,0,288,vx,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;nx(2,e.lens,0,32,px,0,e.work,{bits:5}),fx=!1}e.lencode=vx,e.lenbits=9,e.distcode=px,e.distbits=5}function mx(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 $C.Buf8(o.wsize)),n>=o.wsize?($C.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),$C.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?($C.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}KC.inflateReset=dx,KC.inflateReset2=lx,KC.inflateResetKeep=cx,KC.inflateInit=function(e){return hx(e,15)},KC.inflateInit2=hx,KC.inflate=function(e,t){var r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A=0,R=new $C.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 ix;(r=e.state).mode===ox&&(r.mode=13),a=e.next_out,i=e.output,u=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,c=r.hold,d=r.bits,l=s,h=u,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--,c+=n[o++]<<d,d+=8}if(2&r.wrap&&35615===c){r.check=0,R[0]=255&c,R[1]=c>>>8&255,r.check=tx(r.check,R,2,0),c=0,d=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",r.mode=ax;break}if(8!=(15&c)){e.msg="unknown compression method",r.mode=ax;break}if(d-=4,E=8+(15&(c>>>=4)),0===r.wbits)r.wbits=E;else if(E>r.wbits){e.msg="invalid window size",r.mode=ax;break}r.dmax=1<<E,e.adler=r.check=1,r.mode=512&c?10:ox,c=0,d=0;break;case 2:for(;d<16;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if(r.flags=c,8!=(255&XC(r))){e.msg="unknown compression method",r.mode=ax;break}if(57344&XC(r)){e.msg="unknown header flags set",r.mode=ax;break}r.head&&(r.head.text=c>>8&1),512&XC(r)&&(R[0]=255&c,R[1]=c>>>8&255,r.check=tx(r.check,R,2,0)),c=0,d=0,r.mode=3;case 3:for(;d<32;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}r.head&&(r.head.time=c),512&XC(r)&&(R[0]=255&c,R[1]=c>>>8&255,R[2]=c>>>16&255,R[3]=c>>>24&255,r.check=tx(r.check,R,4,0)),c=0,d=0,r.mode=4;case 4:for(;d<16;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}r.head&&(r.head.xflags=255&c,r.head.os=c>>8),512&XC(r)&&(R[0]=255&c,R[1]=c>>>8&255,r.check=tx(r.check,R,2,0)),c=0,d=0,r.mode=5;case 5:if(1024&XC(r)){for(;d<16;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}r.length=c,r.head&&(r.head.extra_len=c),512&XC(r)&&(R[0]=255&c,R[1]=c>>>8&255,r.check=tx(r.check,R,2,0)),c=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&XC(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)),$C.arraySet(r.head.extra,n,o,v,E)),512&XC(r)&&(r.check=tx(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&XC(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&XC(r)&&(r.check=tx(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&XC(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&XC(r)&&(r.check=tx(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&XC(r)){for(;d<16;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if(c!==(65535&r.check)){e.msg="header crc mismatch",r.mode=ax;break}c=0,d=0}r.head&&(r.head.hcrc=XC(r)>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=ox;break;case 10:for(;d<32;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}e.adler=r.check=sx(c),c=0,d=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=a,e.avail_out=u,e.next_in=o,e.avail_in=s,r.hold=c,r.bits=d,2;e.adler=r.check=1,r.mode=ox;case ox:if(5===t||6===t)break e;case 13:if(r.last){c>>>=7&d,d-=7&d,r.mode=27;break}for(;d<3;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}switch(r.last=1&c,d-=1,3&(c>>>=1)){case 0:r.mode=14;break;case 1:if(_x(r),r.mode=20,6===t){c>>>=2,d-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=ax}c>>>=2,d-=2;break;case 14:for(c>>>=7&d,d-=7&d;d<32;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",r.mode=ax;break}if(r.length=65535&c,c=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>u&&(v=u),0===v)break e;$C.arraySet(i,n,o,v,a),s-=v,o+=v,u-=v,a+=v,r.length-=v;break}r.mode=ox;break;case 17:for(;d<14;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if(r.nlen=257+(31&c),c>>>=5,d-=5,r.ndist=1+(31&c),c>>>=5,d-=5,r.ncode=4+(15&c),c>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=ax;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;d<3;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}r.lens[w[r.have++]]=7&c,c>>>=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=nx(0,r.lens,0,19,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid code lengths set",r.mode=ax;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=(A=r.lencode[c&(1<<r.lenbits)-1])>>>16&255,g=65535&A,!((_=A>>>24)<=d);){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if(g<16)c>>>=_,d-=_,r.lens[r.have++]=g;else{if(16===g){for(I=_+2;d<I;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if(c>>>=_,d-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=ax;break}E=r.lens[r.have-1],v=3+(3&c),c>>>=2,d-=2}else if(17===g){for(I=_+3;d<I;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}d-=_,E=0,v=3+(7&(c>>>=_)),c>>>=3,d-=3}else{for(I=_+7;d<I;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}d-=_,E=0,v=11+(127&(c>>>=_)),c>>>=7,d-=7}if(r.have+v>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=ax;break}for(;v--;)r.lens[r.have++]=E}}if(r.mode===ax)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=ax;break}if(r.lenbits=9,T={bits:r.lenbits},k=nx(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=ax;break}if(r.distbits=6,r.distcode=r.distdyn,T={bits:r.distbits},k=nx(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=ax;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(s>=6&&u>=258){e.next_out=a,e.avail_out=u,e.next_in=o,e.avail_in=s,r.hold=c,r.bits=d,rx(e,h),a=e.next_out,i=e.output,u=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,c=r.hold,d=r.bits,r.mode===ox&&(r.back=-1);break}for(r.back=0;m=(A=r.lencode[c&(1<<r.lenbits)-1])>>>16&255,g=65535&A,!((_=A>>>24)<=d);){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if(m&&0==(240&m)){for(y=_,S=m,b=g;m=(A=r.lencode[b+((c&(1<<y+S)-1)>>y)])>>>16&255,g=65535&A,!(y+(_=A>>>24)<=d);){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}c>>>=y,d-=y,r.back+=y}if(c>>>=_,d-=_,r.back+=_,r.length=g,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=ox;break}if(64&m){e.msg="invalid literal/length code",r.mode=ax;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--,c+=n[o++]<<d,d+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=(A=r.distcode[c&(1<<r.distbits)-1])>>>16&255,g=65535&A,!((_=A>>>24)<=d);){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if(0==(240&m)){for(y=_,S=m,b=g;m=(A=r.distcode[b+((c&(1<<y+S)-1)>>y)])>>>16&255,g=65535&A,!(y+(_=A>>>24)<=d);){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}c>>>=y,d-=y,r.back+=y}if(c>>>=_,d-=_,r.back+=_,64&m){e.msg="invalid distance code",r.mode=ax;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--,c+=n[o++]<<d,d+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=ax;break}r.mode=25;case 25:if(0===u)break e;if(v=h-u,r.offset>v){if((v=r.offset-v)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=ax;break}v>r.wnext?(v-=r.wnext,p=r.wsize-v):p=r.wnext-v,v>r.length&&(v=r.length),f=r.window}else f=i,p=a-r.offset,v=r.length;v>u&&(v=u),u-=v,r.length-=v;do{i[a++]=f[p++]}while(--v);0===r.length&&(r.mode=21);break;case 26:if(0===u)break e;i[a++]=r.length,u--,r.mode=21;break;case 27:if(r.wrap){for(;d<32;){if(0===s)break e;s--,c|=n[o++]<<d,d+=8}if(h-=u,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=XC(r)?tx(r.check,i,h,a-h):ex(r.check,i,h,a-h)),h=u,(XC(r)?c:sx(c))!==r.check){e.msg="incorrect data check",r.mode=ax;break}c=0,d=0}r.mode=28;case 28:if(r.wrap&&XC(r)){for(;d<32;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if(c!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=ax;break}c=0,d=0}r.mode=29;case 29:k=1;break e;case ax:k=-3;break e;case 31:return-4;default:return ix}return e.next_out=a,e.avail_out=u,e.next_in=o,e.avail_in=s,r.hold=c,r.bits=d,(r.wsize||h!==e.avail_out&&r.mode<ax&&(r.mode<27||4!==t))&&mx(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=XC(r)?tx(r.check,i,h,e.next_out-h):ex(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===ox?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===h||4===t)&&0===k&&(k=-5),k},KC.inflateEnd=function(e){if(!e||!e.state)return ix;var t=e.state;return t.window&&(t.window=null),e.state=null,0},KC.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?ix:(r.head=t,t.done=!1,0):ix},KC.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?ix:11===r.mode&&ex(1,t,n,0)!==r.check?-3:mx(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,0):ix},KC.inflateInfo="pako inflate (from Nodeca project)";var gx={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 yx=KC,Sx=ew,bx=yC,Ex=gx,kx=Xw,Tx=AC,Ix=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},Ax=Object.prototype.toString;function Rx(e){if(!(this instanceof Rx))return new Rx(e);this.options=Sx.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 Tx,this.strm.avail_out=0;var r=yx.inflateInit2(this.strm,t.windowBits);if(r!==Ex.Z_OK)throw new Error(kx[r]);if(this.header=new Ix,yx.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=bx.string2buf(t.dictionary):"[object ArrayBuffer]"===Ax.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=yx.inflateSetDictionary(this.strm,t.dictionary))!==Ex.Z_OK))throw new Error(kx[r])}function wx(e,t){var r=new Rx(t);if(r.push(e,!0),r.err)throw r.msg||kx[r.err];return r.result}Rx.prototype.push=function(e,t){var r,n,i,o,a,s=this.strm,u=this.options.chunkSize,c=this.options.dictionary,d=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?Ex.Z_FINISH:Ex.Z_NO_FLUSH,"string"==typeof e?s.input=bx.binstring2buf(e):"[object ArrayBuffer]"===Ax.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 Sx.Buf8(u),s.next_out=0,s.avail_out=u),(r=yx.inflate(s,Ex.Z_NO_FLUSH))===Ex.Z_NEED_DICT&&c&&(r=yx.inflateSetDictionary(this.strm,c)),r===Ex.Z_BUF_ERROR&&!0===d&&(r=Ex.Z_OK,d=!1),r!==Ex.Z_STREAM_END&&r!==Ex.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==Ex.Z_STREAM_END&&(0!==s.avail_in||n!==Ex.Z_FINISH&&n!==Ex.Z_SYNC_FLUSH)||("string"===this.options.to?(i=bx.utf8border(s.output,s.next_out),o=s.next_out-i,a=bx.buf2string(s.output,i),s.next_out=o,s.avail_out=u-o,o&&Sx.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(Sx.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!==Ex.Z_STREAM_END);return r===Ex.Z_STREAM_END&&(n=Ex.Z_FINISH),n===Ex.Z_FINISH?(r=yx.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Ex.Z_OK):n!==Ex.Z_SYNC_FLUSH||(this.onEnd(Ex.Z_OK),s.avail_out=0,!0)},Rx.prototype.onData=function(e){this.chunks.push(e)},Rx.prototype.onEnd=function(e){e===Ex.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Sx.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},NC.Inflate=Rx,NC.inflate=wx,NC.inflateRaw=function(e,t){return(t=t||{}).raw=!0,wx(e,t)},NC.ungzip=wx;var Cx={};(0,ew.assign)(Cx,tw,NC,gx);var xx,Px=Cx,Ox="BytePlusRTC",Dx=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},Mx=function(){function e(t){qd(this,e),sd(this,"storeName",void 0),sd(this,"pendingList",[]),this.storeName=t,!$R()&&Dx()&&this._checkAndCreateStore(t)}var t,r;return Kd(e,[{key:"_checkAndCreateStore",value:function(t,r){var n=this;e.db&&e.db.close();var i=r?Dx().open(Ox,r):Dx().open(Ox);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=Em(Sm().mark((function e(t){var r,i,o,a;return Sm().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 X_((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=Em(Sm().mark((function e(t,r){var n;return Sm().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 X_((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=Em(Sm().mark((function e(t){var r;return Sm().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 X_((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}();sd(Mx,"db",void 0),sd(Mx,"state","init");var Nx,Lx={product_line:"rtc",report_version:"5",os:"web",user_agent:$R()?"":null===(xx=navigator)||void 0===xx?void 0:xx.userAgent,platform:"web",product:"webrtc",app_state:"active"},Ux="ReportErrorBuffer",Vx=function(){function e(){qd(this,e),sd(this,"_buffer",new Mx(Ux))}var t,r;return Kd(e,[{key:"set",value:(r=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._buffer.put(t,Ux);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"get",value:(t=Em(Sm().mark((function e(){var t;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.prev=1,e.next=4,this._buffer.get(Ux);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}(),Fx=function(){function e(){var t=this;qd(this,e),sd(this,"report_common",Lx),sd(this,"dataBuffer",[]),sd(this,"posting",!1),sd(this,"sucSendTimer",void 0),sd(this,"preSucTime",0),sd(this,"errSendTimer",void 0),sd(this,"errSendDelay",100),sd(this,"errSendBuffer",void 0),sd(this,"_logServerUrl",void 0),sd(this,"_retryCount",0),$R()||(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 Kd(e,[{key:"setUrl",value:function(e){this._logServerUrl=e}},{key:"setCommonStats",value:function(e){this.report_common=pb(this.report_common,e)}},{key:"enableErrorBuffer",value:function(){this.errSendBuffer=new Vx,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=Rm(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||GE(r=this.dataBuffer).call(r,0,4e3),header:cd(cd({},this.report_common),{},{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,u;if(e||(i.posting=!1),200===a.status||304===a.status)try{r=JSON.parse(a.responseText)}catch(ZH){n=ZH}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;pP(Rm(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===(u=i.errSendBuffer)||void 0===u||u.set(Kk(i.dataBuffer)),t?i._send():i._errSend()}},a.open("POST",this._logServerUrl,!0),e||(this.posting=!0),!$R()&&vk(n=location.search).call(n,"_rtc_debug_"))a.send(ZE(o));else{var s=Px.gzip(ZE(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=Em(Sm().mark((function e(){var t,r,n=this;return Sm().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}(),Bx=new Fx,jx=function(){function e(t){qd(this,e),sd(this,"report_id",0),sd(this,"modify_ids",{}),this.id=t}return Kd(e,[{key:"report",value:function(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=cd(cd(cd({event_key:e,report_id:this.report_id++,rtc_timestamp:Date.now()},this.modify_ids),t),{},{common_extra_info:ZE(i)});(Bx.push(o),$R())||(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,this.id,o))}},{key:"set",value:function(e){this.modify_ids=pb(this.modify_ids,e)}},{key:"destroy",value:function(){}}]),e}(),Gx=Us("Array").keys,zx=fn,Hx=We,Xx=ae,Kx=Gx,qx=Array.prototype,Yx={DOMTokenList:!0,NodeList:!0},Wx=function(e){var t=e.keys;return e===qx||Xx(qx,e)&&t===qx.keys||Hx(Yx,zx(e))?Kx:t},Qx="@byted/ve-rtc",Jx="@byted/ve-rtc-cache-size",Zx=function(){function e(){qd(this,e),sd(this,"storeKey",void 0),sd(this,"logLevel",void 0),sd(this,"LogfileSize",void 0),sd(this,"db",void 0),sd(this,"logId",void 0),sd(this,"cacheLog",void 0),sd(this,"cachedSize",void 0),sd(this,"preCacheTime",void 0),sd(this,"timer",void 0),sd(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 Kd(e,[{key:"_createStore",value:function(){var e=this;if(!$R()&&window.indexedDB){var t=indexedDB.open("@byted/ve-rtc");t.onupgradeneeded=function(){t.result.createObjectStore(Qx);try{localStorage.removeItem(Jx)}catch(ZH){}},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(Jx);if(t)this.cachedSize=+t;else $I(this).call(this).then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(ZH){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(Jx,"".concat(this.cachedSize))}catch(ZH){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(Qx,e).objectStore(Qx)}},{key:"set",value:function(e){var t=this;return new X_((function(r,n){if("none"===t.logLevel)return r();var i;if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+=Rm(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,u,c,d,l=Rm(i="".concat(a.result||"")).call(i,t.cacheLog),h=e?Rm(s=Rm(u="".concat(l?"\n\n":"")).call(u,t.logId,": ")).call(s,e):"";o.put(Rm(c="".concat(l)).call(c,h),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize([Rm(d="".concat(t.cacheLog)).call(d,h)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(p){var v;if(!e)return n(p);t.cacheLog+=Rm(v="\n\n".concat(t.logId,": ")).call(v,e),t.logId++,n(p)}},a.onerror=function(r){var i;if(!e)return n(r);t.cacheLog+=Rm(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new X_((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 X_((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 Wx(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 X_((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 X_((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,"+(t||""),r.click()}))}}]),e}(),$x=new Zx,eP="[VERTC]",tP=["#0050b3","#0050b3","#0050b3","#0050b3","#0050b3"],rP="undefined"!=typeof window&&vk(Nx=window.location.search).call(Nx,"_rtc_debug_"),nP=function(){function e(t,r,n){qd(this,e),sd(this,"_indent",void 0),sd(this,"_module",void 0),sd(this,"_id",void 0),this._module=t,this._indent=r}return Kd(e,[{key:"print",value:function(e){for(var t,r,n,i,o,a,s,u=arguments.length,c=new Array(u>1?u-1:0),d=1;d<u;d++)c[d-1]=arguments[d];var l=c.shift();try{var h,v,p,f,_=Rm(h=[]).call(h,c),m="".concat(l).replace(/\%o/gi,(function(){var e=_.shift();return ZE(e)}));$x.set(Rm(v=Rm(p=Rm(f="".concat(eP,"[").concat(this._module,".")).call(f,e,"] ")).call(p,m," ")).call(v,YE(_).call(_,(function(e){return ZE(e)})).join(", ")))}catch(ZH){}if(rP){for(var g="",y=0;y<this._indent;y++)g+=" ";(t=console).log.apply(t,Rm(r=[Rm(n=Rm(i=Rm(o=Rm(a=Rm(s="%c".concat(iP(),"-")).call(s,eP)).call(a,g,"[")).call(o,this._module,".")).call(i,e,"] ")).call(n,l),"color:".concat(tP[this._indent],";")]).call(r,c))}}}]),e}(),iP=function(){var e=new Date;return e.toTimeString().split(" ")[0]+":"+e.getMilliseconds()},oP=new nP("MessageReportor",1),aP=function(){function e(t){qd(this,e),sd(this,"_preTime",Date.now()),sd(this,"_one2oneNum",0),sd(this,"_one2manyNum",0),sd(this,"_one2oneMsgCache",new FS),sd(this,"_one2manyMsgCache",new FS),sd(this,"roomId",""),sd(this,"userId",""),sd(this,"rtsSessionId",""),this.id=t}return Kd(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,cd({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,cd(cd({},r),t))}},{key:"cacheCustomMsg",value:function(t){var r;this._one2manyMsgCache.set(t.msg_id,cd({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,cd(cd({},r),t))}},{key:"reportP2PMsg",value:function(e){var t,r=this._one2oneMsgCache.get(e);r&&(oP.print("reportP2PMsg",r.type,ZE(r)),null===(t=mP(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportOne2ManyMsg",value:function(e){var t,r=this._one2manyMsgCache.get(e);r&&(oP.print("reportOne2ManyMsg",r.type,ZE(r)),null===(t=mP(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)||"",oP.print("reportMsgRecv",t.type,ZE(t)),null===(n=mP(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}();sd(aP,"config",void 0);var sP=new FS,uP={_cache:sP,setConfig:function(e){oP.print("setConfig","get config: "+ZE(e)),aP.config=e},setRtsSessionId:function(e,t){var r=sP.get(e);r&&(r.rtsSessionId=t)},createRTSMsgReportor:function(e){var t=sP.get(e)||new aP(e);return sP.set(e,t),t},destroyRTSMsgReportor:function(e){var t=sP.get(e);t&&(t.destroy(),sP.delete(e))},setRoomId:function(e,t){var r=sP.get(e);r&&(r.roomId=t||"")},setUserId:function(e,t){var r=sP.get(e);r&&(r.userId=t||"")},samplingP2PMsg:function(e,t){var r=sP.get(e);if(null!=r&&r.needReport("one2one")){var n,i=Rm(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&&t.report_msg_id&&(null===(n=sP.get(e))||void 0===n||n.updateP2PMsg(Rm(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&&t.report_msg_id){var n,i,o=sP.get(e);null==o||o.updateP2PMsg(Rm(n="".concat(t.from)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportP2PMsg(Rm(i="".concat(t.from)).call(i,t.report_msg_id))}},samplingOne2ManyMsg:function(e,t,r){var n,i=sP.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:Rm(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&&t.report_msg_id){var n,i=sP.get(e),o=t.to?"one2one":"one2many";null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Rm(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&&t.report_msg_id){var n,i,o=sP.get(e);if(o)null==o||o.updateOne2ManyMsg(Rm(n="".concat(t.clientId)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportOne2ManyMsg(Rm(i="".concat(t.clientId)).call(i,t.report_msg_id))}},updateOne2ManyMsgReq:function(e,t,r){if(t.enable_report&&t.report_msg_id){var n,i=sP.get(e);if(i)i.updateOne2ManyMsg(Rm(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&&t.report_msg_id){var n,i=sP.get(e);null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Rm(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})}}},cP=function(){function e(t){qd(this,e),sd(this,"_timer",void 0),sd(this,"userMessage",{}),sd(this,"roomMessage",{}),this.id=t,this._setTimer()}return Kd(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=mP(this.id))||void 0===e||e.report("rtc_message_statistics",{dc_user_message:YE(t=an(this.userMessage)).call(t,(function(e){return n.userMessage[e]})),dc_room_message:YE(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[Rm(r="".concat(t,"-")).call(r,e)]||(this.userMessage[Rm(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: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[Rm(n="".concat(t,"-")).call(n,e)].dc_send_total++,r)&&this.userMessage[Rm(i="".concat(t,"-")).call(i,e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){var r;this._checkInitUserMessage(e,t),this.userMessage[Rm(r="".concat(t,"-")).call(r,e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n,i=this.userMessage[Rm(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)&&(vk(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[Rm(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: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}(),dP=function(e){Bx.setCommonStats(e)},lP=function(e){Bx.setUrl(e)},hP=new jx("global"),vP=function(e,t,r){hP.report("rtc_sdk_api_call",{sdk_api_name:e,error_code:t,message:r})},pP=function(e,t,r){hP.report("rtc_error",{message:e,error_code:t},r)},fP=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;hP.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)},_P=new FS,mP=function(e){return _P.get(e)};function gP(){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,u,c=this.engineId||this.id,d={};(t.forEach((function(e,t){d[e]=o[t]})),"joinRoom"===r)&&(null===(s=mP(c))||void 0===s||s.set({room_id:o[1],user_id:null===(u=o[2])||void 0===u?void 0:u.userId}));null===(e=mP(c))||void 0===e||e.report("rtc_sdk_api_call",{sdk_api_name:r,message:ZE(bP(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 yP(c,r,[e||{}]),e})).catch((function(e){throw yP(c,r,e.message,e.code),e})):(yP(c,r,[l||{}]),l)}}}}var yP=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:ZE(Array.isArray(r)?bP(r):r)};o&&(a.room_id=o),null===(n=mP(e))||void 0===n||n.report("rtc_sdk_callback",a)},SP=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=mP(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 bP(e){return YE(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 u,c,d,l,h=new DataView(o),v=YE(u=Hk({length:5})).call(u,(function(e,t){return h.getUint8(t)})),p=YE(c=YE(d=Hk({length:5})).call(d,(function(e,t){return a-1-t})).reverse()).call(c,(function(e){return h.getUint8(e)}));s=Rm(l=[]).call(l,Kk(v),["..."],Kk(p))}else s=Hk(new Uint8Array(o));return Rm(n=Rm(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return YE(t).call(t,e);if(vk(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 EP,kP,TP,IP,AP,RP,wP,CP,xP=function(e){var t,r=mP(e.engineId),n={keys:Wx(e),labelSelector:"",sdkVersion:e.sdkVersion,deviceType:"web",appId:e.appId},i=YE(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:ZE(n),elapse:0,host:i.join(","),type:"request",config_id:"",enable_cloud_proxy:!1});var o=YE(i).call(i,function(){var e=Em(Sm().mark((function e(t,r){var i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"POST",body:ZE(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 X_((function(e){(function(e){return new X_((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:ZE(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})}))}))},PP=new TextDecoder,OP=new TextEncoder,DP=function(){return ZR()},MP=function(){return Date.now()};function NP(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 u=new e(t),c=0,d=0,l=n;d<l.length;d++){var h=l[d];u.set(h,c),c+=h.length}return u}var LP=function(){return"undefined"==typeof window},UP=function(){function e(){qd(this,e)}var t,r;return Kd(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=gR(t);n<i.length;n++){var o=WT(i[n],2),a=o[0],s=o[1];null!==s&&"object"===Ml(s)?e.merge(t[a],r[a]):void 0!==r[a]&&(t[a]=r[a])}}},{key:"ab2str",value:function(e){return PP.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 OP.encode(e).buffer}},{key:"ab2b64str",value:(r=Em(Sm().mark((function e(t){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new X_((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=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch("data:application/octet;base64,"+t).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();function VP(){var e="none";return LP()||(null!==window.navigator.userAgent.match("Firefox")?e="mozilla":null!==window.navigator.userAgent.match("Chrome")?(e="chrome-stable",null!==window.navigator.userAgent.match("Electron")&&(e="electron")):(null!==window.navigator.userAgent.match("Safari")||null!==window.navigator.userAgent.match("AppleWebKit"))&&(e="safari")),e}var FP=function(){if("chrome-stable"===VP()){var e=window.navigator.userAgent.match(/Chrome\/([\d.]+)/);if(e&&e.length>1)if(Number(e[1].split(".")[0])<114)return!0}return!1}(),BP="mozilla"===VP(),jP="safari"===VP(),GP=0,zP=!LP()&&(null===(EP=navigator.userAgent.match(/version\/(\d+)/i))||void 0===EP?void 0:EP[1]);jP&&zP&&(GP=+zP);var HP=!LP()&&(null===(kP=navigator.userAgent.match(/Firefox\/(\d+)/i))||void 0===kP?void 0:kP[1]);BP&&HP&&(GP=+HP);var XP=GP,KP=GP,qP=!LP()&&!!/(iPhone|iPad|iPod)/i.exec(navigator.userAgent);!LP()&&/(iPhone|iPod)/i.exec(navigator.userAgent);var YP=!LP()&&(!!/(iPad)/i.exec(navigator.userAgent)||/Macintosh/i.test(navigator.userAgent)&&"ontouchend"in document),WP=!LP()&&/MicroMessenger/i.test(navigator.userAgent),QP=!LP()&&/Android/i.test(navigator.userAgent),JP=!LP()&&vk(TP=navigator.userAgent.toLowerCase()).call(TP,"mobile"),ZP=0,$P=!LP()&&(null===(IP=navigator.userAgent.match(/chrome\/(\d+)/i))||void 0===IP?void 0:IP[1]);$P&&(ZP=+$P);var eO=ZP,tO=null!==(AP=!LP()&&(null===(RP=navigator.userAgent.match(/ ([\d_]+) like Mac OS X/i))||void 0===RP||null===(wP=RP[1])||void 0===wP?void 0:YE(CP=wP.split("_")).call(CP,(function(e){return Wm(e)}))))&&void 0!==AP?AP:[],rO=!LP()&&/CriOS/i.test(navigator.userAgent);function nO(){for(var e,t,r=(+FR(e=ym(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=FR(r).call(r,28,"1").split(""),i=[];n.length;)i.push(GE(n).call(n,0,7));return YE(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return jR(r+e.join(""),2)}))}!LP()&&/SM-\w+/i.test(navigator.userAgent);var iO=function(){return Math.floor(65535*Math.random())};function oO(e){return"string"==typeof e&&_E(e).call(e,"__web__rtc__rtt__")>-1}var aO=function(){var e=Em(Sm().mark((function e(){var t,r,n,i=arguments;return Sm().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)}}(),sO=function(e){return new X_((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 uO(e){return+Math.max(-127,10*XR(Math.pow(e/255,2))).toFixed(2)}function cO(e){return(e&Sd.AUDIO)===Sd.AUDIO}function dO(e){return(e&Sd.VIDEO)===Sd.VIDEO}function lO(e){var t={};return an(e).forEach((function(r){"object"===Ml(e[r])?t[r]=lO(e[r]):aR(r).call(r,"_")||(t[r]=e[r])})),t}function hO(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 vO(e){return null==e?"undefined | null":"string"==typeof e?e:ZE({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function pO(e){return void 0===e}function fO(e){return function(t,r,n){var i=n.value;n.value=function(){var t;console.warn(Rm(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 _O(e){console.warn("[RTC WebSDK]: "+e)}function mO(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 gO="BytePlus",yO="RTC_DEVICE_ID",SO="RTC_ACCESS_NODE",bO="RTC_ACCESS_URLS",EO="ENGINE_WEB_CONFIG",kO=function(){function e(){qd(this,e)}return Kd(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,ZE(n)),!0}catch(i){return!1}}},{key:"delete",value:function(e){try{return localStorage.removeItem(e),!0}catch(t){return!1}}}]),e}(),TO=function(e){wI(r,e);var t=XI(r);function r(){return qd(this,r),t.apply(this,arguments)}return Kd(r,[{key:"getDeviceId",value:function(){if(LP())return"";var e=this.get(yO);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 dP({device_id:e}),this.set(yO,e),e}},{key:"getAccessNode",value:function(e){var t;return this.get(Rm(t="".concat(SO,"_").concat(e,"-")).call(t,gO))}},{key:"setAccessNode",value:function(e,t,r){var n;return this.set(Rm(n="".concat(SO,"_").concat(e,"-")).call(n,gO),t,1e3*r)}},{key:"clearAccessNode",value:function(e){var t;this.delete(Rm(t="".concat(SO,"_").concat(e,"-")).call(t,gO))}},{key:"getAccessUrls",value:function(){return this.get("".concat(bO,"-").concat(gO))}},{key:"setAccessUrls",value:function(e){var t=YE(e).call(e,(function(e){var t,r=e.host,n=e.path;return Rm(t="https://".concat(r)).call(t,n)}));return this.set("".concat(bO,"-").concat(gO),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(bO,"-").concat(gO))}},{key:"getEngineWebConfig",value:function(e,t){var r,n,i,o=Rm(r=Rm(n="".concat(e,"_")).call(n,t,"_")).call(r,this.getDeviceId()),a=this.get(EO);return(null==a||null===(i=oE(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=Rm(n=Rm(i="".concat(e,"_")).call(i,t,"_")).call(n,this.getDeviceId()),a=this.get(EO)||[];return(a=Gs(a).call(a,(function(e){return e.key!==o}))).push({key:o,config:r}),this.set(EO,ym(a).call(a,-5))}}}]),r}(kO),IO=new TO,AO="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function RO(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://"+e),"".concat(e,"/dispatch/v1/AccessInfo?Action=GetAccessInfo")}var wO="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",CO="rtc.rtcplus.com".split(","),xO={VERSION:"4.52.4",ICE_CONFIG_REQUEST_URLS_INTERNAL:YE(AO).call(AO,RO),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:wO,CONFIG_REQUEST_DOMAINS:CO,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,ENABLE_REPORT_ERROR_BUFFER:!1};function PO(e,t){var r;if(vP("setParameter",0,Rm(r="key: ".concat(e,", value: ")).call(r,t)),"VERSION"!==e){if("ICE_CONFIG_REQUEST_URLS"===e)return"string"==typeof t&&(t=[t]),void(xO.ICE_CONFIG_REQUEST_URLS=YE(t).call(t,RO));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(xO.FORCE_ENABLED_REPORT_CALLBACKS=t);if("LOG_SERVER_URL"===e){var n=t===Td.overseas?"https://web-log-report.rtcplus.com/video/v1/webrtc_log/":t===Td.domestic?wO:"string"==typeof t?t:void 0;n&&(xO.LOG_SERVER_URL=n,lP(n))}else if("OVERSEA"===e)return dP({extra_is_oversea:t?"1":"0"}),void(xO.OVERSEA=t);"DEVICE_ID"===e&&IO.setDeviceId(t),"ENABLE_REPORT_ERROR_BUFFER"===e&&t&&Bx.enableErrorBuffer(),xO[e]=t}else dP({product:t});else dP({platform:t})}}function OO(e){return"DEVICE_ID"===e?IO.getDeviceId():xO[e]}function DO(e,t,r){var n,i,o,a,s,u,c,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)||Rd.PREV_FRAME,canvas:{bgColor:(null===(u=r.layout)||void 0===u?void 0:u.backgroundColor)||"#000000",bgImage:(null===(c=r.layout)||void 0===c?void 0:c.backgroundImage)||""},regions:(null===(d=r.layout)||void 0===d||null===(l=d.regions)||void 0===l?void 0:YE(l).call(l,(function(e){return{roomId:e.roomId,userId:e.userId,alterImage:e.alertImage||"",alpha:!e.alpha||+e.alpha>1||+e.alpha<=0?1:+e.alpha,x:!e.x||+e.x>=1||+e.x<0?0:+e.x,y:!e.y||+e.y>=1||+e.y<0?0:+e.y,w:!e.w||+e.w>1||+e.w<=0?1:+e.w,h:!e.h||+e.h>1||+e.h<=0?1:+e.h,zorder:!e.zorder||+e.zorder<0||+e.zorder>100?0:+e.zorder,renderMode:void 0===e.renderMode?1:e.renderMode,streamType:e.isScreenStream?1:0,mediaType:e.mediaType||0,sourceCrop:e.sourceCrop}})))||[]}}}}var MO={width:640,height:480,frameRate:15,maxKbps:600},NO={width:1920,height:1080,frameRate:15,maxKbps:3e3};function LO(e,t){if("boolean"!=typeof e)throw new cR(sR.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}function UO(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 cR(sR.INVALID_PARAMS,Rm(i=Rm(o="Invalid ".concat(t,": the value range is [")).call(o,r,", ")).call(i,n,"]. integer only"));throw a}}function VO(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 cR(sR.INVALID_PARAMS,"".concat(t," cannot be empty"));if(!HO(e,i,o))throw new cR(sR.INVALID_PARAMS,Rm(r=Rm(n="Invalid ".concat(t,": The value should be string type. Length of the string: [")).call(n,i,",")).call(r,o,"]"))}function FO(e,t,r){var n;if(!vk(r).call(r,e))throw new cR(sR.INVALID_PARAMS,Rm(n="Invalid ".concat(t,": The value can only be set as ")).call(n,ZE(r)))}function BO(e){if(!(e instanceof MediaStreamTrack))throw new cR(sR.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}function jO(e,t){if(XO(e))throw new cR(sR.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function GO(e,t){if(!(e instanceof ArrayBuffer))throw new cR(sR.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function zO(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 HO(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 XO(e){return null==e}function KO(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new cR(sR.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function qO(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new cR(sR.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function YO(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new cR(sR.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function WO(e){jO(e,"userInfo"),qO(e.userId),XO(e.extraInfo)||VO(e.extraInfo,"userInfo.extraInfo",1,200)}function QO(e){jO(e,"roomConfig"),LO(e.isAutoPublish,"roomConfig.isAutoPublish"),LO(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),LO(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo"),XO(e.roomProfileType)||FO(e.roomProfileType,"roomConfig",[Od.communication,Od.chat,Od.chatRoom,Od.coHost,Od.meeting,Od.classRoom])}function JO(e){jO(e,"videoPlayerOption")}function ZO(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 cR(sR.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:UP.str2ab(ZE(e)))||void 0===t?void 0:t.byteLength)>1e3*r)throw new cR(sR.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function $O(e){var t,r=OO("FORCE_ENABLED_REPORT_CALLBACKS");return!(null==r||!vk(r).call(r,e))||!vk(t=[Hd.onRemoteStreamStats,Hd.onLocalStreamStats,Hd.onAudioVolumeIndication,Hd.onLocalAudioPropertiesReport,Hd.onRemoteAudioPropertiesReport]).call(t,e)}function eD(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new cR(sR.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}function tD(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 cR(sR.INVALID_PARAMS,"".concat(t," is not a valid ConstrainULong"))}}function rD(e){var t,r=YT(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;UO(null==n?void 0:n.maxKbps,"maxKbps"),tD(null==n?void 0:n.width,"width"),tD(null==n?void 0:n.height,"height"),tD(null==n?void 0:n.frameRate,"frameRate")}}catch(i){r.e(i)}finally{r.f()}}function nD(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 UO(e,t,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),e=(e=e>r?e:r)<n?e:n}var iD={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),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],s]:e._events[u].push(s):(e._events[u]=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?ym(n).call(n,1):n);return xs?Rm(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 u,c,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(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];d.fn.apply(d.context,u)}else{var h,v=d.length;for(c=0;c<v;c++)switch(d[c].once&&this.removeListener(e,d[c].fn,void 0,!0),l){case 1:d[c].fn.call(d[c].context);break;case 2:d[c].fn.call(d[c].context,t);break;case 3:d[c].fn.call(d[c].context,t,n);break;case 4:d[c].fn.call(d[c].context,t,n,i);break;default:if(!u)for(h=1,u=new Array(l-1);h<l;h++)u[h-1]=arguments[h];d[c].fn.apply(d[c].context,u)}}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 u=0,c=[],d=s.length;u<d;u++)(s[u].fn!==t||i&&!s[u].once||n&&s[u].context!==n)&&c.push(s[u]);c.length?this._events[o]=1===c.length?c[0]:c: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}(iD);var oD=iD.exports,aD=new nP("VERTC",0),sD=function(e){wI(r,e);var t=XI(r);function r(){return qd(this,r),t.apply(this,arguments)}return Kd(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=AI(TI(r.prototype),"emit",this)).call.apply(n,Rm(i=[this,e]).call(i,a))}catch(ZH){return aD.print("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,ZH),console.error(ZH),Boolean(t)}}}]),r}(iD.exports.EventEmitter),uD=P,cD=tr,dD=$,lD=ZT,hD=Qt,vD=R,pD=mu,fD=V;Rr({target:"Reflect",stat:!0,forced:i((function(){var e=function(){},t=hD.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],u=vD.f(cD(t),r);if(!u){if(dD(o=pD(t)))return e(o,r,n,s);u=fD(0)}if(lD(u)){if(!1===u.writable||!dD(s))return!1;if(i=vD.f(s,r)){if(i.get||i.set||!1===i.writable)return!1;i.value=n,hD.f(s,r,i)}else hD.f(s,r,fD(0,n))}else{if(void 0===(a=u.set))return!1;uD(a,s,n)}return!0}});var _D=ee.Reflect.set;function mD(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],_E(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],_E(t).call(t,r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var gD,yD=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}(yD||{}),SD=function(e){return e.PushLimitWarn="PushLimitWarn",e}(SD||{}),bD=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}(bD||{}),ED=function(e){return e.RSCP="RSCP",e.RTT="RTT",e.SSC="SSC",e}(ED||{}),kD=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e}(kD||{}),TD=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(TD||{}),ID=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(ID||{}),AD=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(AD||{}),RD=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}(RD||{}),wD=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}(wD||{}),CD=(sd(gD={},0,[0,"success"]),sd(gD,1,[sR.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),sd(gD,2,[sR.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),sd(gD,3,[sR.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),sd(gD,4,[sR.USER_MESSAGE_NO_RECEIVER,"cannot find relay path."]),sd(gD,5,[sR.USER_MESSAGE_EXCEED_QPS,"cannot find relay path."]),sd(gD,17,[sR.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),sd(gD,18,[sR.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),sd(gD,100,[sR.USER_MESSAGE_NOT_JOIN,"not join room"]),sd(gD,105,[sR.USER_MESSAGE_NOT_LOGIN,"not login."]),sd(gD,106,[sR.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),sd(gD,1e3,[sR.USER_MESSAGE_UNKNOWN,"unknown."]),gD),xD=["msg"],PD=new nP("DataChannelSignaling",3),OD=["onSpeakerChange"],DD=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}(DD||{}),MD=function(e){wI(a,e);var t,r,n,i,o=XI(a);function a(e,t){var r;return qd(this,a),sd(QT(r=o.call(this)),"_singlingCache",new FS),sd(QT(r),"_p2pCache",new FS),sd(QT(r),"_rttIds",{}),sd(QT(r),"_p2pMessageId",0),sd(QT(r),"_clearDataChannelListener",void 0),sd(QT(r),"_monitor",void 0),r.id=e,r._dataChannel=t,r._clearDataChannelListener=r._handleHandler(),r._monitor=mP(e),window.__rtc_mock_signaling__=r.emit.bind(QT(r)),r}return Kd(a,[{key:"destroy",value:function(){this._dataChannel&&(this._clearDataChannelListener(),this._dataChannel.close()),this._singlingCache.clear(),this._p2pCache.clear(),this._p2pMessageId=0,this._rttIds={}}},{key:"sendSignaling",value:function(e,t,r){var n,i=this;return null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:ZE(t),signaling_event:"call-".concat(e),signaling_type:"Send",stream_id:t.streamId,stream_user_id:t.streamUserId,direction:"up"}),new X_((function(n,o){var a,s=i._genHeader(r);s.id=nO();var u=s.id.join("-"),c="customMessage"===e;c&&uP.samplingOne2ManyMsg(i.id,+s.id.join(""),t);var d=setTimeout((function(){i._singlingCache.delete(u),o(new cR(sR.TIME_OUT,"".concat(e," message time out"))),c&&uP.updateOne2ManyMsgAck(i.id,t,999)}),6e4);i._singlingCache.set(u,{signalingType:e,success:function(e){clearTimeout(d),n(e),c&&uP.updateOne2ManyMsgAck(i.id,t,0)},error:function(e){clearTimeout(d),o(e),c&&uP.updateOne2ManyMsgAck(i.id,t,e.code)}}),PD.print("Signal",Rm(a=">>>>>> [".concat(e,"][")).call(a,u,"]"),t),i._sendMessage(e,s,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(i=Em(Sm().mark((function e(t,r){var n,i,o;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,i=mD(t,xD),o=n instanceof ArrayBuffer,e.t0=this,e.t1=uP,e.t2=this.id,e.t3=cd,e.t4=cd({ver:1,id:this._p2pMessageId++,time:Date.now(),dir:AD.SEND,type:RD.P2P,err:wD.SUCCESS},i),e.t5={},e.t6=o,!o){e.next=15;break}return e.next=12,UP.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 oO(e.msg)?this._rttIds[e.id]=e.id:e.dir===AD.SEND&&PD.print("_sendP2PMessage [DC Signaling p2p >>]",ZE(e)),new X_((function(n,i){var o=t._genHeader(cd(cd({needAck:!0,functionType:1},r),{},{id:nO()}));if(e.dir===AD.SEND){var a=setTimeout((function(){t._p2pCache.delete(e.id),i(new cR(sR.USER_MESSAGE_TIMEOUT,"P2P message timeout")),uP.updateP2PMsgAck(t.id,e,999)}),12e3);t._p2pCache.set(e.id,{success:function(r,i){clearTimeout(a),n(i),uP.updateP2PMsgAck(t.id,e,0)},error:function(r){var n;clearTimeout(a),uP.updateP2PMsgAck(t.id,e,r.err);var o=WT(CD[r.err]||[sR.USER_MESSAGE_UNKNOWN,Rm(n="err: ".concat(r.err,", msg: ")).call(n,r.msg)],2),s=o[0],u=o[1];i({err:r.err,code:s,message:r.msg||u})}})}try{t._sendMessage("p2p",o,e)}catch(s){throw s.code===sR.SIGNALING_CHANNEL_NOT_OPEN&&(s.code=sR.USER_MESSAGE_BROKEN),s}}))}},{key:"_sendMessage",value:function(e,t,r){var n;if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new cR(sR.SIGNALING_CHANNEL_NOT_OPEN,"DataChannel not open");var i=t.version+(+t.zip<<5)+(+t.encrypt<<6),o=+t.needAck+(+t.direction<<1)+(+t.functionType<<2)+(+t.binary<<6),a=UP.str2ab(ZE([e,r])),s=NP(Uint8Array,Rm(n=[i,o]).call(n,Kk(t.id||[])),new Uint8Array(a));this._dataChannel.send(s.buffer),"p2p"===e?uP.updateP2PMsgReq(this.id,r,s.buffer.byteLength):"customMessage"===e&&uP.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=Hk(ym(t).call(t,2,r))}return{header:o,data:ym(t).call(t,r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n,i,o=this._genHeader({needAck:!0,direction:1,id:YE(n=e.split("-")).call(n,(function(e){return+e}))});vk(OD).call(OD,t)||PD.print("Signal",Rm(i=">>>>>> [".concat(t,"-res][")).call(i,e,"]"));this._sendMessage("".concat(t,"-res"),o,r)}},{key:"_handleMessage",value:(n=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d;return Sm().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 Px.Inflate).push(o,!0),o=s.result),u=UP.ab2str(o),c=[],e.prev=8,c=JSON.parse(u),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,c,u,n,r),e.abrupt("break",26);case 21:return this.C2C(c,n,r),e.abrupt("break",26);case 23:return this.C2GW(a,c,u),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=Em(Sm().mark((function e(t,r,n,i,o){var a,s,u,c,d;return Sm().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(c=r[0],r=r[1],vk(OD).call(OD,c)||PD.print("Signal","<<<<<< ".concat(c),r,s),this._feedbackSignaling(s,c,c===bD.ON_CUSTOM_MESSAGE?cd(cd({},r),{},{message:""}):""),!r.binary||"string"!=typeof r.message){e.next=14;break}return e.next=13,UP.b64str2ab(r.message);case 13:r.message=e.sent;case 14:d=Date.now(),this.emit(c,cd({},r)),c===bD.ON_CUSTOM_MESSAGE&&uP.reportOne2ManyMsgRecv(this.id,r,{msg_size:i,recv_msg_ts:o,fwd_msg_ts:d}),null===(u=this._monitor)||void 0===u||u.report("rtc_signaling",{error_code:0,message:n,signaling_event:"on-".concat(c),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=Em(Sm().mark((function e(t,r,n){var i,o,a,s,u,c,d,l,h,v,p,f,_;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Array.isArray(t)&&(t=t[1]),u=null===(i=t)||void 0===i?void 0:i.id,this._rttIds[u]||(null===(o=t)||void 0===o?void 0:o.dir)===AD.FEEDBACK||oO(null===(a=t)||void 0===a?void 0:a.msg)?delete this._rttIds[u]:PD.print("Signal","<<<<<< p2p response",t),e.t0=t.dir,e.next=e.t0===AD.SEND?6:e.t0===AD.FEEDBACK?46:48;break;case 6:if(c=Date.now(),oO(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,p=d.to,f=d.from,_=""===v?l?bD.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:bD.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:l?bD.USER_BINARY_MESSAGE_RECEIVED:bD.USER_MESSAGE_RECEIVED,p){e.next=27;break}if(e.t1=this,e.t2=bD.ON_CUSTOM_MESSAGE,e.t3=f,e.t4=l,!l){e.next=21;break}return e.next=18,UP.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=cd,e.t11=cd({},t),e.t12={},!l){e.next=38;break}return e.next=35,UP.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(cd(cd({},t),{},{dir:AD.FEEDBACK,msg:""})),uP.reportP2PMsgRecv(this.id,t,{msg_size:r,recv_msg_ts:n,fwd_msg_ts:c}),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=WT(t,2),a=o[0],s=o[1],u=void 0===s?{}:s;if("RXMediaMsg"===a){var c,d=u.type,l=u.data;switch(null===(c=this._monitor)||void 0===c||c.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 v=JSON.parse(l);v.length&&this.emit(d,v[0])}catch(f){}break;case"SSC":try{var p=JSON.parse(l);p.length&&this.emit(d,p[0])}catch(f){}}}}}},{key:"_handleHandler",value:function(){var e=this,t=function(t){PD.print("_handleHandler","dataChannel close",t),e.emit("close",t)},r=function(t){PD.print("_handleHandler","dataChannel error",t),e.emit("close",t)},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 cd({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),PD.print("Signal",Rm(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===wD.SUCCESS?t.success(e.id,e):t.error(e))}}]),a}(iD.exports.EventEmitter),ND=function(){function e(){qd(this,e),sd(this,"xhr",void 0),sd(this,"isSending",void 0),sd(this,"timeout",void 0),this.isSending=!1}return Kd(e,[{key:"ajax",value:function(e){var t=this,r=e.method,n=e.url,i=e.body,o=void 0===i?{}:i,a=e.headers,s=void 0===a?{}:a,u=e.stringify,c=void 0===u||u;return new X_((function(e,i){t.isSending=!0;var a=new XMLHttpRequest;a.open(r,n,!0);for(var u=0,d=gR(s);u<d.length;u++){var l=WT(d[u],2),h=l[0],v=l[1];a.setRequestHeader(h,v)}a.onreadystatechange=function(){if(4===a.readyState)if(t.isSending=!1,200===a.status)e(JSON.parse(a.responseText));else{var r=a.statusText,n=a.status;if(a.responseText)try{var o=JSON.parse(a.responseText);o.errMessage&&(r=o.errMessage),o.code&&(n=o.code)}catch(s){}i({message:r,code:n})}},a.onabort=function(){i({code:0,message:"Request abort"})},a.onerror=function(e){t.isSending=!1,i({code:-1,message:a.responseText||"unknown"})},t.timeout&&(a.timeout=t.timeout),c&&(o=ZE(o)),a.send(o),t.xhr=a}))}},{key:"get",value:function(e,t){return this.ajax({method:"GET",url:e,headers:t})}},{key:"post",value:function(e,t,r,n){return this.ajax({method:"POST",url:e,body:t,headers:r,stringify:n})}},{key:"abort",value:function(){var e;null===(e=this.xhr)||void 0===e||e.abort()}}]),e}(),LD=new nP("ICE Request",3),UD=function(){function e(t){qd(this,e),sd(this,"_request",void 0),sd(this,"_monitor",void 0),this.id=t,this._request=new ND,this._monitor=mP(this.id)}var t,r,n;return Kd(e,[{key:"getAccessNode",value:(n=Em(Sm().mark((function e(t,r,n,i,o){var a;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(a=IO.getAccessNode(t))){e.next=9;break}if(this.getAccessNodeFromServer(t,r,n,i,o),SP(this.id,"es.R.node.cache",a),!Array.isArray(a)){e.next=8;break}return e.abrupt("return",X_.resolve(a));case 8:return e.abrupt("return",X_.resolve([a]));case 9:return e.abrupt("return",this.getAccessNodeFromServer(t,r,n,i,o));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i,o){return n.apply(this,arguments)})},{key:"getAccessNodeFromServer",value:(r=Em(Sm().mark((function e(t,r,n,i,o){var a,s,u,c,d=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=IO.getAccessUrls(),c=!0,SP(this.id,"es.R.req.cache.urls",u),(null===(a=u)||void 0===a?void 0:a.length)>0||(u=xO.ICE_CONFIG_REQUEST_URLS,c=!1,SP(this.id,"es.R.req.external.urls",u)),(null===(s=u)||void 0===s?void 0:s.length)>0||(u=xO.ICE_CONFIG_REQUEST_URLS_INTERNAL,c=!1,SP(this.id,"es.R.req.internal.urls",u)),e.abrupt("return",this.getICEConfigFromServer(u,t,r,n,i,o).then((function(e){var r=e.nodes;return IO.setAccessNode(t,r,e.ttl||11200),e.dispatchDomains&&IO.setAccessUrls(e.dispatchDomains),r})).catch((function(e){if(c)return SP(d.id,"es.R.req.fallback",""),IO.clearAccessUrls(),d.getAccessNodeFromServer(t,r,n,i);throw e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"getICEConfigFromServer",value:(t=Em(Sm().mark((function e(t,r,n,i,o,a){var s,u,c,d,l,h=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u={appID:r,deviceID:IO.getDeviceId(),connectSessionID:DP(),os:"web",sdkVersion:xO.VERSION,isOversea:xO.OVERSEA,expectedAddr:OO("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:o,expectedIDC:a},n&&i&&(u.feedbackInfo=[{feedbackIP:null===(c=i.publicIPs[0])||void 0===c?void 0:c.ip,feedbackReason:{type:"NODE_CHANGED",reason:n}}],delete u.expectedAddr),d=Date.now(),null===(s=this._monitor)||void 0===s||s.report("rtc_get_access",{error_code:0,message:ZE(u),elapse:0,type:"request",host:t.join(","),connect_session_id:u.connectSessionID}),l=YE(t).call(t,function(){var e=Em(Sm().mark((function e(t,r){var n,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,h._request.post(t,u);case 3:n=e.sent,e.next=9;break;case 6:throw e.prev=6,e.t0=e.catch(0),new cR(sR.ICE_SERVER_WRONG,"get ICE config failed",e.t0);case 9:if(200===n.code){e.next=11;break}throw new cR(sR.ICE_SERVER_WRONG,"get ICE config failed",{server_code:n.code,message:ZE(n)});case 11:if(i=n.nodes[0]){e.next=14;break}throw new cR(sR.ICE_SERVER_WRONG,"ICE config server return empty nodes",{code:n.code,message:ZE(n)});case 14:return e.abrupt("return",{result:n,firstNode:i,index:r});case 15:case"end":return e.stop()}}),e,null,[[0,6]])})));return function(t,r){return e.apply(this,arguments)}}()),e.abrupt("return",sO(l).then((function(e){var r,n=e.result;e.firstNode;var i=e.index;return null===(r=h._monitor)||void 0===r||r.report("rtc_get_access",{error_code:200,message:ZE(n),elapse:Date.now()-d,type:"response",host:t[i],connect_session_id:u.connectSessionID}),n})).catch((function(e){var r,n,i,o=null===(r=e[0])||void 0===r?void 0:r.error;throw null===(n=h._monitor)||void 0===n||n.report("rtc_get_access",{error_code:+((null==o?void 0:o.code)||(null==o?void 0:o.server_code)),message:null===(i=e[0])||void 0===i?void 0:i.message,elapse:Date.now()-d,type:"response",host:t.join(","),connect_session_id:u.connectSessionID},{error:ZE(o)}),e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,r,n,i,o,a){return t.apply(this,arguments)})},{key:"abort",value:function(){this._request.isSending&&(LD.print("abort","HTTP Request of [getICEConfigFromServer] abort"),this._request.abort())}}]),e}(),VD=hi.f("asyncIterator");function FD(e){var t,r,n,i=2;for(void 0!==fl&&(r=VD,n=Dl);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new BD(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function BD(e){function t(e){if(Object(e)!==e)return X_.reject(new TypeError(e+" is not an object."));var t=e.done;return X_.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(BD=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?X_.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?X_.reject(e):t(r.apply(this.s,arguments))}},new BD(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}];Ng("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Zg);var GD=ee.Set;Rr({target:"Set",stat:!0,forced:!0},{from:sy}),Rr({target:"Set",stat:!0,forced:!0},{of:cy});var zD=P,HD=Ce,XD=tr,KD=function(){for(var e=XD(this),t=HD(e.add),r=0,n=arguments.length;r<n;r++)zD(t,e,arguments[r]);return e};Rr({target:"Set",proto:!0,real:!0,forced:!0},{addAll:KD}),Rr({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:vy});var qD=fh,YD=tr,WD=Wt,QD=qD,JD=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=YD(this),r=QD(t),n=WD(e,arguments.length>1?arguments[1]:void 0);return!JD(r,(function(e,r){if(!n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var ZD=oe,$D=P,eM=Ce,tM=tr,rM=Ev,nM=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){var t=tM(this),r=new(rM(t,ZD("Set")))(t),n=eM(r.delete);return nM(e,(function(e){$D(n,r,e)})),r}});var iM=oe,oM=P,aM=Ce,sM=tr,uM=Wt,cM=Ev,dM=qD,lM=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=sM(this),r=dM(t),n=uM(e,arguments.length>1?arguments[1]:void 0),i=new(cM(t,iM("Set"))),o=aM(i.add);return lM(r,(function(e){n(e,e,t)&&oM(o,i,e)}),{IS_ITERATOR:!0}),i}});var hM=tr,vM=Wt,pM=qD,fM=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=hM(this),r=pM(t),n=vM(e,arguments.length>1?arguments[1]:void 0);return fM(r,(function(e,r){if(n(e,e,t))return r(e)}),{IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var _M=oe,mM=P,gM=Ce,yM=tr,SM=Ev,bM=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){var t=yM(this),r=new(SM(t,_M("Set"))),n=gM(t.has),i=gM(r.add);return bM(e,(function(e){mM(n,t,e)&&mM(i,r,e)})),r}});var EM=P,kM=Ce,TM=tr,IM=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){var t=TM(this),r=kM(t.has);return!IM(e,(function(e,n){if(!0===EM(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var AM=oe,RM=P,wM=Ce,CM=A,xM=tr,PM=fh,OM=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){var t=PM(this),r=xM(e),n=r.has;return CM(n)||(r=new(AM("Set"))(e),n=wM(r.has)),!OM(t,(function(e,t){if(!1===RM(n,r,e))return t()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var DM=P,MM=Ce,NM=tr,LM=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){var t=NM(this),r=MM(t.has);return!LM(e,(function(e,n){if(!1===DM(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var UM=Rr,VM=tr,FM=gn,BM=qD,jM=Dh,GM=E([].join),zM=[].push;UM({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=VM(this),r=BM(t),n=void 0===e?",":FM(e),i=[];return jM(r,zM,{that:i,IS_ITERATOR:!0}),GM(i,n)}});var HM=oe,XM=Wt,KM=P,qM=Ce,YM=tr,WM=Ev,QM=qD,JM=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=YM(this),r=QM(t),n=XM(e,arguments.length>1?arguments[1]:void 0),i=new(WM(t,HM("Set"))),o=qM(i.add);return JM(r,(function(e){KM(o,i,n(e,e,t))}),{IS_ITERATOR:!0}),i}});var ZM=Ce,$M=tr,eN=qD,tN=Dh,rN=TypeError;Rr({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=$M(this),r=eN(t),n=arguments.length<2,i=n?void 0:arguments[1];if(ZM(e),tN(r,(function(r){n?(n=!1,i=r):i=e(i,r,r,t)}),{IS_ITERATOR:!0}),n)throw rN("Reduce of empty set with no initial value");return i}});var nN=tr,iN=Wt,oN=qD,aN=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=nN(this),r=oN(t),n=iN(e,arguments.length>1?arguments[1]:void 0);return aN(r,(function(e,r){if(n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var sN=oe,uN=P,cN=Ce,dN=tr,lN=Ev,hN=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){var t=dN(this),r=new(lN(t,sN("Set")))(t),n=cN(r.delete),i=cN(r.add);return hN(e,(function(e){uN(n,r,e)||uN(i,r,e)})),r}});var vN=oe,pN=Ce,fN=tr,_N=Ev,mN=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){var t=fN(this),r=new(_N(t,vN("Set")))(t);return mN(e,pN(r.add),{that:r}),r}});var gN=GD,yN=new FS,SN=function(){var e=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new X_((function(e,r){var n=OO("STATS_SCALLBACK_SUPPORT");if("chrome-stable"===VP()&&void 0===window.InstallTrigger&&FP&&n)try{t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!vk(TN).call(TN,e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(cd(cd({},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(ZH){r(ZH)}else e({all:[],getTrackStats:function(){return[]}})})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),bN=function(){var e=Em(Sm().mark((function e(t){var r,n,i,o,a,s;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getStats();case 2:return i=e.sent,o={all:[]},a=new FS,i.forEach((function(e){var t=a.get(e.type)||new FS;t.set(e.id,e),a.set(e.type,t),o.all.push(e)})),s=function(e,t){e.forEach((function(e){var r,n,i,o,s,u,c=e.codecId,d=e.transportId,l=e.trackId,h=e.playoutId;if(null===(r=a.get(kN.codec))||void 0===r||r.forEach((function(e){e.id===c&&t.add(e)})),null===(n=a.get(kN.transport))||void 0===n||n.forEach((function(e){e.id===d&&(s=e,t.add(e))})),null===(i=a.get(kN.track))||void 0===i||i.forEach((function(e){e.id===l&&t.add(e)})),null===(o=a.get(kN.mediaPlayout))||void 0===o||o.forEach((function(e){e.id===h&&t.add(e)})),s){var v,p,f=s,_=f.localCertificateId,m=f.remoteCertificateId,g=f.selectedCandidatePairId;null===(v=a.get(kN.certificate))||void 0===v||v.forEach((function(e){(e.id===_||e.id===m)&&t.add(e)})),null===(p=a.get(kN.candidatePair))||void 0===p||p.forEach((function(e){e.id===g&&(u=e,t.add(e))}))}if(u){var y,S,b=u,E=b.localCandidateId,k=b.remoteCandidateId;null===(y=a.get(kN.localCandidate))||void 0===y||y.forEach((function(e){e.id===E&&t.add(e)})),null===(S=a.get(kN.remoteCandidate))||void 0===S||S.forEach((function(e){e.id===k&&t.add(e)}))}}))},null===(r=a.get(kN.mediaSource))||void 0===r||r.forEach((function(e){var t,r=new gN;r.add(e);var n=[];null===(t=a.get(kN.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=a.get(kN.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),s(n,r),o[e.trackIdentifier]=Hk(r)})),null===(n=a.get(kN.inboundRtp))||void 0===n||n.forEach((function(e){var t,r=new gN;r.add(e),null===(t=a.get(kN.remoteOutboundRtp))||void 0===t||t.forEach((function(t){t.localId===e.id&&r.add(t)})),s([e],r);var n,i=e.trackIdentifier;i||(null===(n=a.get(kN.track))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(i=t.trackIdentifier)})));o[i]=Hk(r)})),e.abrupt("return",o);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),EN=function(){var e=Em(Sm().mark((function e(t,r,n){var i,o,a,s,u,c;return Sm().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(!BP&&!jP){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=yN.get(t))||Date.now()-a.timestamp>150)&&(a={timestamp:Date.now(),statsPromise:bN(t),extraStatsPromise:SN(t)},yN.set(t,a)),e.next=14,a.statsPromise;case 14:if(s=e.sent,u=(i?s[i]:s.all)||[],n){e.next=21;break}return e.next=19,a.extraStatsPromise;case 19:c=e.sent,u=Rm(u).call(u,(i?c.getTrackStats(i):c.all)||[]);case 21:return e.abrupt("return",u);case 22:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}();VP();var kN=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}(kN||{}),TN=["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"],IN=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!LP()&&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,MN();case 5:if(e.t0=e.sent,!e.t0){e.next=10;break}return e.next=9,DN();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)}}(),AN=function(){var e=Em(Sm().mark((function e(){var t;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.next=3,MN();case 3:if(e.t0=e.sent,!e.t0){e.next=8;break}return e.next=7,DN();case 7:e.t0=e.sent;case 8:if(!e.t0){e.next=10;break}t.push("H264");case 10:return e.next=12,LN();case 12:if(e.t1=e.sent,!e.t1){e.next=17;break}return e.next=16,NN();case 16:e.t1=e.sent;case 17:if(!e.t1){e.next=19;break}t.push("vp8");case 19:return e.abrupt("return",t);case 20:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),RN=function(){var e=Em(Sm().mark((function e(){var t;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,AN();case 2:return t=e.sent,e.abrupt("return",YE(t).call(t,(function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),wN={};function CN(e){var t;if(oE(t=["level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f","profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1","packetization-mode=1;profile-level-id=42e01f;level-asymmetry-allowed=1"]).call(t,(function(t){return null==e?void 0:vk(e).call(e,t)}))){for(var r=navigator.userAgent.toLowerCase(),n=!1,i=0,o=["miuibrowser"];i<o.length;i++){var a=o[i];vk(r).call(r,a)&&(n=!0)}return!n}return!1}var xN=function(){var e=Em(Sm().mark((function e(t){var r,n;return Sm().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)}}(),PN=function(){var e=Em(Sm().mark((function e(){var t,r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,xN("sendonly");case 2:if(r=e.sent,!vk(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,xN("sendonly");case 6:r=e.sent;case 7:return wN.h264encode=CN(r),wN.vp8encode=_E(r).call(r,"vp8")>-1,e.abrupt("return",wN);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ON=function(){var e=Em(Sm().mark((function e(){var t,r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,xN("recvonly");case 2:if(r=e.sent,!vk(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,xN("recvonly");case 6:r=e.sent;case 7:return wN.h264decode=CN(r),wN.vp8decode=_E(r).call(r,"vp8")>-1,e.abrupt("return",wN);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),DN=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==wN.h264encode){e.next=9;break}return e.prev=1,e.next=4,PN();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",wN.h264encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),MN=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==wN.h264decode){e.next=9;break}return e.prev=1,e.next=4,ON();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",wN.h264decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),NN=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==wN.vp8encode){e.next=9;break}return e.prev=1,e.next=4,PN();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",wN.vp8encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),LN=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==wN.vp8decode){e.next=9;break}return e.prev=1,e.next=4,ON();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",wN.vp8decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),UN=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},VN=function(){return 12!==XP},FN={},BN={},jN={exports:{}},GN=jN.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(GN).forEach((function(e){GN[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=jN.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=ym(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 u=n[t][o];if(u.reg.test(i))return r(u,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 $S(t=e.split(/;\s?/)).call(t,o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){var t;return YE(t=e.toString().split(" ")).call(t,Number)},e.parseRemoteCandidates=function(e){for(var r,n=[],i=YE(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 YE(t=e.split(" ")).call(t,(function(e){var t;return $S(t=e.substring(1,e.length-1).split(",")).call(t,o,{})}))},e.parseSimulcastStreamList=function(e){var r;return YE(r=e.split(";")).call(r,(function(e){var r;return YE(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}}))}))}}(BN);var zN=jN.exports,HN=/%[sdv%]/g,XN=function(e){var t=1,r=arguments,n=r.length;return e.replace(HN,(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""}}))},KN=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 XN.apply(null,n)},qN=["v","o","s","i","u","e","p","c","b","t","r","z","a"],YN=["i","c","b","a"],WN=BN,QN=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||qN,n=t.innerOrder||YN,i=[];return r.forEach((function(t){zN[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(KN(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(KN(t,r,e))}))}))})),e.media.forEach((function(e){i.push(KN("m",zN.m[0],e)),n.forEach((function(t){zN[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(KN(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(KN(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"};FN.write=QN,FN.parse=WN.parse,FN.parseParams=WN.parseParams,FN.parseFmtpConfig=WN.parseFmtpConfig,FN.parsePayloads=WN.parsePayloads,FN.parseRemoteCandidates=WN.parseRemoteCandidates,FN.parseImageAttributes=WN.parseImageAttributes,FN.parseSimulcastStreamList=WN.parseSimulcastStreamList;var JN=new nP("FirefoxHandler",3),ZN=Math.pow(2,32),$N="kp34Za0H+aVf862l",eL="o/i14u9pJrxRKAsu";function tL(e){return e>ZN-18?(JN.print("generateAllSsrc","reset start id",e),tL(e=e-ZN+1e4+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var rL=function(e,t,r){var n,i,o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:eL;return[{id:r,attribute:"cname",value:a},{id:r,attribute:"msid",value:Rm(n=Rm(i="".concat(e," ")).call(i,e,"-")).call(n,t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:Rm(o="".concat(e,"-")).call(o,t)}]},nL=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],u=n.cname,c=n.flexfec;c&&s.push(a);var d,l=$S(s).call(s,(function(t,r){return Rm(t).call(t,rL(e,"video",r,u))}),[]),h=[{semantics:"FID",ssrcs:Rm(r="".concat(i," ")).call(r,o)}];c&&h.push({semantics:"FEC-FR",ssrcs:Rm(d="".concat(i," ")).call(d,a)});return{ssrcs:l,ssrcGroups:h}};function iL(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.bundleOnly,e}var oL=function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=cd(cd({},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,FN.write(i)};function aL(e,t){return sL.apply(this,arguments)}function sL(){return(sL=Em(Sm().mark((function e(t,r){var n,i,o,a,s;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},i=r.publicIPs,o=r.certFingerprint,a=r.iceParams,s=r.iceConfig,n.fingerprint={type:"sha-256",hash:o},n.icePwd=a.serverIcePwd,e.next=6,cL(a.serverIceUfrag);case 6:return n.iceUfrag=e.sent,n.candidates=uL(i,s),n.setup="active",n.iceOptions="renomination",e.abrupt("return",n);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function uL(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(cd(cd({},o),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){i.push(cd(cd({},o),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),i}var cL=function(){var e=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u;return Sm().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,UP.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=NP(Uint8Array,n,i,o,a),e.next=15,UP.ab2b64str(s.buffer);case 15:return u=e.sent,e.abrupt("return",u);case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),dL=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=YT(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o,a,s,u=n.value;if(vk(o=u.config).call(o,"level-asymmetry-allowed=1")&&vk(a=u.config).call(a,"packetization-mode=1")&&vk(s=u.config).call(s,"profile-level-id=42e01f")){r=u.payload;break}}}catch(p){i.e(p)}finally{i.f()}for(var c=0;c<e.rtp.length;c++){var d=e.rtp[c];if("H264"===t){if(d.payload===r){var l;e.rtp.unshift(GE(l=e.rtp).call(l,c,1)[0]);break}}else if(d.codec===t){var h;e.rtp.unshift(GE(h=e.rtp).call(h,c,1)[0]);break}}var v=[];e.rtp.forEach((function(e){return v.push(e.payload)})),e.payloads=v.join(" ")}},lL=new nP("BasicHandler",3),hL={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",encodedInsertableStreams:!!UN()||void 0},vL=function(e){wI(o,e);var t,r,n,i=XI(o);function o(e){var t;return qd(this,o),sd(QT(t=i.call(this)),"_peerConnection",void 0),sd(QT(t),"_dataChannel",void 0),sd(QT(t),"_context",void 0),sd(QT(t),"id",void 0),sd(QT(t),"_monitor",void 0),sd(QT(t),"_offerIce",{}),sd(QT(t),"_answerIce",{}),sd(QT(t),"_initSctpEvents",!1),sd(QT(t),"_nextSsrc",Math.floor(Math.random()*ZN+1e4)),sd(QT(t),"_aSendonlyAnswerTpl",void 0),sd(QT(t),"_vSendonlyAnswerTpl",void 0),sd(QT(t),"_enableSubFlexfec",!1),sd(QT(t),"audioTrack4ff",void 0),sd(QT(t),"_connectionId",void 0),t.id=e.id,t._monitor=mP(t.id),t._peerConnection=new RTCPeerConnection(hL),t._dataChannel=t._peerConnection.createDataChannel("signaling",{negotiated:!0,id:100}),t._context=e,t._dataChannel.binaryType="arraybuffer",t._peerConnection.ontrack=function(e){var r,n,i,o,a=null===(r=e.streams)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.id;lL.print("constructor",Rm(i=Rm(o="pc.ontrack ".concat(e.track.kind," ")).call(o,e.track.id," ")).call(i,a)),"ff-stream"===a&&(t.audioTrack4ff=e.track),t.emit("ontrack",e)},t._peerConnection.onconnectionstatechange=function(e){var r;lL.print("constructor",Rm(r="onconnectionstatechange ".concat(t._peerConnection.iceConnectionState," -> ")).call(r,t._peerConnection.connectionState)),"failed"!==t._peerConnection.iceConnectionState&&"closed"!==t._peerConnection.iceConnectionState&&"failed"!==t._peerConnection.connectionState||t.emit("disconnect")},t._peerConnection.oniceconnectionstatechange=function(){var e=t._peerConnection.iceConnectionState;t._report("rtc_pre_ice_state",{message:e,ice_state:e.toUpperCase()})},t}return Kd(o,[{key:"getConnectionId",value:function(){return this._connectionId}},{key:"disconnect",value:function(){this._peerConnection.close(),this._dataChannel.close(),this._peerConnection.ontrack=null}},{key:"destroy",value:function(){lL.print("destroy"),this.disconnect(),this._context=void 0}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"_simulcast",value:function(e,t,r,n,i){var o,a,s,u=[];1===e.videoEncodeConfig.length?(u=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),lL.print("simulcast() ","simulcastLayers: %o",u)):(u=YE(o=ym(a=ym(s=e.videoEncodeConfig).call(s,1)).call(a,1-i)).call(o,(function(e){var r=mO(e.width),n=t.width/r;return{width:r,height:Math.floor(t.height/n),scaleResolutionDownBy:n,frameRate:mO(e.frameRate)||15,maxkbps:e.maxKbps||600}})),lL.print("simulcast() ","simulcastLayers2: %o",u));var c=[!0];u.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)}),c.push(!0)})),this._context&&(this._context.activeSimStreams=c)}},{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]},u={direction:"sendonly",streams:[t]},c=[],d=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var l=null==r?void 0:r.getTrack(),h=cd({},MO);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 p=null==e?void 0:e.videoEncodeConfig[0],f={maxBitrate:1e3*p.maxKbps,rid:"0"};if(e.prevBitrate=p.maxKbps,u.sendEncodings=[f],c.push({width:h.width,height:h.height,framerate:h.frameRate,maxkbps:p.maxKbps,rid:"0"}),!BP&&i){var _,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(lL.print("simulcast() ","maxLayers: %o",g),g>1)this._simulcast(e,cd(cd({},h),{},{maxKbps:p.maxKbps}),u,c,g),null!==(_=this._context)&&void 0!==_&&null!==(m=_.serverConfig)&&void 0!==m&&m.simulcastOnDemand&&(d=YE(c).call(c,(function(e,t){return cd(cd({},e),{},{video_index:t,sub_index:t})})))}}lL.print("publish videoTransceiverInit videoDescriptions","",u,c);var y=null==n?void 0:n.getTrack("preprocessing");(null==n?void 0:n.mixType)!==jd.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",ZE({aTrack:vO(y),vTrack:vO(S),audioTransceiverInit:s,videoTransceiverInit:u}))}catch(ZH){}return{semantics:"unified-plan",videoDescriptions:c,subVideoDescriptions:d,audioTransceiverInit:{track:y,init:s},videoTransceiverInit:{track:S,init:u}}}},{key:"updateMaxBitrate",value:function(e){var t,r,n,i;lL.print("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 lL.print("updateMaxBitrate()","no change");e.prevBitrate=s}var u=null===(i=a.sender)||void 0===i?void 0:i.getParameters();if(u){var c;u.encodings=null==u||null===(c=u.encodings)||void 0===c?void 0:YE(c).call(c,(function(t){var r,n=+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(u);try{this._reportRtcInvokeStatus("Handler.updateScaleResolutionDownBy",ZE(u.encodings))}catch(ZH){}}}else lL.print("updateMaxBitrate()","no pub")}},{key:"getStats",value:function(e,t){return EN(this._peerConnection,e,t)}},{key:"setLocalDescription",value:(n=Em(Sm().mark((function e(t,r){var n,i,o,a=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=MP(),e.prev=1,e.next=4,this._peerConnection.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:MP()-n},{type:"offer"}),this._initSctpEvents||(this._initSctpEvents=!0,(o=null===(i=this._peerConnection)||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:MP()-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=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=MP(),e.prev=1,e.next=4,this._peerConnection.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:MP()-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:MP()-n},{type:"answer"});case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Em(Sm().mark((function e(){return Sm().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;FN.parse(e).media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r,n=null==e?void 0:oE(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&null!=e&&e.fmtp){var i,o=null==e?void 0:oE(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&&vk(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(vk(n=["vp8","h264"]).call(n,i.toLocaleLowerCase())){var a,s,u=oE(a=e.fmtp).call(a,(function(e){return e.payload===o}));if(u)u.config=Rm(s=[]).call(s,Kk(u.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,cd(cd({},t),{},{connection_id:this._connectionId}),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)}}]),o}(iD.exports.EventEmitter),pL=E,fL=Ug,_L=Qm.exports.getWeakData,mL=vv,gL=tr,yL=H,SL=$,bL=Dh,EL=We,kL=Zi.set,TL=Zi.getterFor,IL=Mo.find,AL=Mo.findIndex,RL=pL([].splice),wL=0,CL=function(e){return e.frozen||(e.frozen=new xL)},xL=function(){this.entries=[]},PL=function(e,t){return IL(e.entries,(function(e){return e[0]===t}))};xL.prototype={get:function(e){var t=PL(this,e);if(t)return t[1]},has:function(e){return!!PL(this,e)},set:function(e,t){var r=PL(this,e);r?r[1]=t:this.entries.push([e,t])},delete:function(e){var t=AL(this.entries,(function(t){return t[0]===e}));return~t&&RL(this.entries,t,1),!!~t}};var OL,DL={getConstructor:function(e,t,r,n){var i=e((function(e,i){mL(e,o),kL(e,{type:t,id:wL++,frozen:void 0}),yL(i)||bL(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=TL(t),s=function(e,t,r){var n=a(e),i=_L(gL(t),!0);return!0===i?CL(n).set(t,r):i[n.id]=r,e};return fL(o,{delete:function(e){var t=a(this);if(!SL(e))return!1;var r=_L(e);return!0===r?CL(t).delete(e):r&&EL(r,t.id)&&delete r[t.id]},has:function(e){var t=a(this);if(!SL(e))return!1;var r=_L(e);return!0===r?CL(t).has(e):r&&EL(r,t.id)}}),fL(o,r?{get:function(e){var t=a(this);if(SL(e)){var r=_L(e);return!0===r?CL(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}},ML=n,NL=E,LL=Ug,UL=Qm.exports,VL=Ng,FL=DL,BL=$,jL=ng,GL=Zi.enforce,zL=Vi,HL=!ML.ActiveXObject&&"ActiveXObject"in ML,XL=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},KL=VL("WeakMap",XL,FL);if(zL&&HL){OL=FL.getConstructor(XL,"WeakMap",!0),UL.enable();var qL=KL.prototype,YL=NL(qL.delete),WL=NL(qL.has),QL=NL(qL.get),JL=NL(qL.set);LL(qL,{delete:function(e){if(BL(e)&&!jL(e)){var t=GL(this);return t.frozen||(t.frozen=new OL),YL(this,e)||t.frozen.delete(e)}return YL(this,e)},has:function(e){if(BL(e)&&!jL(e)){var t=GL(this);return t.frozen||(t.frozen=new OL),WL(this,e)||t.frozen.has(e)}return WL(this,e)},get:function(e){if(BL(e)&&!jL(e)){var t=GL(this);return t.frozen||(t.frozen=new OL),WL(this,e)?QL(this,e):t.frozen.get(e)}return QL(this,e)},set:function(e,t){if(BL(e)&&!jL(e)){var r=GL(this);r.frozen||(r.frozen=new OL),WL(this,e)?JL(this,e,t):r.frozen.set(e,t)}else JL(this,e,t);return this}})}var ZL=ee.WeakMap;Rr({target:"WeakMap",proto:!0,real:!0,forced:!0},{emplace:my}),Rr({target:"WeakMap",stat:!0,forced:!0},{from:sy}),Rr({target:"WeakMap",stat:!0,forced:!0},{of:cy}),Rr({target:"WeakMap",proto:!0,real:!0,forced:!0},{deleteAll:vy}),Rr({target:"WeakMap",proto:!0,real:!0,forced:!0},{upsert:VS});var $L=ZL,eU=function(e){wI(v,e);var t,r,n,i,o,a,s,u,c,d,l,h=XI(v);function v(){var e,t,r;return qd(this,v),sd(QT(r=h.call(this)),"inited",!1),sd(QT(r),"deviceMap",{audioinput:new FS,audiooutput:new FS,videoinput:new FS}),sd(QT(r),"checkDeviceChangeTimer",null),sd(QT(r),"isSupportedPermissionsQuery",!1),sd(QT(r),"isGrantedMicrophonePermission",!1),sd(QT(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!LP()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(QT(r)),!LP()&&r.refreshDevices(),r}return Kd(v,[{key:"refreshDevices",value:(l=Em(Sm().mark((function e(){var t,r,n=this;return Sm().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,!BP){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=Em(Sm().mark((function e(){var t,r,n,i,o=this;return Sm().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:(c=Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=void 0,!BP){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=Hk(Rm(t=[]).call(t,Kk($I(r=this.deviceMap.audioinput).call(r)),Kk($I(n=this.deviceMap.videoinput).call(n)),Kk($I(i=this.deviceMap.audiooutput).call(i)))),a.forEach((function(e){var t,r,n=u.deviceMap[e.kind].get(e.deviceId);u.deviceMap[e.kind].set(e.deviceId,e),n||(vk(t=e.kind).call(t,"video")?u.emit(Hd.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):vk(r=e.kind).call(r,"audio")&&u.emit(Hd.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),s.forEach((function(e){var t,r;oE(a).call(a,(function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(u.deviceMap[e.kind].delete(e.deviceId),vk(t=e.kind).call(t,"video")?u.emit(Hd.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):vk(r=e.kind).call(r,"audio")&&u.emit(Hd.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"getUserMedia",value:(u=Em(Sm().mark((function e(t){var r;return Sm().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 u.apply(this,arguments)})},{key:"checkPermissionsByDevices",value:(s=Em(Sm().mark((function e(){var t,r;return Sm().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=Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u=this,c=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=c.length>0&&void 0!==c[0]?c[0]:{},n=r.audio,i=r.video,o=r.force,n||i||(n=!0,i=!0),a={audio:!1,video:!1},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:case 26: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 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=33;break}return e.next=33,navigator.mediaDevices.getUserMedia({audio:n,video:i}).then((function(e){e&&(e.getTracks().forEach((function(e){return e.stop()})),n&&(a.audio=!0,u.isGrantedMicrophonePermission=!0),i&&(a.video=!0,u.isGrantedCameraPermission=!0))})).catch((function(){}));case 33:return e.next=35,this.refreshDevices();case 35:return e.abrupt("return",a);case 36:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"enumerateDevices",value:(o=Em(Sm().mark((function e(){var t,r,n,i;return Sm().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",Hk(Rm(t=[]).call(t,Kk($I(r=this.deviceMap.audioinput).call(r)),Kk($I(n=this.deviceMap.videoinput).call(n)),Kk($I(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=Em(Sm().mark((function e(){var t;return Sm().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",Hk($I(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=Em(Sm().mark((function e(){var t;return Sm().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",Hk($I(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=Em(Sm().mark((function e(){var t;return Sm().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",Hk($I(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=Em(Sm().mark((function e(t){var r;return Sm().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",oE(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}(sD),tU=new eU;!LP()&&(window.__rtc_dd__=tU);var rU=new nP("AudioContext",1),nU=function(){function e(){var t=this;qd(this,e),sd(this,"_audioContextInstance",void 0),sd(this,"_contextStuckAt",0);var r=0;LP()||setInterval((function(){if(t._audioContextInstance){var e=t._audioContextInstance.currentTime;t._contextStuckAt?t._contextStuckAt!==e&&(t._contextStuckAt=0,rU.print("currentTime resume"),fP("currentTime resume","")):e&&r===e&&(t._contextStuckAt=e,rU.print("currentTime stuck",t._contextStuckAt),t._audioContextInstance.suspend(),t._audioContextInstance.resume(),fP("AudioContext currentTime stuck",t._contextStuckAt)),r=e}}),3e3)}return Kd(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;rU.print("state change",null===(t=e._audioContextInstance)||void 0===t?void 0:t.state),"interrupted"===(null===(r=e._audioContextInstance)||void 0===r?void 0:r.state)&&e._audioContextInstance.resume()}}return this._audioContextInstance}}]),e}(),iU=function(){function e(t){qd(this,e),sd(this,"_ctx",void 0),sd(this,"_analyserNode",void 0),sd(this,"_audioSource",void 0);var r=oU.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 Kd(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=Em(Sm().mark((function e(){var t;return Sm().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}(),oU=new nU,aU=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}(aU||{}),sU=function(){function e(t){qd(this,e),sd(this,"_plugins",new FS),this.id=t}var t;return Kd(e,[{key:"register",value:function(e){var t=this._plugins.get(e.type)||[];if(XA(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 oE(r=this._plugins.get(e)||[]).call(r,(function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=Em(Sm().mark((function e(t){var r,n,i,o,a;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this._plugins.get(1)||[],n=t.getTrack(),i=YT(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}(),uU=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(uU||{}),cU=new nP("VERTC",0),dU=new $L,lU=function(e){wI(r,e);var t=XI(r);function r(e,n){var i;return qd(this,r),sd(QT(i=t.call(this)),"sourceType",1),sd(QT(i),"mediaType",void 0),sd(QT(i),"_trackId",void 0),sd(QT(i),"_ac",void 0),sd(QT(i),"_sourceNode",void 0),sd(QT(i),"_gainNode",void 0),sd(QT(i),"_destNode",void 0),sd(QT(i),"_channelCount",void 0),i._trackId=e,i.mediaType=n,"audio"===n&&VN()&&!OO("SKIP_WEB_AUDIO_IN_TRACK")&&(i._ac=oU.getAudioContextInstance(),i._gainNode=i._ac.createGain(),i._destNode=i._ac.createMediaStreamDestination(),i._gainNode.connect(i._destNode)),i}return Kd(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,!VN()||OO("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:"destory",value:function(){var e,t,r,n;null===(e=this._sourceNode)||void 0===e||e.mediaStream.getTracks().forEach((function(e){e.stop()})),null===(t=this._destNode)||void 0===t||t.stream.getTracks().forEach((function(e){e.stop()})),null===(r=this._sourceNode)||void 0===r||r.disconnect(),null===(n=this._gainNode)||void 0===n||n.disconnect(),delete this._sourceNode,delete this._gainNode,delete this._destNode}}]),r}(sD),hU=function(e){wI(n,e);var t,r=XI(n);function n(e,t,i){var o;return qd(this,n),sd(QT(o=r.call(this,t,i)),"_mediaTrack",void 0),sd(QT(o),"_preProcessingTrack",void 0),sd(QT(o),"_originTrack",void 0),sd(QT(o),"handleTrackEnded",(function(){o.emit("track-ended",QT(o)),o.close()})),sd(QT(o),"handleMute",(function(){o.emit("track-mute",QT(o))})),sd(QT(o),"handleUnmute",(function(){o.emit("track-unmute",QT(o))})),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o._initListeners(),o}return Kd(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=Em(Sm().mark((function e(t){var r;return Sm().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.destory():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}(lU),vU=function(e){wI(r,e);var t=XI(r);function r(e,n,i){var o;return qd(this,r),sd(QT(o=t.call(this,n,i)),"_mediaTrack",void 0),sd(QT(o),"_originTrack",void 0),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o}return Kd(r,[{key:"getTrack",value:function(){return this._mediaTrack}},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){return this.destory()}}]),r}(lU),pU=function(e){wI(n,e);var t,r=XI(n);function n(e,t){var i;return qd(this,n),sd(QT(i=r.call(this,e,t,"video")),"resolution",void 0),sd(QT(i),"dummy",!1),i.resolution={width:0,height:0},i}return Kd(n,[{key:"updateVideoCaptureConfig",value:(t=Em(Sm().mark((function e(t){var r,n;return Sm().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 cU.print("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=cd({},t)).contentHint,BP&&(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&&vk(t=["text","motion","detail"]).call(t,e)&&(this._mediaTrack.contentHint=e)}}]),n}(hU),fU=function(e){wI(n,e);var t,r=XI(n);function n(e,t){var i;return qd(this,n),sd(QT(i=r.call(this,e,t,"audio")),"audioCaptureConfig",void 0),sd(QT(i),"_audioLevelFetcher",void 0),sd(QT(i),"mixedAudioTrack",void 0),sd(QT(i),"mixType",jd.PLAYOUT_AND_PUBLISH),i}return Kd(n,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new iU(this.getTrack("preprocessing"))),this._audioLevelFetcher.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=Em(Sm().mark((function e(){var t;return Sm().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 cU.print("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}(hU),_U=function(e){wI(r,e);var t=XI(r);function r(e,n){return qd(this,r),t.call(this,e,n,"video")}return Kd(r)}(vU),mU=function(e){wI(r,e);var t=XI(r);function r(e,n){var i;return qd(this,r),sd(QT(i=t.call(this,e,n,"audio")),"_audioLevelFetcher",void 0),i}return Kd(r,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new iU(this.getTrack())),this._audioLevelFetcher.getAudioLevel()}}]),r}(vU),gU=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"streamIndex",yd.STREAM_INDEX_MAIN),n}return Kd(r)}(fU),yU=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"streamIndex",yd.STREAM_INDEX_MAIN),n}return Kd(r)}(pU),SU=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"streamIndex",yd.STREAM_INDEX_MAIN),sd(QT(n),"sourceType",0),n}return Kd(r)}(pU),bU=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"streamIndex",yd.STREAM_INDEX_MAIN),sd(QT(n),"sourceType",0),n}return Kd(r)}(fU),EU=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"streamIndex",yd.STREAM_INDEX_SCREEN),n}return Kd(r)}(pU),kU=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"streamIndex",yd.STREAM_INDEX_SCREEN),n}return Kd(r)}(fU),TU=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"streamIndex",yd.STREAM_INDEX_SCREEN),sd(QT(n),"sourceType",0),n}return Kd(r)}(pU),IU=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"streamIndex",yd.STREAM_INDEX_SCREEN),sd(QT(n),"sourceType",0),n}return Kd(r)}(fU);function AU(e,t){return RU.apply(this,arguments)}function RU(){return(RU=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new yU(t,DP())).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 wU(e,t){return CU.apply(this,arguments)}function CU(){return(CU=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new EU(t,DP())).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 xU(e,t){return PU.apply(this,arguments)}function PU(){return(PU=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d;return Sm().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=mP(r.id),e.prev=2,cU.print("createCameraVideoTrack","constraints:",t),null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o}),s=MP(),BP&&(t.frameRate={ideal:30,max:30}),e.next=9,tU.getUserMedia({video:t});case 9:i=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:o,reason:"success",elapse:MP()-s}),e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(2),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}),new cR(sR.GET_VIDEO_TRACK_FAILED,Rm(u="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(u,e.t0.message||"unknown message","."),e.t0);case 17:return c=i.getVideoTracks()[0],dU.set(c,i),d=new yU(c,DP()),e.next=22,d.generatePreProcessingTrack(r);case 22:return e.abrupt("return",d);case 23:case"end":return e.stop()}}),e,null,[[2,13]])})))).apply(this,arguments)}function OU(e,t){return DU.apply(this,arguments)}function DU(){return(DU=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return cU.print("createMicrophoneAudioTrack","constraints:",t),o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=mP(r.id),e.prev=3,null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o}),s=MP(),(u=r.getPluginByName(aU.PRE_PROCESSING,"RTCAIAnsExtension"))&&(u.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=10,tU.getUserMedia({audio: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:MP()-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}),new cR(sR.GET_AUDIO_TRACK_FAILED,Rm(c="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(c,e.t0.message||"unknown message","."),e.t0);case 18:return d=i.getAudioTracks()[0],dU.set(d,i),l=new gU(d,DP()),e.next=23,l.generatePreProcessingTrack(r);case 23:return e.abrupt("return",l);case 24:case"end":return e.stop()}}),e,null,[[3,14]])})))).apply(this,arguments)}function MU(){return NU.apply(this,arguments)}function NU(){return NU=Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u,c,d,l=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=l.length>0&&void 0!==l[0]&&l[0],r=l.length>1?l[1]:void 0,n=l.length>2?l[2]:void 0,cU.print("createScreenTracks","withAudio: %o, constraints: %o",t,n),o=mP(r.id),e.prev=5,null==o||o.report("rtc_video_capture_event",{event_type:"start",media_device_id:"screen"}),a=MP(),e.next=10,navigator.mediaDevices.getDisplayMedia({video:!(n&&(!jP||16!==XP))||n,audio:!!t&&{channelCount:2,noiseSuppression:!1,echoCancellation:!1,autoGainControl:!1}});case 10:i=e.sent,null==o||o.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:"screen",reason:"success",elapse:MP()-a}),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(5),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}),new cR(sR.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 18:return s=i.getVideoTracks()[0],u=new EU(s,DP()),e.next=22,u.generatePreProcessingTrack(r);case 22:if(!(c=i.getAudioTracks()[0])){e.next=28;break}return d=new kU(c,DP()),e.next=27,d.generatePreProcessingTrack(r);case 27:return e.abrupt("return",[u,d]);case 28:return e.abrupt("return",[u,void 0]);case 29:case"end":return e.stop()}}),e,null,[[5,14]])}))),NU.apply(this,arguments)}function LU(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:DP();return new mU(e,t)}function UU(e,t){return VU.apply(this,arguments)}function VU(){return(VU=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new SU(t,DP()),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 FU(e,t){return BU.apply(this,arguments)}function BU(){return(BU=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new bU(t,DP()),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 jU(e,t){return GU.apply(this,arguments)}function GU(){return(GU=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new TU(t,DP()),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 zU(e,t){return HU.apply(this,arguments)}function HU(){return(HU=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new IU(t,DP()),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 XU=fU,KU=mU,qU=function(e){return e[e.NONE=0]="NONE",e}(qU||{}),YU=function(){function e(){qd(this,e)}return Kd(e,null,[{key:"getNalunits",value:function(t){if(t.length-t.position<4)return[];var r=t.position;return 1===t.getInt32(r)||0===t.getInt16(r)&&1===t.getInt8(r+2)?e.getAnnexbNals(t):e.getAvccNals(t)}},{key:"getAnnexbNals",value:function(t){for(var r=[],n=e.getHeaderPositionAnnexB(t),i=n.pos,o=i;i<t.length-4;){var a,s,u=new Uint8Array(ym(a=t.buffer).call(a,i,i+n.headerLength));n.pos===t.position&&t.skip(n.headerLength),o=(n=e.getHeaderPositionAnnexB(t)).pos;var c={header:u,body:new Uint8Array(ym(s=t.buffer).call(s,i+u.byteLength,o)),type:-1};e.analyseNal(c),c.type<=9&&0!==c.type&&r.push(c),t.skip(o-t.position),i=o}return r}},{key:"getAvccNals",value:function(t){for(var r=[];t.position<t.length-4;){var n=t.getInt32(t.position);if(!(t.length-t.position>=n))break;var i,o,a=new Uint8Array(ym(i=t.buffer).call(i,t.position,t.position+4));t.skip(4);var s=new Uint8Array(ym(o=t.buffer).call(o,t.position,t.position+n));t.skip(n);var u={header:a,body:s,type:-1};e.analyseNal(u),u.type<=9&&0!==u.type&&r.push(u)}return r}},{key:"analyseNal",value: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}}},{key:"getHeaderPositionAnnexB",value: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}}}]),e}(),WU=function(){function e(t){qd(this,e),sd(this,"_position",0),sd(this,"_dataview",void 0),this._dataview=new DataView(t)}return Kd(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}(),QU=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(QU||{}),JU=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),ZU=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]),$U=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 eV(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function tV(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 rV=function(){function e(){qd(this,e)}return Kd(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?JU:ZU,s=eV(e.byteLength+a.byteLength),u=$U(e);return new Uint8Array(Rm(t=[]).call(t,Kk(n),Kk(i),Kk(o),Kk(s),Kk(a),Kk(u),[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=ym(e).call(e,0,e.length-1));if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=WT(tV(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=ZU.byteLength&&i>=ZU.byteLength&&ym(t).call(t,r,r+ZU.byteLength).toString()===ZU.toString()?(r+=ZU.byteLength,o=1):t.byteLength>=ZU.byteLength&&i>=ZU.byteLength&&ym(t).call(t,r,r+JU.byteLength).toString()===JU.toString()&&(r+=JU.byteLength,o=0),{type:o,payload:ym(t).call(t,r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new FS,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=WT(tV(e.payload,r),2),i=n[0];r=n[1];var o,a=WT(tV(e.payload,r),2),s=a[0];if(r=a[1],t.get(i)||!(s<=e.payload.byteLength-r))break;t.set(i,ym(o=e.payload).call(o,r,r+s)),r+=s}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=YT(e);try{for(n.s();!(t=n.n()).done;){var i=WT(t.value,2),o=i[0],a=i[1],s=eV(o),u=eV(a.byteLength);r.push(s,u,a)}}catch(l){n.e(l)}finally{n.f()}var c=$S(r).call(r,(function(e,t){return e+t.byteLength}),0),d=new Uint8Array(c);return $S(r).call(r,(function(e,t){return d.set(t,e),e+t.byteLength}),0),d}}]),e}(),nV=function(){function e(t){qd(this,e),sd(this,"player",void 0),sd(this,"_timer",void 0),sd(this,"handler",void 0),sd(this,"_monitor",void 0),this.id=t,this._monitor=mP(t)}return Kd(e,[{key:"setVar",value:function(e){this.handler=e}},{key:"clearTimer",value:function(){this._timer&&(clearTimeout(this._timer),delete this._timer,SP(this.id,"del_media_statistics_timer","".concat((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(){SP(this.id,"media_statistics_destroy","".concat((new Error).stack),0,"".concat(this._stream.streamId)),this.clearTimer()}}]),e}(),iV=function(e){wI(i,e);var t,r,n=XI(i);function i(e,t){var r;return qd(this,i),sd(QT(r=n.call(this,e)),"_context",void 0),r._stream=t,r}return Kd(i,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t,r){var n,i,o,a=this;if(!this._timer){this.setVar(t),this._context=r;var s={audio:{},video:{}},u=this._stream,c=null===(n=u.audioTrack)||void 0===n?void 0:n.getTrack("preprocessing"),d=null===(i=u.videoTrack)||void 0===i?void 0:i.getTrack("preprocessing");this.getAudioStats(c,s,null===(o=u.audioTrack)||void 0===o?void 0:o.getAudioLevel()),this.getVideoStats(d,s);var l=function(){var e=Em(Sm().mark((function e(){var t,r,n,i,o,c,d;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=u.audioTrack)||void 0===t?void 0:t.getTrack("preprocessing"),o=null===(r=u.videoTrack)||void 0===r?void 0:r.getTrack("preprocessing"),e.next=4,a.getAudioStats(i,s,null===(n=u.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return c=e.sent,e.next=7,a.getVideoStats(o,s);case 7:return d=e.sent,e.abrupt("return",{audioStats:c,videoStats:d,isScreen:u.isScreen});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),h=function(){var t=Em(Sm().mark((function t(){var r;return Sm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,l();case 2:r=t.sent,e(r),a._timer=setTimeout(h,2e3);case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();this._timer=setTimeout(h,2e3)}}},{key:"unpublish",value:function(){this.clearTimer()}},{key:"getAudioStats",value:(r=Em(Sm().mark((function e(t,r,n){var i,o,a,s,u,c,d,l,h,v,p,f,_;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o={},a={timestamp:Date.now()},s=this._stream,u=s.streamId,c=s.audioMid,d=s.isScreen,l=s.pubAttributes,h=s.pubAudio,v=s.audioTrack,p={media_type:"audio",is_screen:!!d,direction:"up",stream_id:u,vid:c,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:l.localaudio?"capture_state_on":"capture_state_off",mute_state:h?"mute_state_off":"mute_state_on"},v&&(p.playback_volume=v.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",o);case 7:return e.next=9,this.handler.getStats(t);case 9:if((f=e.sent).length){e.next=12;break}return e.abrupt("return",o);case 12:if(f.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,i=e.bytesSent,s=e.clockRate,u=e.roundTripTime,c=e.channels,d=e.audioLevel;e.googRtt;var l=e.mimeType,h=e.availableIncomingBitrate,v=e.availableOutgoingBitrate,f=e.bytesReceived,_=e.nominated,m=e.id,g=e.currentRoundTripTime,y=e.state,S=e.writable,b=e.requestsReceived,E=e.responsesReceived,k=e.requestsSent,T=e.consentRequestsSent,I=e.responsesSent,A=e.jitter,R=e.candidateType,w=e.ip,C=e.address,x=e.networkType,P=e.port,O=e.protocol,D=e.nackCount,M=e.retransmittedBytesSent,N=e.retransmittedPacketsSent,L=e.audioInputLevel,U=e.ssrc,V=e.totalAudioEnergy,F=e.totalSamplesDuration,B=e.mediaType,j=e.fractionLost;"outbound-rtp"===t?(a.packetsSent=r,a.bytesSent=i,p.bytes=i,p.packetsSent=r,p.nackCount=D,p.ssrc=U,p.retransmitted_bytes_sent=M,p.retransmitted_packets_sent=N,a.retransmittedBytesSent=M,a.retransmittedPacketsSent=N):"remote-inbound-rtp"===t?(a.packetsLost=n,p.packetsLost=n,p.net_jitter=1e3*A,o.rtt=1e3*u,p.rtt=o.rtt,o._fractionLost=j||0):"codec"===t?(o.recordSampleRate=s,o.numChannels=c,p.codecName=l):"media-source"===t&&void 0!==d?(p.audio_level=d?-10*XR(Math.pow(d,2)):d,p.volume=255*d,p.total_audio_energy=V,p.totalInputDuration=F):"ssrc"===t&&"audio"===B?p.send_level=L:"candidate-pair"===t?(p.ice_available_incoming_bitrate=h,p.ice_available_outgoing_bitrate=v,p.ice_bytes_received=f,p.ice_bytes_sent=i,p.ice_nominated=+_,p.ice_pair_id=m,p.ice_pair_rtt=g,p.ice_pair_state=y,p.ice_pair_writable=S,p.recv_ping_requests=b,p.recv_ping_responses=E,p.sent_ping_requests_before_first_response=k,p.sent_ping_requests_total=k+(T||0),p.sent_ping_responses=I):"local-candidate"===t?(p.local_candidate_type=R,p.local_ip=w||C,p.local_network_type=x,p.local_port=P,p.protocol=O):"remote-candidate"===t&&(p.remote_candidate_type=R,p.remote_ip=w||C,p.remote_port=P);var G=OO("STATS_SCALLBACK_SUPPORT");FP&&G||"media-source"===t&&(p.send_level=d)})),void 0===p.volume&&void 0!==n&&(p.volume=n,p.audio_level=n?-10*XR(Math.pow(n/255,2)):n),(_=r.audio).timestamp){e.next=18;break}return r.audio=a,e.abrupt("return",this.filterIllegal(o));case 18:return void 0!==a.packetsLost&&(o.audioLossRate=(a.packetsLost-_.packetsLost)/(a.packetsSent-_.packetsSent),o.audioLossRate=Number.isNaN(o.audioLossRate)?0:o.audioLossRate,p.fraction_lost=o.audioLossRate),o.statsInterval=a.timestamp-_.timestamp,p.stats_interval=o.statsInterval,o.sendKBitrate=(a.bytesSent-_.bytesSent||0)/o.statsInterval*8,p.mediaBitratebps=Math.round(1e3*o.sendKBitrate),p.bandwidth=Math.round(p.mediaBitratebps/1024),void 0!==a.retransmittedBytesSent&&(p.retransmitBitratebps=(a.retransmittedBytesSent-_.retransmittedBytesSent||0)/o.statsInterval),r.audio=a,null===(i=this._monitor)||void 0===i||i.report("rtc_media_statistics",p),o._retransmittedRate=(a.retransmittedPacketsSent-_.retransmittedPacketsSent)/(a.packetsSent-_.packetsSent),void 0===o.audioLossRate&&(o.audioLossRate=o._retransmittedRate,p.fraction_lost=o.audioLossRate),o._fractionLost=Math.max(o._fractionLost,o.audioLossRate),e.abrupt("return",this.filterIllegal(o));case 31:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S;return Sm().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,u=o.isScreen,c=o.pubAttributes,d=o.enableSimulcast,l=o.pubVideo,e.t0=cd,e.t1={media_type:"video",is_screen:!!u,direction:"up",stream_id:a,vid:s,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:c.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,n.isScreen=u,e.next=16,this.handler.getStats(t);case 16:if((v=e.sent).length){e.next=19;break}return e.abrupt("return",n);case 19:if(p=0,v.forEach((function(e){var o=e.type,a=e.framesEncoded,s=e.packetsLost,u=e.bytesSent,c=e.framesSent,l=e.retransmittedBytesSent,v=e.totalPacketSendDelay,f=e.totalEncodeTime,_=e.firCount,m=e.targetBitrate,g=e.roundTripTime,y=e.mimeType,S=e.frameWidth,b=e.frameHeight,E=e.packetsSent,k=e.googActualEncBitrate,T=e.googAvailableReceiveBandwidth,I=e.googAvailableSendBandwidth,A=e.googAvgEncodeMs,R=e.googBucketDelay,w=e.googEncodeUsagePercent,C=e.googFrameRateInput,x=e.availableIncomingBitrate,P=e.availableOutgoingBitrate,O=e.bytesReceived,D=e.nominated,M=e.id,N=e.currentRoundTripTime,L=e.state,U=e.writable,V=e.candidateType,F=e.ip,B=e.address,j=e.networkType,G=e.port,z=e.nackCount,H=e.pliCount,X=e.protocol,K=e.qpSum,q=e.requestsReceived,Y=e.responsesReceived,W=e.googRetransmitBitrate,Q=e.requestsSent,J=e.consentRequestsSent,Z=e.responsesSent,$=e.ssrc,ee=e.googTargetEncBitrate,te=e.googTransmitBitrate,re=e.retransmittedPacketsSent,ne=e.encoderImplementation,ie=e.jitter,oe=e.rid,ae=e.fractionLost,se=e.googAdaptationChanges,ue=e.qualityLimitationReason,ce=e.qualityLimitationDurations,de=e.googFirsReceived,le=e.googFrameRateSent,he=e.keyFramesEncoded;"outbound-rtp"===o?(d&&(oe?i.simulcast[oe]=e:i.simulcast[p]=e,p++),i.framesEncoded=a||i.framesEncoded||0,h.key_frames_encoded=he||0,i.bytesSent=u||i.bytesSent||0,i.framesSent=c||i.framesSent||0,h.bytes=u||h.bytes||0,i.packetsSent=E||i.packetsSent||0,h.packetsSent=E||h.packetsSent||0,h.nackCount=z||h.nackCount||0,h.pli_count=H||h.pli_count||0,h.qp_sum=K||h.qp_sum||0,h.ssrc=$||h.ssrc||0,h.retransmitted_packets_sent=re,i.retransmittedPacketsSent=re,i.retransmittedBytesSent=l,h.encoder_implementation=ne,h.qualityLimitationReason=ue,h.qualityLimitationDurations=ce,void 0!==S&&((!n.encodedFrameWidth||S>n.encodedFrameWidth)&&(n.encodedFrameWidth=S),(!n.encodedFrameHeight||b>n.encodedFrameHeight)&&(n.encodedFrameHeight=b),h.frame_size_height=b,h.frame_size_width=S)):"track"===o?(n.encodedFrameWidth=S,n.encodedFrameHeight=b,h.frame_size_height=b,h.frame_size_width=S):"remote-inbound-rtp"===o?(i.packetsLost=s,n.rtt=1e3*g,h.rtt=n.rtt,h.jitter=ie,h.packetsLost=s,n._fractionLost=ae||0):"codec"===o?(n.codecType=y,h.codecName=y):"candidate-pair"===o?(h.ice_available_incoming_bitrate=x,h.ice_available_outgoing_bitrate=P,h.ice_bytes_received=O,h.ice_bytes_sent=u,h.ice_nominated=+D,h.ice_pair_id=M,h.ice_pair_rtt=N,h.ice_pair_state=L,h.ice_pair_writable=U,h.recv_ping_requests=q,h.recv_ping_responses=Y,h.sent_ping_requests_before_first_response=Q,h.sent_ping_requests_total=Q+J,h.sent_ping_responses=Z):"local-candidate"===o?(h.local_candidate_type=V,h.local_ip=F||B,h.local_network_type=j,h.local_port=G,h.protocol=X):"remote-candidate"===o?(h.remote_candidate_type=V,h.remote_ip=F||B,h.remote_port=G):"VideoBwe"===o?(h.encBitratebps=k,h.available_receive_bandwidth=T,h.available_send_bandwidth=I,h.bucket_delay=R,h.retransmitBitratebps=W,h.targetEncBitratebps=ee,h.transmit_bitrate=te,n._sendBandWidth=+I):"ssrc"===o&&(h.avg_encode_ms=A,h.encodeUsage=w,h.frame_rate_input=C,h.orignal_input_Framerate=+C,h.ddaptationChanges=se,h.firsReceived=de,h.frameRateSent=le);var ve=OO("STATS_SCALLBACK_SUPPORT");if(!FP||!ve){var pe=r.video,fe=i.timestamp-pe.timestamp;if("outbound-rtp"===o){var _e=u-pe.bytesSent,me=l-pe.retransmittedBytesSent;h.encBitratebps=Math.round(8e3*(_e-me)/fe),h.bucket_delay=v/E,h.retransmitBitratebps=Math.round(8e3*me/fe),h.targetEncBitratebps=m,h.transmit_bitrate=Math.round(1e3*(u-pe.bytesSent)*8/fe),h.avg_encode_ms=1e3*f/a,h.firsReceived=_+H}else"candidate-pair"===o&&(h.available_send_bandwidth=P,n._sendBandWidth=P);if(t){var ge=null==t?void 0:t.getSettings().frameRate;h.orignal_input_Framerate=ge,h.frameRateSent=t.getSettings().frameRate}}})),(f=r.video).timestamp){e.next=25;break}return r.video=i,e.abrupt("return",this.filterIllegal(n));case 25: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=[],y=!1,LA(_).call(_,(function(e,t){return+e-+t})).forEach((function(e){var t=i.simulcast[e],r=t.frameWidth,o=t.frameHeight,a=t.bytesSent,s=t.framesEncoded,u=t.framesSent,c=t.packetsLost,d=t.packetsSent,l=t.qualityLimitationReason,v=t.qualityLimitationDurations,p=t.qualityLimitationResolutionChanges,_=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(p));var S=f.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),S){var b=(a-S.bytesSent||0)/n.statsInterval;h.sim_enc_bps.push(Math.round(8e3*b)),h.sim_enc_bandwidth.push(Math.round(8e3*b/1024));var E=1e3*(s-S.framesEncoded)/n.statsInterval;h.sim_enc_framerate.push(Math.round(E)),h.sim_rids.push(e);var k=void 0!==u?u-S.framesSent:s-S.framesEncoded,T=1e3*k/n.statsInterval;h.sim_sent_framerate.push(Math.round(T));var I=(c-S.packetsLost)/(d-S.packetsSent);n._retransmittedRate=(_-S.retransmittedPacketsSent)/(d-S.packetsSent),I=Number.isNaN(I)?0:I,h.sim_fraction_lost.push(I),h.sim_keyencoded.push(m-S.pliCount>0),h.sim_retransmittedRate.push(n._retransmittedRate),r>0&&!y&&(n.sentKBitrate=8*b,n.encoderOutputFrameRate=E,n.encodedFrameCount=k,n.sentFrameRate=T,n.videoLossRate=I,y=!0)}})),null===(g=this._monitor)||void 0===g||g.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),null===(S=this._monitor)||void 0===S||S.report("rtc_media_statistics",h)),r.video=i,n._fractionLost=Math.max(n._fractionLost,n.videoLossRate),e.abrupt("return",this.filterIllegal(n));case 32:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}(nV),oV=function(e){wI(o,e);var t,r,n,i=XI(o);function o(e,t){var r;return qd(this,o),sd(QT(r=i.call(this,e)),"isPaused",void 0),sd(QT(r),"pauseStart",void 0),sd(QT(r),"pauseDuration",void 0),sd(QT(r),"_audioStallCount",void 0),sd(QT(r),"_setAudioStallCount",void 0),sd(QT(r),"_audioStallTimer",void 0),sd(QT(r),"_audioStallInterval",void 0),sd(QT(r),"_audioStallRatio",void 0),sd(QT(r),"_videoInWaiting",void 0),sd(QT(r),"_context",void 0),r._stream=t,r._videoInWaiting=!1,r.pauseDuration=0,r}return Kd(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=Em(Sm().mark((function e(t,r,n){var i,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S=this;return Sm().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 this.setVar(r),this._context=n,this._audioStallInterval=o.audioStallInterval||100,this._audioStallRatio=o.audioStallRatio||.6,u={audio:{},video:{}},c=this._stream,d=null===(i=c.audioTrack)||void 0===i?void 0:i.getOrgTrack(),l=null===(a=c.videoTrack)||void 0===a?void 0:a.getTrack(),this.getRemoteVideoStats(l,u),e.next=13,this.getRemoteAudioStats(d,u,null===(s=this._stream.audioTrack)||void 0===s?void 0:s.getAudioLevel());case 13:this.delStatsEvtInterval(),h=0,v=0,f=[],_=0,m=MP(),this._setAudioStallCount=function(){if(xO.AUDIO_STALL&&S._audioStallInterval>0&&void 0!==u.audio.concealedSamples){var e=u.audio.concealedSamples,t=u.audio.totalSamplesReceived;m=MP();var r={isStall:!1,counted:!1,diff:0},n=.5*S._audioStallInterval;S._audioStallCount=Em(Sm().mark((function i(){var o,a,s,u,d,l,p,g,y,b,E,k,T,I,A,R,w;return Sm().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=c.hasAudio,s=c.subAudio,a&&s){i.next=7;break}return r.isStall=!1,r.counted=!1,f.push({reason:Rm(u="hasAudio: ".concat(a,", subAudio: ")).call(u,s)}),m=MP(),i.abrupt("return",{stall_count:h,stall_duration:v,stall_list:f,stats_count:_});case 7:return d=null===(o=c.audioTrack)||void 0===o?void 0:o.getOrgTrack(),l=Date.now(),i.next=11,S.handler.getStats(d,!0);case 11:if(p=i.sent,g=Date.now(),y=MP(),!((b=y-m)<n)){i.next=18;break}return f.push({diff:b,start:m,end:y,get_stats_cost:g-l,get_stats_start:l,get_stats_end:g,reason:Rm(E="diff(".concat(b,") < minInterval(")).call(E,n,")")}),i.abrupt("return",{stall_count:h,stall_duration:v,stall_list:f,stats_count:_});case 18:if(k=p.length,T=oE(p).call(p,(function(e){return"inbound-rtp"===e.type}))){i.next=23;break}return f.push({diff:b,start:m,end:y,get_stats_cost:g-l,get_stats_start:l,get_stats_end:g,reason:k?"no inbound-rtp":"no report"}),i.abrupt("return",{stall_count:h,stall_duration:v,stall_list:f,stats_count:_});case 23:return I=T.concealedSamples,A=T.totalSamplesReceived,w=A-t,(R=I-e)>=0&&w>=0&&R>=S._audioStallRatio*w?(f.push({concealed:R,received:w,diff:b,start:m,end:y,get_stats_cost:g-l,get_stats_start:l,get_stats_end:g,is_stall:!0}),r.isStall?(r.counted?v+=b:(v=v+r.diff+b,h++),r.counted=!0):b>=200?(v+=b,h++,r.counted=!0):(r.counted=!1,r.diff=b),r.isStall=!0):(f.push({concealed:R,received:w,diff:b,start:m,end:y,get_stats_cost:g-l,get_stats_start:l,get_stats_end:g}),r.isStall=!1,r.counted=!1),e=I,t=A,m=y,_++,i.abrupt("return",{stall_count:h,stall_duration:v,stall_list:f,stats_count:_});case 32:case"end":return i.stop()}}),i)}))),p=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!S._audioStallCount&&S._setAudioStallCount&&S._setAudioStallCount(),!S._audioStallCount){e.next=6;break}return e.next=4,S._audioStallCount();case 4:S._audioStallTimer&&clearTimeout(S._audioStallTimer),S._audioStallTimer=setTimeout(p,S._audioStallInterval);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),S._audioStallTimer&&clearTimeout(S._audioStallTimer),S._audioStallTimer=setTimeout(p,S._audioStallInterval)}},this._setAudioStallCount(),g=function(){var e=Em(Sm().mark((function e(){var t,r,n,i,o,a,s;return Sm().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,S.getRemoteAudioStats(i,u,null===(n=S._stream.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return a=e.sent,h=0,v=0,f=[],_=0,e.next=11,S.getRemoteVideoStats(o,u);case 11:return s=e.sent,e.abrupt("return",{audioStats:a,videoStats:s,isScreen:c.isScreen,userId:c.userId});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),y=function(){var e=Em(Sm().mark((function e(){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,g();case 2:r=e.sent,t(r),p&&(m=MP(),S._audioStallTimer&&clearTimeout(S._audioStallTimer),S._audioStallTimer=setTimeout(p,S._audioStallInterval)),S._timer&&clearTimeout(S._timer),S._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 25:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"delStatsEvtInterval",value:function(){AI(TI(o.prototype),"clearTimer",this).call(this),clearTimeout(this._audioStallTimer),this._audioStallCount=void 0,this._setAudioStallCount=void 0,this.pauseDuration=0}},{key:"unsubscribe",value:function(){this.delStatsEvtInterval(),this._videoInWaiting=!1}},{key:"getRemoteAudioStats",value:(r=Em(Sm().mark((function e(t,r,n){var i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o={},a={},s=this._stream,u=s.streamId,c=s.userId,d=s.isScreen,l=s.audioMid,h=s.subMediaType,v=s._attributes,p=s.virtual,f=s.audioTrack,_={media_type:"audio",is_screen:!!d,direction:"down",stream_id:u,stream_user_id:c,vid:l,audio_mux:p,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:cO(h)?"mute_state_off":"mute_state_on",remote_user_capture_state:v.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:v.localaudio&&v.audiostream?"mute_state_off":"mute_state_on"},f&&(_.playback_volume=f.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",o);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",o);case 12:if(m.forEach((function(e){var t=e.type,r=e.packetsLost,i=e.packetsReceived,s=e.bytesReceived,c=e.jitterBufferDelay,d=e.jitterBufferEmittedCount,l=e.clockRate,h=e.channels,v=e.totalSamplesReceived,p=e.concealedSamples,f=e.silentConcealedSamples,m=e.concealmentEvents,g=e.totalRoundTripTime,y=e.packetsDiscarded,S=e.state,b=e.currentRoundTripTime,E=e.audioLevel,k=e.totalAudioEnergy,T=e.totalSamplesDuration,A=e.mimeType,R=e.googDecodingNormal,w=e.googDecodingMuted,C=e.availableIncomingBitrate,x=e.availableOutgoingBitrate,P=e.bytesSent,O=e.nominated,D=e.id,M=e.writable,N=e.jitter,L=e.candidateType,U=e.ip,V=e.address,F=e.networkType,B=e.port,j=e.protocol,G=e.audioOutputLevel,z=e.requestsReceived,H=e.responsesReceived,X=e.requestsSent,K=e.consentRequestsSent,q=e.responsesSent,Y=e.ssrc;e.kind;var W=e.nackCount,Q=e.lastPacketReceivedTimestamp,J=e.concealmentevents,Z=e.fecPacketsReceived;if("inbound-rtp"===t)a.packetsLost=r,a.packetsReceived=i,_.packetsReceived=i,_.packetsDiscarded=y,_.nackCount=W,_.lastPacketReceivedTimestamp=Q,_.concealmentevents=J,a.bytesReceived=s,void 0!==c&&(o.jitterBufferDelay=c/d*1e3,_.average_jitter_buffer_delay_ms=o.jitterBufferDelay),void 0!==v&&(a.totalSamplesReceived=v,o.concealedSamples=p,a.concealedSamples=p,a.silentConcealedSamples=f,_.concealedSamples=p,o.concealmentEvents=m,_.totalSamplesReceived=v),void 0!==Z&&(_.fec_packets_received=Z,a.fecPacketsReceived=Z),_.jitter=1e3*N,_.ssrc=Y,void 0!==E&&0!==E?(_.audio_level=E?-10*XR(Math.pow(E,2)):E,_.volume=255*E):(_.volume=null!=n?n:255*E,_.audio_level=n?-10*XR(Math.pow(n/255,2)):n),void 0!==k&&(_.total_audio_energy=k),void 0!==T&&(_.totalAudioDuration=T);else if("codec"===t)o.recordSampleRate=l,h&&(o.numChannels=h),_.codecName=A;else if("candidate-pair"===t){var $,ee,te;_.ice_available_incoming_bitrate=C,_.ice_available_outgoing_bitrate=x,_.ice_bytes_received=s,_.ice_bytes_sent=P,_.ice_nominated=+O,_.ice_pair_id=D,_.ice_pair_rtt=b,_.rtt=1e3*b,_.rtt&&null!==($=I._context)&&void 0!==$&&null!==(ee=$.streamRTT)&&void 0!==ee&&null!==(te=ee[u])&&void 0!==te&&te.audio&&(_.total_rtt_ms=_.rtt+I._context.streamRTT[u].audio),_.ice_pair_state=S,_.ice_pair_writable=M,_.recv_ping_requests=z,_.recv_ping_responses=H,_.sent_ping_requests_before_first_response=X,_.sent_ping_requests_total=X+(K||0),_.sent_ping_responses=q,"succeeded"===S&&(o.rtt=1e3*b,o.total_rtt=1e3*g)}else"track"===t&&void 0!==E?(0===E&&0!==n?(_.volume=n,_.audio_level=n?-10*XR(Math.pow(n/255,2)):n):(_.audio_level=E?-10*XR(Math.pow(E,2)):E,_.volume=255*E),_.total_audio_energy=k,_.totalAudioDuration=T):"ssrc"===t?(_.decodingNormal=R,_.recvAudioLevel=G,_.decodingMuted=w):"local-candidate"===t?(_.local_candidate_type=L,_.local_ip=U||V,_.local_network_type=F,_.local_port=B,_.protocol=j):"remote-candidate"===t&&(_.remote_candidate_type=L,_.remote_ip=U||V,_.remote_port=B)})),(g=r.audio).timestamp){e.next=18;break}return a.timestamp=Date.now(),r.audio=a,e.abrupt("return",this.filterIllegal(o));case 18:if(y={},void 0!==a.concealedSamples&&(_.interval_concealed_samples=a.concealedSamples-g.concealedSamples,_.interval_samples_received=a.totalSamplesReceived-g.totalSamplesReceived,_.interval_silent_concealed_samples=a.silentConcealedSamples-g.silentConcealedSamples),!(this._audioStallInterval>0&&void 0!==g.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:S=e.sent,b=S.stall_count,E=S.stall_duration,k=S.stall_list,T=S.stats_count,y.stall_list=k,y.stats_count=T,_.concealedSamples===_.interval_concealed_samples&&_.totalSamplesReceived===_.interval_samples_received?(_.stall_count=0,_.stall_duration=0):(_.stall_count=b,_.stall_duration=E),o.stallCount=_.stall_count,o.stallDuration=_.stall_duration;case 36:return a.timestamp=Date.now(),o.audioLossRate=(a.packetsLost-g.packetsLost)/(a.packetsReceived-g.packetsReceived+(a.packetsLost-g.packetsLost)),o.audioLossRate=Number.isNaN(o.audioLossRate)?0:o.audioLossRate,_.packetsLost=Math.round(a.packetsLost-g.packetsLost),_.fraction_lost=o.audioLossRate,o.statsInterval=a.timestamp-g.timestamp,_.stats_interval=o.statsInterval,o.receivedKBitrate=(a.bytesReceived-g.bytesReceived||0)/o.statsInterval*8,_.bandwidth=Math.round(1e3*o.receivedKBitrate/1024),void 0!==a.concealedSamples&&(o.receivedSampleRate=1e3*_.interval_samples_received/o.statsInterval),void 0!==a.fecPacketsReceived&&(_.fecBitratebps=(a.fecPacketsReceived-g.fecPacketsReceived||0)/o.statsInterval),_.average_jitter_buffer_delay_ms&&_.total_rtt_ms&&(o.e2eDelay=_.average_jitter_buffer_delay_ms+_.total_rtt_ms),r.audio=a,null===(i=this._monitor)||void 0===i||i.report("rtc_media_statistics",_,y),e.abrupt("return",this.filterIllegal(o));case 51:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h,v,p,f,_=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={},o={timestamp:Date.now()},a=this._stream,s=a.streamId,u=a.userId,c=a.isScreen,d=a.subMediaType,l=a._attributes,e.t0=cd,e.t1={media_type:"video",is_screen:!!c,direction:"down",stream_id:s,stream_user_id:u,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:dO(d)?"mute_state_off":"mute_state_on",remote_user_capture_state:l.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:l.localvideo&&l.videostream?"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",i);case 11:return i.isScreen=c,e.next=14,this.handler.getStats(t);case 14:if((v=e.sent).length){e.next=17;break}return e.abrupt("return",i);case 17:if(v.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,a=e.packetsLost,u=e.packetsReceived,c=e.bytesReceived,d=e.framesDecoded,l=e.jitterBufferDelay,v=e.jitterBufferEmittedCount,p=e.mimeType,f=e.firCount,m=e.availableIncomingBitrate,g=e.availableOutgoingBitrate,y=e.bytesSent,S=e.nominated,b=e.id,E=e.currentRoundTripTime,k=e.state,T=e.writable,I=e.candidateType,A=e.ip,R=e.address,w=e.networkType,C=e.port,x=e.nackCount,P=e.pliCount,O=e.protocol,D=e.requestsReceived,M=e.responsesReceived,N=e.requestsSent,L=e.consentRequestsSent,U=e.responsesSent,V=e.ssrc,F=e.jitter,B=e.framesReceived,j=e.keyFramesDecoded,G=e.totalDecodeTime,z=e.decoderImplementation,H=e.lastPacketReceivedTimestamp;if("inbound-rtp"===t)o.packetsLost=a,h.packetsLost=a,o.packetsReceived=u,h.packetsReceived=u,o.bytesReceived=c,h.bytes=c,o.framesDecoded=d,o.totalDecodeTime=G,void 0!==l&&(o.jitterBufferDelay=l/v*1e3,h.average_jitter_buffer_delay_ms=o.jitterBufferDelay),h.fir_count=f,h.nackCount=x,o.nackCount=x,h.pli_count=P,h.ssrc=V,h.jitter=F,h.framesReceived=B,o.framesReceived=B,h.framesDecoded=d,h.key_frames_decoded=j,h.decoder_name=z,h.last_packet_received_timestamp=H,void 0!==n&&(i.width=n,h.frame_size_width=n,i.height=r,h.frame_size_height=r);else if("track"===t&&void 0!==n)i.width=n,h.frame_size_width=n,i.height=r,h.frame_size_height=r,void 0!==B&&(h.framesReceived=B,o.framesReceived=B);else if("codec"===t)h.codecName=p;else if("candidate-pair"===t){var X,K,q;h.ice_available_incoming_bitrate=m,h.ice_available_outgoing_bitrate=g,h.ice_bytes_received=c,h.ice_bytes_sent=y,h.ice_nominated=+S,h.ice_pair_id=b,h.ice_pair_rtt=E,h.rtt=1e3*E,h.rtt&&null!==(X=_._context)&&void 0!==X&&null!==(K=X.streamRTT)&&void 0!==K&&null!==(q=K[s])&&void 0!==q&&q.video&&(h.total_rtt_ms=h.rtt+_._context.streamRTT[s].video),i.rtt=h.rtt,h.ice_pair_state=k,h.ice_pair_writable=T,h.recv_ping_requests=D,h.recv_ping_responses=M,h.sent_ping_requests_before_first_response=N,h.sent_ping_requests_total=N+(L||0),h.sent_ping_responses=U}else"local-candidate"===t?(h.local_candidate_type=I,h.local_ip=A||R,h.local_network_type=w,h.local_port=C,h.protocol=O):"remote-candidate"===t&&(h.remote_candidate_type=I,h.remote_ip=A||R,h.remote_port=C)})),(p=r.video).timestamp){e.next=22;break}return r.video=o,e.abrupt("return",this.filterIllegal(i));case 22:return i.videoLossRate=(o.packetsLost-p.packetsLost)/(o.packetsReceived-p.packetsReceived+(o.packetsLost-p.packetsLost)),p.totalDecodeTime&&p.framesDecoded&&o.framesDecoded!==p.framesDecoded&&(h.decode_elapse_per_frame=+((o.totalDecodeTime-p.totalDecodeTime)/(o.framesDecoded-p.framesDecoded)*1e3).toFixed(2)),i._retransmittedRate=(o.nackCount-p.nackCount)/(o.packetsReceived-p.packetsReceived+(o.packetsLost-p.packetsLost)),i.videoLossRate=Number.isNaN(i.videoLossRate)?0:i.videoLossRate,h.fraction_lost=i.videoLossRate,i.statsInterval=o.timestamp-p.timestamp,h.stats_interval=i.statsInterval,i.receivedKBitrate=(o.bytesReceived-p.bytesReceived||0)/i.statsInterval*8,h.bitrate=Math.round(1e3*i.receivedKBitrate),h.bandwidth=Math.round(h.bitrate/1024),i.decoderOutputFrameRate=1e3*(o.framesDecoded-p.framesDecoded)/i.statsInterval,i.receivedFrameRate=1e3*(o.framesReceived-p.framesReceived)/i.statsInterval,h.frame_rate_decoded=Math.round(i.decoderOutputFrameRate),h.frame_rate_received=Math.round(i.receivedFrameRate),h.average_jitter_buffer_delay_ms&&h.total_rtt_ms&&(i.e2eDelay=h.average_jitter_buffer_delay_ms+h.total_rtt_ms),r.video=o,this.processStall(this._stream,h,i,c),this.isPaused?(f=o.timestamp-(this.pauseStart||0),h.pause_duration=this.pauseDuration+(f>500?f:0),this.pauseStart=o.timestamp):h.pause_duration=this.pauseDuration,h.pause_duration=Math.min(h.stall_duration||h.stuck_length||0,h.pause_duration),this.pauseDuration=0,null===(n=this._monitor)||void 0===n||n.report("rtc_media_statistics",h),e.abrupt("return",this.filterIllegal(i));case 44: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(){AI(TI(o.prototype),"destroy",this).call(this),this.delStatsEvtInterval(),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}(nV);sd(oV,"audioStallInterval",void 0),sd(oV,"audioStallRatio",void 0);var aV,sV,uV,cV=new nP("Stream",0),dV=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"videoDom",void 0),n}return Kd(r,[{key:"requestVideoFrameCallback",value:function(){var e=this;return new X_((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 Rm(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(){this.statsReport.destroy()}}]),r}(sD),lV=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}(lV||{}),hV=function(e){wI(r,e);var t=XI(r);function r(e){var n;return qd(this,r),sd(QT(n=t.call(this)),"isScreen",!1),sd(QT(n),"stream",void 0),sd(QT(n),"streamId",void 0),sd(QT(n),"audioMid",void 0),sd(QT(n),"videoMid",void 0),sd(QT(n),"seiList",[]),sd(QT(n),"videoTrack",void 0),sd(QT(n),"audioTrack",void 0),sd(QT(n),"videoTransceiver",void 0),sd(QT(n),"audioTransceiver",void 0),sd(QT(n),"videoEncodeConfig",[MO]),sd(QT(n),"subVideoDescriptions",[]),sd(QT(n),"enableSimulcast",!1),sd(QT(n),"observer",void 0),sd(QT(n),"statsReport",void 0),sd(QT(n),"prevBitrate",0),sd(QT(n),"pubAudio",!1),sd(QT(n),"pubVideo",!1),sd(QT(n),"pubAttributes",void 0),n.engineId=e,n.stream=new MediaStream,n.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1},n.statsReport=new iV(e,QT(n)),n}return Kd(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:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.sender){var t=this.videoTransceiver.sender;if(UN()){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=rV.generateSEI(n.content),a=new Uint8Array(o.byteLength+t.data.byteLength);if(0===n.repeatCount)GE(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 cV.print("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 cV.print("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){var e;SP(this.engineId,"localstream_clean","".concat((new Error).stack),0,this.streamId||""),this.audioMid=void 0,this.videoMid=void 0,this.videoTransceiver=void 0,this.audioTransceiver=void 0,null===(e=this.observer)||void 0===e||e.reset(),this.stopReport(),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}(dV),vV=function(e){wI(r,e);var t=XI(r);function r(e,n,i,o,a){var s;return qd(this,r),sd(QT(s=t.call(this)),"streamId",void 0),sd(QT(s),"userId",void 0),sd(QT(s),"isScreen",void 0),sd(QT(s),"hasVideo",void 0),sd(QT(s),"hasAudio",void 0),sd(QT(s),"_attributes",void 0),sd(QT(s),"streamState",void 0),sd(QT(s),"observer",void 0),sd(QT(s),"statsReport",void 0),sd(QT(s),"subVideo",void 0),sd(QT(s),"subAudio",void 0),sd(QT(s),"subMediaType",void 0),sd(QT(s),"subLayer",void 0),sd(QT(s),"audioMid",void 0),sd(QT(s),"videoMid",void 0),sd(QT(s),"_sequenceId",void 0),sd(QT(s),"stream",void 0),sd(QT(s),"videoTrack",void 0),sd(QT(s),"audioTrack",void 0),sd(QT(s),"videoTransceiver",void 0),sd(QT(s),"audioTransceiver",void 0),sd(QT(s),"recordedVideoFrames",void 0),sd(QT(s),"stillExist",void 0),sd(QT(s),"originalMediaType",void 0),sd(QT(s),"priority",void 0),sd(QT(s),"originalStreamIndex",0),sd(QT(s),"virtual",void 0),s.engineId=e,s.virtual=!1,s.userId=n,s.isScreen=o,s.streamId=i,s.hasAudio=a.audiostream&&a.localaudio,s.hasVideo=a.videostream&&a.localvideo,s._attributes=a,s.subVideo=!1,s.subAudio=!1,s._sequenceId=0,s.subMediaType=qU.NONE,s.subLayer={spatialLayer:0,spatialSubLayer:-1},s.streamState=0,s.statsReport=new oV(e,QT(s)),s}return Kd(r,[{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:"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}},{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){YU.getNalunits(new WU(t.data)).forEach((function(t){if(t.sei){var r=rV.decodeSeiBody(t.body);r&&r.type!==QU.internal&&e.safeEmit("onSEIMessage",r.payload)}})),r.enqueue(t)}})).pipeTo(n)}else cV.print("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){t.enqueue(e)}})).pipeTo(r)}else cV.print("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r,n,i,o,a;try{var s;SP(this.engineId,"Stream.ontrack",ZE({uid:this.userId,streamId:this.streamId,streams:$S(s=e.streams).call(s,(function(e,t){return e+(null==(r=t)?"undefined | null":"string"==typeof r?r:ZE({id:r.id,active:r.active}));var r}),""),transceiver:(i=e.transceiver,null==i?"undefined | null":"string"==typeof i?i:ZE({currentDirection:i.currentDirection,direction:i.direction,mid:i.mid,stopped:i.stopped,receiver:(a=i.receiver,null==a?"undefined | null":"string"==typeof a?a:ZE({track:vO(a.track)})),sender:(o=i.sender,null==o?"undefined | null":"string"==typeof o?o:ZE({track:vO(o.track)}))})),track:vO(e.track)}),0,this.streamId||"")}catch(ZH){}if(null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&vk(n).call(n,this.streamId)){var u,c=e.track;"video"===(null==c?void 0:c.kind)?this._setVideoTrack(c):"audio"===(null===(u=e.track)||void 0===u?void 0:u.kind)&&this._setAudioTrack(c),this._setStream(e.streams[0])}this.safeEmit("ontrack",e)}},{key:"clean",value:function(){var e,t,r;cV.print("clean",Rm(e="exec stream.clean ".concat(this.streamId," ")).call(e,this.userId)),SP(this.engineId,"remotestream_clean","".concat((new Error).stack),0,this.streamId),this.subAudio=!1,this.subVideo=!1,this.audioMid=void 0,this.videoMid=void 0,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.videoTransceiver=void 0,this.audioTransceiver=void 0,this.recordedVideoFrames=void 0,null===(r=this.observer)||void 0===r||r.reset(),this.stopReport(),delete this.priority}},{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=LU(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]:DP();return new _U(e,t)}(e),this.emit("ontrack",this.videoTrack))}},{key:"_getSubLayerBySpatialLayer",value:function(e){var t=this._attributes,r=t.videoDescriptions,n=t.subVideoDescriptions,i=void 0===n?[]:n,o=r[e],a=o.width,s=o.height,u=oE(i).call(i,(function(e){return e.width===a&&e.height===s}));return{spatialLayer:e,spatialSubLayer:(null==u?void 0:u.sub_index)||-1}}}]),r}(dV),pV=new nP("queue",4),fV=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(fV||{}),_V=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}(_V||{}),mV=(sd(aV={},"publish","unpublish"),sd(aV,"subscribe","unsubscribe"),sd(aV,"pushtrack","removetrack"),aV),gV=(sd(sV={},"publish",0),sd(sV,"subscribe",0),sd(sV,"pushtrack",0),sd(sV,"unpublish",1),sd(sV,"unsubscribe",1),sd(sV,"removetrack",1),sV),yV=function(e){wI(r,e);var t=XI(r);function r(){var e;return qd(this,r),sd(QT(e=t.call(this)),"_queue",void 0),e._queue=[],e}return Kd(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!==mV[t.action]||(n=t.streamId,pV.print("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;eO&&eO>=86&&eO<=92&&(t=Math.min(this._queue.length,5));for(var r=gV[this._queue[0].action],n=1;n<t;n++){var i;if(gV[this._queue[n].action]!==r)return{sdpStrategy:r,items:GE(i=this._queue).call(i,0,n)}}return{sdpStrategy:r,items:GE(e=this._queue).call(e,0,t)}}}]),r}(oD),SV=new nP("ChromeHandler",3),bV=UN(),EV=function(e){wI(l,e);var t,r,n,i,o,a,s,u,c,d=XI(l);function l(e){var t;return qd(this,l),sd(QT(t=d.call(this,e)),"name","chrome"),sd(QT(t),"_queueBusy",!1),sd(QT(t),"_sdpQueue",void 0),sd(QT(t),"_aSendonlyOfferTpl",void 0),sd(QT(t),"_vSendonlyOfferTpl",void 0),sd(QT(t),"_aRecvonlyOfferTpl",void 0),sd(QT(t),"_vRecvonlyOfferTpl",void 0),sd(QT(t),"_mid",10),sd(QT(t),"_offerSession",void 0),sd(QT(t),"_answerSession",void 0),sd(QT(t),"_offerMlines",[]),sd(QT(t),"_answerMlines",[]),sd(QT(t),"_inactiveMlineIndex",[]),sd(QT(t),"_mlinesCache",{}),t._sdpQueue=new yV,t._sdpQueue.on("start",(function(){t._queueBusy||"stable"!==t._peerConnection.signalingState||(SV.print("dequeue start"),t.dequeue())})),t}return Kd(l,[{key:"connect",value:(c=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return SV.print("connect","invoke connect"),this._offerIce={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=4,aL(this.id,t);case 4:return this._answerIce=e.sent,this._connectionId=this._answerIce.iceUfrag,e.next=8,this._peerConnection.createOffer();case 8:return i=e.sent,o=FN.parse(i.sdp),a=WT(o.media,1),s=a[0],this._offerIce.fingerprint=o.fingerprint||s.fingerprint,delete o.media,this._offerSession=cd({},o),this._answerSession=cd({},o),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),this._offerMlines=[cd(cd(cd({},s),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[cd(cd(cd({},s),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription(),e.next=22,new X_((function(e,t){u._dataChannel.onopen=function(){SV.print("connect","dataChannel open"),u._reportRtcInvokeStatus("es.dc.open",""),e("")},u._dataChannel.onerror=function(e){u._report("rtc_signaling_msg_error",{error_code:e.error.sdpLineNumber,message:e.error.errorDetail,reason:"invalid data"}),u._reportRtcInvokeStatus("es.dc.error",""),t(e)},u._dataChannel.onclose=function(e){u._reportRtcInvokeStatus("es.dc.close",""),t(e)},u._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==u._peerConnection.iceConnectionState&&"closed"!==u._peerConnection.iceConnectionState&&"failed"!==u._peerConnection.connectionState||t(e)}))}));case 22:return SV.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 24:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"disconnect",value:function(){this._peerConnection.close(),this._dataChannel.close(),this._peerConnection.ontrack=null}},{key:"destroy",value:function(){AI(TI(l.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(u=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A,R,w,C,x,P,O,D,M,N,L,U,V,F;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=t.stream,d=t.enableSimulcast,h=AI(TI(l.prototype),"internalPublish",this).call(this,t),v=h.videoDescriptions,p=h.subVideoDescriptions,f=h.audioTransceiverInit,_=h.videoTransceiverInit,m=tL(this._nextSsrc),this._nextSsrc=m.next,g="".concat(this._mid++),y="".concat(this._mid++),S=cd(cd(cd({},this._aSendonlyOfferTpl),this._offerIce),{},{mid:g,msid:Rm(r="".concat(c.id," ")).call(r,c.id,"-audio"),ssrcs:rL(c.id,"audio",m.audio,$N)}),b=cd(cd(cd({},this._vSendonlyOfferTpl),this._offerIce),{},{mid:y,msid:Rm(n="".concat(c.id," ")).call(n,c.id,"-video")}),d?(SV.print("subVideoDesc","desc: %o ",p),delete b.ssrcGroups,delete b.ssrcs,E=[],b.rids=YE(v).call(v,(function(e){var t=e.rid;return E.unshift(t),{id:t,direction:"send"}})),b.simulcast={dir1:"send",list1:E.join(";")}):(k=nL(c.id,m,{cname:$N}),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!==(R=XA(A=S.rtp).call(A,(function(e){return"red"===e.codec})))&&(C=GE(w=S.rtp).call(w,R,1),x=WT(C,1),P=x[0],S.rtp.unshift(P)),O=[],S.rtp.forEach((function(e){return O.push(e.payload)})),S.payloads=O.join(" ")),null!==(a=this._context)&&void 0!==a&&null!==(s=a.serverConfig)&&void 0!==s&&s.videoCodec&&dL(b,null===(D=this._context)||void 0===D||null===(M=D.serverConfig)||void 0===M?void 0:M.videoCodec),(jP||qP)&&Array.isArray(b.ext)&&(b.ext=Gs(N=b.ext).call(N,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&vk(t).call(t,"video-orientation"))}))),(L=null==S?void 0:oE(u=S.rtp).call(u,(function(e){return"opus"===e.codec})))&&S.fmtp&&(F=oE(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)),d||jP||this.addBitrateLimit(b,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[S,b],e.abrupt("return",{partialSdp:oL(this._offerSession,S,b),audioMid:g,videoMid:y,type:"incroffer",semantics:"unified-plan",videoDescriptions:v,subVideoDescriptions:p,audioTransceiverInit:f,videoTransceiverInit:_});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"subscribe",value:(s=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A,R,w,C,x,P,O,D=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(SV.print("subscribe"),a="incroffer",s="unified-plan",this._aRecvonlyOfferTpl&&this._vRecvonlyOfferTpl){e.next=9;break}return e.next=6,this._genOfferSdp();case 6:return u=e.sent,e.next=9,this.createAVMlineOfferTpl(u);case 9:if(c="",d="",l=!1,h=!1,v=void 0,p=void 0,this._mlinesCache[t.streamId]=[v,p],t.virtual?(c="".concat(this._mid++),l=!0):r.multiChatMode?(c="".concat(this._mid++),d="".concat(this._mid++),h=!0):(l=!0,h=!0,c="".concat(this._mid++),d="".concat(this._mid++)),c&&(v=cd(cd({},this._aRecvonlyOfferTpl),{},{mid:c})),l&&(this._mlinesCache[t.streamId][0]=v,f={track:"audio",init:{direction:"recvonly"}}),d&&(p=cd(cd({},this._vRecvonlyOfferTpl),{},{mid:d})),h&&(this._mlinesCache[t.streamId][1]=p,_={track:"video",init:{direction:"recvonly"}}),m=oL(this._offerSession,v,p),g=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._vSendonlyAnswerTpl){e.next=32;break}return g=tL(this._nextSsrc),this._nextSsrc=g.next,A=cd(cd(cd({},this._aSendonlyAnswerTpl),this._answerIce),{},{mid:c,msid:Rm(y=Rm(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:rL(t.streamId,"audio",g.audio)}),R=cd(cd(cd({},this._vSendonlyAnswerTpl),this._answerIce),{},{mid:d,msid:Rm(E=Rm(k="".concat(t.streamId)).call(k,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-video"," ")).call(E,t.streamId,"-video")},nL(t.streamId,g,{flexfec:this._enableSubFlexfec})),w=new X_((function(e){D._sdpQueue.enqueue({action:_V.subscribe,streamId:t.streamId,audioMid:c,videoMid:d,audioTransceiverInit:f,videoTransceiverInit:_,signalingAck:{sdp:FN.write(cd(cd({},D._answerSession),{},{media:[A,R]})),sequenceId:t.sequenceId?++t.sequenceId:0},stream:t,sdp:m,onSuccess:function(){SV.print("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:oE(i=n.rtp).call(i,(function(e){return"opus"===e.codec})))&&null!==(o=v)&&void 0!==o&&o.fmtp&&(O=null===(x=v)||void 0===x?void 0:oE(P=x.fmtp).call(P,(function(e){return e.payload===C.payload})))&&this._context&&(O.config+=";stereo=1;sprop-stereo=1"),e.abrupt("return",{partialSdp:m,audioMid:c,videoMid:d,type:a,semantics:s,audioTransceiverInit:f,videoTransceiverInit:_,allSsrc:g});case 35:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(SV.print("handleAck()","item: %o",t),!t.generatorSsrc){e.next=4;break}return SV.print("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 a.apply(this,arguments)})},{key:"dequeue",value:(o=Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u,c,d,l,h,v,p,f,_=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._queueBusy=!0,t=this._sdpQueue.dequeue(),SV.print("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!==fV.ADD){e.next=15;break}return e.delegateYield(Sm().mark((function e(){var t,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(t=cd({},_._answerIce)).candidates,s=!1,u=!1,e.prev=4,d=FD(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,u=n.audioTransceiverInit,c=n.videoTransceiverInit,d=n.signalingAck,l=n.stream,h=l instanceof vV;if(n.onSuccess&&a.push(n.onSuccess),h&&(null==d?void 0:d.sequenceId)<l.sequenceId)return"break";var v,p={},f={},m=FN.parse(d.sdp);Array.isArray(m.media)&&LA(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=cd(cd({},n),t)).type?(p=n).mid=e:(f=n).mid=r}));var g,y=l.streamId;if(s===_V.publish&&(y=null===(g=l.stream)||void 0===g?void 0:g.id),!_._mlinesCache[y])return"break";var S=WT(_._mlinesCache[y],2),b=S[0],E=S[1];if(u&&b){l.audioTransceiver=_._peerConnection.addTransceiver(u.track,u.init),_._reportRtcInvokeStatus("chromeHandler.addTrack",ZE({audioStreamTrack:vO(u.track)}));var k=_._inactiveMlineIndex.shift();k||(k=_._offerMlines.length),_._offerMlines[k]=cd({},b),_._answerMlines[k]=p,bV&&l.initAudioEncodedTransform()}if(c&&E){var T,I;l.videoTransceiver=_._peerConnection.addTransceiver(c.track,c.init),_._reportRtcInvokeStatus("chromeHandler.addTrack",ZE({videoStreamTrack:vO(c.track)}));var A,R,w=_._inactiveMlineIndex.shift();w||(w=_._offerMlines.length),_._offerMlines[w]=cd({},E),s===_V.publish&&null!==(T=_._context)&&void 0!==T&&null!==(I=T.serverConfig)&&void 0!==I&&I.videoCodec&&dL(f,null===(A=_._context)||void 0===A||null===(R=A.serverConfig)||void 0===R?void 0:R.videoCodec),_._answerMlines[w]=f,bV&&l.initVideoEncodedTransform()}i.push(l.streamId||""),o.push(h?l.userId:"local"),h&&(l.sequenceId=null==d?void 0:d.sequenceId),delete _._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),u=!0,c=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,!u){e.next=30;break}throw c;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!==_V.removetrack&&(f[r]=r),f[t]=t})),this._offerMlines=YE(h=this._offerMlines).call(h,(function(e,t){return f[e.mid]&&(e=iL(e),_._inactiveMlineIndex.push(t)),e})),LA(v=this._inactiveMlineIndex).call(v,(function(e,t){return e-t})),this._answerMlines=YE(p=this._answerMlines).call(p,(function(e){return f[e.mid]&&(e=iL(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(ZH){}SV.print("dequeue","loop"),e.next=29;break;case 26:e.prev=26,e.t1=e.catch(6),SV.print("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 o.apply(this,arguments)})},{key:"setDescription",value:(i=Em(Sm().mark((function e(t){var r,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return SV.print("setDescription"),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=MP(),t&&this._report("rtc_begin_create_offer",{direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId}),e.next=10,this._peerConnection.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:MP()-n}),e.next=13,this.setLocalDescription(FN.write(this._offerSession),t);case 13:return e.next=15,this.setRemoteDescription(FN.write(this._answerSession),t);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getDefaultSdp",value:(n=Em(Sm().mark((function e(){var t,r,n,i;return Sm().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=FN.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(e.mid+""),!0)})),n.groups=[{mids:i.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:FN.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=Em(Sm().mark((function e(t){return Sm().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;FN.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=Em(Sm().mark((function e(){var t,r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,aO(!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 cR(sR.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)})}]),l}(vL),kV=new nP("FirefoxHandler",3),TV=function(e){wI(l,e);var t,r,n,i,o,a,s,u,c,d=XI(l);function l(){var e,t;qd(this,l);for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return sd(QT(t=d.call.apply(d,Rm(e=[this]).call(e,n))),"name","firefox"),sd(QT(t),"_aRecvonlyOfferTpl",void 0),t}return Kd(l,[{key:"connect",value:(c=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l,h=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return kV.print("connect","invoke connect"),this._offerIce={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=4,aL(this.id,t);case 4:return this._answerIce=e.sent,this._connectionId=this._answerIce.iceUfrag,this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),this._peerConnection.addTransceiver("video",{direction:"recvonly"}),e.next=10,this._peerConnection.createOffer();case 10:return s=e.sent,u=FN.parse(s.sdp),c=WT(u.media,1),d=c[0],this._offerIce.fingerprint=u.fingerprint||d.fingerprint,u.media=YE(i=u.media).call(i,(function(e){return cd(cd({},e),h._offerIce)})),YE(o=u.media).call(o,(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===_E(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})))})),(l=cd({},u)).fingerprint=this._answerIce.fingerprint,l.media=YE(a=l.media).call(a,(function(e){return delete(e=cd(cd({},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=21,this.setLocalDescription(FN.write(u));case 21:return e.next=23,this.setRemoteDescription(FN.write(l));case 23:return e.next=25,new X_((function(e,t){h._dataChannel.onopen=function(){kV.print("connect","dataChannel open"),h._reportRtcInvokeStatus("es.dc.open",""),e("")},h._dataChannel.onerror=function(e){h._report("rtc_signaling_msg_error",{error_code:e.error.sdpLineNumber,message:e.error.errorDetail,reason:"invalid data"}),h._reportRtcInvokeStatus("es.dc.error",""),t(e)},h._dataChannel.onclose=function(e){h._reportRtcInvokeStatus("es.dc.close",""),t(e)},h._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==h._peerConnection.iceConnectionState&&"closed"!==h._peerConnection.iceConnectionState&&"failed"!==h._peerConnection.connectionState||t(e)}))}));case 25:return kV.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 27:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"publish",value:(u=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,h,v,p,f,_,m=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=AI(TI(l.prototype),"internalPublish",this).call(this,t),o=i.videoDescriptions,a=i.subVideoDescriptions,s=i.audioTransceiverInit,u=i.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(s.track,s.init),t.videoTransceiver=this._peerConnection.addTransceiver(u.track,u.init),c=MP(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:""}),e.next=7,this._peerConnection.createOffer();case 7:return d=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:MP()-c}),(h=FN.parse(d.sdp)).media=null===(r=h.media)||void 0===r?void 0:YE(r).call(r,(function(e){return cd(cd({},e),m._offerIce)})),e.next=13,this.setLocalDescription(FN.write(h));case 13:return v=t.audioTransceiver.mid,p=t.videoTransceiver.mid,f=null,_=null,h.media=null===(n=h.media)||void 0===n?void 0:YE(n).call(n,(function(e){if("".concat(e.mid)===v){var t,r,n=null===(t=f=e)||void 0===t?void 0:oE(r=t.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&f.fmtp){var i,o,a=oE(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)===p){var s,u,c,d;null!==(s=m._context)&&void 0!==s&&null!==(u=s.serverConfig)&&void 0!==u&&u.videoCodec&&dL(e,null===(c=m._context)||void 0===c||null===(d=c.serverConfig)||void 0===d?void 0:d.videoCodec),_=e}return e})),this.addBitrateLimit(_,t.videoEncodeConfig[0].maxKbps),e.next=21,this.setLocalDescription(FN.write(h));case 21:return e.abrupt("return",{partialSdp:oL(h,f,_,!1),audioMid:v,videoMid:p,type:"incroffer",semantics:"unified-plan",videoDescriptions:o,subVideoDescriptions:a,audioTransceiverInit:s,videoTransceiverInit:u});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"subscribe",value:(s=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A,R=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return kV.print("subscribe()"),u="",c="",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"})),p=MP(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId}),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:MP()-p}),(_=FN.parse(f.sdp)).media=null===(n=_.media)||void 0===n?void 0:YE(n).call(n,(function(e){return cd(cd({},e),R._offerIce)})),YE(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===_E(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(FN.write(_),{streamId:t.streamId||"",streamUserId:t.userId});case 21:if(u=null===(o=t.audioTransceiver)||void 0===o?void 0:o.mid,c=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid,null===(s=_.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===u?h=e:"".concat(e.mid)===c&&(v=e)})),u&&h||(u="audio_".concat(c),h=cd(cd({},this._aRecvonlyOfferTpl),{},{mid:u})),t.audioMid=u,t.videoMid=c,m=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=36;break}return m=tL(this._nextSsrc),this._nextSsrc=m.next,I=cd(cd(cd({},this._aSendonlyAnswerTpl),this._answerIce),{},{mid:u,msid:Rm(g=Rm(y="".concat(t.streamId)).call(y,null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-audio"," ")).call(g,t.streamId,"-audio"),ssrcs:rL(t.streamId,"audio",m.audio)}),A=cd(cd(cd({},this._vSendonlyAnswerTpl),this._answerIce),{},{mid:c,msid:Rm(b=Rm(E="".concat(t.streamId)).call(E,null!==(k=this._context)&&void 0!==k&&k.avSync?"":"-video"," ")).call(b,t.streamId,"-video")},nL(t.streamId,m,{flexfec:this._enableSubFlexfec})),e.next=35,this._internalSetRemoteDescription([I,A],t);case 35:null===(T=m)||void 0===T||delete T.next;case 36:return e.abrupt("return",{partialSdp:oL(_,h,v,!1),audioMid:u,videoMid:c,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});case 37:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Em(Sm().mark((function e(t){var r,n,i,o;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==_V.unpublish&&i!==_V.unsubscribe&&i!==_V.removetrack){e.next=5;break}return e.next=4,this.close(n);case 4:return e.abrupt("return",n.streamId||"");case 5:if(!t.generatorSsrc){e.next=8;break}return kV.print("already set remote"),e.abrupt("return","");case 8:return o=FN.parse(null==r?void 0:r.sdp),e.next=11,this._internalSetRemoteDescription(o.media,n);case 11:return e.abrupt("return","");case 12:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(u=FN.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=cd(cd({},e),l._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type){if(r instanceof hV&&KP<=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}})),c=FN.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=YE(o=c.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),u.groups=c.groups,u.media=d,YE(a=u.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===_E(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(FN.write(u));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Em(Sm().mark((function e(){var t,r,n,i,o;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=FN.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(e.mid+""),!0)})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:FN.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=Em(Sm().mark((function e(t,r,n){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return kV.print("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=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return kV.print("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 u=e.sent,(c=FN.parse(null==u?void 0:u.sdp)).media=YE(n=c.media).call(n,(function(e){return a[e.mid]&&(e=iL(e)),"inactive"!==e.direction&&s.push(e.mid),cd(cd({},e),h._offerIce)})),d=FN.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=YE(o=c.media).call(o,(function(e){return"inactive"===e.direction?e:l[e.mid]})),c.groups&&d.groups&&(c.groups[0].mids=s.join(" "),d.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(FN.write(c));case 17:return e.next=19,this.setRemoteDescription(FN.write(d));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Em(Sm().mark((function e(){return Sm().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;FN.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),l}(vL),IV=function(e){return BP?new TV(e):new EV(e)},AV=new nP("Locker",2),RV=1,wV=function(){function e(t){var r;qd(this,e),sd(this,"lockingPromise",X_.resolve()),sd(this,"locks",0),sd(this,"name",""),sd(this,"lockId",void 0),this.lockId=RV++,t&&(this.name=t),AV.print(Rm(r="[lock-".concat(this.name,"-")).call(r,this.lockId,"] is created."))}return Kd(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t,r,n=this;this.locks+=1,AV.print(Rm(e=Rm(t="[lock-".concat(this.name,"-")).call(t,this.lockId,"] locked, current queue ")).call(e,this.locks,"."));var i=new X_((function(e){r=function(){var t,r;n.locks-=1,AV.print(Rm(t=Rm(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}(),CV=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}(CV||{}),xV=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}(xV||{}),PV=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(PV||{}),OV=function(e){return e[e.SUB=0]="SUB",e[e.UNSUB=1]="UNSUB",e}(OV||{}),DV=(sd(uV={},Od.communication,[0]),sd(uV,Od.chat,[0]),sd(uV,Od.chatRoom,[1,"IES_chatroom"]),sd(uV,Od.coHost,[1,"IES_PK"]),sd(uV,Od.meeting,[16]),sd(uV,Od.classRoom,[0]),uV),MV=ad,NV=tu,LV=function(e,t,r,n){for(var i,o=n>1?void 0:n?NV(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&&MV(t,r,o),o},UV=new nP("MediaServerClient",2),VV=6e4,FV=function(e){return e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTED="connected",e.CONNECTING="connecting",e}(FV||{}),BV=function(e,t){UV.print(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)},jV=function(e){wI(k,e);var t,r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E=XI(k);function k(e){var t;return qd(this,k),sd(QT(t=E.call(this)),"id",void 0),sd(QT(t),"_token",void 0),sd(QT(t),"_appId",void 0),sd(QT(t),"_roomId",void 0),sd(QT(t),"_roomAttributes",void 0),sd(QT(t),"_clientId",void 0),sd(QT(t),"_businessId",void 0),sd(QT(t),"_userInfo",void 0),sd(QT(t),"_useCloudProxy",void 0),sd(QT(t),"_expectedIDC",void 0),sd(QT(t),"_authorization",void 0),sd(QT(t),"_sessionId",void 0),sd(QT(t),"_iceConfigRequestManager",void 0),sd(QT(t),"_ontrackCallbackMap",new FS),sd(QT(t),"_subResolves",{}),sd(QT(t),"supportConcurrent",!1),sd(QT(t),"_handler",void 0),sd(QT(t),"_pubSubLock",void 0),sd(QT(t),"_joinLeaveLock",void 0),sd(QT(t),"_state",void 0),sd(QT(t),"_dataChannelSignal",void 0),sd(QT(t),"_subConfig",{}),sd(QT(t),"_monitor",void 0),sd(QT(t),"_roomProfile",Od.communication),sd(QT(t),"_context",void 0),sd(QT(t),"_subStreamQueue",{}),t.id=e.id,t._monitor=mP(t.id),t._pubSubLock=new wV("pubSubLock"),t._joinLeaveLock=new wV("joinLeaveLock"),t._state="disconnected",t._roomAttributes={multiChatMode:!1,bigRoomMode:!1},t._context=e,t.on("SUB_END",(function(e){return t._handleSubStreamQueue(e)})),t}return Kd(k,[{key:"_addHandlerEvents",value:function(){var e,t=this;null===(e=this._handler)||void 0===e||e.once("disconnect",(function(){UV.print("emit ABNORMAL_DISCONNECTION ice"),t.safeEmit(kD.ABNORMAL_DISCONNECTION)}))}},{key:"_addSignalEventHandler",value:function(){var e,t=this;[bD.ON_ADD_STREAM,bD.ON_ADD_STREAM_LIST,bD.ON_REMOVE_STREAM,bD.ON_REMOVE_STREAM_LIST,bD.USER_CONNECTION,bD.USER_CONNECTION_LIST,bD.USER_DISCONNECTION,bD.USER_DISCONNECTION_LIST,bD.ON_UPDATE_STREAM_ATTRIBUTES,bD.ON_UPDATE_ROOM_ATTRIBUTES,bD.ON_PUSH_TRACK,bD.NODE_CHANGE,bD.ON_CUSTOM_MESSAGE,bD.USER_MESSAGE_RECEIVED,bD.USER_BINARY_MESSAGE_RECEIVED,bD.POST_PROCESSING_MESSAGE,bD.ON_USER_TOKEN_WILL_EXPIRE,bD.STREAM_CONTROL_MESSAGE,bD.ON_UPDATE_USER_ATTRIBUTES,bD.ON_SPEAKER_CHANGE,ED.RSCP,ED.RTT,ED.SSC,bD.ON_STREAM_FAILED].forEach((function(e){var r;null===(r=t._dataChannelSignal)||void 0===r||r.on(e,(function(r){t.safeEmit(e,r)}))})),null===(e=this._dataChannelSignal)||void 0===e||e.once("close",(function(){UV.print("emit ABNORMAL_DISCONNECTION datachannel"),t.safeEmit(kD.ABNORMAL_DISCONNECTION)}))}},{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(kD.ON_CONNECTION_STATE_CHANGE,{prev:this._state,next:e}),this._state=e)}},{key:"businessId",set:function(e){this._businessId=e}},{key:"connect",value:(b=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u=this,c=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=c.length>1&&void 0!==c[1]?c[1]:{},this.connectionState="connecting",this._appId=t,this._handler&&(this._removeSignalEventHandler(),this._handler.destroy()),!r.node){e.next=9;break}n=[r.node],SP(this.id,"es.join.nodeChange",r),e.next=18;break;case 9:return X_.resolve().then((function(){return u.emit("onGetIceConfigHook")})),this._iceConfigRequestManager=new UD(this.id),e.next=13,null===(i=this._iceConfigRequestManager)||void 0===i?void 0:i.getAccessNode(t,null==r?void 0:r.reason,null==r?void 0:r.feedbackNode,this._useCloudProxy,this._expectedIDC);case 13:if(n=e.sent){e.next=17;break}throw SP(this.id,"es.join.getNodeFailed",""),new cR(sR.ICE_SERVER_WRONG,"get ICE config failed");case 17:SP(this.id,"es.join.getNodeSuccess",n);case 18:return X_.resolve().then((function(){return u.emit("onEstablishConnectionHook")})),e.prev=19,a=!1,s=YE(n).call(n,(function(e){var t=IV(u._context);return t.connect(e).then((function(r){var i,s;u.emit("onConnectSuccessHook",null===(i=n)||void 0===i?void 0:i.length),a?t.destroy():(a=!0,o=r,u.safeEmit("prevIceNode",e),u._handler=t,u.supportConcurrent="chrome"===t.name,u._addHandlerEvents(),null===(s=u._monitor)||void 0===s||s.set({connection_id:t.getConnectionId()}))})).catch((function(e){throw t.destroy(),e}))})),e.next=24,sO(s);case 24:UV.print("connect","establish peerConnection success"),e.next=31;break;case 27:throw e.prev=27,e.t0=e.catch(19),this.connectionState="disconnected",new cR(sR.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed",e.t0);case 31:if(!o){e.next=37;break}this._dataChannelSignal=new MD(this.id,o),this._addSignalEventHandler(),this._dataChannelSignal.sendPingSignaling(),e.next=39;break;case 37:throw this.connectionState="disconnected",new cR(sR.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed");case 39:case"end":return e.stop()}}),e,this,[[19,27]])}))),function(e){return b.apply(this,arguments)})},{key:"join",value:(S=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g=this,y=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=y.length>1&&void 0!==y[1]?y[1]:{},i=y.length>2&&void 0!==y[2]&&y[2],o=y.length>3?y[3]:void 0,UV.print("join()","info: %o, params: %o, reconnect: %o, controlMessage: %o",t,n,i,o),this._appId=t.appId,this._token=t.token,this._roomId=t.roomId,this._clientId=t.userInfo.userId,this._businessId=t.userInfo.businessId,this._userInfo=t.userInfo,this._useCloudProxy=t.useCloudProxy,this._expectedIDC=t.expectedIDC,this._roomProfile=t.roomProfile,this._sessionId=n.sessionId,this._handler){e.next=17;break}return e.next=17,this.connect(this._appId,n);case 17:return e.t0=UP.token2auth(this._appId,this._roomId,this._clientId,this._token),e.t1=this._sessionId||"",e.t2=Date.now(),e.t3=o,e.t4={extra_info:this._userInfo.extraInfo,role:this._userInfo.role},e.next=24,null===(r=this._handler)||void 0===r?void 0:r.getDefaultSdp();case 24:return e.t5=e.sent,e.next=27,AN();case 27:return e.t6=e.sent,e.t7=window.navigator.userAgent,e.t8=xO.VERSION,e.t9=IO.getDeviceId(),e.t10=this._appId,e.t11=this._roomId,e.t12=this._clientId,e.t13=this._businessId,e.t14=this._useCloudProxy,e.t15=DV[this._roomProfile]?DV[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},a={Authorization:e.t0,sessionId:e.t1,timestamp:e.t2,controlMessage:e.t3,userAttributes:e.t4,sdpInfo:e.t5,params:e.t16,options:e.t17},X_.resolve().then((function(){return g.emit("onSendingJoinMessageHook")})),e.prev=41,u=i?"reconnected":"joinRoom",e.next=45,this._dataChannelSignal.sendSignaling(u,a);case 45:return c=e.sent,UV.print("join","send join message success"),d=c.config||{},l=d.engine_WEB,this._authorization=a.Authorization,this.connectionState="connected",IO.setEngineWebConfig(this._appId,this._roomId,l),this._context&&(this._context.serverConfig={videoCodec:(null==l?void 0:l.video_codec)||"H264",audioRed:!(null==l||!l.pub_audio_red),muteReplaceUnsub:!(null===(h=c.config)||void 0===h||!h.mute_replace_unsub),simulcastOnDemand:!(BP||!1===(null===(v=c.config)||void 0===v||null===(p=v.engine_VPM)||void 0===p||null===(f=p.ondemand)||void 0===f?void 0:f.enable))},"boolean"==typeof(null==l?void 0:l.av_sync)&&(this._context.avSync=l.av_sync)),oV.audioStallConfig=l,null!=c&&null!==(s=c.relayMessage)&&void 0!==s&&s.sdp&&(null===(_=this._handler)||void 0===_||_.createAVMlineAnswerTpl(c.relayMessage.sdp)),e.abrupt("return",c);case 57:if(e.prev=57,e.t18=e.catch(41),this.connectionState="disconnected",m={461:sR.ROOM_FORBIDDEN,462:sR.USER_FORBIDDEN},!((null===e.t18||void 0===e.t18?void 0:e.t18.code)>=700&&(null===e.t18||void 0===e.t18?void 0:e.t18.code)<800)){e.next=65;break}throw new cR(sR.INVALID_TOKEN,(null===e.t18||void 0===e.t18?void 0:e.t18.message)||"Invalid token");case 65:if(!m[null===e.t18||void 0===e.t18?void 0:e.t18.code]){e.next=67;break}throw new cR(m[null===e.t18||void 0===e.t18?void 0:e.t18.code],(null===e.t18||void 0===e.t18?void 0:e.t18.message)||m[null===e.t18||void 0===e.t18?void 0:e.t18.code]);case 67:if(200===(null===e.t18||void 0===e.t18?void 0:e.t18.code)){e.next=69;break}throw new cR(sR.JOIN_ROOM_FAILED,(null===e.t18||void 0===e.t18?void 0:e.t18.message)||"Join room failed");case 69:case"end":return e.stop()}}),e,this,[[41,57]])}))),function(e){return S.apply(this,arguments)})},{key:"publish",value:(y=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return UV.print("publish()","localStream: %o",t),r=t.videoTrack,n=t.audioTrack,i=MP(),o="",a="",e.prev=6,e.next=9,null===(s=this._handler)||void 0===s?void 0:s.publish(t);case 9:if(g=e.sent){e.next=12;break}throw new cR(sR.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 12:if("H264"!==(null===(u=this._context)||void 0===u||null===(c=u.serverConfig)||void 0===c?void 0:c.videoCodec)){e.next=18;break}return e.next=15,DN();case 15:if(e.sent){e.next=18;break}throw new cR(sR.PUBLISH_FAILED,"h264 is not supported");case 18:return o=g.audioMid,a=g.videoMid,t.pubAttributes={localaudio:!!n,localvideo:!!r,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(r instanceof SU),extaudio:!!(n instanceof bU)},y={attributes:cd({videoDescriptions:g.videoDescriptions},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:o,videoMid:a,sdpInfo:{msid:t.stream.id,type:g.type,sdp:g.partialSdp,semantics:g.semantics}},(S=t.enableSimulcast&&(null===(d=this._context)||void 0===d||null===(l=d.serverConfig)||void 0===l?void 0:l.simulcastOnDemand)&&(null===(h=g.subVideoDescriptions)||void 0===h?void 0:h.length))&&(y.attributes.subVideoDescriptions=g.subVideoDescriptions),e.next=26,null===(v=this._dataChannelSignal)||void 0===v?void 0:v.sendSignaling("publish",y);case 26:if(200===(null==(b=e.sent)?void 0:b.code)){e.next=29;break}throw new cR(sR.PUBLISH_FAILED,(null==b?void 0:b.message)||"publish failed");case 29:if(null===(p=this._monitor)||void 0===p||p.report("rtc_recv_answer",{error_code:0,answer_type:"incranswer",sequence_id:(null==b||null===(f=b.relayMessage)||void 0===f?void 0:f.sequenceId)||0,message:null==b||null===(_=b.relayMessage)||void 0===_?void 0:_.sdp,direction:"up",stream_id:"",stream_user_id:""}),E=new X_((function(e,r){var n,i,s;null===(n=I._handler)||void 0===n||n.handleAck({action:_V.publish,streamId:b.streamId,audioMid:o,videoMid:a,audioTransceiverInit:null==g?void 0:g.audioTransceiverInit,videoTransceiverInit:null==g?void 0:g.videoTransceiverInit,signalingAck:{sdp:null==b||null===(i=b.relayMessage)||void 0===i?void 0:i.sdp,sequenceId:null==b||null===(s=b.relayMessage)||void 0===s?void 0:s.sequenceId},sdp:g.sdp,stream:t,onSuccess:function(){UV.print("publish()","publish success"),e(0)}})})),e.t0=!BP,!e.t0){e.next=35;break}return e.next=35,E;case 35:return S&&this.emit(ED.RSCP,[{StreamIds:[t.stream.id],Metadata:{VideoIndex:0}}]),t.streamId=b.streamId,t.videoMid=a,t.audioMid=o,t.subVideoDescriptions=g.subVideoDescriptions,null===(m=this._monitor)||void 0===m||m.report("rtc_publish_stat",{result:"success",is_screen:"0",start:i,message:"unknown"}),t.statsReport.setLocalStreamStatsEvtInterval((function(e){return I.emit("onLocalStreamStats",e)}),this._handler,this._context),e.abrupt("return");case 45:return e.prev=45,e.t1=e.catch(6),e.t1 instanceof Error&&(null===(T=this._monitor)||void 0===T||T.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:i,message:e.t1.message})),e.next=50,null===(k=this._handler)||void 0===k?void 0:k.rollback(t.stream.id,t);case 50:throw e.t1;case 51:case"end":return e.stop()}}),e,this,[[6,45]])}))),function(e){return y.apply(this,arguments)})},{key:"updatePubTrack",value:(g=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A,R,w,C,x,P,O;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:UV.print("updatePubTrack()","localStream: %o",t),i=t.videoTrack,o=t.audioTrack,a=t.pubAudio,s=t.pubVideo,u=null==o?void 0:o.getTrack("preprocessing"),c=null==i?void 0:i.getTrack("preprocessing"),s&&c?null===(d=t.videoTransceiver)||void 0===d||d.sender.replaceTrack(c):null===(l=t.videoTransceiver)||void 0===l||l.sender.replaceTrack(null),null===(r=this._handler)||void 0===r||r.updateMaxBitrate(t),a&&u?(v=o.mixType,(p=o.mixedAudioTrack)&&v!==jd.PLAYOUT&&!0===u.enabled&&(u=p),null===(h=t.audioTransceiver)||void 0===h||h.sender.replaceTrack(u)):(null===(f=t.audioTransceiver)||void 0===f||f.sender.replaceTrack(null),SP(this.id,"MediaClient.updatePubTrack(audio)","null"));try{SP(this.id,"MediaClient.updatePubTrack",ZE({audioStreamTrack:vO(u),videoStreamTrack:vO(c)}))}catch(ZH){}for(m={},g=0,y=gR(_={localaudio:!!o,localvideo:!!i,videostream:s,audiostream:a,extvideo:!!(i instanceof SU),extaudio:!!(o instanceof bU)});g<y.length;g++)S=WT(y[g],2),b=S[0],(E=S[1])!==oI(t.pubAttributes,b)&&_D(m,b,E);if(an(m).length){e.next=13;break}return e.abrupt("return");case 13:return t.observer&&(k=t.observer,T=m.audiostream,I=m.videostream,A=m.localaudio,R=m.localvideo,w=m.extaudio,C=m.extvideo,void 0!==R?void 0!==C?k.setPushVideo(C):k.setEnableVideo(R):void 0!==I&&k.setUnmuteVideo(I),void 0!==A?void 0!==w?k.setPushAudio(w):k.setEnableAudio(A):void 0!==T&&k.setUnmuteAudio(T)),t.pubAttributes=_,x={roomId:this._roomId,streamId:t.streamId,attributes:m},e.next=18,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateStreamAttributes",x);case 18:if(200===(null==(P=e.sent)?void 0:P.code)){e.next=21;break}throw new cR(sR.UPDATE_TRACK_FAILED,(null==P?void 0:P.message)||"update track failed");case 21:if(!BP){e.next=24;break}return e.next=24,null===(O=this._handler)||void 0===O?void 0:O.setCurrentDescription();case 24:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"updateToken",value:(m=Em(Sm().mark((function e(t){var r,n,i,o,a;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(UV.print("updateToken()","newToken: %o",t),this._token=t,this._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._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 cR(sR.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 cR(sR.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 m.apply(this,arguments)})},{key:"unpublish",value:(_=Em(Sm().mark((function e(t){var r,n,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return UV.print("unpublish()","localStream: %o",t),i={roomId:this._roomId,initStreamId:t.initStreamId,streamId:t.streamId},null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unpublish",i),e.next=5,null===(n=this._handler)||void 0===n?void 0:n.handleAck({action:_V.unpublish,audioMid:t.audioMid,videoMid:t.videoMid,stream:t,streamId:t.streamId});case 5:t.statsReport.unpublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"subscribe",value:(f=Em(Sm().mark((function e(t,r,n){var i=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new X_(function(){var e=Em(Sm().mark((function e(o,a){var s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A,R,w,C,x,P,O,D,M,N,L,U,V,F;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.streamState!==lV.SUB_ED){e.next=2;break}return e.abrupt("return",i._updateSubTrack(t,r,OV.SUB).then(o,a));case 2:if(t.streamState!==lV.SUB_ING){e.next=7;break}return i._subStreamQueue[t.streamId]||(i._subStreamQueue[t.streamId]=[]),UV.print("_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(UV.print("subscribe()","mediaType: %o",r),BV("subscribe()",t),t.streamState=lV.SUB_ING,u=!1,c=!1,cO(r)&&(c=!0),dO(r)&&(u=!0),u||!i.multiChatMode()){e.next=17;break}return t.streamState=lV.INIT,i.emit("SUB_END",t.streamId),e.abrupt("return",o(null));case 17:return d=MP(),l=t.subVideo,h=[],v=!i.multiChatMode(),i._subResolves[t.streamId]||(i._subResolves[t.streamId]=[]),h.push(new X_((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new cR(sR.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),VV);t.on("ontrack",(function r(i){"video"===i.mediaType&&(UV.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v&&h.push(new X_((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new cR(sR.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),VV);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(UV.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p=function(e){t.ontrack(e)},null===(s=i._handler)||void 0===s||s.on("ontrack",p),i._ontrackCallbackMap.set(t,p),e.prev=27,e.next=30,null===(f=i._handler)||void 0===f?void 0:f.subscribe(t,{multiChatMode:i.multiChatMode()});case 30:if(I=e.sent){e.next=33;break}throw new cR(sR.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 33:return A=I.audioMid,R=I.videoMid,t.subVideo=u,w={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},C={audio:!i.multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:R,audioMid:A,sdpInfo:{sdp:null==I?void 0:I.partialSdp,semantics:null==I?void 0:I.semantics,type:null==I?void 0:I.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!i.multiChatMode()||c,video:u},qualityLayer:w},extra:{enableSendRTT:!0}},x=i._context||{},P=x.subscribeFallbackOption,O=x.userPriority,"number"==typeof P&&(C.config.fallbackOption=P),null!=O&&O.has(t.userId)&&(C.config.priority=O.get(t.userId)),null!=I&&I.allSsrc&&(C.extra.subscribeSSRC=I.allSsrc),e.next=44,null===(_=i._dataChannelSignal)||void 0===_?void 0:_.sendSignaling("subscribe",C);case 44:if(200===(null==(D=e.sent)?void 0:D.code)){e.next=47;break}throw new cR(sR.SUBSCRIBE_FAILED,(null==D?void 0:D.message)||"subscribe failed");case 47:return M=null==D?void 0:D.relayMessage,N=M.audioMid,L=M.videoMid,sd(m={},A,N),sd(m,R,L),U=m,UV.print("sub midmap",t.userId,U),t.videoMid=R,t.audioMid=A,t.subMediaType=r,t.streamState=lV.SUB_ED,t.subLayer=w,null===(g=i._monitor)||void 0===g||g.report("rtc_recv_answer",{error_code:0,answer_type:"incranswer",sequence_id:(null==D||null===(y=D.relayMessage)||void 0===y?void 0:y.sequenceId)||0,message:null==D||null===(S=D.relayMessage)||void 0===S?void 0:S.sdp,direction:"down",stream_id:t.streamId,stream_user_id:t.userId}),e.next=58,null===(b=i._handler)||void 0===b?void 0:b.handleAck({action:_V.subscribe,streamId:t.streamId,audioMid:A,videoMid:R,audioTransceiverInit:null==I?void 0:I.audioTransceiverInit,videoTransceiverInit:null==I?void 0:I.videoTransceiverInit,signalingAck:{sdp:null==D||null===(E=D.relayMessage)||void 0===E?void 0:E.sdp,sequenceId:null==D||null===(k=D.relayMessage)||void 0===k?void 0:k.sequenceId},stream:t,sdp:I.sdp,generatorSsrc:!!I.allSsrc});case 58:return e.next=60,X_.all(h);case 60:i.multiChatMode()||(t.subAudio=c),null===(T=i._monitor)||void 0===T||T.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)}),i._handler,i._context),o(null),i.emit("SUB_END",t.streamId),e.next=76;break;case 67:return e.prev=67,e.t0=e.catch(27),e.t0 instanceof Error&&(null===(F=i._monitor)||void 0===F||F.report("rtc_subscribe_stat",{result:"fail",start:d,message:e.t0.message,stream_user_id:t.userId})),t.subVideo=l,t.streamState=lV.INIT,e.next=74,null===(V=i._handler)||void 0===V?void 0:V.rollback(t.streamId,t);case 74:a(e.t0),i.emit("SUB_END",t.streamId);case 76:case"end":return e.stop()}}),e,null,[[27,67]])})));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){UV.print("_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 UV.print("_subStreamQueue","streamId: %o, END",e)}},{key:"controlMessage",value:(p=Em(Sm().mark((function e(t){var r,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return UV.print("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:(v=Em(Sm().mark((function e(t){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return UV.print("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:(h=Em(Sm().mark((function e(t,r,n){return Sm().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 h.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(l=Em(Sm().mark((function e(t,r){var n,i,o;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(UV.print("updateSubTrack()","subLayer: %o",r),t.subLayer.spatialLayer!==r.spatialLayer||t.subLayer.spatialSubLayer!==r.spatialSubLayer){e.next=4;break}return UV.print("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 cR(sR.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 l.apply(this,arguments)})},{key:"updateSubPriority",value:(d=Em(Sm().mark((function e(t,r){var n,i,o;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(UV.print("updateSubPriority()","priority: %o",r),t.priority!==r){e.next=4;break}return UV.print("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 cR(sR.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 d.apply(this,arguments)})},{key:"_updateSubTrack",value:(c=Em(Sm().mark((function e(t,r,n){var i,o,a,s,u,c,d,l;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(UV.print("updateSubTrack()","mediaType: %o",r),BV("updateSubTrack()",t),!this.multiChatMode()||r!==Sd.AUDIO){e.next=5;break}return UV.print("updateSubTrack","multiChatMode mediaType only audio"),e.abrupt("return",t);case 5:return a=0,a=n===OV.SUB?t.subMediaType|r:t.subMediaType-(t.subMediaType&r),UV.print("updateSubTrack","prev: %o, direction: %o, mediaType: %o, newMediaType: %o",t.subMediaType,n,r,a),t.subMediaType===a&&UV.print("updateSubTrack","mediaType no change"),s=!1,u=!1,cO(a)&&(u=!0),dO(a)&&(s=!0),c={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:s,audio:!!this.multiChatMode()||u}}},e.next=15,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("updateSubscribe",c);case 15:if(200===(null==(d=e.sent)?void 0:d.code)){e.next=18;break}throw new cR(sR.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(u),t.subAudio=u),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 c.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(u=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return UV.print("subscribe4pushTrack()","streamInfo: %o",r),BV("subscribe4pushTrack()",t),t.subAudio=!0,null===(n=t.observer)||void 0===n||n.setPushTrack(!0),e.next=6,null===(i=this._handler)||void 0===i?void 0:i.subscribe(t,{multiChatMode:this.multiChatMode()});case 6:if(s=e.sent){e.next=9;break}throw new cR(sR.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 9:return u=s.audioMid,c=s.videoMid,(d=[]).push(new X_((function(e,r){var n=setTimeout((function(){return r(new cR(sR.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),VV);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(UV.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),l=function(e){t.ontrack(e)},null===(o=this._handler)||void 0===o||o.on("ontrack",l),this._ontrackCallbackMap.set(t,l),e.next=18,null===(a=this._handler)||void 0===a?void 0:a.handleAck({action:_V.pushtrack,streamId:t.streamId,audioMid:u,videoMid:c,stream:t,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:null==r?void 0:r.message,sdp:s.sdp});case 18:return e.next=20,X_.all(d);case 20:this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return h.emit("onRemoteStreamStats",e)}),this._handler,this._context);case 21:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(s=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:BV("unsubscribe4removeTrack()",t),UV.print("unsubscribe4removeTrack()","sequenceId: ",r.sequenceId);case 2:case"end":return e.stop()}}),e)}))),function(e,t){return s.apply(this,arguments)})},{key:"unsubscribe",value:(a=Em(Sm().mark((function e(t,r){var n,i,o=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>2&&void 0!==o[2]&&o[2],BV("unsubscribe()",t),!n){e.next=4;break}return e.abrupt("return",this._unsubscribe(t,r));case 4:if(!this.multiChatMode()||!dO(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!==qU.NONE){e.next=9;break}return e.abrupt("return",this._unsubscribe(t,r));case 9:return e.abrupt("return",this._updateSubTrack(t,r,OV.UNSUB));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"_unsubscribe",value:(o=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u;return Sm().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,OV.UNSUB));case 2:return s={roomId:this._roomId,streamId:t.streamId,userId:t.userId},null===(n=this._dataChannelSignal)||void 0===n||n.sendSignaling("unsubscribe",s).catch((function(){})),t.streamState=lV.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=11,null===(a=this._handler)||void 0===a?void 0:a.handleAck({action:_V.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 11:u=e.sent,this._subResolves[u]&&this._subResolves[u].forEach((function(e){return e(0)})),UV.print("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"removeOnTrackListener",value:function(e){var t,r=this._ontrackCallbackMap.get(e);r&&(null===(t=this._handler)||void 0===t||t.off("ontrack",r),this._ontrackCallbackMap.delete(e))}},{key:"handleRemoveStream",value:(i=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BV("handleRemoveStream()",t),t.subVideo=!1,t.streamState!==lV.INIT){e.next=4;break}return e.abrupt("return");case 4:this.unsubscribe(t,Sd.AUDIO_AND_VIDEO,!0);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"leave",value:(n=Em(Sm().mark((function e(){var t,r,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(UV.print("leave()"),"connected"!==this.connectionState){e.next=22;break}return this.connectionState="disconnecting",t={Authorization:this._authorization,roomId:this._roomId,sessionId:this._sessionId},e.next=6,this._joinLeaveLock.lock();case 6:return r=e.sent,e.prev=7,e.next=10,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("leaveRoom",t);case 10:this.connectionState="disconnected",e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(7),this.connectionState="connected",e.t0;case 17:return e.prev=17,r(),e.finish(17);case 20:e.next=23;break;case 22:return e.abrupt("return",X_.reject(new cR(sR.NOT_CONNECTED_YET,"server not connected")));case 23:case"end":return e.stop()}}),e,this,[[7,13,17,20]])}))),function(){return n.apply(this,arguments)})},{key:"subscribePublicStream",value:(r=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g=this;return Sm().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 cR(sR.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return u=MP(),c=s.audioMid,d=s.videoMid,e.t0=this._appId,e.t1=t.streamId,e.t2=c,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,AN();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=xO.VERSION,e.t8=IO.getDeviceId(),e.t9=this._appId,e.t10=this._businessId,e.t11=this._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 X_((function(e,r){g._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new cR(sR.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),VV);t.on("ontrack",(function r(i){"video"===i.mediaType&&(UV.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v.push(new X_((function(e,r){g._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new cR(sR.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),VV);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(UV.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",p),this._ontrackCallbackMap.set(t,p),f=null==h?void 0:h.relayMessage,_=f.sequenceId,m=f.sdp,t.videoMid=d,t.audioMid=c,t.sequenceId=_,t.streamState=lV.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=44,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:_V.subscribe,streamId:t.streamId,audioMid:c,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,X_.all(v);case 46:null===(a=this._monitor)||void 0===a||a.report("rtc_subscribe_stat",{result:"success",start:u,message:"unknown",stream_user_id:t.userId}),this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return g.emit("onRemoteStreamStats",e)}),this._handler,this._context);case 48:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"unsubscribePublicStream",value:(t=Em(Sm().mark((function e(t){var r,n,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BV("unsubscribePublicStream()",t),n={appId:this._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=lV.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._handler)||void 0===r?void 0:r.handleAck({action:_V.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 t.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r,n;UV.print("destroy()"),this._token=void 0,this._appId=void 0,this._roomId=void 0,this._clientId=void 0,this._authorization=void 0,this._sessionId=void 0,null===(e=this._handler)||void 0===e||e.destroy(),null===(t=this._monitor)||void 0===t||t.set({connection_id:""}),null===(r=this._dataChannelSignal)||void 0===r||r.destroy(),null===(n=this._iceConfigRequestManager)||void 0===n||n.abort(),this._handler=void 0,this._dataChannelSignal=void 0,this._iceConfigRequestManager=void 0,this._removeSignalEventHandler(),this.connectionState="disconnected",this.emit("INTERRUPT")}},{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._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:"multiChatMode",value:function(){var e;return null===(e=this._roomAttributes)||void 0===e?void 0:e.multiChatMode}},{key:"handler",get:function(){return this._handler}},{key:"roomAttributes",get:function(){return this._roomAttributes},set:function(e){this._roomAttributes=e}}]),k}(sD);function GV(e,t,r){var n=r.value;return r.value=Em(Sm().mark((function e(){var r,i,o,a=arguments;return Sm().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 cR(sR.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 7:case"end":return e.stop()}}),e,this)}))),r}function zV(e,t,r){var n=r.value;return r.value=Em(Sm().mark((function e(){var t,r,i,o,a=arguments;return Sm().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}LV([function(e,t,r){var n=r.value;return r.value=Em(Sm().mark((function e(){var t,r,i,o,a=this,s=arguments;return Sm().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 X_(function(){var e=Em(Sm().mark((function e(t,i){var s;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a.on("INTERRUPT",(function(){o=!0,i(new cR(sR.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}],jV.prototype,"join",1),LV([zV,GV],jV.prototype,"publish",1),LV([zV,GV],jV.prototype,"updatePubTrack",1),LV([zV,GV],jV.prototype,"unpublish",1),LV([zV,GV],jV.prototype,"subscribe",1),LV([GV],jV.prototype,"controlMessage",1),LV([GV],jV.prototype,"updateUserAttributes",1),LV([GV],jV.prototype,"updateSubTrack",1),LV([GV],jV.prototype,"updateSubTrackLayer",1),LV([GV],jV.prototype,"updateSubPriority",1),LV([zV,GV],jV.prototype,"subscribe4pushTrack",1),LV([zV,GV],jV.prototype,"unsubscribe4removeTrack",1),LV([zV,GV],jV.prototype,"unsubscribe",1),LV([GV],jV.prototype,"handleRemoveStream",1),LV([zV],jV.prototype,"subscribePublicStream",1),LV([zV],jV.prototype,"unsubscribePublicStream",1);var HV,XV=new nP("RecvFrameObserver",0),KV=function(e){wI(a,e);var t,r,n,i,o=XI(a);function a(e,t){var r;return qd(this,a),sd(QT(r=o.call(this)),"_audioEventSessionId",iO()),sd(QT(r),"_videoEventSessionId",iO()),sd(QT(r),"_handler",void 0),sd(QT(r),"_stream",void 0),sd(QT(r),"_firstAudioFrameTimer",void 0),sd(QT(r),"_firstVideoFrameTimer",void 0),sd(QT(r),"_transportDelayInterval",void 0),sd(QT(r),"_transportDelay",void 0),sd(QT(r),"_firstVideoFrameInterval",void 0),sd(QT(r),"_firstAudioFrameInterval",void 0),sd(QT(r),"_isScreen",!1),sd(QT(r),"_audioFirstFrameState",0),sd(QT(r),"_videoFirstFrameState",0),sd(QT(r),"_timeout",1e4),sd(QT(r),"_currentAudioRecv",{startTime:0,eventSessionId:0,type:"login"}),sd(QT(r),"_currentVideoRecv",{startTime:0,eventSessionId:0,type:"login"}),sd(QT(r),"_login",!1),sd(QT(r),"_unMuteAudio",!1),sd(QT(r),"_enableAudio",!1),sd(QT(r),"_unMuteVideo",!1),sd(QT(r),"_enableVideo",!1),sd(QT(r),"_remoteUnmuteAudio",!1),sd(QT(r),"_remoteUnmuteVideo",!1),sd(QT(r),"_audioExternal",!1),sd(QT(r),"_pushAudio",!1),sd(QT(r),"_videoExternal",!1),sd(QT(r),"_pushVideo",!1),sd(QT(r),"_autoSubscribeVideo",!1),sd(QT(r),"_autoSubscribeAudio",!1),sd(QT(r),"_autoSubscribe",!1),sd(QT(r),"_publishVideo",!1),sd(QT(r),"_publishAudio",!1),sd(QT(r),"_subscribeAudio",!1),sd(QT(r),"_subscribeVideo",!1),sd(QT(r),"_subscribe",!1),sd(QT(r),"_pushTrack",!1),sd(QT(r),"_multiChatMode",!1),sd(QT(r),"_monitor",void 0),r._stream=e,r._handler=t,r.getTransportDelay(),r._monitor=mP(e.engineId),r}return Kd(a,[{key:"beginRecvFrame",value:(i=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h,v,p,f,_=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:i=this._transportDelay,o=!0,_E(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},d={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===(u=this._stream)||void 0===u?void 0:u.userId,transport_delay:i},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){_.stopRecvFrame("audio","timeout"),_._firstAudioFrameInterval&&window.clearInterval(_._firstAudioFrameInterval)}),this._timeout),XV.print("rtcFirstFrameRecv",ZE(d)),null===(c=this._monitor)||void 0===c||c.report("rtc_first_frame",d),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},f={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),start:null===(h=this._currentVideoRecv)||void 0===h?void 0:h.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(v=this._stream)||void 0===v?void 0:v.userId,transport_delay:i},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u,c,d,l,h,v,p,f,m,g;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=null===(t=_._handler)||void 0===t?void 0:t.pc,!e.t0){e.next=5;break}return e.next=4,EN(null===(r=_._handler)||void 0===r?void 0:r.pc,null===(n=_._stream)||void 0===n||null===(i=n.videoTrack)||void 0===i?void 0:i.getTrack());case 4:e.t0=e.sent;case 5:return p=e.t0,f=oE(o=p||[]).call(o,(function(e){return"inbound-rtp"===e.type})),e.next=9,null===(a=_._stream)||void 0===a||null===(s=a.videoTransceiver)||void 0===s?void 0:s.receiver.getStats();case 9:m=e.sent,g=[],null==m||m.forEach((function(e){return g.push(e.type)})),null===(u=_._monitor)||void 0===u||u.report("rtc_invoke_status",{sdk_api_name:"first_video_frame_timeout",error_code:-1,message:ZE({reports:YE(p).call(p,(function(e){return e.type})),reports2:g,pc:(null===(c=_._handler)||void 0===c?void 0:c.pc)||null,track:(null===(d=_._stream)||void 0===d||null===(l=d.videoTrack)||void 0===l?void 0:l.getTrack().id)||null,framesReceived:null==f?void 0:f.framesReceived,packetsReceived:null==f?void 0:f.packetsReceived}),stream_id:(null===(h=_._stream)||void 0===h?void 0:h.streamId)||"",stream_user_id:null===(v=_._stream)||void 0===v?void 0:v.userId,elapse:0});case 13:case"end":return e.stop()}}),e)})))(),_.stopRecvFrame("video","timeout"),_._firstVideoFrameInterval&&window.clearInterval(_._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),XV.print("rtcFirstFrameRecv",ZE(f)),null===(p=this._monitor)||void 0===p||p.report("rtc_first_frame",f),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;if(1!==this._audioFirstFrameState)return;var s={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};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,XV.print("rtcFirstFrameRecv",ZE(s)),null===(a=this._monitor)||void 0===a||a.report("rtc_first_frame",s),this._audioFirstFrameState=2}else if("video"===e){var u,c,d,l,h;if(1!==this._videoFirstFrameState)return;var v={event_type:"recv_end",media_type:e,is_screen:!(null===(u=this._stream)||void 0===u||!u.isScreen),start:null===(c=this._currentVideoRecv)||void 0===c?void 0:c.startTime,reason:t,result:!1,stream_user_id:null===(d=this._stream)||void 0===d?void 0:d.userId,event_session_id:this._videoEventSessionId,type:null===(l=this._currentVideoRecv)||void 0===l?void 0:l.type};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,XV.print("rtcFirstFrameRecv",ZE(v)),null===(h=this._monitor)||void 0===h||h.report("rtc_first_frame",v),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g;return Sm().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:s=this._currentAudioRecv,u=s.type,c=s.startTime,_E(n=["login","unmute","subscribe","push_track"]).call(n,u)>=0&&(r=0),d={event_type:"recv_end",media_type:t,start:c,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:u,transport_delay:r},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),XV.print("rtcFirstFrameRecv",ZE(d)),null===(a=this._monitor)||void 0===a||a.report("rtc_first_frame",d),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:f=this._currentVideoRecv,_=f.type,m=f.startTime,_E(l=["login","unmute","subscribe","push_track"]).call(l,_)>=0&&(r=0),g={event_type:"recv_end",media_type:t,is_screen:!(null===(h=this._stream)||void 0===h||!h.isScreen),start:m,result:!0,stream_user_id:null===(v=this._stream)||void 0===v?void 0:v.userId,event_session_id:this._videoEventSessionId,type:_,transport_delay:r},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),XV.print("rtcFirstFrameRecv",ZE(g)),null===(p=this._monitor)||void 0===p||p.report("rtc_first_frame",g),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){var t;this._enableAudio!==e&&(this._enableAudio=e,this._enableAudio?this.beginRecvFrame("audio","enable"):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&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:"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(Em(Sm().mark((function n(){var i,o,a,s,u,c,d,l;return Sm().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,EN(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(u=e._stream)||void 0===u||null===(c=u.videoTrack)||void 0===c?void 0:c.getTrack());case 3:if(d=n.sent,!(l=oE(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(Em(Sm().mark((function n(){var i,o,a,s,u,c,d,l;return Sm().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,EN(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(u=e._stream)||void 0===u||null===(c=u.audioTrack)||void 0===c?void 0:c.getOrgTrack());case 3:if(d=n.sent,!(l=oE(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=Em(Sm().mark((function e(){var t=this;return Sm().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(Em(Sm().mark((function e(){return Sm().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=Em(Sm().mark((function e(){var t,r,n,i,o;return Sm().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,EN(null===(r=this._handler)||void 0===r?void 0:r.pc);case 3:n=e.sent,i=oE(n).call(n,(function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(o=oE(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:"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}(iD.exports.EventEmitter),qV=new nP("SendFrameObserver",0),YV=function(){function e(t,r){qd(this,e),sd(this,"_audioEventSessionId",iO()),sd(this,"_videoEventSessionId",iO()),sd(this,"_pcSessionId",void 0),sd(this,"_handler",void 0),sd(this,"_firstAudioFrameTimer",void 0),sd(this,"_firstVideoFrameTimer",void 0),sd(this,"_stream",void 0),sd(this,"_firstVideoFrameInterval",void 0),sd(this,"_firstAudioFrameInterval",void 0),sd(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:"login"}),sd(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:"login"}),sd(this,"_login",!1),sd(this,"_publisher",!1),sd(this,"_unMuteAudio",!1),sd(this,"_enableAudio",!1),sd(this,"_unMuteVideo",!1),sd(this,"_enableVideo",!1),sd(this,"_audioExternal",!1),sd(this,"_pushAudio",!1),sd(this,"_videoExternal",!1),sd(this,"_pushVideo",!1),sd(this,"_autoPublish",!1),sd(this,"_publish",!1),sd(this,"_timeout",1e4),sd(this,"_audioFirstFrameState",0),sd(this,"_videoFirstFrameState",0),sd(this,"_monitor",void 0),this._stream=t,this._handler=r,this._monitor=mP(t.engineId)}var t,r;return Kd(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if("audio"===e){var n,i,o;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var a={event_type:"begin_send",media_type:e,is_screen:!(null===(n=this._stream)||void 0===n||!n.isScreen),type:t,start:null===(i=this._currentAudioSend)||void 0===i?void 0:i.startTime,event_session_id:this._audioEventSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){r.stopSendFrame("audio","timeout"),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),qV.print("rtcFirstFrameSend",ZE(a)),null===(o=this._monitor)||void 0===o||o.report("rtc_first_frame",a),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 s,u,c;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var d={event_type:"begin_send",media_type:e,is_screen:!(null===(s=this._stream)||void 0===s||!s.isScreen),type:t,start:null===(u=this._currentVideoSend)||void 0===u?void 0:u.startTime,event_session_id:this._videoEventSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){r.stopSendFrame("video","timeout"),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),qV.print("rtcFirstFrameSend",ZE(d)),null===(c=this._monitor)||void 0===c||c.report("rtc_first_frame",d),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;if(1!==this._audioFirstFrameState)return;var a={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};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,qV.print("rtcFirstFrameSend",ZE(a)),null===(o=this._monitor)||void 0===o||o.report("rtc_first_frame",a),this._audioFirstFrameState=2}else if("video"===e){var s,u,c,d;if(1!==this._videoFirstFrameState)return;var l={event_type:"sent_end",media_type:e,start:null===(s=this._currentVideoSend)||void 0===s?void 0:s.startTime,is_screen:!(null===(u=this._stream)||void 0===u||!u.isScreen),reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(c=this._currentVideoSend)||void 0===c?void 0:c.type};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,qV.print("rtcFirstFrameSend",ZE(l)),null===(d=this._monitor)||void 0===d||d.report("rtc_first_frame",l),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if("audio"===e){var t,r;if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var n=this._currentAudioSend,i=n.type,o=n.startTime,a={event_type:"sent_end",media_type:e,is_screen:!(null===(t=this._stream)||void 0===t||!t.isScreen),start:o,result:!0,event_session_id:this._audioEventSessionId,type:i};delete this._currentAudioSend,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),qV.print("rtcFirstFrameSend",ZE(a)),null===(r=this._monitor)||void 0===r||r.report("rtc_first_frame",a),this._audioFirstFrameState=3}else if("video"===e){var s,u;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var c=this._currentVideoSend,d=c.type,l=c.startTime,h={event_type:"sent_end",media_type:e,is_screen:!(null===(s=this._stream)||void 0===s||!s.isScreen),start:l,result:!0,event_session_id:this._videoEventSessionId,type:d};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),qV.print("rtcFirstFrameSend",ZE(h)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",h),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,n,i;if(this._publish=e,e)(null===(t=this._stream)||void 0===t?void 0:t.videoTrack)&&(null===(r=this._stream)||void 0===r?void 0:r.pubVideo)&&this.beginSendFrame("video","publish"),(null===(n=this._stream)||void 0===n?void 0:n.audioTrack)&&(null===(i=this._stream)||void 0===i?void 0:i.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:"setExternalAudioSource",value:function(e){this._audioExternal!==e&&(this._audioExternal=e,e&&(this._audioSending&&this.stopSendFrame("audio","disable"),this._enableAudio=!1),e||(this._audioSending&&this.stopSendFrame("audio","stop_push"),this._pushAudio=!1))}},{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:"setExternalVideoSource",value:function(e){this._videoExternal!==e&&(this._videoExternal=e,e&&(this._videoSending&&this.stopSendFrame("video","disable"),this._enableVideo=!1),e||(this._videoSending&&this.stopSendFrame("video","stop_push"),this._pushVideo=!1))}},{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:"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=Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u;return Sm().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,EN(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,u=Gs(s).call(s,(function(e){return"outbound-rtp"===e.type})),e.abrupt("return",u);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=Em(Sm().mark((function e(){var t,r,n,i,o,a,s;return Sm().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,EN(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",oE(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(Em(Sm().mark((function n(){var i,o,a;return Sm().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||YE(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(Em(Sm().mark((function r(){var n;return Sm().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}(),WV=(sd(HV={},"audio",{delay:1200,stallRadio:.3}),sd(HV,"video",{delay:1200,stallRadio:.6}),sd(HV,"screen_audio",{delay:1600,stallRadio:.8}),sd(HV,"screen_video",{delay:1600,stallRadio:.8}),HV),QV=function(){function e(){qd(this,e),sd(this,"_preUplinkStats",new FS),sd(this,"_preDownlinkStats",new FS),sd(this,"_timer",void 0),sd(this,"_delayTimer",void 0),sd(this,"_connectionState",FV.CONNECTED),sd(this,"reportor",void 0)}return Kd(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,u=t._fractionLost,c=t._retransmittedRate,d=this._getQosLevel(s,u||0,c||0),l=this._preUplinkStats.get(a)||[d];this._preUplinkStats.set(a,ym(i=Rm(o=[]).call(o,Kk(l),[d])).call(i,-2))}if(r.sentKBitrate>0&&r.rtt){var h,v,p=n?"screen_video":"video",f=r._fractionLost,_=r.rtt,m=r._sendBandWidth,g=r._retransmittedRate;0===m&&(f=Math.max(.65,f));var y=this._getQosLevel(_,f||0,g||0),S=this._preUplinkStats.get(p)||[y];this._preUplinkStats.set(p,ym(h=Rm(v=[]).call(v,Kk(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,u=e.videoStats,c=e.isScreen,d=e.userId;if(o)if(0===s.receivedKBitrate)r=xd.VBAD;else{var l=s.rtt,h=s.audioLossRate,v=s.stallDuration,p=s.statsInterval,f=s.e2eDelay,_=v/p,m=c?"screen_audio":"audio",g=this._getQosLevel(l,h||0,u._retransmittedRate||0),y=this._getDownlinkQoE(m,_,f);r=this._getNetworkQuality(g,y)}if(a)if(0===u.receivedKBitrate||0===u.rtt)n=xd.VBAD;else{var S=u.rtt,b=u.videoLossRate,E=u.stallDuration,k=u.statsInterval,T=u.e2eDelay,I=u._retransmittedRate,A=E/k,R=c?"screen_video":"video",w=this._getQosLevel(S,b||0,I||0),C=this._getDownlinkQoE(R,A,T);n=this._getNetworkQuality(w,C)}var x=r&&n?Math.ceil((r+n)/2):r||n;if(x){var P,O,D,M=Rm(P="".concat(d)).call(P,c?"_screen":""),N=this._preDownlinkStats.get(M)||[x];this._preDownlinkStats.set(M,ym(O=Rm(D=[]).call(D,Kk(N),[x])).call(O,-2)),this._startNetworkQualityReport()}}}},{key:"setConnectionState",value:function(e){this._connectionState=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=this;if(this._connectionState!==FV.CONNECTED)e=t=xd.VBAD;else{var n,i,o,a=this._getBetterQualityAndRemoveOldest("audio","up"),s=this._getBetterQualityAndRemoveOldest("video","up");e=a&&s?Math.ceil((a+s)/2):a||s||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||xd.EXCELLENT;var u=Gs(n=YE(i=Hk(Wx(o=this._preDownlinkStats).call(o))).call(i,(function(e){return r._getBetterQualityAndRemoveOldest(e,"down")}))).call(n,(function(e){return e}));t=Math.ceil($S(u).call(u,(function(e,t){return t+e}),0)/u.length)||xd.UNKNOWN}"function"==typeof this.reportor&&this.reportor(e,t)}},{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=WV[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=xd.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,Kk(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&&cO(t)&&r.localaudio&&r.audiostream,videoActive:n&&dO(t)&&r.localvideo&&r.videostream}}}]),e}(),JV=function(){function e(t){qd(this,e),sd(this,"_timer",void 0),sd(this,"_remoteVideoSizeCache",{}),sd(this,"_remoteScreenSizeCache",{}),sd(this,"onchange",void 0),this._room=t,this._start()}return Kd(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,u=s[i]||{},c=u.width,d=void 0===c?0:c,l=u.height,h=void 0===l?0:l,v=a.getSettings(),p=v.width,f=void 0===p?0:p,_=v.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}(),ZV=Hk((new TextEncoder).encode("subt")),$V={1:sR.SUBTITLE_ERR_POSTPROCESS,2:sR.SUBTITLE_ERR_CONNECTION_ERROR,3:sR.SUBTITLE_ERR_PROCESS_ERROR},eF=new nP("SubtitleTool",1),tF=function(e){if(e.extraInfo)try{var t,r=JSON.parse(e.extraInfo);r.source_language&&_E(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))||"";_E(i=["zh","en","ja"]).call(i,o)>-1&&(e.extraInfo=ZE({source_language:o}))}},rF=function(){function e(t){var r,n,i;qd(this,e),sd(this,"_taskId",void 0),sd(this,"_appId",void 0),sd(this,"_roomId",void 0),sd(this,"_userId",void 0),sd(this,"onEvent",void 0),sd(this,"onMessage",void 0),sd(this,"_preConfig",void 0),sd(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 Kd(e,[{key:"start",value:(n=Em(Sm().mark((function e(t){var r=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(eF.print("start","Invoke config: %o",t),FO(t.mode,"mode",[Ud.ASR_ONLY,Ud.ASR_AND_TRANSLATION]),t.mode!==Ud.ASR_AND_TRANSLATION||-1!==_E(iF).call(iF,t.targetLanguage||"")){e.next=4;break}throw new cR(sR.INVALID_PARAMS,"Invalid targetLanguage.");case 4:if(!this._taskId){e.next=6;break}throw new cR(sR.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:Vd.ERROR,errorCode:sR.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=Em(Sm().mark((function e(t){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FO(t.mode,"mode",[Ud.ASR_ONLY,Ud.ASR_AND_TRANSLATION]),t.mode!==Ud.ASR_AND_TRANSLATION||-1!==_E(iF).call(iF,t.targetLanguage||"")){e.next=3;break}throw new cR(sR.INVALID_PARAMS,"Invalid targetLanguage.");case 3:if(!this._taskId){e.next=5;break}throw new cR(sR.SUBTITLE_ALREADY_ON,"Already started subtitle");case 5:if(this._taskId){e.next=7;break}throw new cR(sR.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;eF.print("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:Vd.STOPPED}),e._clearTimer()}))}},{key:"reconnect",value:(t=Em(Sm().mark((function e(){return Sm().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(){eF.print("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 cR($V[r]||sR.SUBTITLE_ERR_UNKNOWN,n||"");null===(o=this.onEvent)||void 0===o||o.call(this,{event:Vd.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:Vd.STARTED}),this._clearTimer()}}},{key:"onMessageRecv",value:function(e){if(this._taskId&&this._preConfig){var t=nF(e);if(t&&t.length>0){var r,n=this._preConfig,i=n.mode,o=n.targetLanguage,a=[];if(t.forEach((function(e){i===Ud.ASR_ONLY?e.mode===i&&a.push(e):i===Ud.ASR_AND_TRANSLATION&&(e.language!==o&&e.mode!==Ud.ASR_ONLY||a.push(e),e.mode===Ud.ASR_ONLY&&e.language===o&&a.push(cd(cd({},e),{},{mode:Ud.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}(),nF=function(e){var t=e.message;if(t instanceof ArrayBuffer&&t.byteLength>8)try{var r=new DataView(t,0),n=0;if(ZV.every((function(e){return r.getUint8(n++)===e}))){var i=r.getUint32(n);if(n+=4,i===r.byteLength-8){var o=UP.ab2str(ym(t).call(t,8)),a=JSON.parse(o),s=a.data;if("subtitle"===a.type)return s}}}catch(u){}return!1},iF=["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"],oF=new nP("Room",1),aF={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1,publishTime:0},sF=function(e){wI(A,e);var t,r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I=XI(A);function A(e,t){var r;return qd(this,A),sd(QT(r=I.call(this)),"id",void 0),sd(QT(r),"_mediaServerClient",void 0),sd(QT(r),"_localStream",void 0),sd(QT(r),"_localScreenStream",void 0),sd(QT(r),"_remoteUsers",new FS),sd(QT(r),"_remoteStreams",new FS),sd(QT(r),"_remoteStreamStreamIdUserIdMap",{}),sd(QT(r),"_virtualStreams",[]),sd(QT(r),"_joinResolveCallback",void 0),sd(QT(r),"_joinRejectCallback",void 0),sd(QT(r),"_getAccessNode",void 0),sd(QT(r),"_getAccessFeedback",void 0),sd(QT(r),"_getAccessFeedbackIceNode",void 0),sd(QT(r),"_reconnectTimer",void 0),sd(QT(r),"_isReconnecting",void 0),sd(QT(r),"_context",void 0),sd(QT(r),"_sessionId",void 0),sd(QT(r),"_reconnectRecord",void 0),sd(QT(r),"_connectionLostTimer",void 0),sd(QT(r),"_liveControlMessage",void 0),sd(QT(r),"_serverConfig",void 0),sd(QT(r),"_liveTranscodingOnceSucc",!1),sd(QT(r),"_roomConfig",void 0),sd(QT(r),"_roomInfo",void 0),sd(QT(r),"_userDuplicateLoginTimerMap",new FS),sd(QT(r),"_networkQualityManager",void 0),sd(QT(r),"_videoSizeObserver",void 0),sd(QT(r),"_hasPublished",!1),sd(QT(r),"_subtitleTool",void 0),sd(QT(r),"_csrcUserIdMap",void 0),sd(QT(r),"_publishOnDemandItem",void 0),sd(QT(r),"_publishOnDemandBusy",!1),sd(QT(r),"_monitor",void 0),r.id=t.id,r._roomConfig=e,r._mediaServerClient=new jV(t),r._reconnectRecord=new uF,r._addHandlerEventHandler(),r._isReconnecting=!1,r._networkQualityManager=new QV,r._networkQualityManager.reportor=r._reportNetworkQuality.bind(QT(r)),r._videoSizeObserver=new JV(QT(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(QT(r)),r._context=t,r._csrcUserIdMap={},r._monitor=mP(r.id),r}return Kd(A,[{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,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A,R,w,C,x=this;null===(e=this._mediaServerClient)||void 0===e||e.on(bD.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on(bD.ON_ADD_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return x._onAddStream(e)}))})),null===(r=this._mediaServerClient)||void 0===r||r.on(bD.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(bD.ON_REMOVE_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return x._onRemoveStream(e)}))})),null===(i=this._mediaServerClient)||void 0===i||i.on(bD.USER_CONNECTION,this._onUserConnection.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(bD.USER_CONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return x._onUserConnection(e)}))})),null===(a=this._mediaServerClient)||void 0===a||a.on(bD.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(bD.USER_DISCONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return x._onUserDisconnection(e)}))})),null===(u=this._mediaServerClient)||void 0===u||u.on(bD.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(c=this._mediaServerClient)||void 0===c||c.on(bD.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(bD.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(bD.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(bD.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(bD.NODE_CHANGE,this._nodeChange.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(bD.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(bD.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(bD.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(bD.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(bD.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(bD.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(bD.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(b=this._mediaServerClient)||void 0===b||b.on(ED.RSCP,(function(e){!!oE(e).call(e,(function(e){var t,r,n;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:vk(t).call(t,null===(r=x._localStream)||void 0===r||null===(n=r.stream)||void 0===n?void 0:n.id)}))&&(x._publishOnDemandItem=e,x._onPublishOnDemand())})),null===(E=this._mediaServerClient)||void 0===E||E.on(ED.RTT,this._onRTT.bind(this)),null===(k=this._mediaServerClient)||void 0===k||k.on(ED.SSC,this._onSSC.bind(this)),null===(T=this._mediaServerClient)||void 0===T||T.on(kD.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(I=this._mediaServerClient)||void 0===I||I.on(kD.ABNORMAL_DISCONNECTION,this._handleAbnormalDisconnection.bind(this)),null===(A=this._mediaServerClient)||void 0===A||A.on(bD.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),null===(R=this._mediaServerClient)||void 0===R||R.on("onRemoteStreamStats",(function(e){x._networkQualityManager.updateDownlinkStats(e,x._findRemoteStreamByScreen(e.userId,e.isScreen)),x.emit(CV.ON_REMOTE_STREAM_STATS,lO(e))})),null===(w=this._mediaServerClient)||void 0===w||w.on("onLocalStreamStats",(function(e){x._networkQualityManager.updateUplinkStats(e),x.emit(CV.ON_LOCAL_STREAM_STATS,lO(e))})),null===(C=this._mediaServerClient)||void 0===C||C.on("prevIceNode",(function(e){x._getAccessFeedbackIceNode=e}))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(T=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.connect(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"join",value:(k=Em(Sm().mark((function e(t,r,n,i,o,a,s){var u,c=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(u=this._monitor)||void 0===u||u.set({rtc_app_id:t,room_id:r,user_id:i.userId}),oF.print("join()"),e.abrupt("return",new X_((function(e,u){var d,l,h,v=MP();c._joinResolveCallback=function(t){var r,n;null===(r=c._monitor)||void 0===r||r.report("join_room",{type:"end",start:v,result:!0,reason:""},{enable_cloud_proxy:null===(n=c._roomInfo)||void 0===n?void 0:n.useCloudProxy}),c._initSubtitleTool(),e(t)},c._joinRejectCallback=function(e){var t,r;Array.isArray(e)&&e.length&&(e=e[0]),null===(t=c._monitor)||void 0===t||t.report("join_room",{type:"end",start:v,result:!1,reason:e.message},{enable_cloud_proxy:null===(r=c._roomInfo)||void 0===r?void 0:r.useCloudProxy}),u(e)},c._liveControlMessage=o,c._roomInfo={appId:t,roomId:r,token:n,userInfo:i,useCloudProxy:a,roomProfile:c._roomConfig.roomProfileType,expectedIDC:s},c.setSessionId(),null===(d=c._monitor)||void 0===d||d.report("join_room",{type:"begin",start:v,result:!1,reason:""},{enable_cloud_proxy:null===(l=c._roomInfo)||void 0===l?void 0:l.useCloudProxy,expectedIDC:null===(h=c._roomInfo)||void 0===h?void 0:h.expectedIDC}),c._join(c._joinResolveCallback,c._joinRejectCallback,!1)})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i,o,a){return k.apply(this,arguments)})},{key:"_join",value:(E=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=l.length>2&&void 0!==l[2]&&l[2],i=MP(),oF.print("_join()"),e.prev=3,e.next=6,this._mediaServerClient.join(this._roomInfo,{node:this._getAccessNode,reason:this._getAccessFeedback,sessionId:this._sessionId,feedbackNode:this._getAccessFeedbackIceNode},n,this._liveControlMessage);case 6:d=e.sent,this._mediaServerClient.roomAttributes=d.roomAttributes,null!==(o=d.roomAttributes)&&void 0!==o&&o.multiChatMode&&this._handleFFAudioTrack(),this._reconnectRecord.clear(),this._joinResolveCallback=void 0,this._joinRejectCallback=void 0,this._getAccessFeedback=void 0,this._getAccessNode=void 0,"function"==typeof t&&t({users:d.clients,streams:d.streams}),this._isReconnecting=!1,null===(a=this._monitor)||void 0===a||a.set({rtc_vid:(null===(s=this._getAccessFeedbackIceNode)||void 0===s||null===(u=s.iceConfig)||void 0===u?void 0:u._abtest_vid)||""}),null===(c=this._monitor)||void 0===c||c.report("rtc_join_room",{error_code:0,deviceModel:"web",deviceManufacturer:"web",elapse:MP()-i}),this._onJoinSucc(d,n),e.next=27;break;case 21:if(e.prev=21,e.t0=e.catch(3),this._getAccessFeedback=void 0,this._getAccessNode=void 0,e.t0.code===sR.OPERATION_CANCEL||"function"!=typeof r){e.next=27;break}return e.abrupt("return",r(e.t0));case 27:case"end":return e.stop()}}),e,this,[[3,21]])}))),function(e,t){return E.apply(this,arguments)})},{key:"publishScreen",value:(b=Em(Sm().mark((function e(t,r,n,i,o){var a,s,u,c,d,l,h,v,p,f;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(oF.print("publishScreen()"),this._localScreenStream||(this._localScreenStream=new hV(this.id),this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new YV(this._localScreenStream,this._mediaServerClient.handler))),a=!1,s=!1,u=!1,c=!1,!this._localScreenStream.videoTrack&&r?(r instanceof SU&&(s=!0),a=!0):this._localScreenStream.videoTrack&&!r&&(a=!1),!this._localScreenStream.audioTrack&&n?(n instanceof bU&&(c=!0),u=!0):this._localScreenStream.audioTrack&&!n&&(u=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(cO(i)&&(this._localScreenStream.pubAudio=o===PV.PUB),dO(i)&&(this._localScreenStream.pubVideo=o===PV.PUB),oF.print("publishScreen mediaType","pubAudio: %o, pubVideo: %o",this._localScreenStream.pubAudio,this._localScreenStream.pubVideo)),this._localScreenStream.pubAudio||this._localScreenStream.pubVideo){e.next=18;break}if(null===(d=this._localScreenStream)||void 0===d||!d.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===(l=this._localScreenStream.observer)||void 0===l||l.setPublish(!0),e.next=22,this._mediaServerClient.publish(this._localScreenStream);case 22:e.next=28;break;case 24:return s?null===(h=this._localScreenStream.observer)||void 0===h||h.setPushVideo(a):null===(v=this._localScreenStream.observer)||void 0===v||v.setEnableVideo(a),c?null===(p=this._localScreenStream.observer)||void 0===p||p.setPushAudio(u):null===(f=this._localScreenStream.observer)||void 0===f||f.setEnableAudio(u),e.next=28,this.updatePubScreenTrack();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return b.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(S=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(oF.print("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 S.apply(this,arguments)})},{key:"unpublishScreen",value:(y=Em(Sm().mark((function e(){var t;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(oF.print("unpublish","Invoke unpublishScreen"),!this._localScreenStream){e.next=7;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.clean(),this._localScreenStream=void 0;case 7:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"liveControlMessage",value:(g=Em(Sm().mark((function e(t){var r,n=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oF.print("controlMessage","Invoke controlMessage"),null===(r=t.transcodeMeta)||void 0===r||r.layout.regions.forEach((function(e){n.roomInfo&&(e.roomID=n.roomInfo.roomId)})),this._liveControlMessage=t,e.next=5,this._mediaServerClient.controlMessage(t);case 5:"stopped"===t.action&&(delete this._liveControlMessage,this._liveTranscodingOnceSucc=!1),this._liveTranscodingOnceSucc=!0;case 7:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(m=Em(Sm().mark((function e(t){return Sm().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 m.apply(this,arguments)})},{key:"subtitleControlMessage",value:(_=Em(Sm().mark((function e(t){return Sm().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 _.apply(this,arguments)})},{key:"updateUserAttributes",value:(f=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oF.print("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 f.apply(this,arguments)})},{key:"publish",value:(p=Em(Sm().mark((function e(t,r,n,i,o,a){var s,u,c,d,l,h,v,p,f,_,m,g,y=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=y.length>6&&void 0!==y[6]&&y[6],oF.print("publish","Invoke publish"),u=!1,this._localStream||(this._localStream=new hV(this.id),this._mediaServerClient.handler&&(this._localStream.observer=new YV(this._localStream,this._mediaServerClient.handler)),u=!0),this._localStream.videoTrack=n,this._localStream.audioTrack=i,this._localStream.videoEncodeConfig=t,this._localStream.enableSimulcast=r,o&&(cO(o)&&(this._localStream.pubAudio=a===PV.PUB),dO(o)&&(this._localStream.pubVideo=a===PV.PUB),oF.print("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===(c=this._localStream.observer)||void 0===c||c.setLogin(!0):u&&(d=!!this._localStream.videoTrack,l=!!this._localStream.audioTrack,h=this._localStream.videoTrack instanceof SU,v=this._localStream.audioTrack instanceof bU,this._roomConfig.isAutoPublish&&!this._hasPublished?(d&&(h?null===(p=this._localStream.observer)||void 0===p||p.setPushVideo(!0):null===(f=this._localStream.observer)||void 0===f||f.setEnableVideo(!0)),l&&(v?null===(_=this._localStream.observer)||void 0===_||_.setPushAudio(!0):null===(m=this._localStream.observer)||void 0===m||m.setEnableAudio(!0))):null===(g=this._localStream.observer)||void 0===g||g.setPublish(!0)),e.next=16,this._mediaServerClient.publish(this._localStream);case 16:this._hasPublished=!0,this.emit(CV.ON_PUBLISH_RESULT,{isScreen:!1,state:_d.PUBLISH_SUCC}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(12),this.emit(CV.ON_PUBLISH_RESULT,{isScreen:!1,state:_d.PUBLISH_FAIL}),e.t0;case 24:e.next=28;break;case 26:return e.next=28,this.updatePubTrack();case 28:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e,t,r,n,i,o){return p.apply(this,arguments)})},{key:"updatePubTrack",value:(v=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(oF.print("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 v.apply(this,arguments)})},{key:"unpublish",value:(h=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(oF.print("unpublish","Invoke unpublish"),!this._localStream){e.next=6;break}return e.next=4,this._mediaServerClient.unpublish(this._localStream);case 4:this._localStream.clean(),this._localStream=void 0;case 6:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"subscribe",value:(l=Em(Sm().mark((function e(t,r,n){var i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oF.print("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 l.apply(this,arguments)})},{key:"updateSubTrack",value:(d=Em(Sm().mark((function e(t,r,n,i){var o,a;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(oF.print("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 d.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(c=Em(Sm().mark((function e(t,r){var n,i,o,a,s;return Sm().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 c.apply(this,arguments)})},{key:"_getSubLayer",value:function(e,t){for(var r,n,i,o,a,s=null==t?void 0:t.attributes,u=s.videoDescriptions,c=s.subVideoDescriptions,d=Array.isArray(c)?c:u,l=-1,h=e.width*e.height,v=0;v<(null==d?void 0:d.length);v++){var p,f;if(h>=(null===(p=d[v])||void 0===p?void 0:p.width)*(null===(f=d[v])||void 0===f?void 0:f.height)){l=v;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,g=(m-h)/(m-d[l].width*d[l].height);_=g<.1?d[l-1]:d[l],l=g<.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:(u=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oF.print("unsubscribe","Invoke unsubscribe"),e.next=3,this._mediaServerClient.unsubscribe(t,r);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"startSubtitle",value:(s=Em(Sm().mark((function e(t){return Sm().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 cR(sR.INVOKED_BEFORE_JOIN_ROOM,"join first");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"stopSubtitle",value:(a=Em(Sm().mark((function e(){var t;return Sm().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 a.apply(this,arguments)})},{key:"leave",value:(o=Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u,c,d,l,h=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=h.length>0&&void 0!==h[0]&&h[0],oF.print("leave","Invoke leave"),n=MP(),null===(t=this._subtitleTool)||void 0===t||t.destroy(),delete this._subtitleTool,e.prev=5,this._mediaServerClient.connectionState!==FV.CONNECTED&&this._joinRejectCallback&&this._joinRejectCallback(new Error("leave_room")),clearTimeout(this._reconnectTimer),s=YT($I(a=this._remoteStreams).call(a));try{for(s.s();!(u=s.n()).done;)c=u.value,Array.isArray(c)&&c.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=13,this._mediaServerClient.leave();case 13:this.destroy(),null===(i=this._monitor)||void 0===i||i.report("rtc_leave_room",{error_code:0,message:"",elapse:MP()-n}),null===(o=this._monitor)||void 0===o||o.set({room_id:"",user_id:"",rtc_session_id:"",rtc_vid:""}),e.next=26;break;case 18:if(e.prev=18,e.t0=e.catch(5),!r){e.next=24;break}throw e.t0;case 24:this.destroy();case 25:e.t0 instanceof Error&&(null===(l=this._monitor)||void 0===l||l.report("rtc_leave_room",{error_code:-1,message:e.t0.message,elapse:MP()-n}));case 26:case"end":return e.stop()}}),e,this,[[5,18]])}))),function(){return o.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&&null!=n&&n.has(e)&&r._mediaServerClient.updateSubPriority(t,n.get(e))}))}},{key:"destroy",value:function(){var e;oF.print("destroy","Invoke destroy"),SP(this.id,"room_destroy","".concat((new Error).stack)),null===(e=this._subtitleTool)||void 0===e||e.destroy(),delete this._subtitleTool,this._destroyAndInitMediaServerClient(),this._roomInfo=void 0,this._remoteUsers=new FS;var t,r,n,i=YT(this._remoteStreams);try{for(i.s();!(t=i.n()).done;){var o=WT(t.value,2)[1];Array.isArray(o)&&o.forEach((function(e){e&&e.clean()}))}}catch(a){i.e(a)}finally{i.f()}(this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new FS,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._reconnectRecord=new uF,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={}}},{key:"updateToken",value:(i=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oF.print("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(CV.ON_ROOM_ERROR,{errorCode:sR.UPDATE_TOKEN_WITH_INVALID_TOKEN}),e.t0;case 11:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return i.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=ZR(),null===(e=this._monitor)||void 0===e||e.set({rtc_session_id:this._sessionId})}},{key:"sendRoomMessage",value:(n=Em(Sm().mark((function e(t){var r,n,i,o,a,s=arguments;return Sm().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,UP.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 n.apply(this,arguments)})},{key:"_destroyAndInitMediaServerClient",value:function(){oF.print("_destroyAndInitMediaServerClient()"),this._mediaServerClient&&(this._mediaServerClient.destroy(),this._removeHandlerEventHandler()),this._mediaServerClient=new jV(this._context),this._addHandlerEventHandler()}},{key:"_onJoinSucc",value:function(e,t){var r,n,i,o=this;oF.print("JoinSuccess()"),this._serverConfig=e.config;var a=[],s=[],u=[],c=[],d=[];null===(r=e.clientsDetail)||void 0===r||r.forEach((function(t){if(t.attributes&&(t.attributes.serverMuteVideo&&o.safeEmit(CV.ON_VIDEO_STREAM_BANNED,{uid:t.clientId,banned:1===t.attributes.serverMuteVideo}),t.attributes.serverMuteAudio&&o.safeEmit(CV.ON_AUDIO_STREAM_BANNED,{uid:t.clientId,banned:1===t.attributes.serverMuteAudio})),t.clientId!==e.clientId){var r=o._remoteUsers.get(t.clientId);r?r._stillExist=!0:a.push(t)}}));var l,h=YT($I(n=this._remoteUsers).call(n));try{for(h.s();!(l=h.n()).done;){var v=l.value;v._stillExist||s.push({clientId:v.userId}),delete v._stillExist}}catch(m){h.e(m)}finally{h.f()}e.streams.forEach((function(e){var t=o._findRemoteStreamByScreen(e.clientId,e.screen);t?(t.stillExist=!0,t.streamId=e.streamId,d.push(e)):c.push(e)}));var p,f=YT($I(i=this._remoteStreams).call(i));try{for(f.s();!(p=f.n()).done;){var _=p.value;Array.isArray(_)&&_.forEach((function(e){e.stillExist?delete e.stillExist:u.push({clientId:e.userId,streamId:e.streamId,message:yD.clientDisconnected})}))}}catch(m){f.e(m)}finally{f.f()}s.forEach((function(e){return o._onUserDisconnection(e)})),a.forEach((function(e){return o._onUserConnection(e)})),u.forEach((function(e){return o._onRemoveStream(e)})),c.forEach((function(e){return o._onAddStream(e,{fromSignal:!1})})),d.forEach((function(e){return o._onUpdateStreamAttributes(e)})),t&&this._handleSendOrRecvStreamAfterReconnect()}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e,t,r=this;this._localStream&&(this._localStream.clean(),this._mediaServerClient.publish(this._localStream).catch((function(e){}))),this._localScreenStream&&(this._localScreenStream.clean(),this._mediaServerClient.publish(this._localScreenStream).catch((function(e){})));var n,i=YT($I(t=this._remoteStreams).call(t));try{for(i.s();!(n=i.n()).done;){var o=n.value;Array.isArray(o)&&o.forEach(function(){var e=Em(Sm().mark((function e(t){var n,i,o,a;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasSubscribed){e.next=15;break}return t.resetHasSubscribed(),e.prev=2,oF.print(Rm(n="start resubscribe ".concat(t.userId," with ")).call(n,t.subMediaType)),e.next=6,r._mediaServerClient.subscribe(t,t.subMediaType);case 6:oF.print(Rm(i="success resubscribe ".concat(t.userId," with ")).call(i,t.subMediaType)),r.safeEmit(CV.RESUBSCRIBE,{stream:t}),e.next=15;break;case 10:e.prev=10,e.t0=e.catch(2),oF.print(Rm(o=Rm(a="failed resubscribe ".concat(t.userId," with ")).call(a,t.subMediaType,", error:")).call(o,e.t0)),t.clean(),null==t||t.resetHasSubscribed();case 15:case"end":return e.stop()}}),e,null,[[2,10]])})));return function(t){return e.apply(this,arguments)}}())}}catch(a){i.e(a)}finally{i.f()}null===(e=this._subtitleTool)||void 0===e||e.reconnect()}},{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=oE(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 vV(this.id,"ff-stream","ff-stream",!1,aF);s.virtual=!0,s.audioTransceiver=a,s.audioMid="0",s.audioTrack=LU(i),this._virtualStreams.push(s),this.safeEmit(CV.SUBSCRIBE_PUSH_TRACK,{stream:s})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?oE(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)?oE(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,u=void 0!==s&&s;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var c=this._roomConfig,d=c.isAutoSubscribeAudio,l=c.isAutoSubscribeVideo,h=this._findRemoteStreamByScreen(e.clientId,e.screen);if(h&&h.streamId!==e.streamId){var v,p=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,p||[])}var f=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,f)f.attributes=e.attributes;else if((f=new vV(this.id,e.clientId,e.streamId,e.screen,e.attributes)).virtual=u,this._initStreamListeners(f),!u){var _=this._remoteStreams.get(e.clientId);_?_.push(f):this._remoteStreams.set(e.clientId,[f])}if(this._mediaServerClient.handler&&(f.observer=new KV(f,this._mediaServerClient.handler)),!f.isScreen&&l){var m,g,y,S,b,E,k,T;if(a&&f.hasVideo)if(f.attributes.extvideo)null===(m=f.observer)||void 0===m||m.setExternalVideoSource(!0),null===(g=f.observer)||void 0===g||g.setPushVideo(!0);else null===(y=f.observer)||void 0===y||y.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(!0===i&&!1===a){var I,A=this._roomConfig,R=A.isAutoSubscribeAudio,w=A.isAutoSubscribeVideo;null===(I=f.observer)||void 0===I||I.setLogin(!0,{audio:!!R,video:!!w})}}return i&&this.safeEmit(bD.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,cd({},n)),this.safeEmit(bD.USER_CONNECTION,{userInfo:n}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(CV.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(CV.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,a=e.forbiddenTime;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var s=null;i===TD.kickedByAdmin?s=sR.KICKED_OUT:i===TD.onUserTokenDidExpire?s=sR.TOKEN_EXPIRED:i===TD.userDuplicateLogin&&(s=sR.DUPLICATE_LOGIN),o===ID.roomDismissByAdmin&&(s=sR.ROOM_DISMISS),s&&this.safeEmit(CV.ON_ROOM_ERROR,{errorCode:s,forbiddenTime:a})}else{var u=hd.DROPPED;i===TD.userLeave?u=hd.QUIT:i===TD.kickedByAdmin?u=hd.KICKED_BY_ADMIN:i===TD.roleChanged&&(u=hd.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){e.clean(),r._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:yD.clientDisconnected})})),r._remoteStreams.delete(n),r.safeEmit(CV.ON_USER_LEAVE,{userInfo:{userId:n},reason:u})};if(i===TD.userDuplicateLogin){var d=this._userDuplicateLoginTimerMap.get(n);d&&self.clearTimeout(d);var l=self.setTimeout(c,5e3);this._userDuplicateLoginTimerMap.set(n,l)}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=oE(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(bD.ON_REMOVE_STREAM,{stream:i,reason:e.message})})),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(CV.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(CV.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){var t;e.roomAttributes&&(this._mediaServerClient.roomAttributes=cd(cd({},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 u,c,d=s.attributes,l=cd(cd({},d),a),h=!1,v=l.localaudio!==d.localaudio,p=!1,f=!1,_=l.localvideo!==d.localvideo,m=!1,g=qU.NONE,y=qU.NONE;if(l.audiostream!==d.audiostream&&(h=l.localaudio,p=!!l.audiostream,l.audiostream?g|=Sd.AUDIO:y|=Sd.AUDIO),l.videostream!==d.videostream&&(f=l.localvideo,m=!!l.videostream,l.videostream?g|=Sd.VIDEO:y|=Sd.VIDEO),g&&this.safeEmit(CV.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:g,isScreen:s.isScreen,pubState:PV.PUB,remoteStream:s}),y&&this.safeEmit(CV.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:y,isScreen:s.isScreen,pubState:PV.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(CV.ON_USER_START_AUDIO_CAPTURE,{userId:i},s)}else{var T,I,A,R;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===(A=s.observer)||void 0===A||A.setExternalAudioSource(!1),null===(R=s.observer)||void 0===R||R.setEnableAudio(!1);!s.isScreen&&this.safeEmit(CV.ON_USER_STOP_AUDIO_CAPTURE,{userId:i})}if(l.localvideo!==d.localvideo)if(l.localvideo){var w,C,x,P;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===(P=s.observer)||void 0===P||P.setEnableVideo(!0);this.safeEmit(CV.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var O,D,M,N;if(l.extvideo)null===(O=s.observer)||void 0===O||O.setExternalVideoSource(!0),null===(D=s.observer)||void 0===D||D.setPushVideo(!1);else null===(M=s.observer)||void 0===M||M.setExternalVideoSource(!1),null===(N=s.observer)||void 0===N||N.setEnableVideo(!1);!s.isScreen&&this.safeEmit(CV.ON_USER_STOP_VIDEO_CAPTURE,{userId:i})}if(h&&!v)null===(u=s.observer)||void 0===u||u.setRemoteUnmuteAudio(p);if(f&&!_)null===(c=s.observer)||void 0===c||c.setRemoteUnmuteVideo(m)}}},{key:"_onPushTrack",value:function(e){var t,r=this;if(null!==(t=e.streamId)&&void 0!==t&&aR(t).call(t,"audio_mux")){var n=this._onAddStream(cd(cd({},e),{},{attributes:aF}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._mediaServerClient.subscribe4pushTrack(n,e).then((function(){r.safeEmit(CV.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){oF.print("subscribe","push track failed %o",e)}))}else{var i,o;null===(i=this._monitor)||void 0===i||i.report("rtc_error",{message:Rm(o="onPushTrack, userId: ".concat(e.clientId,", ")).call(o,e.streamId),error_code:-1001})}}},{key:"_onRemoveTrack",value:function(e){var t,r=e.clientId,n=e.streamId,i=e.message;oF.print("_onRemoveTrack","remove track: %o",r);var o=this._findRemoteStream(r,n);o&&(null===(t=this._mediaServerClient)||void 0===t||t.unsubscribe4removeTrack(o,i))}},{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}}},{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=WT(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&&LA(t).call(t,(function(e,t){return e.audioLevel-t.audioLevel})),t}},{key:"_nodeChange",value:function(e){var t,r,n=e.nodes,i=e.reason;IO.clearAccessNode(null===(t=this._roomInfo)||void 0===t?void 0:t.appId),this._destroyAndInitMediaServerClient(),Array.isArray(n)&&n.length?this._getAccessNode=n[0]:this._getAccessFeedback=i,null===(r=this._monitor)||void 0===r||r.report("rtc_node_change",{error_code:0,message:ZE(e),reason:ZE(i)}),this._joinResolveCallback&&this._joinRejectCallback?this._join(this._joinResolveCallback,this._joinRejectCallback):this._reconnect()}},{key:"_reconnect",value:function(){var e,t,r=this;this._isReconnecting=!0;var n,i=YT($I(t=this._remoteStreams).call(t));try{for(i.s();!(n=i.n()).done;){var o=n.value;Array.isArray(o)&&o.forEach((function(e){return e.clean()}))}}catch(a){i.e(a)}finally{i.f()}null===(e=this._monitor)||void 0===e||e.report("rtc_reconnect",{error_code:1002,message:"peerconnection reconnecting",reconnect_id:this._roomInfo.userInfo.userId,reconnect_type:"peerconnection"}),this._liveTranscodingOnceSucc||delete this._liveControlMessage,this._join((function(){var e;null===(e=r._monitor)||void 0===e||e.report("rtc_reconnected",{message:"peerconnection reconnected",reconnect_type:"peerconnection"})}),(function(e){r._reconnectRecord.record(e),r._reconnectRecord.shouldReconnect?(oF.print("Reconnecting error, will reconnect after 3s",e),r._reconnectTimer=window.setTimeout(r._reconnect.bind(r),3e3)):(r.safeEmit(CV.RECONNECT_FAILED),r.destroy())}),!0)}},{key:"_handleAbnormalDisconnection",value:function(){var e,t;oF.print("on ABNORMAL_DISCONNECTION"),null===(e=this.localStream)||void 0===e||e.stopReport(),null===(t=this.remoteStreams)||void 0===t||t.forEach((function(e){return null==e?void 0:e.forEach((function(e){return e.stopReport()}))})),this._destroyAndInitMediaServerClient(),navigator.onLine?this._reconnect():this._reconnectTimer=window.setTimeout(this._reconnect.bind(this),3e3)}},{key:"_onConnectionStateChange",value:function(e){var t,r=this;if(e.next===FV.DISCONNECTED)t=Ed.CONNECTION_STATE_DISCONNECTED;else if(e.next===FV.CONNECTED)clearTimeout(this._connectionLostTimer),t=this._isReconnecting?Ed.CONNECTION_STATE_RECONNECTED:Ed.CONNECTION_STATE_CONNECTED;else{if(e.next!==FV.CONNECTING)return;t=this._isReconnecting?Ed.CONNECTION_STATE_RECONNECTING:Ed.CONNECTION_STATE_CONNECTING}e.prev===FV.CONNECTED&&e.next===FV.DISCONNECTED&&(this._connectionLostTimer=window.setTimeout((function(){r.safeEmit(kD.ON_CONNECTION_STATE_CHANGE,{state:Ed.CONNECTION_STATE_LOST})}),1e4)),this._networkQualityManager.setConnectionState(e.next),this.safeEmit(kD.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(CV.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?yd.STREAM_INDEX_SCREEN:yd.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){this.safeEmit(bD.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(bD.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(bD.USER_BINARY_MESSAGE_RECEIVED,r)}},{key:"_initSubtitleTool",value:function(){var e=this;this._subtitleTool=new rF(this),this._subtitleTool.onEvent=function(t){e.emit(CV.ON_SUBTITLE_STATE_CHANGED,t)},this._subtitleTool.onMessage=function(t){e.emit(CV.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=xV.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=xV.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?xV.START_FAILED:xV.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?xV.STOP_FAILED:xV.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?xV.UPDATE_FAILED:xV.UPDATE_SUCCESS}this.safeEmit(bD.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(bD.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(bD.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onStreamFailed",value:(r=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l;return Sm().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(u=this._remoteStreamStreamIdUserIdMap[t.streamId],!(c=this._findRemoteStream(u,t.streamId))){e.next=20;break}return e.next=17,null===(d=this._mediaServerClient)||void 0===d?void 0:d.unsubscribe(c,Sd.AUDIO_AND_VIDEO);case 17:return e.next=19,null===(l=this._mediaServerClient)||void 0===l?void 0:l.subscribe(c,c.subMediaType,c.subLayer);case 19:this.safeEmit(CV.RESUBSCRIBE,{stream:c});case 20:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_onStreamControlMessage",value:function(e){var t,r;e.type===SD.PushLimitWarn&&(null!==(t=this._localStream)&&void 0!==t&&t.pubAudio||null!==(r=this._localStream)&&void 0!==r&&r.pubVideo||this.unpublish())}},{key:"_onPublishOnDemand",value:(t=Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u,c,d,l,h,v,p;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!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(a=this._publishOnDemandItem,this._publishOnDemandItem=void 0,a){e.next=6;break}return e.abrupt("return");case 6:if(null===(i=this._localStream)||void 0===i||!i.enableSimulcast||null===(o=this._localStream)||void 0===o||!o.videoTransceiver){e.next=16;break}return c=[],this._publishOnDemandBusy=!0,d=null===(s=this._localStream)||void 0===s?void 0:s.stream.id,l=null===(u=this._localStream)||void 0===u?void 0:u.videoTransceiver.sender,h=l.getParameters(),Array.isArray(h.encodings)&&Array.isArray(a)&&(p={},oF.print("_onPublishOnDemand exec","usedDescriptions: %o",a),a.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&vk(t).call(t,d)){var r=null==e?void 0:e.Metadata.VideoIndex;p[r]=!0}})),h.encodings=YE(v=h.encodings).call(v,(function(e){if(e.rid){p[e.rid]?e.active=!0:e.active=!1;var t=+e.rid;c[t]=e.active}return e})),this._context&&(this._context.activeSimStreams=c)),e.next=15,l.setParameters(h);case 15:this._publishOnDemandBusy=!1;case 16:this._onPublishOnDemand();case 17:case"end":return e.stop()}}),e,this)}))),function(){return t.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(CV.ON_SIMULCAST_SUBSCRIBE_FALLBACK,a)}},{key:"_reportNetworkQuality",value:function(e,t){this.emit(CV.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){var i;this.emit(CV.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:null===(i=this.roomInfo)||void 0===i?void 0:i.roomId,userId:e,streamIndex:t?yd.STREAM_INDEX_SCREEN:yd.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()}}]),A}(sD),uF=function(){function e(){qd(this,e),sd(this,"_all_201_count",void 0),sd(this,"_has_4xx",void 0),this._all_201_count=0,this._has_4xx=!1}return Kd(e,[{key:"shouldReconnect",get:function(){return!(this._all_201_count>=3||this._has_4xx)}},{key:"record",value:function(e){var t=!1,r=!1;if(Array.isArray(e)){var n=0;YE(e).call(e,(function(e){var t,i,o;400<=(null===(t=e.error)||void 0===t?void 0:t.code)&&(null===(i=e.error)||void 0===i?void 0:i.code)<500&&(r=!0),201===(null===(o=e.error)||void 0===o?void 0:o.code)&&n++})),n===e.length&&(t=!0),t&&this._all_201_count++,r&&(this._has_4xx=!0)}}},{key:"clear",value:function(){this._all_201_count=0,this._has_4xx=!1}}]),e}(),cF=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&&pb(r.style,t.style),t.attributes&&gR(t.attributes).forEach((function(e){var t=WT(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},dF=new nP("Player",0),lF=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],hF={playsinline:"","webkit-playsinline":""},vF={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},pF=function(e){wI(n,e);var t,r=XI(n);function n(e,t){var i;qd(this,n),sd(QT(i=r.call(this)),"_containerDom",void 0),sd(QT(i),"_videoDom",void 0),sd(QT(i),"__cumulativeTime",void 0),sd(QT(i),"userId",void 0),sd(QT(i),"renderMode",void 0),sd(QT(i),"mirrorType",kd.MIRROR_TYPE_NONE),sd(QT(i),"isScreen",void 0),sd(QT(i),"isLocal",void 0),sd(QT(i),"played",!1),sd(QT(i),"_needLoad",!1),sd(QT(i),"_emitPlayFailed",!1),sd(QT(i),"_videoContainer",void 0),sd(QT(i),"_safari15VideoTimer",void 0),sd(QT(i),"_monitor",void 0),sd(QT(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":dF.print("VideoPlayerPlaying","[userId-".concat(i.userId,"] video element playing"))}})),sd(QT(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&&rO&&!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:Rm(r="video autoplay failed, userId: ".concat(i.userId,", ")).call(r,e.name),error_code:-1e3}),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:Rm(s="video autoplay failed, userId: ".concat(i.userId,", ")).call(s,e.name),error_code:-1e3}))}))}})),i.engineId=e;var o=t.renderDom;i._monitor=mP(e);var a=t.userId;i.renderMode=void 0!==t.renderMode?t.renderMode:gd.RENDER_MODE_FIT;var s="string"==typeof o?document.getElementById(o):o;if(!s)throw new cR(sR.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=s,i.userId=a,i.isLocal=!!t.isLocal,i.isScreen=!!t.isScreen,i._initVideo(),i}return Kd(n,[{key:"_initVideo",value:function(){var e;this._videoDom||(this._videoDom=cF("video",{style:{width:"100%",height:"100%"},attributes:vF}),this._videoDom.id=Rm(e="".concat(this.userId,"_")).call(e,DP()),this.renderMode===gd.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this._videoDom.style.objectFit="cover",this.mirror(this.mirrorType===kd.MIRROR_TYPE_RENDER));this._videoContainer.appendChild(this._videoDom),this._containerDom.appendChild(this._videoContainer),this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._videoDom&&lF.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&&lF.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(jP){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,u=(a-t.__cumulativeTime)%2e3,c=u>1e3*r;null===(s=e.recordedVideoFrames)||void 0===s||s.push({playTime:a,isStall:c,stallCount:c?1:0,stallDuration:u})}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=MP();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=MP()-(e.statsReport.pauseStart||0);i>500&&(e.statsReport.pauseDuration+=i)}}}))}},{key:"playVideo",value:(t=Em(Sm().mark((function e(t,r){var n,i,o,a,s=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=this._videoDom,dF.print("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{SP(this.engineId,"playVideo","play video repeatedly",0,this.userId)}catch(ZH){}return e.abrupt("return");case 5:o||(this._initVideo(),o=this._videoDom),dF.print("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&&xO.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(dF.print("Invoke VideoPlayer.manuallyPlay",this.userId,this.isScreen),this._emitPlayFailed=!1,!this._videoDom)throw new cR(sR.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||WP?this._videoDom.play():X_.resolve()}},{key:"mirror",value:function(e){var t;dF.print("mirror",Rm(t="".concat(this.userId," set mirror: ")).call(t,e)),this.mirrorType=e?kd.MIRROR_TYPE_RENDER:kd.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;(dF.print("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];dF.print("destroy","video player: ".concat(this.userId)),this.stop(e),AI(TI(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._videoDom&&delete this._videoDom,this._safari15VideoTimer&&(window.clearInterval(this._safari15VideoTimer),this._safari15VideoTimer=void 0)}},{key:"domElement",get:function(){return this._videoDom}}]),n}(iD.exports.EventEmitter),fF=function(e){wI(i,e);var t,r,n=XI(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,u=o.isScreen;if(qd(this,i),sd(QT(r=n.call(this)),"_containerDom",void 0),sd(QT(r),"_audioDom",void 0),sd(QT(r),"_fakeAudioDom",void 0),sd(QT(r),"userId",void 0),sd(QT(r),"muted",!1),sd(QT(r),"_emitPlayFailed",!1),sd(QT(r),"played",!1),sd(QT(r),"isScreen",void 0),sd(QT(r),"_wechatTimer",void 0),sd(QT(r),"_monitor",void 0),sd(QT(r),"_pasued",!0),sd(QT(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&&dF.print("AudioPlayerPlaying","[userId-".concat(r.userId,"] audio element playing")),"pause"===e.type&&(dF.print("AudioPlayerPause","[userId-".concat(r.userId,"] audio element pause")),r._pasued||r._internalPlay()),QP&&WP&&("canplay"===e.type?(clearTimeout(r._wechatTimer),r._wechatTimer=window.setTimeout((function(){r._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(r._wechatTimer)),r.emit("playback_event",i)})),sd(QT(r),"_internalPlay",(function(){var e,t;if(SP(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=oU.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"),error_code:-1e3}));clearTimeout(s)}));a.then((function(){clearTimeout(s)}))}null!==(n=i)&&void 0!==n&&n.then&&(QP&&JP&&(i=i.then((function(){return new X_((function(e){setTimeout(Em(Sm().mark((function t(){var n;return Sm().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(){SP(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:Rm(n=Rm(i="audio autoplay failed, userId: ".concat(r.userId,": ")).call(i,e.message," ")).call(n,e.name),error_code:-1e3})})))}catch(l){var u,c,d;r._autoPlayError(l),null===(u=r._monitor)||void 0===u||u.report("rtc_error",{message:Rm(c=Rm(d="audio autoplay failed, userId: ".concat(r.userId,": ")).call(d,l.message," ")).call(c,l.name),error_code:-1e3})}})),r.engineId=e,a){var c=document.getElementById(a);if(!c)throw new cR(sR.CANT_FIND_DOM,"can't find dom");r._containerDom=c}else r._containerDom=document.body;return r.userId=t,r.muted=s,r.isScreen=u,r._monitor=mP(e),r._initAudio(),r}return Kd(i,[{key:"_initAudio",value:function(){var e;this._audioDom||(this._audioDom=cF("audio",{style:{display:"none"},attributes:hF}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id=Rm(e="".concat(this.userId,"_")).call(e,DP()),this._containerDom.appendChild(this._audioDom));this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&lF.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&&(lF.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=Em(Sm().mark((function e(t){var r,n,i,o,a,s=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(dF.print("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 KU?(this._fakeAudioDom=new Audio,this._fakeAudioDom.muted=!0,this._fakeAudioDom.srcObject=new MediaStream([t.getOrgTrack()]),a.addTrack(t.getTrack())):a.addTrack(t.getTrack("preprocessing")),QP&&JP&&(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 cR(sR.INVALID_PARAMS,"Player not found");this._pasued=!0,this._audioDom.pause()}},{key:"manuallyPlay",value:function(){var e,t=this;if(dF.print("Invoke AudioPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._audioDom)throw new cR(sR.INVALID_PARAMS,"Player not found");if(!this.played)return X_.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=oU.getAudioContextInstance();if("suspended"===i.state){var o=i.resume();null!=o&&o.then&&r.push(o)}(r.length>0?X_.all(r):X_.resolve(n)).then((function(){t._pasued=!1}))}},{key:"setPlaybackDevice",value:(t=Em(Sm().mark((function e(t){var r,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dF.print("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,tU.enumerateAudioPlaybackDevices();case 3:if(r=e.sent,n=YE(r).call(r,(function(e){return e.deviceId})),vk(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;dF.print("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(){dF.print("destroy","audio player: ".concat(this.userId)),this.stop(),AI(TI(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(this._audioDom.srcObject=null,delete this._audioDom)}}]),i}(iD.exports.EventEmitter);function _F(e,t,r,n){var i=function(){var e=Em(Sm().mark((function e(t,i){var o,a;return Sm().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:oE(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 pF&&o.videoTrack&&t.playVideo(o.videoTrack,o),t instanceof fF&&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))})),X_.all(o)}var mF="object"==typeof global&&global&&global.Object===Object&&global,gF="object"==typeof self&&self&&self.Object===Object&&self,yF=mF||gF||Function("return this")(),SF=yF.Symbol,bF=Object.prototype,EF=bF.hasOwnProperty,kF=bF.toString,TF=SF?SF.toStringTag:void 0;var IF=Object.prototype.toString;var AF=SF?SF.toStringTag:void 0;function RF(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":AF&&AF in Object(e)?function(e){var t=EF.call(e,TF),r=e[TF];try{e[TF]=void 0;var n=!0}catch(o){}var i=kF.call(e);return n&&(t?e[TF]=r:delete e[TF]),i}(e):function(e){return IF.call(e)}(e)}function wF(e){return null!=e&&"object"==typeof e}var CF=Array.isArray;function xF(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function PF(e){return e}function OF(e){if(!xF(e))return!1;var t=RF(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var DF,MF=yF["__core-js_shared__"],NF=(DF=/[^.]+$/.exec(MF&&MF.keys&&MF.keys.IE_PROTO||""))?"Symbol(src)_1."+DF:"";var LF=Function.prototype.toString;var UF=/^\[object .+?Constructor\]$/,VF=Function.prototype,FF=Object.prototype,BF=VF.toString,jF=FF.hasOwnProperty,GF=RegExp("^"+BF.call(jF).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function zF(e){return!(!xF(e)||(t=e,NF&&NF in t))&&(OF(e)?GF:UF).test(function(e){if(null!=e){try{return LF.call(e)}catch(t){}try{return e+""}catch(t){}}return""}(e));var t}function HF(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 XF=Date.now;var KF,qF,YF,WF=function(){try{var e=zF(t=function(e,t){return null==e?void 0:e[t]}(Object,"defineProperty"))?t:void 0;return e({},"",{}),e}catch(r){}var t}(),QF=WF,JF=QF?function(e,t){return QF(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:PF,ZF=(KF=JF,qF=0,YF=0,function(){var e=XF(),t=16-(e-YF);if(YF=e,t>0){if(++qF>=800)return arguments[0]}else qF=0;return KF.apply(void 0,arguments)}),$F=ZF,eB=/^(?:0|[1-9]\d*)$/;function tB(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&eB.test(e))&&e>-1&&e%1==0&&e<t}function rB(e,t,r){"__proto__"==t&&QF?QF(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function nB(e,t){return e===t||e!=e&&t!=t}var iB=Object.prototype.hasOwnProperty;function oB(e,t,r){var n=e[t];iB.call(e,t)&&nB(n,r)&&(void 0!==r||t in e)||rB(e,t,r)}var aB=Math.max;function sB(e,t){return $F(function(e,t,r){return t=aB(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=aB(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),HF(e,this,s)}}(e,t,PF),e+"")}function uB(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function cB(e){return null!=e&&uB(e.length)&&!OF(e)}var dB=Object.prototype;function lB(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||dB)}function hB(e){return wF(e)&&"[object Arguments]"==RF(e)}var vB=Object.prototype,pB=vB.hasOwnProperty,fB=vB.propertyIsEnumerable,_B=hB(function(){return arguments}())?hB:function(e){return wF(e)&&pB.call(e,"callee")&&!fB.call(e,"callee")},mB=_B;var gB="object"==typeof exports&&exports&&!exports.nodeType&&exports,yB=gB&&"object"==typeof module&&module&&!module.nodeType&&module,SB=yB&&yB.exports===gB?yF.Buffer:void 0,bB=(SB?SB.isBuffer:void 0)||function(){return!1},EB={};EB["[object Float32Array]"]=EB["[object Float64Array]"]=EB["[object Int8Array]"]=EB["[object Int16Array]"]=EB["[object Int32Array]"]=EB["[object Uint8Array]"]=EB["[object Uint8ClampedArray]"]=EB["[object Uint16Array]"]=EB["[object Uint32Array]"]=!0,EB["[object Arguments]"]=EB["[object Array]"]=EB["[object ArrayBuffer]"]=EB["[object Boolean]"]=EB["[object DataView]"]=EB["[object Date]"]=EB["[object Error]"]=EB["[object Function]"]=EB["[object Map]"]=EB["[object Number]"]=EB["[object Object]"]=EB["[object RegExp]"]=EB["[object Set]"]=EB["[object String]"]=EB["[object WeakMap]"]=!1;var kB="object"==typeof exports&&exports&&!exports.nodeType&&exports,TB=kB&&"object"==typeof module&&module&&!module.nodeType&&module,IB=TB&&TB.exports===kB&&mF.process,AB=function(){try{var e=TB&&TB.require&&TB.require("util").types;return e||IB&&IB.binding&&IB.binding("util")}catch(t){}}(),RB=AB&&AB.isTypedArray,wB=RB?function(e){return function(t){return e(t)}}(RB):function(e){return wF(e)&&uB(e.length)&&!!EB[RF(e)]},CB=wB,xB=Object.prototype.hasOwnProperty;function PB(e,t){var r=CF(e),n=!r&&mB(e),i=!r&&!n&&bB(e),o=!r&&!n&&!i&&CB(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):[],u=s.length;for(var c in e)!t&&!xB.call(e,c)||a&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||tB(c,u))||s.push(c);return s}var OB=function(e,t){return function(r){return e(t(r))}}(Object.keys,Object),DB=OB,MB=Object.prototype.hasOwnProperty;function NB(e){return cB(e)?PB(e):function(e){if(!lB(e))return DB(e);var t=[];for(var r in Object(e))MB.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}var LB=Object.prototype.hasOwnProperty;function UB(e){if(!xF(e))return function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}(e);var t=lB(e),r=[];for(var n in e)("constructor"!=n||!t&&LB.call(e,n))&&r.push(n);return r}var VB,FB=(VB=function(e,t){!function(e,t,r,n){var i=!r;r||(r={});for(var o=-1,a=t.length;++o<a;){var s=t[o],u=n?n(r[s],e[s],s,r,e):void 0;void 0===u&&(u=e[s]),i?rB(r,s,u):oB(r,s,u)}}(t,function(e){return cB(e)?PB(e,!0):UB(e)}(t),e)},sB((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=VB.length>3&&"function"==typeof i?(n--,i):void 0,o&&function(e,t,r){if(!xF(r))return!1;var n=typeof t;return!!("number"==n?cB(r)&&tB(t,r.length):"string"==n&&t in r)&&nB(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&&VB(e,a,r,i)}return e})));function BB(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 jB(e){return null==e?[]:BB(e,NB(e))}var GB=i,zB=lt("iterator"),HB=!GB((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[zB]||"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})),XB=Qt,KB=E,qB=2147483647,YB=/[^\0-\u007E]/,WB=/[.\u3002\uFF0E\uFF61]/g,QB="Overflow: input needs wider integers to process",JB=RangeError,ZB=KB(WB.exec),$B=Math.floor,ej=String.fromCharCode,tj=KB("".charCodeAt),rj=KB([].join),nj=KB([].push),ij=KB("".replace),oj=KB("".split),aj=KB("".toLowerCase),sj=function(e){return e+22+75*(e<26)},uj=function(e,t,r){var n=0;for(e=r?$B(e/700):e>>1,e+=$B(e/t);e>455;)e=$B(e/35),n+=36;return $B(n+36*e/(e+38))},cj=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=tj(e,r++);if(i>=55296&&i<=56319&&r<n){var o=tj(e,r++);56320==(64512&o)?nj(t,((1023&i)<<10)+(1023&o)+65536):(nj(t,i),r--)}else nj(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&&nj(t,ej(n));var u=t.length,c=u;for(u&&nj(t,"-");c<i;){var d=qB;for(r=0;r<e.length;r++)(n=e[r])>=o&&n<d&&(d=n);var l=c+1;if(d-o>$B((qB-a)/l))throw JB(QB);for(a+=(d-o)*l,o=d,r=0;r<e.length;r++){if((n=e[r])<o&&++a>qB)throw JB(QB);if(n==o){for(var h=a,v=36;;){var p=v<=s?1:v>=s+26?26:v-s;if(h<p)break;var f=h-p,_=36-p;nj(t,ej(sj(p+f%_))),h=$B(f/_),v+=36}nj(t,ej(sj(h))),s=uj(a,l,c==u),a=0,c++}}a++,o++}return rj(t,"")},dj=Rr,lj=n,hj=P,vj=E,pj=w,fj=HB,_j=li,mj=Ug,gj=Ni,yj=Mu,Sj=Zi,bj=vv,Ej=A,kj=We,Tj=Wt,Ij=fn,Aj=tr,Rj=$,wj=gn,Cj=zn,xj=V,Pj=fh,Oj=uh,Dj=Tv,Mj=oA,Nj=lt("iterator"),Lj="URLSearchParams",Uj="URLSearchParamsIterator",Vj=Sj.set,Fj=Sj.getterFor(Lj),Bj=Sj.getterFor(Uj),jj=Object.getOwnPropertyDescriptor,Gj=function(e){if(!pj)return lj[e];var t=jj(lj,e);return t&&t.value},zj=Gj("fetch"),Hj=Gj("Request"),Xj=Gj("Headers"),Kj=Hj&&Hj.prototype,qj=Xj&&Xj.prototype,Yj=lj.RegExp,Wj=lj.TypeError,Qj=lj.decodeURIComponent,Jj=lj.encodeURIComponent,Zj=vj("".charAt),$j=vj([].join),eG=vj([].push),tG=vj("".replace),rG=vj([].shift),nG=vj([].splice),iG=vj("".split),oG=vj("".slice),aG=/\+/g,sG=Array(4),uG=function(e){return sG[e-1]||(sG[e-1]=Yj("((?:%[\\da-f]{2}){"+e+"})","gi"))},cG=function(e){try{return Qj(e)}catch(ZH){return e}},dG=function(e){var t=tG(e,aG," "),r=4;try{return Qj(t)}catch(ZH){for(;r;)t=tG(t,uG(r--),cG);return t}},lG=/[!'()~]|%20/g,hG={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},vG=function(e){return hG[e]},pG=function(e){return tG(Jj(e),lG,vG)},fG=yj((function(e,t){Vj(this,{type:Uj,iterator:Pj(Fj(e).entries),kind:t})}),"Iterator",(function(){var e=Bj(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),_G=function(e){this.entries=[],this.url=null,void 0!==e&&(Rj(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===Zj(e,0)?oG(e,1):e:wj(e)))};_G.prototype={type:Lj,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,u=Oj(e);if(u)for(r=(t=Pj(e,u)).next;!(n=hj(r,t)).done;){if(o=(i=Pj(Aj(n.value))).next,(a=hj(o,i)).done||(s=hj(o,i)).done||!hj(o,i).done)throw Wj("Expected sequence with length 2");eG(this.entries,{key:wj(a.value),value:wj(s.value)})}else for(var c in e)kj(e,c)&&eG(this.entries,{key:c,value:wj(e[c])})},parseQuery:function(e){if(e)for(var t,r,n=iG(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=iG(t,"="),eG(this.entries,{key:dG(rG(r)),value:dG($j(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],eG(r,pG(e.key)+"="+pG(e.value));return $j(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var mG=function(){bj(this,gG);var e=arguments.length>0?arguments[0]:void 0;Vj(this,new _G(e))},gG=mG.prototype;if(mj(gG,{append:function(e,t){Dj(arguments.length,2);var r=Fj(this);eG(r.entries,{key:wj(e),value:wj(t)}),r.updateURL()},delete:function(e){Dj(arguments.length,1);for(var t=Fj(this),r=t.entries,n=wj(e),i=0;i<r.length;)r[i].key===n?nG(r,i,1):i++;t.updateURL()},get:function(e){Dj(arguments.length,1);for(var t=Fj(this).entries,r=wj(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){Dj(arguments.length,1);for(var t=Fj(this).entries,r=wj(e),n=[],i=0;i<t.length;i++)t[i].key===r&&eG(n,t[i].value);return n},has:function(e){Dj(arguments.length,1);for(var t=Fj(this).entries,r=wj(e),n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){Dj(arguments.length,1);for(var r,n=Fj(this),i=n.entries,o=!1,a=wj(e),s=wj(t),u=0;u<i.length;u++)(r=i[u]).key===a&&(o?nG(i,u--,1):(o=!0,r.value=s));o||eG(i,{key:a,value:s}),n.updateURL()},sort:function(){var e=Fj(this);Mj(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=Fj(this).entries,n=Tj(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 fG(this,"keys")},values:function(){return new fG(this,"values")},entries:function(){return new fG(this,"entries")}},{enumerable:!0}),_j(gG,Nj,gG.entries,{name:"entries"}),_j(gG,"toString",(function(){return Fj(this).serialize()}),{enumerable:!0}),gj(mG,Lj),dj({global:!0,constructor:!0,forced:!fj},{URLSearchParams:mG}),!fj&&Ej(Xj)){var yG=vj(qj.has),SG=vj(qj.set),bG=function(e){if(Rj(e)){var t,r=e.body;if(Ij(r)===Lj)return t=e.headers?new Xj(e.headers):new Xj,yG(t,"content-type")||SG(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),Cj(e,{body:xj(0,wj(r)),headers:xj(0,t)})}return e};if(Ej(zj)&&dj({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return zj(e,arguments.length>1?bG(arguments[1]):{})}}),Ej(Hj)){var EG=function(e){return bj(this,Kj),new Hj(e,arguments.length>1?bG(arguments[1]):{})};Kj.constructor=EG,EG.prototype=Kj,dj({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:EG})}}var kG,TG=Rr,IG=w,AG=HB,RG=n,wG=Wt,CG=E,xG=li,PG=function(e,t,r){return XB.f(e,t,r)},OG=vv,DG=We,MG=hb,NG=Gk,LG=ni,UG=Tl.codeAt,VG=function(e){var t,r,n=[],i=oj(ij(aj(e),WB,"."),".");for(t=0;t<i.length;t++)r=i[t],nj(n,ZB(YB,r)?"xn--"+cj(r):r);return rj(n,".")},FG=gn,BG=Ni,jG=Tv,GG={URLSearchParams:mG,getState:Fj},zG=Zi,HG=zG.set,XG=zG.getterFor("URL"),KG=GG.URLSearchParams,qG=GG.getState,YG=RG.URL,WG=RG.TypeError,QG=RG.parseInt,JG=Math.floor,ZG=Math.pow,$G=CG("".charAt),ez=CG(/./.exec),tz=CG([].join),rz=CG(1..toString),nz=CG([].pop),iz=CG([].push),oz=CG("".replace),az=CG([].shift),sz=CG("".split),uz=CG("".slice),cz=CG("".toLowerCase),dz=CG([].unshift),lz="Invalid scheme",hz="Invalid host",vz="Invalid port",pz=/[a-z]/i,fz=/[\d+-.a-z]/i,_z=/\d/,mz=/^0x/i,gz=/^[0-7]+$/,yz=/^\d+$/,Sz=/^[\da-f]+$/i,bz=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Ez=/[\0\t\n\r #/:<>?@[\\\]^|]/,kz=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,Tz=/[\t\n\r]/g,Iz=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)dz(t,e%256),e=JG(e/256);return tz(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+=rz(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},Az={},Rz=MG({},Az,{" ":1,'"':1,"<":1,">":1,"`":1}),wz=MG({},Rz,{"#":1,"?":1,"{":1,"}":1}),Cz=MG({},wz,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),xz=function(e,t){var r=UG(e,0);return r>32&&r<127&&!DG(t,e)?e:encodeURIComponent(e)},Pz={ftp:21,file:null,http:80,https:443,ws:80,wss:443},Oz=function(e,t){var r;return 2==e.length&&ez(pz,$G(e,0))&&(":"==(r=$G(e,1))||!t&&"|"==r)},Dz=function(e){var t;return e.length>1&&Oz(uz(e,0,2))&&(2==e.length||"/"===(t=$G(e,2))||"\\"===t||"?"===t||"#"===t)},Mz=function(e){return"."===e||"%2e"===cz(e)},Nz={},Lz={},Uz={},Vz={},Fz={},Bz={},jz={},Gz={},zz={},Hz={},Xz={},Kz={},qz={},Yz={},Wz={},Qz={},Jz={},Zz={},$z={},eH={},tH={},rH=function(e,t,r){var n,i,o,a=FG(e);if(t){if(i=this.parse(a))throw WG(i);this.searchParams=null}else{if(void 0!==r&&(n=new rH(r,!0)),i=this.parse(a,null,n))throw WG(i);(o=qG(new KG)).bindURL(this),this.searchParams=o}};rH.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,u=this,c=t||Nz,d=0,l="",h=!1,v=!1,p=!1;for(e=FG(e),t||(u.scheme="",u.username="",u.password="",u.host=null,u.port=null,u.path=[],u.query=null,u.fragment=null,u.cannotBeABaseURL=!1,e=oz(e,kz,"")),e=oz(e,Tz,""),n=NG(e);d<=n.length;){switch(i=n[d],c){case Nz:if(!i||!ez(pz,i)){if(t)return lz;c=Uz;continue}l+=cz(i),c=Lz;break;case Lz:if(i&&(ez(fz,i)||"+"==i||"-"==i||"."==i))l+=cz(i);else{if(":"!=i){if(t)return lz;l="",c=Uz,d=0;continue}if(t&&(u.isSpecial()!=DG(Pz,l)||"file"==l&&(u.includesCredentials()||null!==u.port)||"file"==u.scheme&&!u.host))return;if(u.scheme=l,t)return void(u.isSpecial()&&Pz[u.scheme]==u.port&&(u.port=null));l="","file"==u.scheme?c=Yz:u.isSpecial()&&r&&r.scheme==u.scheme?c=Vz:u.isSpecial()?c=Gz:"/"==n[d+1]?(c=Fz,d++):(u.cannotBeABaseURL=!0,iz(u.path,""),c=$z)}break;case Uz:if(!r||r.cannotBeABaseURL&&"#"!=i)return lz;if(r.cannotBeABaseURL&&"#"==i){u.scheme=r.scheme,u.path=LG(r.path),u.query=r.query,u.fragment="",u.cannotBeABaseURL=!0,c=tH;break}c="file"==r.scheme?Yz:Bz;continue;case Vz:if("/"!=i||"/"!=n[d+1]){c=Bz;continue}c=zz,d++;break;case Fz:if("/"==i){c=Hz;break}c=Zz;continue;case Bz:if(u.scheme=r.scheme,i==kG)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=LG(r.path),u.query=r.query;else if("/"==i||"\\"==i&&u.isSpecial())c=jz;else if("?"==i)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=LG(r.path),u.query="",c=eH;else{if("#"!=i){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=LG(r.path),u.path.length--,c=Zz;continue}u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=LG(r.path),u.query=r.query,u.fragment="",c=tH}break;case jz:if(!u.isSpecial()||"/"!=i&&"\\"!=i){if("/"!=i){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,c=Zz;continue}c=Hz}else c=zz;break;case Gz:if(c=zz,"/"!=i||"/"!=$G(l,d+1))continue;d++;break;case zz:if("/"!=i&&"\\"!=i){c=Hz;continue}break;case Hz:if("@"==i){h&&(l="%40"+l),h=!0,o=NG(l);for(var f=0;f<o.length;f++){var _=o[f];if(":"!=_||p){var m=xz(_,Cz);p?u.password+=m:u.username+=m}else p=!0}l=""}else if(i==kG||"/"==i||"?"==i||"#"==i||"\\"==i&&u.isSpecial()){if(h&&""==l)return"Invalid authority";d-=NG(l).length+1,l="",c=Xz}else l+=i;break;case Xz:case Kz:if(t&&"file"==u.scheme){c=Qz;continue}if(":"!=i||v){if(i==kG||"/"==i||"?"==i||"#"==i||"\\"==i&&u.isSpecial()){if(u.isSpecial()&&""==l)return hz;if(t&&""==l&&(u.includesCredentials()||null!==u.port))return;if(a=u.parseHost(l))return a;if(l="",c=Jz,t)return;continue}"["==i?v=!0:"]"==i&&(v=!1),l+=i}else{if(""==l)return hz;if(a=u.parseHost(l))return a;if(l="",c=qz,t==Kz)return}break;case qz:if(!ez(_z,i)){if(i==kG||"/"==i||"?"==i||"#"==i||"\\"==i&&u.isSpecial()||t){if(""!=l){var g=QG(l,10);if(g>65535)return vz;u.port=u.isSpecial()&&g===Pz[u.scheme]?null:g,l=""}if(t)return;c=Jz;continue}return vz}l+=i;break;case Yz:if(u.scheme="file","/"==i||"\\"==i)c=Wz;else{if(!r||"file"!=r.scheme){c=Zz;continue}if(i==kG)u.host=r.host,u.path=LG(r.path),u.query=r.query;else if("?"==i)u.host=r.host,u.path=LG(r.path),u.query="",c=eH;else{if("#"!=i){Dz(tz(LG(n,d),""))||(u.host=r.host,u.path=LG(r.path),u.shortenPath()),c=Zz;continue}u.host=r.host,u.path=LG(r.path),u.query=r.query,u.fragment="",c=tH}}break;case Wz:if("/"==i||"\\"==i){c=Qz;break}r&&"file"==r.scheme&&!Dz(tz(LG(n,d),""))&&(Oz(r.path[0],!0)?iz(u.path,r.path[0]):u.host=r.host),c=Zz;continue;case Qz:if(i==kG||"/"==i||"\\"==i||"?"==i||"#"==i){if(!t&&Oz(l))c=Zz;else if(""==l){if(u.host="",t)return;c=Jz}else{if(a=u.parseHost(l))return a;if("localhost"==u.host&&(u.host=""),t)return;l="",c=Jz}continue}l+=i;break;case Jz:if(u.isSpecial()){if(c=Zz,"/"!=i&&"\\"!=i)continue}else if(t||"?"!=i)if(t||"#"!=i){if(i!=kG&&(c=Zz,"/"!=i))continue}else u.fragment="",c=tH;else u.query="",c=eH;break;case Zz:if(i==kG||"/"==i||"\\"==i&&u.isSpecial()||!t&&("?"==i||"#"==i)){if(".."===(s=cz(s=l))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(u.shortenPath(),"/"==i||"\\"==i&&u.isSpecial()||iz(u.path,"")):Mz(l)?"/"==i||"\\"==i&&u.isSpecial()||iz(u.path,""):("file"==u.scheme&&!u.path.length&&Oz(l)&&(u.host&&(u.host=""),l=$G(l,0)+":"),iz(u.path,l)),l="","file"==u.scheme&&(i==kG||"?"==i||"#"==i))for(;u.path.length>1&&""===u.path[0];)az(u.path);"?"==i?(u.query="",c=eH):"#"==i&&(u.fragment="",c=tH)}else l+=xz(i,wz);break;case $z:"?"==i?(u.query="",c=eH):"#"==i?(u.fragment="",c=tH):i!=kG&&(u.path[0]+=xz(i,Az));break;case eH:t||"#"!=i?i!=kG&&("'"==i&&u.isSpecial()?u.query+="%27":u.query+="#"==i?"%23":xz(i,Az)):(u.fragment="",c=tH);break;case tH:i!=kG&&(u.fragment+=xz(i,Rz))}d++}},parseHost:function(e){var t,r,n;if("["==$G(e,0)){if("]"!=$G(e,e.length-1))return hz;if(t=function(e){var t,r,n,i,o,a,s,u=[0,0,0,0,0,0,0,0],c=0,d=null,l=0,h=function(){return $G(e,l)};if(":"==h()){if(":"!=$G(e,1))return;l+=2,d=++c}for(;h();){if(8==c)return;if(":"!=h()){for(t=r=0;r<4&&ez(Sz,h());)t=16*t+QG(h(),16),l++,r++;if("."==h()){if(0==r)return;if(l-=r,c>6)return;for(n=0;h();){if(i=null,n>0){if(!("."==h()&&n<4))return;l++}if(!ez(_z,h()))return;for(;ez(_z,h());){if(o=QG(h(),10),null===i)i=o;else{if(0==i)return;i=10*i+o}if(i>255)return;l++}u[c]=256*u[c]+i,2!=++n&&4!=n||c++}if(4!=n)return;break}if(":"==h()){if(l++,!h())return}else if(h())return;u[c++]=t}else{if(null!==d)return;l++,d=++c}}if(null!==d)for(a=c-d,c=7;0!=c&&a>0;)s=u[c],u[c--]=u[d+a-1],u[d+--a]=s;else if(8!=c)return;return u}(uz(e,1,-1)),!t)return hz;this.host=t}else if(this.isSpecial()){if(e=VG(e),ez(bz,e))return hz;if(t=function(e){var t,r,n,i,o,a,s,u=sz(e,".");if(u.length&&""==u[u.length-1]&&u.length--,(t=u.length)>4)return e;for(r=[],n=0;n<t;n++){if(""==(i=u[n]))return e;if(o=10,i.length>1&&"0"==$G(i,0)&&(o=ez(mz,i)?16:8,i=uz(i,8==o?1:2)),""===i)a=0;else{if(!ez(10==o?yz:8==o?gz:Sz,i))return e;a=QG(i,o)}iz(r,a)}for(n=0;n<t;n++)if(a=r[n],n==t-1){if(a>=ZG(256,5-t))return null}else if(a>255)return null;for(s=nz(r),n=0;n<r.length;n++)s+=r[n]*ZG(256,3-n);return s}(e),null===t)return hz;this.host=t}else{if(ez(Ez,e))return hz;for(t="",r=NG(e),n=0;n<r.length;n++)t+=xz(r[n],Az);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return DG(Pz,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&Oz(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,u=e.fragment,c=t+":";return null!==i?(c+="//",e.includesCredentials()&&(c+=r+(n?":"+n:"")+"@"),c+=Iz(i),null!==o&&(c+=":"+o)):"file"==t&&(c+="//"),c+=e.cannotBeABaseURL?a[0]:a.length?"/"+tz(a,"/"):"",null!==s&&(c+="?"+s),null!==u&&(c+="#"+u),c},setHref:function(e){var t=this.parse(e);if(t)throw WG(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new nH(e.path[0]).origin}catch(ZH){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+Iz(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(FG(e)+":",Nz)},getUsername:function(){return this.username},setUsername:function(e){var t=NG(FG(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=xz(t[r],Cz)}},getPassword:function(){return this.password},setPassword:function(e){var t=NG(FG(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=xz(t[r],Cz)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?Iz(e):Iz(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,Xz)},getHostname:function(){var e=this.host;return null===e?"":Iz(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Kz)},getPort:function(){var e=this.port;return null===e?"":FG(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=FG(e))?this.port=null:this.parse(e,qz))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+tz(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Jz))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=FG(e))?this.query=null:("?"==$G(e,0)&&(e=uz(e,1)),this.query="",this.parse(e,eH)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=FG(e))?("#"==$G(e,0)&&(e=uz(e,1)),this.fragment="",this.parse(e,tH)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var nH=function(e){var t=OG(this,iH),r=jG(arguments.length,1)>1?arguments[1]:void 0,n=HG(t,new rH(e,!1,r));IG||(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())},iH=nH.prototype,oH=function(e,t){return{get:function(){return XG(this)[e]()},set:t&&function(e){return XG(this)[t](e)},configurable:!0,enumerable:!0}};if(IG&&(PG(iH,"href",oH("serialize","setHref")),PG(iH,"origin",oH("getOrigin")),PG(iH,"protocol",oH("getProtocol","setProtocol")),PG(iH,"username",oH("getUsername","setUsername")),PG(iH,"password",oH("getPassword","setPassword")),PG(iH,"host",oH("getHost","setHost")),PG(iH,"hostname",oH("getHostname","setHostname")),PG(iH,"port",oH("getPort","setPort")),PG(iH,"pathname",oH("getPathname","setPathname")),PG(iH,"search",oH("getSearch","setSearch")),PG(iH,"searchParams",oH("getSearchParams")),PG(iH,"hash",oH("getHash","setHash"))),xG(iH,"toJSON",(function(){return XG(this).serialize()}),{enumerable:!0}),xG(iH,"toString",(function(){return XG(this).serialize()}),{enumerable:!0}),YG){var aH=YG.createObjectURL,sH=YG.revokeObjectURL;aH&&xG(nH,"createObjectURL",wG(aH,YG)),sH&&xG(nH,"revokeObjectURL",wG(sH,YG))}BG(nH,"URL"),TG({global:!0,constructor:!0,forced:!AG,sham:!IG},{URL:nH});var uH=ee.URL,cH=function(){var e=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(uH.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)}}(),dH=ad,lH=tu,hH=function(e,t,r,n){for(var i,o=n>1?void 0:n?lH(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&&dH(t,r,o),o},vH=function(){function e(t,r){qd(this,e),sd(this,"_sharedAudioContext",new AudioContext),sd(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),sd(this,"_localGainNode",this._sharedAudioContext.createGain()),sd(this,"_bufferGainNode",this._sharedAudioContext.createGain()),sd(this,"_audioBufferSource",void 0),sd(this,"_localSource",void 0),sd(this,"_context",void 0),sd(this,"_failedAudioList",[]),sd(this,"_startingIds",new FS),sd(this,"_revokeURLs",new gN),sd(this,"mixingMap",new FS),sd(this,"resourcesCache",new FS),sd(this,"volumeConfig",new FS),sd(this,"cachedBuffer",[]),sd(this,"id","AudioMixingManager"),this.engineId=r,this._context=t,this._localGainNode.gain.value=1}var t,r,n;return Kd(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=Em(Sm().mark((function e(t,r,n){var i,o,a,s,u,c,d,l,h,v,p,f,_,m=this;return Sm().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,FO(o=n.type,"mixingType",jB(jd)),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!=(u=this.mixingMap.get(t))&&u.audioNode){u.audioNode.pause(),this._context.emitMessage({mixId:t,state:Gd.AUDIO_MIXING_STATE_STOPPED,error:uR.AUDIO_MIXING_ERROR_OK});try{u.gainNode.disconnect(this._audioDestination),u.audioSource.disconnect(u.gainNode)}catch(g){}}if(!(d=this.resourcesCache.get(t))||d.filePath!==r){e.next=18;break}c=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:Gd.AUDIO_MIXING_STATE_FAILED,error:uR.AUDIO_MIXING_ERROR_START_FAILED}),new cR(sR.LOAD_RESOURCES_FAILED,e.statusText)}));case 20:return l=e.sent,Ub(r).call(r,"mp3")?h={type:"audio/mpeg"}:Ub(r).call(r,"aac")&&(h={type:"audio/aac"}),e.next=24,cH(l,h);case 24:if(e.sent){e.next=28;break}throw this._context.emitMessage({mixId:t,state:Gd.AUDIO_MIXING_STATE_FAILED,error:uR.AUDIO_MIXING_ERROR_START_FAILED}),new cR(sR.LOAD_RESOURCES_FAILED,"invalid audio resource");case 28:(c=new Audio).crossOrigin="anonymous",c.src=uH.createObjectURL(new Blob([l],h));case 31:return i<=0?c.loop=!0:i>0&&(v=i,c.onended=function(){--v>0?c.play():(m.mixingMap.delete(t),m._context.emitMessage({mixId:t,state:Gd.AUDIO_MIXING_STATE_FINISHED,error:uR.AUDIO_MIXING_ERROR_OK}))}),e.prev=32,e.next=35,c.play();case 35:e.next=42;break;case 37:e.prev=37,e.t0=e.catch(32),console.error(e.t0),this._failedAudioList.push(c),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:yd.STREAM_INDEX_MAIN,mediaType:Sd.AUDIO});case 42:if(this._startingIds.delete(t),p=this._sharedAudioContext.createMediaElementSource(c),f=this._sharedAudioContext.createGain(),_=this.volumeConfig.get(t),f.gain.value=_?_/100:1,p.connect(f).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:p,audioNode:c,gainNode:f,type:"file"}),o===jd.PUBLISH)try{f.disconnect(this._sharedAudioContext.destination)}catch(g){}else f.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:Gd.AUDIO_MIXING_STATE_PLAYING,error:uR.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:Gd.AUDIO_MIXING_STATE_STOPPED,error:uR.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Gd.AUDIO_MIXING_STATE_PAUSED,error:uR.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:Gd.AUDIO_MIXING_STATE_PLAYING,error:uR.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=Em(Sm().mark((function e(t,r){var n,i,o=this;return Sm().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 cR(sR.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(o._context.emitMessage({mixId:t,state:Gd.AUDIO_MIXING_STATE_FAILED,error:uR.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof cR)throw e;throw new cR(sR.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,Ub(r).call(r,"mp3")?i={type:"audio/mpeg"}:Ub(r).call(r,"aac")&&(i={type:"audio/aac"}),e.next=7,cH(n,i);case 7:if(e.sent){e.next=11;break}throw this._context.emitMessage({mixId:t,state:Gd.AUDIO_MIXING_STATE_FAILED,error:uR.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new cR(sR.LOAD_RESOURCES_FAILED,"Load resources failed");case 11:return this._context.emitMessage({mixId:t,state:Gd.AUDIO_MIXING_STATE_PRELOADED,error:uR.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){var e=uH.createObjectURL(new Blob([n],i));return o._revokeURLs.add(e),new Audio(e)},filePath:r,duration:0}),e.next=15,new X_((function(e){var r=uH.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)),uH.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){FO(e,"type",jB(jd));var t=this._context.getLocalAudioTrack();if(t){var r=t.getTrack("preprocessing");if(r&&this.mixMediaStream(new MediaStream([r])),e===jd.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:Gd.AUDIO_MIXING_STATE_PCM_ENABLED,error:uR.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:Gd.AUDIO_MIXING_STATE_PCM_DISABLED,error:uR.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=Em(Sm().mark((function e(){var t,r,n,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=YT(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:yd.STREAM_INDEX_MAIN,mediaType:Sd.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 FS,this._revokeURLs.forEach((function(e){uH.revokeObjectURL(e)}))}}]),e}();hH([gP("id","filePath","options")],vH.prototype,"startAudioMixing",1),hH([gP("id")],vH.prototype,"stopAudioMixing",1),hH([gP("id")],vH.prototype,"pauseAudioMixing",1),hH([gP("id")],vH.prototype,"resumeAudioMixing",1),hH([gP("id")],vH.prototype,"preloadAudioMixing",1),hH([gP("id")],vH.prototype,"unloadAudioMixing",1),hH([gP("id")],vH.prototype,"getAudioMixingVolume",1),hH([gP("id","volume")],vH.prototype,"setAudioMixingVolume",1),hH([gP("id")],vH.prototype,"getAudioMixingDuration",1),hH([gP("id")],vH.prototype,"getAudioMixingCurrentPosition",1),hH([gP("id","position")],vH.prototype,"setAudioMixingPosition",1),hH([gP("type")],vH.prototype,"enableAudioMixingBuffer",1),hH([gP()],vH.prototype,"disableAudioMixingBuffer",1),hH([gP("buffer")],vH.prototype,"pushAudioMixingBuffer",1);var pH=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(pH||{}),fH=new nP("RTMClient",1),_H=function(e){wI(c,e);var t,r,n,i,o,a,s,u=XI(c);function c(e,t){var r;return qd(this,c),sd(QT(r=u.call(this)),"_dataChannelSignal",null),sd(QT(r),"_handler",null),sd(QT(r),"_dataChannelSignalState",FV.DISCONNECTED),sd(QT(r),"_loginSessionId",null),sd(QT(r),"_userId",null),sd(QT(r),"_token",null),sd(QT(r),"_isReconnecting",!1),sd(QT(r),"_reconnectTimer",null),sd(QT(r),"_loginResolveCallback",null),sd(QT(r),"_loginRejectCallback",null),sd(QT(r),"_iceConfigNode",null),sd(QT(r),"_wait_login_token",!1),sd(QT(r),"_serverParamsCache",void 0),r.id=e,r._appId=t,r}return Kd(c,[{key:"login",value:function(e,t){var r=this;return new X_((function(n,i){var o;if(fH.print("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new cR(sR.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new cR(sR.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,null===(o=mP(r.id))||void 0===o||o.set({rtm_user_id:t}),r._loginResolveCallback=n,r._loginRejectCallback=i,r._dataChannelSignal?r._login():(fH.print("login","init dataChannelSingling"),r._dataChannelSignalState=FV.CONNECTING,r._createDataChannelSignaling(t).then((function(e){r._dataChannelSignal=e,r._login()})).catch((function(){r._onDisconnect()})))}))}},{key:"logout",value:(s=Em(Sm().mark((function e(){var t;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new cR(sR.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._appId},{functionType:DD.C2RTM}).catch((function(){}));case 4:this._closeDataChannelSignaling(),this._clearState();case 6:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"updateLoginToken",value:(a=Em(Sm().mark((function e(t){var r=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new X_((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 a.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(o=Em(Sm().mark((function e(t){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new cR(sR.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.next=5,this._dataChannelSignal.sendSignaling("getPeerOnlineStatus",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._appId,peerUserId:t},{functionType:DD.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 o.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(i=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new cR(sR.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._appId,to:t,room:"",msg:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"setServerParams",value:(n=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,VO(t,"signature"),VO(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new cR(sR.NOT_LOGIN,"login first");case 5:return this._checkDataChannelSignal(),e.next=8,this._dataChannelSignal.sendSignaling("setServerParams",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._appId,signature:t,url:r},{functionType:DD.C2RTM}).catch((function(e){throw new cR(sR.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 n.apply(this,arguments)})},{key:"sendServerMessage",value:(r=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new cR(sR.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._appId,to:"",room:"",type:RD.BUSINESS_SERVER,msg:t}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){this._clearState(),this._closeDataChannelSignaling(),AI(TI(c.prototype),"removeAllListeners",this).call(this),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=DP();this._checkDataChannelSignal(),this._dataChannelSignal.sendSignaling("login",{Token:UP.token2auth(this._appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:xO.VERSION,deviceId:IO.getDeviceId(),appId:this._appId,userId:this._userId}},{functionType:DD.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,uP.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=sR.INVALID_PARAMS,n="Invalid userId"):(r=sR.INVALID_TOKEN,n="Invalid token",e._wait_login_token=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=sR.LOGIN_FAILED,n="login failed"),"function"==typeof e._loginRejectCallback&&e._loginRejectCallback(new cR(r,a||n))})).finally((function(){e._loginResolveCallback=null,e._loginRejectCallback=null}))}}},{key:"_createDataChannelSignaling",value:(t=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=new UD(this.id),i=this._iceConfigNode){e.next=16;break}return e.prev=3,e.next=6,null==n?void 0:n.getAccessNode(this._appId,"");case 6:if(o=e.sent,i=o[0]){e.next=10;break}throw new Error;case 10:e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(3),SP(this.id,"rtm.login.getNodeFailed",null===e.t0||void 0===e.t0?void 0:e.t0.message),new cR(sR.ICE_SERVER_WRONG,"get ICE config failed");case 16:return SP(this.id,"rtm.login.getNodeSuccess",i),fH.print("_createDataChannelSignaling()","get node success",i),this._handler=IV({id:this.id,avSync:!0}),null===(r=this._handler)||void 0===r||r.once("disconnect",(function(){fH.print("_createDataChannelSignaling()","recv BasicHandler event: disconnect"),c._onDisconnect()})),e.prev=20,e.next=23,null===(s=this._handler)||void 0===s?void 0:s.connect(i);case 23:a=e.sent,fH.print("_createDataChannelSignaling()","establish peerConnection success"),this._dataChannelSignalState=FV.CONNECTED,e.next=33;break;case 28:throw e.prev=28,e.t1=e.catch(20),this._iceConfigNode=null,this._dataChannelSignalState=FV.DISCONNECTED,new cR(sR.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed",e.t1);case 33:return u=new MD(this.id,a),fH.print("_createDataChannelSignaling()","send ping"),u.sendPingSignaling(),u.once("close",(function(){fH.print("_createDataChannelSignaling()","recv DataChannelSignaling event: close"),c._onDisconnect()})),u.on(bD.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){c.emit("onUserMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),u.on(bD.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){c.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),u.on(bD.USER_DISCONNECTION,(function(){c.emit("onUserDisconnection"),c._clearState()})),u.on(bD.NODE_CHANGE,(function(e){SP(c.id,"rtm.nodeChange",ZE(e)),Array.isArray(e.nodes)&&e.nodes.length&&(c._iceConfigNode=e.nodes[0]),c._loginResolveCallback&&c._loginRejectCallback?c._login():c._reconnect()})),e.abrupt("return",u);case 42:case"end":return e.stop()}}),e,this,[[3,12],[20,28]])}))),function(e){return t.apply(this,arguments)})},{key:"_closeDataChannelSignaling",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.destroy(),this._dataChannelSignal=null,null===(t=this._handler)||void 0===t||t.destroy(),this._handler=null}},{key:"_checkDataChannelSignal",value:function(){if(!this._dataChannelSignal||this._dataChannelSignalState!==FV.CONNECTED)throw new cR(sR.NOT_CONNECTED_YET,"datachannel not connect")}},{key:"_onDisconnect",value:function(){this._dataChannelSignalState=FV.DISCONNECTED,this._closeDataChannelSignaling(),navigator.onLine?this._reconnect():this._reconnectTimer=self.setTimeout(this._reconnect.bind(this),3e3)}},{key:"_reconnect",value:function(){var e=this;!this._isReconnecting&&this._userId&&(fH.print("_reconnect()","start reconnect..."),this._isReconnecting=!0,this._createDataChannelSignaling(this._userId).then((function(t){fH.print("_reconnect()","reconnect success!"),e._dataChannelSignal=t,e._login(),e._reconnectTimer=null})).catch((function(t){fH.print("_reconnect()","Reconnecting error, will reconnect after 3s",t),e._reconnectTimer=self.setTimeout(e._reconnect.bind(e),3e3)})).finally((function(){e._isReconnecting=!1})))}},{key:"_clearState",value:function(){this._userId=null,this._token=null,this._loginSessionId=null,uP.setRtsSessionId(this.id,""),null!==this._reconnectTimer&&(self.clearTimeout(this._reconnectTimer),this._reconnectTimer=null)}}]),c}(iD.exports.EventEmitter),mH=function(e){wI(o,e);var t,r,n,i=XI(o);function o(e,t,r){var n,a=r.businessId;return qd(this,o),sd(QT(n=i.call(this)),"_mediaServerClient",void 0),sd(QT(n),"_appId",void 0),sd(QT(n),"_reconnectTimer",void 0),sd(QT(n),"remoteStreams",void 0),sd(QT(n),"_businessId",void 0),n.id=e,n._appId=t,n.remoteStreams=new FS,n._businessId=a,n}return Kd(o,[{key:"connect",value:(n=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._mediaServerClient=new jV({id:this.id,avSync:!0}),this._businessId&&(this._mediaServerClient.businessId=this._businessId),this._bindEvents(),e.next=5,this._mediaServerClient.connect(this._appId);case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startPlayPublicStream",value:(r=Em(Sm().mark((function e(t){var r,n=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.remoteStreams.get(t)){e.next=2;break}throw new cR(sR.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new vV(this.id,t,t,!1,{audiostream:!0,localaudio:!0,videostream:!0,localvideo:!0,extaudio:!1,extvideo:!1,videoDescriptions:[]})).on("onSEIMessage",(function(e){if(e instanceof Uint8Array)for(var t=hO(e),i=0;i<t.seiCount;i++)n.emit(CV.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(){this.remoteStreams=new FS,this._mediaServerClient&&this._mediaServerClient.destroy()}},{key:"_handleReconnected",value:(t=Em(Sm().mark((function e(){var t,r,n,i=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:clearTimeout(this._reconnectTimer),t=YT(this.remoteStreams);try{for(n=function(){var e=WT(r.value,1)[0];i.remoteStreams.delete(e),i.startPlayPublicStream(e).then((function(){var t=i.remoteStreams.get(e);i.safeEmit(CV.RESUBSCRIBE,{stream:t})}))},t.s();!(r=t.n()).done;)n()}catch(o){t.e(o)}finally{t.f()}case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_reconnect",value:function(){var e=this;this._mediaServerClient.removeAllListeners(),this._mediaServerClient.destroy(),navigator.onLine?this.connect().then(this._handleReconnected.bind(this)):this._reconnectTimer=window.setTimeout((function(){return e.connect().then(e._handleReconnected.bind(e))}),3e3)}},{key:"_bindEvents",value:function(){var e,t,r=this;null===(e=this._mediaServerClient)||void 0===e||e.on(kD.ABNORMAL_DISCONNECTION,this._reconnect.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on("onRemoteStreamStats",(function(e){r.emit("onRemoteStreamStats",e)}))}}]),o}(sD),gH=new nP("AudioDeviceManager",1),yH=function(e){wI(u,e);var t,r,n,i,o,a,s=XI(u);function u(e){var t;return qd(this,u),sd(QT(t=s.call(this)),"_audioLevelFetcher",void 0),sd(QT(t),"_playbackDeviceTestTimer",void 0),sd(QT(t),"_audioElement",void 0),sd(QT(t),"_audioTrack",void 0),sd(QT(t),"_mediaRecorder",void 0),sd(QT(t),"_recoderTimer",void 0),sd(QT(t),"_isAudioPlaybackDeviceTesting",!1),sd(QT(t),"_isAudioDeviceRecordTesting",!1),sd(QT(t),"_audioCaptureAndRecoderResolve",void 0),sd(QT(t),"_onAutoplayFailed",void 0),sd(QT(t),"_audioPlaybackDeviceId",void 0),t._extensionManager=e,t}return Kd(u,[{key:"audioTrack",get:function(){return this._audioTrack}},{key:"startAudioPlaybackDeviceTest",value:(a=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new cR(sR.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,gH.print("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),gH.print("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&&(gH.print("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(o=Em(Sm().mark((function e(t,r,n){var i=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(window.MediaRecorder){e.next=2;break}throw new cR(sR.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 2:if(!this._isAudioDeviceRecordTesting){e.next=4;break}throw new cR(sR.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 4:return this._isAudioDeviceRecordTesting=!0,gH.print("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){gH.print("startAudioDeviceRecordTest()","".concat(3e4,'ms automatic call method "stopAudioDeviceRecordAndPlayTest"')),i._stopAudioCaptureAndRecoder()}),3e4),e.prev=7,this._onAutoplayFailed=r,e.next=11,this._startAudioCaptureAndRecoder(t,null!=n?n:100);case 11:e.next=18;break;case 13:throw e.prev=13,e.t0=e.catch(7),this._isAudioDeviceRecordTesting=!1,delete this._onAutoplayFailed,e.t0;case 18:delete this._audioCaptureAndRecoderResolve;case 19:case"end":return e.stop()}}),e,this,[[7,13]])}))),function(e,t,r){return o.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){gH.print("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(gH.print("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=Em(Sm().mark((function e(t){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(gH.print("setSinkId()","Invoke"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=3;break}throw new cR(sR.NOT_SUPPORTED,"setSinkId not supported by current browser");case 3:return e.next=5,tU.getDeviceById(t);case 5:if(r=e.sent){e.next=8;break}throw new cR(sR.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(){gH.print("destroy()","Invoke"),AI(TI(u.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:(n=Em(Sm().mark((function e(t,r){var n,i=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return gH.print("_playAudioFile()",Rm(n="Invoke url=".concat(t,"; loop=")).call(n,r.loop)),e.abrupt("return",new X_((function(e,n){var o=cF("audio",{attributes:{src:t,crossOrigin:"anonymous"}});i._audioElement=o,o.loop=r.loop,i._audioLevelFetcher=new iU(o),o.onplaying=function(){o.onplaying=null,gH.print("_playAudioFile()","onplaying"),e()},o.onerror=function(){var e=Em(Sm().mark((function e(t){var r,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:gH.print("_playAudioFile()","onerror",t),i=t.message||(null==o||null===(r=o.error)||void 0===r?void 0:r.message),n(new cR(sR.LOAD_RESOURCES_FAILED,"Failed to play recorded audio"+(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;gH.print("_playAudioFile()","autoplay error",e);var r=Rm(t="Failed to play recorded audio, ".concat(e.name,": ")).call(t,e.message);"NotAllowedError"===e.name&&i._onAutoplayFailed?i._onAutoplayFailed((function(){var e;return X_.all([null===(e=i._audioLevelFetcher)||void 0===e?void 0:e.resume(),o.play()])})):n(new cR(sR.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&&(gH.print("_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&&(gH.print("_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&&(gH.print("_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=Em(Sm().mark((function e(t,r){var n,i=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,OU({},this._extensionManager);case 2:return this._audioTrack=e.sent,this._audioTrack.setVolume(r),n=new MediaStream([this._audioTrack.getTrack("preprocessing")]),gH.print("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new X_((function(e,r){var o,a;"function"==typeof MediaRecorder.isTypeSupported&&(o=oE(a=["audio/webm","audio/mp4"]).call(a,(function(e){return MediaRecorder.isTypeSupported(e)})),gH.print("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=Em(Sm().mark((function n(o){var a,u;return Sm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!i._isAudioDeviceRecordTesting){n.next=16;break}return gH.print("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),u=new Blob([o.data],{type:s}),n.prev=3,n.next=6,i._playAudioFile(uH.createObjectURL(u),{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 cR(sR.AUDIO_DEVICE_TEST_FAILED,e.message||"mediaRecorder error"))},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=Em(Sm().mark((function e(){var t,r,n,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._audioPlaybackDeviceId){"default"===t&&(t="");try{null===(r=oU.getAudioContextInstance())||void 0===r||null===(n=r.setSinkId)||void 0===n||n.call(r,t),gH.print("setSinkId","ctx.sinkId=".concat(t))}catch(o){gH.print("setSinkId",Rm(i="failed, ".concat(o.name," - ")).call(i,o.message))}}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),u}(iD.exports.EventEmitter),SH=function(){function e(t){qd(this,e),sd(this,"_roomId",void 0),sd(this,"_constraints",{}),sd(this,"_profile",void 0),this._appId=t}return Kd(e,[{key:"setRoomId",value:function(e){this._roomId=e}},{key:"setAudioProfile",value:function(e){this._profile=e}},{key:"getOpusConfigStr",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=IO.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,u="number"==typeof a?a:null==a?void 0:a.exact,c={};t.split(";").forEach((function(e){var t=WT(e.split("="),2),r=t[0],n=t[1];r&&n&&(c[r]=n)}));var d=(null==n?void 0:n.bitrate)||this._getConfigByAudioProfile().bitrate;d&&(c.maxaveragebitrate=d);var l=(null==n?void 0:n.enc_sample_rate)||s;l&&(c["sprop-maxcapturerate"]=l);var h=(null==n?void 0:n.playback_rate)||s;return h&&(c.maxplaybackrate=h),(u&&u>1||null!=n&&n.stereo)&&(c["sprop-stereo"]=1,c.stereo=1),null!=n&&n.dtx&&(c.usedtx=1),YE(e=an(c)).call(e,(function(e){var t;return Rm(t="".concat(e,"=")).call(t,c[e])})).join(";")}},{key:"updateConstraints",value:function(e){this._constraints=cd(cd({},this._constraints),e)}},{key:"getConstraints",value:function(){var e=cd({},this._constraints),t=IO.getEngineWebConfig(this._appId,this._roomId||"").audio_capture;pO(null==t?void 0:t.sample_rate)||(e.sampleRate=t.sample_rate),pO(null==t?void 0:t.channel)||(e.channelCount=t.channel),pO(null==t?void 0:t.agc)||(e.autoGainControl=t.agc),pO(null==t?void 0:t.ans)||(e.noiseSuppression=t.ans),pO(null==t?void 0:t.aec)||(e.echoCancellation=t.aec);var r=this._getConfigByAudioProfile(),n=r.sampleRate,i=r.channel;return pO(e.sampleRate)&&!pO(n)&&(e.sampleRate=n),pO(e.channelCount)&&!pO(i)&&(e.channelCount=i),e}},{key:"_getConfigByAudioProfile",value:function(){var e={};switch(this._profile){case Dd.fluent:e.sampleRate=16e3,e.bitrate=24e3;break;case Dd.standard:e.sampleRate=48e3,e.bitrate=48e3;break;case Dd.hd:e.sampleRate=48e3,e.bitrate=128e3,e.channel=2;break;case Dd.standardStereo:e.sampleRate=48e3,e.bitrate=8e4,e.channel=2;break;case Dd.hdMono:e.sampleRate=48e3,e.bitrate=128e3}return e}}]),e}(),bH=new nP("VideoSnapshot",1),EH=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},kH=function(){var e=Em(Sm().mark((function e(t,r,n){var i,o,a,s,u,c,d,l;return Sm().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(),!(u=EH(n))){e.next=16;break}return bH.print("takeSnapshot","VideoPlayer already set."),e.next=11,a(u,u.videoWidth,u.videoHeight);case 11:return c=e.sent,bH.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",c);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 bH.print("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,bH.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",l);case 29:return bH.print("takeSnapshot","use temp video"),e.abrupt("return",new X_((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);bH.print("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)}}(),TH=function(){return{url:"",video:{codec:Ld.H264,width:640,height:360,fps:15,gop:2,kBitRate:IH(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:Nd.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function IH(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 AH(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new cR(sR.INVALID_PARAMS,"Invalid rtmp address")}function RH(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new cR(sR.INVALID_PARAMS,"regions should not be empty.");var t,r=YT(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new cR(sR.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if("boolean"!=typeof n.isScreenStream)throw new cR(sR.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(i){r.e(i)}finally{r.f()}}function wH(e,t){var r,n,i,o=function(e,r){var n=$S(e).call(e,(function(e,t){return null==e?void 0:e[t]}),t),i=$S(e).call(e,(function(e,t){return null==e?void 0:e[t]}),TH());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}))),u=a(o(["video","height"],(function(e){return e>=2&&e<=1920}))),c=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!!oE(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 vk(t=[1,2]).call(t,e)})),profile:o(["audio","AACProfile"],(function(e){var t;return vk(t=[Nd.LC,Nd.HEv1,Nd.HEv2]).call(t,e)}))},video:{codec:o(["video","codec"],(function(e){var t;return vk(t=["H264","H265"]).call(t,e)})),fps:c,gop:o(["video","gop"],(function(e){return e>=1&&e<=5}))*c,bitRate:1e3*(d>=16&&d<=1e4?d:IH(s,u,c)),width:s,height:u},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:YE(i).call(i,(function(e){var t,r;return{alpha:!e.alpha||+e.alpha>1||+e.alpha<=0?1:+e.alpha,uid:e.userId,zorder:!e.zorder||+e.zorder<0||+e.zorder>100?0:+e.zorder,x:!e.x||+e.x>=1||+e.x<0?0:+e.x,y:!e.y||+e.y>=1||+e.y<0?0:+e.y,w:!e.w||+e.w>1||+e.w<=0?1:+e.w,h:!e.h||+e.h>1||+e.h<=0?1:+e.h,renderMode:e.renderMode&&vk(t=[1,2,3]).call(t,e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&vk(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 CH,xH={getDefaultValue:TH,checkStartParams:function(e){var t;AH(e.url),RH(null===(t=e.layout)||void 0===t?void 0:t.regions)},checckUpdateParams:function(e){var t;e.url&&AH(e.url),RH(null===(t=e.layout)||void 0===t?void 0:t.regions)},getStartParams:function(e){return wH("started",e)},getUpdateParams:function(e){return wH("layoutChanged",e)}},PH=ad,OH=tu,DH=function(e,t,r,n){for(var i,o=n>1?void 0:n?OH(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&&PH(t,r,o),o},MH=new nP("Engine",0),NH=function(e){wI(me,e);var t,r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A,R,w,C,x,P,O,D,M,N,L,U,V,F,B,j,G,z,H,X,K,q,Y,W,Q,J,Z,$,ee,te,re,ne,ie,oe,ae,se,ue,ce,de,le,he,ve,pe,fe,_e=XI(me);function me(e,t,r){var n;return qd(this,me),sd(QT(n=_e.call(this)),"monitor",void 0),sd(QT(n),"_room",void 0),sd(QT(n),"_publicStreamManager",void 0),sd(QT(n),"_appId",void 0),sd(QT(n),"_businessId",void 0),sd(QT(n),"_visibility",!0),sd(QT(n),"_localVideoTrack",void 0),sd(QT(n),"_localAudioTrack",void 0),sd(QT(n),"_localImgVideoTrack",void 0),sd(QT(n),"_localImgScreenTrack",void 0),sd(QT(n),"_localScreenVideoTrack",void 0),sd(QT(n),"_localScreenAudioTrack",void 0),sd(QT(n),"_tempMixingAudioTrack",void 0),sd(QT(n),"_localAudioVolume",100),sd(QT(n),"_localScreenAudioVolume",100),sd(QT(n),"_remoteAudioVolume",new FS),sd(QT(n),"_remoteScreenAudioVolume",new FS),sd(QT(n),"_publicAudioVolume",new FS),sd(QT(n),"_videoPlayer",void 0),sd(QT(n),"_screenPlayer",void 0),sd(QT(n),"_remoteVideoPlayer",new FS),sd(QT(n),"_remoteScreenPlayer",new FS),sd(QT(n),"_remoteAudioPlayer",new FS),sd(QT(n),"_remoteScreenAudioPlayer",new FS),sd(QT(n),"_publicStreamAudioPlayer",new FS),sd(QT(n),"_publicStreamVideoPlayer",new FS),sd(QT(n),"_publicStreamIds",new FS),sd(QT(n),"_roomConfig",void 0),sd(QT(n),"_videoStreamConstraints",MO),sd(QT(n),"_audioStreamConstraints",{}),sd(QT(n),"_enableSimulcast",!1),sd(QT(n),"_videoStreamEncodeConfig",[MO]),sd(QT(n),"_screenStreamEncodeConfig",[NO]),sd(QT(n),"_dummyMainImage",void 0),sd(QT(n),"_dummyScreenImage",void 0),sd(QT(n),"_trackSourceType",void 0),sd(QT(n),"_liveTranscodeConfig",void 0),sd(QT(n),"_useCloudProxy",void 0),sd(QT(n),"_startCloudProxyTimestamp",void 0),sd(QT(n),"_localVideoDeviceId",void 0),sd(QT(n),"_localAudioDeviceId",void 0),sd(QT(n),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeStreamIds:{}}),sd(QT(n),"_audioVolumeIndicationTimer",void 0),sd(QT(n),"_dummyMainTimer",void 0),sd(QT(n),"_dummyScreenTimer",void 0),sd(QT(n),"_audioPropertiesReportTimer",null),sd(QT(n),"_mirrorType",kd.MIRROR_TYPE_RENDER),sd(QT(n),"_audioMixingManager",void 0),sd(QT(n),"_pubLock",void 0),sd(QT(n),"_rtmClient",void 0),sd(QT(n),"_messageStatisticsObserver",void 0),sd(QT(n),"_tempRoomInfo",void 0),sd(QT(n),"_originIceConfigRequestUrls",void 0),sd(QT(n),"_originConfigServerUrls",void 0),sd(QT(n),"_originLogServerUrl",void 0),sd(QT(n),"_extensionManager",void 0),sd(QT(n),"_audioDeviceManager",void 0),sd(QT(n),"_audioProfileManager",void 0),sd(QT(n),"_remoteVideoConfig",new FS),sd(QT(n),"_userPriorityMap",new FS),sd(QT(n),"_subscribeFallbackOption",void 0),sd(QT(n),"_cameraCapturing",!1),sd(QT(n),"_interruptCameraCapture",!1),sd(QT(n),"_micCapturing",!1),sd(QT(n),"_interruptMicCapture",!1),sd(QT(n),"_avSync",!0),sd(QT(n),"_config",void 0),sd(QT(n),"_needClosePreTrack",!1),sd(QT(n),"_updateMixAudioTrack",function(){var e=Em(Sm().mark((function e(t){var r,i,o=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.length>1&&void 0!==o[1]?o[1]:jd.PLAYOUT_AND_PUBLISH,MH.print("_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)}}()),sd(QT(n),"_onAudioMixingMessage",(function(e){n.safeEmit(Hd.onAudioMixingStateChanged,e)})),sd(QT(n),"_onAudioMixingAutoplayFailed",(function(e){n.safeEmit(Hd.onAutoplayFailed,e)})),n.id=t,n._appId=e,n._pubLock=new wV("pubLock"),n._addDeviceEventHandler(),n._extensionManager=new sU(t),n._audioDeviceManager=new yH(n._extensionManager),n._audioMixingManager=new vH({getLocalAudioTrack:function(){return n._localAudioTrack},updateLocalAudioTrack:n._updateMixAudioTrack,emitMessage:n._onAudioMixingMessage,onAutoPlayFailed:n._onAudioMixingAutoplayFailed},t),n._audioProfileManager=new SH(e),window.__rtc_engine__=QT(n),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=QT(n),n._trackSourceType={video:dd.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:dd.VIDEO_SOURCE_TYPE_INTERNAL,audio:ld.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:ld.AUDIO_SOURCE_TYPE_INTERNAL},n._config=r,n._rtmClient=new _H(t,e),n._handleRTMClient(n._rtmClient),n._useCloudProxy=!1,n._handleAudioDeviceManager(),n._messageStatisticsObserver=new cP(t),n.monitor=mP(t),uP.createRTSMsgReportor(n.id),n._getServerConfig(),n}return Kd(me,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(fe=Em(Sm().mark((function e(t){var r,n,i,o,a;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("updateToken()","token: %s",t),VO(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 cR(sR.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 fe.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(pe=Em(Sm().mark((function e(t){var r,n,i,o=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("setVideoCaptureDevice()","deviceId: %s",t),VO(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:return r=FB({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete r.deviceId,r.facingMode=t):r.deviceId={exact:t},QP&&eO&&eO>=85&&eO<=91&&(null===(n=this._videoPlayer)||void 0===n||n.removeTrack()),this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),delete this._localVideoTrack),MH.print("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=12,xU(r,this._extensionManager).catch((function(e){if(o._localVideoTrack&&!o._localVideoTrack.dummy)return MH.print("setVideoCaptureDevice()","createCameraVideoTrack failed, stop pre VideoTrack."),o._removeLocalTrackEvents(o._localVideoTrack),o._localVideoTrack.close(),delete o._localVideoTrack,xU(r,o._extensionManager).then((function(e){return o._needClosePreTrack=!0,e})).catch(Em(Sm().mark((function t(){var r;return Sm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return MH.print("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,xU(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 12:return i=e.sent,MH.print("setVideoCaptureDevice()","createCameraVideoTrack success."),this._videoStreamConstraints=r,this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),e.next=18,this._switchTrack(i);case 18:case"end":return e.stop()}}),e,this)}))),function(e){return pe.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(ve=Em(Sm().mark((function e(t){var r,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("setAudioCaptureDevice()","deviceId: %s",t),VO(t,"deviceId"),this._localAudioDeviceId=t,this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return this._audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._localAudioTrack.close(),this._removeLocalTrackEvents(this._localAudioTrack),e.prev=8,this._micCapturing=!0,e.next=12,OU(this._audioProfileManager.getConstraints(),this._extensionManager);case 12:if(n=e.sent,!this._interruptMicCapture){e.next=17;break}return this._interruptMicCapture=!1,n.close(),e.abrupt("return");case 17:if(this._initLocalTrackEvents(n),this._localAudioTrack=n,this._localAudioTrack.setVolume(this._localAudioVolume),this._room){e.next=22;break}return e.abrupt("return");case 22:if(null===(r=this._room)||void 0===r||!r.hasPublished){e.next=25;break}return e.next=25,this._updatePublish();case 25:return e.prev=25,this._micCapturing=!1,e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[8,,25,28]])}))),function(e){return ve.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){tU.on(Hd.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),tU.on(Hd.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A,R,w,C,x,P=this;null===(e=this._room)||void 0===e||e.on(bD.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(bD.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(bD.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(CV.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(CV.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(CV.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(bD.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(bD.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(bD.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(bD.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(d=this._room)||void 0===d||d.on(bD.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(kD.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(h=this._room)||void 0===h||h.on(CV.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(v=this._room)||void 0===v||v.on(CV.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(p=this._room)||void 0===p||p.on(CV.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(f=this._room)||void 0===f||f.on(CV.ON_PUBLISH_RESULT,(function(e){var t;null!==(t=P._room)&&void 0!==t&&t._roomConfig.isAutoPublish&&P.safeEmit(Hd.onAutoPublishResult,e)})),null===(_=this._room)||void 0===_||_.on(CV.ON_REMOTE_STREAM_STATS,(function(e){P.safeEmit(Hd.onRemoteStreamStats,e)})),null===(m=this._room)||void 0===m||m.on(CV.ON_LOCAL_STREAM_STATS,(function(e){P.safeEmit(Hd.onLocalStreamStats,e)})),null===(g=this._room)||void 0===g||g.on(CV.ON_SUBTITLE_STATE_CHANGED,(function(e){P.safeEmit(Hd.onSubtitleStateChanged,e)})),null===(y=this._room)||void 0===y||y.on(CV.ON_SUBTITLE_MESSAGE_RECEIVED,(function(e){P.safeEmit(Hd.onSubtitleMessageReceived,e)})),null===(S=this._room)||void 0===S||S.on(CV.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(b=this._room)||void 0===b||b.on(CV.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;P._updateAudioPlayerState(t),P.safeEmit(Hd.onUserStartAudioCapture,{userId:r})})),null===(E=this._room)||void 0===E||E.on(CV.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(Hd.onUserStopAudioCapture,{userId:t})})),null===(k=this._room)||void 0===k||k.on(CV.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(Hd.onUserStartVideoCapture,{userId:t})})),null===(T=this._room)||void 0===T||T.on(CV.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(Hd.onUserStopVideoCapture,{userId:t})})),null===(I=this._room)||void 0===I||I.on(CV.ON_SEI_MESSAGED_RECEIVED,(function(e){P.safeEmit(Hd.onSEIMessageReceived,e)})),null===(A=this._room)||void 0===A||A.on(CV.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){P.safeEmit(Hd.onRemoteVideoSizeChanged,e,t)})),null===(R=this._room)||void 0===R||R.on(CV.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return P.safeEmit(Hd.onSimulcastSubscribeFallback,e)})),null===(w=this._room)||void 0===w||w.on(CV.RECONNECT_FAILED,(function(){P.safeEmit(Hd.onError,{errorCode:sR.RECONNECT_FAILED})})),null===(C=this._room)||void 0===C||C.on(CV.ON_VIDEO_STREAM_BANNED,(function(e){P.safeEmit(Hd.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(x=this._room)||void 0===x||x.on(CV.ON_AUDIO_STREAM_BANNED,(function(e){P.safeEmit(Hd.onAudioStreamBanned,{uid:e.uid,banned:e.banned})}))}},{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 $O(e)&&yP(this.id,e,i),(t=AI(TI(me.prototype),"safeEmit",this)).call.apply(t,Rm(r=[this,e]).call(r,i))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(he=Em(Sm().mark((function e(){return Sm().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 sF({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:Od.communication},{id:this.id,audioProfileManager:this._audioProfileManager,streamRTT:{},subscribeFallbackOption:this._subscribeFallbackOption,userPriority:this._userPriorityMap,avSync:this._avSync}),this._addHandlerEventHandler(),e.next=6,this._room.connect(this._appId);case 6:case"end":return e.stop()}}),e,this)}))),function(){return he.apply(this,arguments)})},{key:"joinRoom",value:(le=Em(Sm().mark((function e(t,r,n,i){var o,a,s,u,c,d,l;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("joinRoom()","token: %o roomId: %o, userInfo: %o, roomConfig: %o",t,r,n,i),XO(t)||VO(t,"token"),KO(r),WO(n),QO(i=FB({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:Od.communication},i)),(null===(o=this._room)||void 0===o?void 0:o.connectionState)!==FV.CONNECTED){e.next=8;break}throw new cR(sR.REPEAT_JOIN,"Already joined");case 8:return this._room||(this._room=new sF(i,{id:this.id,audioProfileManager:this._audioProfileManager,streamRTT:{},subscribeFallbackOption:this._subscribeFallbackOption,userPriority:this._userPriorityMap,avSync:this._avSync}),this._addHandlerEventHandler()),this._room.roomConfig=i,a=this._liveTranscodeConfig&&xH.getStartParams(this._liveTranscodeConfig),s=cd(cd({},n),{},{businessId:this._businessId,role:this._visibility?pH.NORMAL_USER:pH.SILENT_USER}),e.prev=12,this._useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),tF(s),e.next=17,this._room.join(this._appId,r,t,s,a,this._useCloudProxy,null===(u=this._config)||void 0===u?void 0:u.expectedIDC);case 17:return d=e.sent,this._roomConfig=i,this._audioProfileManager.setRoomId(r),this._tempRoomInfo&&delete this._tempRoomInfo,null!==(c=i)&&void 0!==c&&c.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:Sd.AUDIO_AND_VIDEO}):this.safeEmit(Hd.onAutoPublishResult,{isScreen:!1,state:_d.PUBLISH_FAIL})),uP.setRoomId(this.id,r),uP.setUserId(this.id,n.userId),e.abrupt("return",d);case 27:throw e.prev=27,e.t0=e.catch(12),e.t0.code===sR.INVALID_TOKEN&&(this._tempRoomInfo={config:i,roomId:r,userInfo:s}),null===(l=this._room)||void 0===l||l.destroy(),e.t0;case 32:case"end":return e.stop()}}),e,this,[[12,27]])}))),function(e,t,r,n){return le.apply(this,arguments)})},{key:"leaveRoom",value:(de=Em(Sm().mark((function e(){var t,r,n,i=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],MH.print("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._audioProfileManager.setRoomId(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new FS,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new FS,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new FS,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new FS,this._roomConfig=void 0,this._publicStreamIds=new FS,uP.setRoomId(this.id,""),uP.setUserId(this.id,"");case 24:case"end":return e.stop()}}),e,this)}))),function(){return de.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;MH.print("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=[MO],this._screenStreamEncodeConfig=[NO],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeStreamIds:{}},this._messageStatisticsObserver.destroy(),this.monitor.destroy(),uP.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 FS,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new FS,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new FS,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new FS,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new FS,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new FS,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._publicStreamManager)||void 0===r||r.destroy(),this._publicStreamIds=new FS,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new FS,this._userPriorityMap.clear(),this._extensionManager.destroy(),this._cameraCapturing=!1,this._micCapturing=!1,this._interruptCameraCapture=!1,this._interruptMicCapture=!1,this._avSync=!0,this._localAudioVolume=100,this._localScreenAudioVolume=100,this._remoteAudioVolume.clear(),this._remoteScreenAudioVolume.clear(),this._publicAudioVolume.clear()}},{key:"publishStream",value:(ce=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!dO(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,AU(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 ce.apply(this,arguments)})},{key:"unpublishStream",value:(ue=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("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:PV.UNPUB});case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return ue.apply(this,arguments)})},{key:"publishScreen",value:(se=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("publishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.prev=3,!dO(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,wU(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:PV.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof cR)){e.next=18;break}throw e.t0;case 18:throw new cR(sR.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return se.apply(this,arguments)})},{key:"unpublishScreen",value:(ae=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MH.print("unpublishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.next=5,this._updateScreenPublish({mediaType:t,pubState:PV.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return ae.apply(this,arguments)})},{key:"subscribeStream",value:(oe=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MH.print("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 oe.apply(this,arguments)})},{key:"_subscribe",value:(ie=Em(Sm().mark((function e(t,r,n){var i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._checkMediaType(n),this._assertNotInRoom(),n!==Sd.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){e.next=5;break}return MH.print("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 5:if(c=this._room.remoteStreams.get(r),d=null==c?void 0:oE(c).call(c,(function(e){return e.isScreen===t}))){e.next=9;break}throw new cR(sR.STREAM_NOT_EXIST,"stream not exist");case 9:return l=this._pauseAllSubscribeState.audio,h=this._pauseAllSubscribeState.video,this._pauseAllSubscribeState.audio&&(n-=n&Sd.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&Sd.VIDEO),MH.print("subscribeStream()","due to pauseAll mediaType: %o",n),v=d.hasSubscribed,p=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,p);case 19:cO(n)&&this._updateAudioPlayerState(d),dO(n)&&this._updateVideoPlayerState(d),f=0,_=0,l!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?f|=Sd.AUDIO:_|=Sd.AUDIO),h!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?f|=Sd.VIDEO:_|=Sd.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:fd.SUBSCRIBE_SUCC},this.safeEmit(Hd.onAutoSubscribeResult,m)),null!==(u=this._room)&&void 0!==u&&u.multiChatMode||v||!cO(n)||!d.hasAudio||null===(g=d.observer)||void 0===g||g.setSubscribeAudio(!0),!v&&dO(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 ie.apply(this,arguments)})},{key:"unsubscribeStream",value:(ne=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:MH.print("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 ne.apply(this,arguments)})},{key:"subscribeScreen",value:(re=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MH.print("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 re.apply(this,arguments)})},{key:"unsubscribeScreen",value:(te=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:MH.print("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 te.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(this._checkMediaType(r),this._assertNotInRoom(),r!==Sd.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){var a=this._room.remoteStreams.get(t),s=null==a?void 0:oE(a).call(a,(function(t){return t.isScreen===e}));if(null==s||!s.hasSubscribed)throw new cR(sR.STREAM_NOT_EXIST,"stream not exist");if(QP&&eO&&eO>=85&&eO<=91&&r!==Sd.AUDIO)(e?this._remoteScreenPlayer.get(t):this._remoteVideoPlayer.get(t)).stop();return this._room.unsubscribe(s,r).then((function(){n||delete o._pauseAllSubscribeState.resumeStreamIds[s.streamId]}))}MH.print("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(ee=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MH.print("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),qO(t),eD(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 ee.apply(this,arguments)})},{key:"startVideoCapture",value:($=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("startVideoCapture()","deviceId: %s",t),XO(t)||VO(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,this._trackSourceType.video!==dd.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new cR(sR.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(!(this._cameraCapturing||this._localVideoTrack&&!this._localVideoTrack.dummy)){e.next=8;break}throw new cR(sR.REPEAT_CAPTURE,"Has already capture");case 8:return i=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?i.facingMode=t:i.deviceId={exact:t},this._videoStreamConstraints=i),o={},e.prev=11,this._cameraCapturing=!0,e.next=15,xU(i,this._extensionManager);case 15:if(s=e.sent,!this._interruptCameraCapture){e.next=21;break}throw this._interruptCameraCapture=!1,this._removeLocalTrackEvents(s),s.close(),new cR(sR.INTERRUPT,"interrupt by stopVideoCapture");case 21:if(this._initLocalTrackEvents(s),this._localVideoTrack=s,null===(a=this._videoPlayer)||void 0===a||a.playVideo(s),(u=null==s?void 0:s.getTrack())&&(o=u.getSettings(),c={width:o.width,height:o.height},this._localVideoTrack.resolution=c,setTimeout((function(){return l.safeEmit(Hd.onLocalVideoSizeChanged,{streamIndex:yd.STREAM_INDEX_MAIN,info:c})}))),this._room){e.next=28;break}return e.abrupt("return",o);case 28:return e.prev=28,this._cameraCapturing=!1,e.finish(28);case 31:return d=this._room._roomConfig.isAutoPublish,(this._room.hasPublished||d)&&(this._visibility?this._updatePublish():this.safeEmit(Hd.onAutoPublishResult,{isScreen:!1,state:_d.PUBLISH_FAIL})),null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableVideo(!0),e.abrupt("return",o);case 35:case"end":return e.stop()}}),e,this,[[11,,28,31]])}))),function(e){return $.apply(this,arguments)})},{key:"stopVideoCapture",value:(Z=Em(Sm().mark((function e(){var t,r,n,i,o,a,s;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("stopVideoCapture()"),!this._cameraCapturing){e.next=5;break}return this._interruptCameraCapture=!0,MH.print("stopVideoCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.video!==dd.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new cR(sR.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||((a=this._extensionManager.getPluginByName(aU.PRE_PROCESSING,"RTCBeautyExtension"))&&a.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localImgVideoTrack?(null===(s=this._localVideoTrack)||void 0===s||s.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||!r.hasPublished){e.next=14;break}return e.next=14,this._updatePublish();case 14:null===(n=this._room)||void 0===n||null===(i=n.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableVideo(!1);case 15:case"end":return e.stop()}}),e,this)}))),function(){return Z.apply(this,arguments)})},{key:"startAudioCapture",value:(J=Em(Sm().mark((function e(t){var r,n,i,o;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("startAudioCapture()","deviceId: $o",t),XO(t)||VO(t,"deviceId"),t=t||this._localAudioDeviceId,this._localAudioDeviceId=t,this._trackSourceType.audio!==ld.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new cR(sR.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 6:if(!this._micCapturing&&!this._localAudioTrack){e.next=8;break}throw new cR(sR.REPEAT_CAPTURE,"Has already capture");case 8:return t&&this._audioProfileManager.updateConstraints({deviceId:{exact:t}}),e.prev=9,this._micCapturing=!0,e.next=13,OU(this._audioProfileManager.getConstraints(),this._extensionManager);case 13:if(i=e.sent,!this._interruptMicCapture){e.next=19;break}throw this._interruptMicCapture=!1,this._removeLocalTrackEvents(i),i.close(),new cR(sR.INTERRUPT,"interrupt by stopAudioCapture");case 19:if(this._initLocalTrackEvents(i),this._localAudioTrack=i,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),this._room){e.next=25;break}return e.abrupt("return");case 25:return e.prev=25,this._micCapturing=!1,e.finish(25);case 28:o=this._room._roomConfig.isAutoPublish,(this._room.hasPublished||o)&&(this._visibility?this._updatePublish():this.safeEmit(Hd.onAutoPublishResult,{isScreen:!1,state:_d.PUBLISH_FAIL})),null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableAudio(!0);case 31:case"end":return e.stop()}}),e,this,[[9,,25,28]])}))),function(e){return J.apply(this,arguments)})},{key:"stopAudioCapture",value:(Q=Em(Sm().mark((function e(){var t,r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("stopAudioCapture()"),!this._micCapturing){e.next=5;break}return this._interruptMicCapture=!0,MH.print("stopAudioCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.audio!==ld.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new cR(sR.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(!this._room.hasPublished){e.next=15;break}return e.next=15,this._updatePublish();case 15:null===(t=this._room.localStream)||void 0===t||null===(r=t.observer)||void 0===r||r.setEnableAudio(!1);case 16:case"end":return e.stop()}}),e,this)}))),function(){return Q.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return MH.print("getAudioMixingManager()","invoke"),this._audioMixingManager}},{key:"startScreenCapture",value:(W=Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u,c,d,l,h,v,p=this,f=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=f.length>0&&void 0!==f[0]?f[0]:{},MH.print("startScreenCapture()","config: %o",o),a=o.enableAudio,s=void 0!==a&&a,this._trackSourceType.screenVideo!==dd.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new cR(sR.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 5:if(this._trackSourceType.screenAudio!==ld.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new cR(sR.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:return e.next=9,MU(s,this._extensionManager,this._screenStreamEncodeConfig[0]);case 9:if(u=e.sent,c=WT(u,2),d=c[0],null==(l=c[1])||l.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=d,null!==(r=this._screenStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&d.setContentHint(null===(h=this._screenStreamEncodeConfig[0])||void 0===h?void 0:h.contentHint),(v=null==d?void 0:d.getTrack())&&setTimeout((function(){var e=v.getSettings(),t={width:e.width,height:e.height};d.resolution=t,p.safeEmit(Hd.onLocalVideoSizeChanged,{streamIndex:yd.STREAM_INDEX_SCREEN,info:{width:e.width,height:e.height}})}),500),l&&(this._localScreenAudioTrack=l,this._initLocalTrackEvents(l)),null===(n=this._screenPlayer)||void 0===n||n.playVideo(this._localScreenVideoTrack),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(i=this._room)||void 0===i||!i.hasScreenPublished){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(){return W.apply(this,arguments)})},{key:"stopScreenCapture",value:(Y=Em(Sm().mark((function e(){var t,r,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("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===(n=this._localScreenVideoTrack)||void 0===n||n.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||!r.hasScreenPublished){e.next=8;break}return e.next=8,this._updateScreenPublish();case 8:case"end":return e.stop()}}),e,this)}))),function(){return Y.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){if(MH.print("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),FO(e,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),t&&t.renderDom){var r,n,i,o,a=cd(cd({userId:this._getUserId()},t),{},{isLocal:!0});if(JO(a),e===yd.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new pF(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)!==Md.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===yd.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new pF(this.id,cd(cd({},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)!==Md.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}else{var s,u;e===yd.STREAM_INDEX_MAIN?(null===(s=this._videoPlayer)||void 0===s||s.destroy(!0),delete this._videoPlayer):(null===(u=this._screenPlayer)||void 0===u||u.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:(q=Em(Sm().mark((function e(t){var r,n,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("startLiveTranscoding()","transcode: %o",t),xH.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 cR(sR.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(Hd.onStreamMixingEvent,{event:xV.START,error:0,message:""}),!this._room||this._room.connectionState!==FV.CONNECTED){e.next=11;break}return e.next=11,null===(i=this._room)||void 0===i?void 0:i.liveControlMessage(xH.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof cR)){e.next=19;break}throw e.t0;case 19:throw new cR(sR.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return q.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(K=Em(Sm().mark((function e(t){var r,n,i,o;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("updateLiveTranscoding()","transcode: %o",t),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete(i=FB({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,xH.checckUpdateParams(i),this._liveTranscodeConfig=FB(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(Hd.onStreamMixingEvent,{event:xV.UPDATE,error:0,message:""}),e.next=13,null===(o=this._room)||void 0===o?void 0:o.liveControlMessage(xH.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(e.t0 instanceof cR)){e.next=21;break}throw e.t0;case 21:throw new cR(sR.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return K.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(X=Em(Sm().mark((function e(){var t;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("stopLiveTranscoding()"),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete this._liveTranscodeConfig,e.prev=4,this.safeEmit(Hd.onStreamMixingEvent,{event:xV.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 cR)){e.next=16;break}throw e.t0;case 16:throw new cR(sR.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return X.apply(this,arguments)})},{key:"startSubtitle",value:(H=Em(Sm().mark((function e(t){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MH.print("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 H.apply(this,arguments)})},{key:"stopSubtitle",value:function(){var e;MH.print("stopSubtitle()","invoke"),null===(e=this._room)||void 0===e||e.stopSubtitle()}},{key:"setBusinessId",value:function(e){return MH.print("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:(z=Em(Sm().mark((function e(t){var r,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("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?pH.NORMAL_USER:pH.SILENT_USER});case 15:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:Sd.AUDIO_AND_VIDEO});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return z.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]:yd.STREAM_INDEX_MAIN,i=n===yd.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",""),u=null===(o=t._room)||void 0===o||null===(a=o.remoteStreams.get(s))||void 0===a?void 0:oE(a).call(a,(function(e){return e.isScreen===i})),c=function(){r?t.safeEmit(Hd.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:s}):(t.safeEmit(Hd.onAudioFirstFrameDecoded,{userId:s,isScreen:i}),t.safeEmit(Hd.onRemoteAudioFirstFrame,{userId:s,isScreen:i})),t.monitor.report("first_remote_audio_render",{stream_id:"",stream_user_id:s||""},{isScreen:i})};u&&u.observer&&!u.observer.audioFirstFrameReceived?u.observer.once("recvAudioFirstFrame",c):c()}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(Hd.onFirstPublicStreamVideoFrameRendered,h),t.safeEmit(Hd.onFirstPublicStreamVideoFrameDecoded,h)):e.isLocal||(t.safeEmit(Hd.onVideoFirstFrameRendered,h),t.safeEmit(Hd.onVideoFirstFrameDecoded,h),t.safeEmit(Hd.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),SP(t.id,"autoplay-error",e instanceof pF?"video":"audio",0,n.userId||""),void t.safeEmit(Hd.onAutoplayFailed,{userId:n.userId,kind:e instanceof pF?"video":"audio",mediaType:e instanceof pF?Sd.VIDEO:Sd.AUDIO,streamIndex:e.isScreen?yd.STREAM_INDEX_SCREEN:yd.STREAM_INDEX_MAIN})}t.safeEmit(Hd.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=Em(Sm().mark((function e(n){var i,o;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.monitor.report("rtc_error",{message:Rm(i="track-".concat(r," mediaType: ")).call(i,n.getTrack().kind),error_code:-1001}),o=!1,n!==t._localScreenAudioTrack&&n!==t._localScreenVideoTrack||(o=!0),t.safeEmit({"track-ended":Hd.onTrackEnded,"track-mute":Hd.onTrackMute,"track-unmute":Hd.onTrackUnmute}[r],{kind:n.getTrack().kind,isScreen:o});case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())})),e.on("resolution-change",(function(e){t._extensionManager.getPluginsByType(aU.PRE_PROCESSING).forEach((function(t){var r;null==t||null===(r=t.applyConstraints)||void 0===r||r.call(t,e)})),t.safeEmit(Hd.onLocalVideoSizeChanged,{streamIndex:r?yd.STREAM_INDEX_SCREEN:yd.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){MH.print("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),FO(e,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),JO(t);var r,n,i,o=t.userId;if(e===yd.STREAM_INDEX_MAIN){var a,s,u;if(null===(a=this._remoteVideoPlayer.get(o))||void 0===a||a.destroy(),!t.renderDom)return;var c=new pF(this.id,t);this._initPlayerEvents(c,!1,e),this._remoteVideoPlayer.set(o,c);var d=null===(s=this._room)||void 0===s||null===(u=s.remoteStreams.get(o))||void 0===u?void 0:oE(u).call(u,(function(e){return!e.isScreen}));return d&&(this._updateVideoPlayerState(d),d.videoDom=c.domElement),c.domElement}if(null===(r=this._remoteScreenPlayer.get(o))||void 0===r||r.destroy(),t.renderDom){var l=new pF(this.id,cd(cd({},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:oE(i).call(i,(function(e){return e.isScreen}));return h&&(this._updateVideoPlayerState(h),h.videoDom=l.domElement),l.domElement}}},{key:"setLocalVideoMirrorType",value:function(e){MH.print("setLocalVideoMirrorType()","mirrorType: %o",e),FO(e,"mirrorType",[kd.MIRROR_TYPE_NONE,kd.MIRROR_TYPE_RENDER]),this._mirrorType=e,this._videoPlayer&&this._videoPlayer.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(G=Em(Sm().mark((function e(t){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MH.print("setAudioPlaybackDevice()","deviceId: %s",t),VO(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(Hd.onAudioPlaybackDeviceChanged,r),this.monitor.report("rtc_audio_device",{audio_event:"playout_device_switch",message:ZE(r),error_code:0});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return G.apply(this,arguments)})},{key:"play",value:(j=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=g.length>1&&void 0!==g[1]?g[1]:Sd.AUDIO_AND_VIDEO,a=g.length>2?g[2]:void 0,MH.print("play()","userId: %s, mediaType: %s, streamIndex: %s",t,o,a),s=!t||t===this._getUserId()||"local_user"===t,u=void 0===a||a===yd.STREAM_INDEX_MAIN,c=void 0===a||a===yd.STREAM_INDEX_SCREEN,d=o!==Sd.VIDEO,l=o!==Sd.AUDIO,h=[],s&&l&&(u&&this._localVideoTrack&&(null===(v=this._videoPlayer)||void 0===v||v.mirror(!!this._mirrorType),h.push(null===(p=this._videoPlayer)||void 0===p?void 0:p.playVideo(this._localVideoTrack))),c&&this._localScreenVideoTrack&&h.push(null===(f=this._screenPlayer)||void 0===f?void 0:f.playVideo(this._localScreenVideoTrack))),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&&u&&h.push(_F(this._remoteVideoPlayer,t,!1,_)),l&&c&&h.push(_F(this._remoteScreenPlayer,t,!0,_)),d&&u&&h.push(_F(this._remoteAudioPlayer,t,!1,_)),l&&c&&h.push(_F(this._remoteScreenAudioPlayer,t,!0,_)),m=null===(i=this._publicStreamManager)||void 0===i?void 0:i.remoteStreams,d&&h.push(_F(this._publicStreamVideoPlayer,t,!1,m)),l&&h.push(_F(this._publicStreamAudioPlayer,t,!1,m)),e.abrupt("return",X_.all(h).then((function(){})));case 20:case"end":return e.stop()}}),e,this)}))),function(e){return j.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(B=Em(Sm().mark((function e(t){var r,n,i,o,a,s=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),cO(t)&&(s._pauseAllSubscribeState.audio=!0),dO(t)&&(s._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",X_.resolve());case 6:n=[],i=YT($I(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(u){i.e(u)}finally{i.f()}return e.abrupt("return",X_.all(n).then((function(){})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return B.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(F=Em(Sm().mark((function e(t){var r,n,i,o,a,s=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),cO(t)&&(s._pauseAllSubscribeState.audio=!1),dO(t)&&(s._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",X_.resolve());case 6:n=[],i=YT($I(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(u){i.e(u)}finally{i.f()}return e.abrupt("return",X_.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 F.apply(this,arguments)})},{key:"sendUserMessage",value:(V=Em(Sm().mark((function e(t,r){var n,i,o,a=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qO(t),ZO(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 V.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(U=Em(Sm().mark((function e(t,r){var n,i,o,a=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qO(t),GO(r,"message"),ZO(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 U.apply(this,arguments)})},{key:"sendRoomMessage",value:(L=Em(Sm().mark((function e(t){var r,n,i,o=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ZO(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 L.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(N=Em(Sm().mark((function e(t){var r,n,i,o=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ZO(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 N.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(M=Em(Sm().mark((function e(){var t,r=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.length>0&&void 0!==r[0]?r[0]:{},MH.print("setAudioCaptureConfig()","config: %o",t),delete t.deviceId,zO(t),this._shouldUpdateAudioConf("setAudioCaptureConfig")&&this._audioProfileManager.updateConstraints(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return M.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(D=Em(Sm().mark((function e(){var t,r=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},MH.print("setVideoCaptureConfig()","config: %o",t),e.abrupt("return",this._setVideoCaptureConfig(t));case 3:case"end":return e.stop()}}),e,this)}))),function(){return D.apply(this,arguments)})},{key:"_setVideoCaptureConfig",value:(O=Em(Sm().mark((function e(){var t,r,n,i=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(delete(r=i.length>0&&void 0!==i[0]?i[0]:{}).deviceId,zO(r),n=cd(cd({},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 O.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){var t;return MH.print("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,14!==(null==tO?void 0:tO[0])&&(null!==(t=this._room)&&void 0!==t&&t.hasPublished&&_O("You must call this API before publishing the video streams"),!0)}},{key:"setVideoEncoderConfig",value:(P=Em(Sm().mark((function e(t){var r,n,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(MH.print("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),rD(t=Gs(t).call(t,(function(e){return!!e}))),t.length>3&&(_O("setVideoEncoderConfig: You can set parameters for up to 3 streams"),t=ym(t).call(t,0,3)),n=1;n<t.length;n++)i=mO(t[0].width)/mO(t[n].width)||1,Math.floor(i)!==i&&_O("setVideoEncoderConfig: The resolution setting needs to be an integer multiple");LA(t).call(t,(function(e,t){return t.maxKbps-e.maxKbps})),this._setVideoCaptureConfig(cd({},t[0])),this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(yd.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 P.apply(this,arguments)})},{key:"setScreenEncoderConfig",value:(x=Em(Sm().mark((function e(t){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:MH.print("setScreenEncoderConfig()","description: %o",t),this._screenStreamEncodeConfig=[t],this._localScreenVideoTrack&&(this._localScreenVideoTrack.updateVideoCaptureConfig(t),t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint)),this._updateDummyCaptureImage(yd.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 x.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(MH.print("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!UN())throw new cR(sR.NOT_SUPPORTED,"Browser does not support sending SEI");FO(e,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),UO(r,"repeatCount",0,30);var n="string"==typeof t?new Uint8Array(UP.str2ab(t)):t;if(t.length){var i;if(e===yd.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 u,c,d;if(null===(u=this._room)||void 0===u||null===(c=u.localScreenStream)||void 0===c||!c.hasPublished)return;i=null===(d=this._room)||void 0===d?void 0:d.localScreenStream}if(n.byteLength>4096)MH.print("sei size must not bigger than 4KB");else{var l=DP();i.seiList.push({content:n,uuid:l,repeatCount:r}),setTimeout((function(){var e;if(i){var t,r=XA(e=i.seiList).call(e,(function(e){return e.uuid===l}));if(r)GE(t=i.seiList).call(t,r,1)}}),2e3)}}else MH.print("sei message must not be empty")}},{key:"setAudioVolumeIndicationInterval",value:function(e){var t=this;MH.print("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=oE(e).call(e,(function(e){return!1===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(Hd.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n=e[0],i=$S(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(Hd.onActiveSpeaker,{userId:o.userId,extraInfo:o.extraInfo})}}}},{key:"enableAudioPropertiesReport",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};MH.print("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:yd.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:i,nonlinearVolume:uO(i)}})}if(e._localScreenAudioTrack){var o=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:yd.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:o,nonlinearVolume:uO(o)}})}if(e.safeEmit(Hd.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:yd.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:uO(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?yd.STREAM_INDEX_SCREEN:yd.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:uO(o)}})}}))}));e.safeEmit(Hd.onRemoteAudioPropertiesReport,s),e._sendActiveSpeaker(t,Gs(s).call(s,(function(e){return e.streamKey.streamIndex!==yd.STREAM_INDEX_SCREEN})))}}}),o))}},{key:"setVideoSourceType",value:(C=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),FO(t,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),FO(r,"VideoSourceType",[dd.VIDEO_SOURCE_TYPE_EXTERNAL,dd.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===yd.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,MH.print("setVideoSourceType",Rm(i="set ".concat(n," source type to ")).call(i,r)),!this._localVideoTrack||t!==yd.STREAM_INDEX_MAIN){e.next=17;break}if(u=!1,r===dd.VIDEO_SOURCE_TYPE_EXTERNAL&&(u=!0,(c=this._extensionManager.getPluginByName(aU.PRE_PROCESSING,"RTCBeautyExtension"))&&c.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null===(o=this._videoPlayer)||void 0===o||o.stop(),this._localVideoTrack=void 0,d=null===(a=this._room)||void 0===a?void 0:a._roomConfig.isAutoPublish,u?null===(l=this._room)||void 0===l||null===(h=l.localStream)||void 0===h||null===(v=h.observer)||void 0===v||v.setEnableVideo(!1):null===(p=this._room)||void 0===p||null===(f=p.localStream)||void 0===f||null===(_=f.observer)||void 0===_||_.setPushVideo(!1),!(null!==(s=this._room)&&void 0!==s&&s.hasPublished||d)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(!this._localScreenVideoTrack||t!==yd.STREAM_INDEX_SCREEN){e.next=26;break}if(y=!1,r===dd.VIDEO_SOURCE_TYPE_EXTERNAL&&(y=!0,this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(m=this._screenPlayer)||void 0===m||m.stop(),this._localScreenVideoTrack=void 0,y?null===(S=this._room)||void 0===S||null===(b=S.localScreenStream)||void 0===b||null===(E=b.observer)||void 0===E||E.setEnableVideo(!1):null===(k=this._room)||void 0===k||null===(T=k.localScreenStream)||void 0===T||null===(I=T.observer)||void 0===I||I.setPushVideo(!1),null===(g=this._room)||void 0===g||!g.hasScreenPublished){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return C.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(w=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("setExternalVideoTrack()","index: %o, track: %o",t,r),FO(t,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),BO(r),t!==yd.STREAM_INDEX_MAIN){e.next=15;break}if(this._trackSourceType.video===dd.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new cR(sR.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,UU(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),a=null===(i=this._room)||void 0===i?void 0:i._roomConfig.isAutoPublish,!(null!==(o=this._room)&&void 0!==o&&o.hasPublished||a)){e.next=15;break}return e.next=15,this._updatePublish();case 15:if(t!==yd.STREAM_INDEX_SCREEN){e.next=27;break}if(this._trackSourceType.screenVideo===dd.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=18;break}throw new cR(sR.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 18:return e.next=20,jU(r,this._extensionManager);case 20:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(s=this._screenPlayer)||void 0===s||s.playVideo(this._localScreenVideoTrack),null===(u=this._room)||void 0===u||null===(c=u.localScreenStream)||void 0===c||null===(d=c.observer)||void 0===d||d.setPushVideo(!0),null===(l=this._room)||void 0===l||!l.hasScreenPublished){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(e,t){return w.apply(this,arguments)})},{key:"setAudioSourceType",value:(R=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),FO(t,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),FO(r,"audioSourceType",[ld.AUDIO_SOURCE_TYPE_EXTERNAL,ld.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===yd.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,MH.print("setVideoSourceType",Rm(i="set ".concat(n," source type to ")).call(i,r)),!this._localAudioTrack||t!==yd.STREAM_INDEX_MAIN){e.next=16;break}if(s=!1,this._trackSourceType.audio===ld.AUDIO_SOURCE_TYPE_EXTERNAL&&(s=!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,s?null===(c=this._room)||void 0===c||null===(d=c.localStream)||void 0===d||null===(l=d.observer)||void 0===l||l.setEnableAudio(!1):null===(h=this._room)||void 0===h||null===(v=h.localStream)||void 0===v||null===(p=v.observer)||void 0===p||p.setPushAudio(!1),!(null!==(a=this._room)&&void 0!==a&&a.hasPublished||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(!this._localScreenAudioTrack||t!==yd.STREAM_INDEX_SCREEN){e.next=24;break}if(_=!1,this._trackSourceType.audio===ld.AUDIO_SOURCE_TYPE_EXTERNAL&&(_=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,_?null===(m=this._room)||void 0===m||null===(g=m.localScreenStream)||void 0===g||null===(y=g.observer)||void 0===y||y.setEnableAudio(!1):null===(S=this._room)||void 0===S||null===(b=S.localScreenStream)||void 0===b||null===(E=b.observer)||void 0===E||E.setPushAudio(!1),null===(f=this._room)||void 0===f||!f.hasScreenPublished){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(A=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("setExternalAudioTrack()","index: %o, track: %o",t,r),FO(t,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),BO(r),t!==yd.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.audio===ld.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new cR(sR.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,FU(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&&s.hasPublished||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(t!==yd.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenAudio===ld.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new cR(sR.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 19:return e.next=21,zU(r,this._extensionManager);case 21:if(this._localScreenAudioTrack=e.sent,this._localScreenAudioTrack.setVolume(this._localScreenAudioVolume),this._initLocalTrackEvents(this._localScreenAudioTrack),null===(c=this._room)||void 0===c||null===(d=c.localScreenStream)||void 0===d||null===(l=d.observer)||void 0===l||l.setPushAudio(!0),null===(h=this._room)||void 0===h||!h.hasScreenPublished){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return A.apply(this,arguments)})},{key:"login",value:(I=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MH.print("login()","token: %o, userInfo: %o",t,r),XO(t)||VO(t,"token"),qO(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return I.apply(this,arguments)})},{key:"logout",value:(T=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MH.print("logout()"),e.abrupt("return",this._rtmClient.logout());case 2:case"end":return e.stop()}}),e,this)}))),function(){return T.apply(this,arguments)})},{key:"updateLoginToken",value:(k=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MH.print("updateLoginToken()","token: %o",t),XO(t)||VO(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(E=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MH.print("getPeerOnlineStatus()","userId: %o",t),qO(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(b=Em(Sm().mark((function e(t,r){var n,i=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qO(t),ZO(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 b.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(S=Em(Sm().mark((function e(t,r){var n,i=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qO(t),GO(r,"message"),ZO(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 S.apply(this,arguments)})},{key:"setServerParams",value:(y=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MH.print("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 y.apply(this,arguments)})},{key:"sendServerMessage",value:(g=Em(Sm().mark((function e(t){var r,n=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return VO(t,"message"),ZO(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 g.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(m=Em(Sm().mark((function e(t){var r,n=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return GO(t,"message"),ZO(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 m.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new cR(sR.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");MH.print("startCloudProxy()",e),VO(e.logProxy,"logProxy"),VO(e.accessProxy,"accessProxy"),VO(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=OO("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=OO("LOG_SERVER_URL"),this._originConfigServerUrls=OO("CONFIG_REQUEST_DOMAINS"),PO("ICE_CONFIG_REQUEST_URLS",e.accessProxy),PO("LOG_SERVER_URL",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://"+e),"".concat(e,"/video/v1/webrtc_log/")}(e.logProxy)),PO("CONFIG_REQUEST_DOMAINS",[e.configProxy]),this._useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){if(this._room)throw new cR(sR.STOP_CLOUD_PROXY_BEFORE_LEAVE,"[stopCloudProxy] should be invoke after leave room ");MH.print("stopCloudProxy()"),PO("ICE_CONFIG_REQUEST_URLS",[]),PO("LOG_SERVER_URL",this._originLogServerUrl),PO("CONFIG_REQUEST_DOMAINS",this._originConfigServerUrls),this._useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(_=Em(Sm().mark((function e(t,r){var n,i,o,a=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),YO(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new cR(sR.REPEAT_PUSH,"repeat push public media stream");case 5:return o=DO(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 _.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(f=Em(Sm().mark((function e(t,r){var n,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MH.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),YO(t),this._assertNotInRoom(),i=DO(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 f.apply(this,arguments)})},{key:"stopPushPublicStream",value:(p=Em(Sm().mark((function e(t){var r,n=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MH.print("startPushPublicStream()","publicStreamId: %o",t),YO(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 p.apply(this,arguments)})},{key:"startPlayPublicStream",value:(v=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(YO(t),this._publicStreamManager){e.next=8;break}return this._publicStreamManager=new mH(this.id,this._appId,{businessId:this._businessId}),this._publicStreamManager.on(CV.RESUBSCRIBE,(function(e){var t=e.stream;if(t){var r,n=u._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=u._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,u.safeEmit(Hd.onPublicStreamStats,e)})),null===(n=this._publicStreamManager)||void 0===n||n.on(CV.ON_SEI_MESSAGED_RECEIVED,(function(e){u.safeEmit(Hd.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 fF(this.id,t,{muted:(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)===Md.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 v.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(h=Em(Sm().mark((function e(t){var r;return Sm().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 h.apply(this,arguments)})},{key:"setAudioProfile",value:(l=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:MH.print("setAudioProfile()","profile: %o",t),this._shouldUpdateAudioConf("setAudioProfile")&&this._audioProfileManager.setAudioProfile(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,i,o;MH.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 pF(this.id,cd(cd({},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)!==Md.PLAY_MANUALLY&&a.playVideo(s.videoTrack,s)}else this._publicStreamVideoPlayer.delete(e)}},{key:"setDummyCaptureImagePath",value:(d=Em(Sm().mark((function e(t,r){var n=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new X_((function(e,i){VO(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){t===yd.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),e()}catch(r){i(new cR(sR.UNEXPECTED_ERROR,r.message))}},o.onerror=function(){i(new cR(sR.UNEXPECTED_ERROR,"Load image error"))}})));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return d.apply(this,arguments)})},{key:"_updateDummyCaptureImage",value:function(e){var t,r;if(e===yd.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=mO(r.width),u=mO(r.height);if(!a)throw new cR(sR.UNEXPECTED_ERROR,"Not support canvas");!s||!u||t.width<=s&&t.height<=u?(n=t.width,i=t.height):(n=Math.min(s,t.width*u/t.height),i=Math.min(u,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 c=window.setInterval((function(){t&&a.drawImage(t,0,0,t.width,t.height,0,0,n,i)}),200);e===yd.STREAM_INDEX_MAIN?(clearInterval(this._dummyMainTimer),this._dummyMainTimer=c):(clearInterval(this._dummyScreenTimer),this._dummyScreenTimer=c);var d,l,h,v,p=o.captureStream(5).getVideoTracks()[0];if(e===yd.STREAM_INDEX_MAIN){if(this._localImgVideoTrack=p,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=p,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",Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t._localVideoTrack||t._localVideoTrack.dummy){e.next=6;break}return t._localVideoTrack&&t._removeLocalTrackEvents(t._localVideoTrack),e.next=4,t._localVideoTrack.generatePreProcessingTrack(t._extensionManager);case 4:return e.next=6,t._switchTrack(t._localVideoTrack);case 6:case"end":return e.stop()}}),e)}))))}},{key:"registerExtension",value:(c=Em(Sm().mark((function e(t){return Sm().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 c.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(ZE(xH.getDefaultValue()))}},{key:"_updatePublish",value:(u=Em(Sm().mark((function e(){var t,r,n,i=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},MH.print("_updatePublish()","config: %o",t),r={mediaType:void 0,invokeByJoinRoom:!1,pubState:PV.PUB},t=cd(cd({},r),t),this._visibility){e.next=6;break}throw new cR(sR.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===FV.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 cR)){e.next=24;break}throw e.t0;case 24:throw new cR(sR.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 u.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(s=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MH.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),VO(t,"filePath"),UO(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 s.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){MH.print("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(a=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return MH.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),UO(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 a.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){MH.print("stopAudioDeviceRecordAndPlayTest()"),this._audioDeviceManager.stopAudioDeviceRecordAndPlayTest()}},{key:"stopAudioDevicePlayTest",value:function(){MH.print("stopAudioDevicePlayTest()"),this._audioDeviceManager.stopAudioDevicePlayTest()}},{key:"setRemoteUserPriority",value:function(e,t){var r;MH.print("setRemoteUserPriority()","userId: %o, priority: %o",e,t);try{qO(e),FO(t,"priority",[Cd.HIGH,Cd.MEDIUM,Cd.LOW])}catch(n){return console.warn(n),!1}return this._userPriorityMap.set(e,t),null===(r=this._room)||void 0===r||r.updateRemoteUserPriority(e),!0}},{key:"takeLocalSnapshot",value:(o=Em(Sm().mark((function e(t){var r,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("takeLocalSnapshot()","streamIndex: %o",t),FO(t,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),r=t===yd.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new cR(sR.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return n=t===yd.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer,e.abrupt("return",kH(r.getTrack("preprocessing"),(null==n?void 0:n.mirrorType)===kd.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(i=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MH.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),VO(t,"id"),FO(r,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),u=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=oE(i).call(i,(function(e){return e.isScreen===(r===yd.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 cR(sR.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",kH(u.getTrack(),!1,r===yd.STREAM_INDEX_MAIN?this._remoteVideoPlayer.get(t):this._remoteScreenPlayer.get(t)));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){MH.print("setSubscribeFallbackOption()","option: %o",e);try{FO(e,"option",[wd.DISABLE,wd.VIDEO_STREAM_LOW,wd.AUDIO_ONLY])}catch(t){return console.warn(t),!1}return!this._room&&(this._subscribeFallbackOption=e,!0)}},{key:"getLocalStreamTrack",value:function(e,t){var r,n,i,o=this;if(e===yd.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 XU&&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,u,c,d;if(t===yd.STREAM_INDEX_MAIN)a=oE(o).call(o,(function(e){return!e.isScreen})),i="video"===r?null===(s=a)||void 0===s?void 0:s.videoTrack:null===(u=a)||void 0===u?void 0:u.audioTrack;else a=oE(o).call(o,(function(e){return e.isScreen})),i="video"===r?null===(c=a)||void 0===c?void 0:c.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._avSync=!!e,!0)}},{key:"setCaptureVolume",value:function(e,t){var r,n,i;(FO(e,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),t=nD(t,"volume",0,400),e===yd.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(qO(e),FO(t,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),r=nD(r,"volume",0,400),null!==(n=this._room)&&void 0!==n&&n.multiChatMode)_O("setPlaybackVolume is not supported in Conference mode");else{var a=t===yd.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;VO(e,"publicStreamId"),t=nD(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:"_reportMsTrackEvent",value:function(e,t){var r=this;if(!e.hookStop){e.hookStop=!0;var n=e.stop;e.stop=function(){SP(r.id,"stop",t,0,t),n.call(e)}}}},{key:"_updateScreenPublish",value:(n=Em(Sm().mark((function e(){var t,r,n,i=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:{},MH.print("_updateScreenPublish()"),r={mediaType:void 0,pubState:PV.PUB},t=cd(cd({},r),t),e.next=6,this._pubLock.lock();case 6:if(n=e.sent,this._room&&this._room.connectionState===FV.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 cR)){e.next=22;break}throw e.t0;case 22:throw new cR(sR.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){MH.print("_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||this.multiChatMode)){var a,s,u,c=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(c),!o){var d;o=new fF(this.id,r,{muted:(null===(d=this._config)||void 0===d?void 0:d.autoPlayPolicy)===Md.VIDEO_ONLY,isScreen:n}),this._initPlayerEvents(o,!1,n?yd.STREAM_INDEX_SCREEN:yd.STREAM_INDEX_MAIN),i.set(r,o);var l=this._audioDeviceManager.getSinkId();l&&o.setPlaybackDevice(l)}(null===(u=this._config)||void 0===u?void 0:u.autoPlayPolicy)!==Md.PLAY_MANUALLY&&o.playAudio(e.audioTrack),jP&&YP&&(t=this._remoteAudioPlayer,CH&&clearTimeout(CH),CH=setTimeout((function(){var e,r=YT(t);try{for(r.s();!(e=r.n()).done;){var n=WT(e.value,2),i=n[0],o=n[1];null!=i&&aR(i).call(i,"mux")&&o.pause()}}catch(l){r.e(l)}finally{r.f()}var a,s=YT(t);try{for(s.s();!(a=s.n()).done;){var u=WT(a.value,2),c=u[0],d=u[1];null!=c&&aR(c).call(c,"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;MH.print("_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)!==Md.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=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d;return Sm().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,u=i.videostream,c=qU.NONE,a&&(c|=Sd.AUDIO),u&&(c|=Sd.VIDEO),!c){e.next=12;break}return e.next=9,new X_((function(e){return setTimeout(e)}));case 9:null!=n&&n.isScreen?this.safeEmit(Hd.onUserPublishScreen,{userId:n.userId,mediaType:c}):(this.safeEmit(Hd.onUserPublishStream,{userId:n.userId,mediaType:c,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:c,isScreen:!(null==n||!n.isScreen)}),null!=n&&n.isScreen||(o&&this.safeEmit(Hd.onUserStartAudioCapture,{userId:n.userId}),s&&this.safeEmit(Hd.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=qU.NONE;if(null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoSubscribeAudio&&(i|=Sd.AUDIO),null!==(n=this._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo&&(i|=Sd.VIDEO),i){var o,a;if(t&&cO(i))null===(o=e.observer)||void 0===o||o.setAutoSubscribeAudio(!0);if(t&&dO(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=UH[e.reason])&&void 0!==t?t:bd.STREAM_REMOVE_REASON_OTHER,o=n.isScreen?Hd.onUserUnpublishScreen:Hd.onUserUnpublishStream,a=qU.NONE;n.attributes.audiostream&&(a|=Sd.AUDIO),n.attributes.videostream&&(a|=Sd.VIDEO),a!==qU.NONE&&(this.safeEmit(o,{userId:n.userId,mediaType:a,reason:i}),this.safeEmit("onRemoveStream",{userId:n.userId,isScreen:n.isScreen})),this._getRemotePlayer(n.userId,n.isScreen).forEach((function(e){var t=n.isScreen?"".concat(n.userId,"_screen"):n.userId;r._remoteAudioPlayer.delete(t),n.isScreen?r._remoteScreenPlayer.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(Hd.onUserJoined,e)}))}},{key:"_onUserLeave",value:function(e){this.safeEmit(Hd.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(Hd.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,Rm(e=[Hd.onNetworkQuality]).call(e,r))}},{key:"_onConnectionStateChange",value:function(e){if(void 0!==this._startCloudProxyTimestamp&&this._useCloudProxy&&e.state===Ed.CONNECTION_STATE_CONNECTED&&this.safeEmit(Hd.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),this.safeEmit(Hd.onConnectionStateChanged,e),e.state===Ed.CONNECTION_STATE_RECONNECTING){var t,r=YT(this._remoteAudioPlayer);try{for(r.s();!(t=r.n()).done;){var n=WT(t.value,2),i=n[0],o=n[1];null!=i&&aR(i).call(i,"mux")&&o.stop()}}catch(a){r.e(a)}finally{r.f()}}}},{key:"_getRemotePlayer",value:function(e,t){return[(t?this._remoteScreenAudioPlayer:this._remoteAudioPlayer).get(e),(t?this._remoteScreenPlayer:this._remoteVideoPlayer).get(e)]}},{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){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(Hd.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(Hd.onAudioDeviceStateChanged,e)}},{key:"_onUserPublishStateChange",value:function(e){var t,r=e.userId,n=e.isScreen,i=e.mediaType,o=e.pubState,a=e.remoteStream,s={userId:r,mediaType:i};n?o===PV.PUB?this.safeEmit(Hd.onUserPublishScreen,s):this.safeEmit(Hd.onUserUnpublishScreen,cd(cd({},s),{},{reason:bd.STREAM_REMOVE_REASON_UNPUBLISH})):o===PV.PUB?(s.videoStreamDescriptions=null==a||null===(t=a.attributes)||void 0===t?void 0:t.videoDescriptions,this.safeEmit(Hd.onUserPublishStream,s),this._handleAutoSubscribe(a,!0)):this.safeEmit(Hd.onUserUnpublishStream,cd(cd({},s),{},{reason:bd.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(Hd.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(Hd.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Hd.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Hd.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(Hd.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(Hd.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(Hd.onTokenWillExpire)}},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(Hd.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Hd.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Hd.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(Hd.onError,{errorCode:sR.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(Hd.onError,{errorCode:sR.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(Hd.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(Hd.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||this._room.connectionState!==FV.CONNECTED)throw new cR(sR.NOT_CONNECTED_YET,"server not connected")}},{key:"_checkMediaType",value:function(e){FO(e,"mediaType",[Sd.AUDIO,Sd.VIDEO,Sd.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=Em(Sm().mark((function e(t){var r,n;return Sm().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||!n.hasPublished){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=(null===(t=this._room)||void 0===t?void 0:t.hasPublished)||this._localAudioTrack&&this._localAudioTrack.sourceType===uU.INTERNAL;if(r){var n="engine.".concat(e," should be called before publishing or capturing.");console.warn("[RTC WebSDK]: "+n),SP(this.id,e,n)}return!r}},{key:"_getServerConfig",value:function(){xP({engineId:this.id,appId:this.appId,sdkVersion:OO("VERSION"),requestDomains:OO("CONFIG_REQUEST_DOMAINS"),keys:["rts_report"]}).then((function(e){e.rts_report&&uP.setConfig(e.rts_report)}))}}]),me}(sD);DH([gP()],NH.prototype,"updateToken",1),DH([gP()],NH.prototype,"setVideoCaptureDevice",1),DH([gP()],NH.prototype,"setAudioCaptureDevice",1),DH([function(e,t,r){if("function"==typeof r.value){var n=r.value;r.value=function(){for(var e,t=mP(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)}}},gP()],NH.prototype,"connect",1),DH([gP()],NH.prototype,"joinRoom",1),DH([gP()],NH.prototype,"leaveRoom",1),DH([gP()],NH.prototype,"destroy",1),DH([gP()],NH.prototype,"publishStream",1),DH([gP()],NH.prototype,"unpublishStream",1),DH([gP()],NH.prototype,"publishScreen",1),DH([gP()],NH.prototype,"unpublishScreen",1),DH([gP()],NH.prototype,"subscribeStream",1),DH([gP()],NH.prototype,"unsubscribeStream",1),DH([gP()],NH.prototype,"subscribeScreen",1),DH([gP()],NH.prototype,"unsubscribeScreen",1),DH([gP()],NH.prototype,"setRemoteVideoConfig",1),DH([gP()],NH.prototype,"startVideoCapture",1),DH([gP()],NH.prototype,"stopVideoCapture",1),DH([gP()],NH.prototype,"startAudioCapture",1),DH([gP()],NH.prototype,"stopAudioCapture",1),DH([gP()],NH.prototype,"getAudioMixingManager",1),DH([gP()],NH.prototype,"startScreenCapture",1),DH([gP()],NH.prototype,"stopScreenCapture",1),DH([gP()],NH.prototype,"setLocalVideoPlayer",1),DH([gP()],NH.prototype,"startLiveTranscoding",1),DH([gP()],NH.prototype,"updateLiveTranscoding",1),DH([gP()],NH.prototype,"stopLiveTranscoding",1),DH([gP()],NH.prototype,"startSubtitle",1),DH([gP()],NH.prototype,"stopSubtitle",1),DH([gP()],NH.prototype,"setBusinessId",1),DH([gP()],NH.prototype,"setUserVisibility",1),DH([gP()],NH.prototype,"setRemoteVideoPlayer",1),DH([gP()],NH.prototype,"setLocalVideoMirrorType",1),DH([gP()],NH.prototype,"setAudioPlaybackDevice",1),DH([gP()],NH.prototype,"play",1),DH([gP()],NH.prototype,"pauseAllSubscribedStream",1),DH([gP()],NH.prototype,"resumeAllSubscribedStream",1),DH([gP()],NH.prototype,"sendUserMessage",1),DH([gP()],NH.prototype,"sendUserBinaryMessage",1),DH([gP()],NH.prototype,"sendRoomMessage",1),DH([gP()],NH.prototype,"sendRoomBinaryMessage",1),DH([gP()],NH.prototype,"setAudioCaptureConfig",1),DH([fO("4.51"),gP()],NH.prototype,"setVideoCaptureConfig",1),DH([gP()],NH.prototype,"enableSimulcastMode",1),DH([gP()],NH.prototype,"setVideoEncoderConfig",1),DH([gP()],NH.prototype,"setScreenEncoderConfig",1),DH([gP()],NH.prototype,"sendSEIMessage",1),DH([fO("4.42"),gP()],NH.prototype,"setAudioVolumeIndicationInterval",1),DH([gP()],NH.prototype,"enableAudioPropertiesReport",1),DH([gP()],NH.prototype,"setVideoSourceType",1),DH([gP()],NH.prototype,"setExternalVideoTrack",1),DH([gP()],NH.prototype,"setAudioSourceType",1),DH([gP()],NH.prototype,"setExternalAudioTrack",1),DH([gP()],NH.prototype,"login",1),DH([gP()],NH.prototype,"logout",1),DH([gP()],NH.prototype,"updateLoginToken",1),DH([gP()],NH.prototype,"getPeerOnlineStatus",1),DH([gP()],NH.prototype,"sendUserMessageOutsideRoom",1),DH([gP()],NH.prototype,"sendUserBinaryMessageOutsideRoom",1),DH([gP()],NH.prototype,"setServerParams",1),DH([gP()],NH.prototype,"sendServerMessage",1),DH([gP()],NH.prototype,"sendServerBinaryMessage",1),DH([gP()],NH.prototype,"startCloudProxy",1),DH([gP()],NH.prototype,"stopCloudProxy",1),DH([gP()],NH.prototype,"startPushPublicStream",1),DH([gP()],NH.prototype,"updatePublicStreamParam",1),DH([gP()],NH.prototype,"stopPushPublicStream",1),DH([gP("streamId")],NH.prototype,"startPlayPublicStream",1),DH([gP("streamId")],NH.prototype,"stopPlayPublicStream",1),DH([gP()],NH.prototype,"setAudioProfile",1),DH([gP()],NH.prototype,"setPublicStreamVideoPlayer",1),DH([gP()],NH.prototype,"setDummyCaptureImagePath",1),DH([gP()],NH.prototype,"registerExtension",1),DH([gP()],NH.prototype,"startAudioPlaybackDeviceTest",1),DH([gP()],NH.prototype,"stopAudioPlaybackDeviceTest",1),DH([gP()],NH.prototype,"startAudioDeviceRecordTest",1),DH([gP()],NH.prototype,"stopAudioDeviceRecordAndPlayTest",1),DH([gP()],NH.prototype,"stopAudioDevicePlayTest",1),DH([gP()],NH.prototype,"setRemoteUserPriority",1),DH([gP()],NH.prototype,"takeLocalSnapshot",1),DH([gP()],NH.prototype,"takeRemoteSnapshot",1),DH([gP()],NH.prototype,"setSubscribeFallbackOption",1),DH([gP()],NH.prototype,"getLocalStreamTrack",1),DH([gP()],NH.prototype,"getRemoteStreamTrack",1),DH([gP()],NH.prototype,"getPublicStreamTrack",1),DH([gP()],NH.prototype,"setRemoteStreamRenderSync",1);var LH,UH={"client unpublished":bd.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":bd.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":bd.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":bd.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":bd.STREAM_REMOVE_REASON_REPUBLISH},VH=new nP("VERTC",0);$x.storeKey=Rm(LH="".concat(Date.now(),"-")).call(LH,IO.getDeviceId()),dP({rtc_sdk_version:xO.VERSION,device_id:IO.getDeviceId(),log_cache_key:$x.storeKey}),lP(xO.LOG_SERVER_URL);var FH=1,BH=function(e,t){VH.print("createEngine","Invoke VERTC.createEngine"),VO(e,"appId");var r=(FH++).toString();return function(e,t){var r=new jx(e);r.set(cd(cd({},t),{},{engine_session_id:ZR()})),r.report("sdk_init_engine",{start:Date.now(),type:"begin"}),_P.set(e,r)}(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new NH(e,r,t)},jH=function(e){if(VH.print("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof NH))throw new cR(sR.INVALID_ENGINE,"Invalid engine object");var t;e.destroy(),(t=e.monitor).report("sdk_init_engine",{start:Date.now(),type:"end"}),_P.delete(t.id)},GH=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",tU.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),zH=function(){var e=Em(Sm().mark((function e(){var t,r,n,i,o,a,s=arguments;return Sm().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=13;break}return e.prev=4,e.next=7,tU.getPermissions({video:!0,force:!0});case 7:o=e.sent,i.video=o.video,e.next=13;break;case 11:e.prev=11,e.t0=e.catch(4);case 13:if(!n){e.next=23;break}return e.prev=14,e.next=17,tU.getPermissions({audio:!0,force:!0});case 17:a=e.sent,i.audio=a.audio,e.next=23;break;case 21:e.prev=21,e.t1=e.catch(14);case 23:return e.abrupt("return",i);case 24:case"end":return e.stop()}}),e,null,[[4,11],[14,21]])})));return function(){return e.apply(this,arguments)}}(),HH=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",tU.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),XH=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",tU.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),KH=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",tU.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),qH=function(){return xO.VERSION},YH=function(){return vP("isSupported",0,""),IN()},WH=function(){return vP("getSupportedCodecs",0,""),RN()},QH=function(e){var t=e.logLevel,r=e.LogfileSize;t&&($x.logLevel=t),r&&($x.LogfileSize=r)},JH=function(e){$x.download(e)};return cd(cd(cd(cd({},new(Kd((function e(){qd(this,e),sd(this,"getSdkVersion",qH),sd(this,"createEngine",BH),sd(this,"destroyEngine",jH),sd(this,"enumerateDevices",GH),sd(this,"enableDevices",zH),sd(this,"enumerateAudioCaptureDevices",HH),sd(this,"enumerateVideoCaptureDevices",XH),sd(this,"enumerateAudioPlaybackDevices",KH),sd(this,"getParameter",OO),sd(this,"setParameter",PO),sd(this,"isSupported",YH),sd(this,"getSupportedCodecs",WH),sd(this,"events",Hd),sd(this,"ErrorCode",sR),sd(this,"platform","BytePlus"),sd(this,"downloadLog",JH),sd(this,"setLogConfig",QH)})))),Fd),zd),{},{events:Hd})}));
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,u=s.apply,c=s.call,d="object"==typeof Reflect&&Reflect.apply||(a?c.bind(u):function(){return c.apply(u,arguments)}),l=o,h=Function.prototype,v=h.call,p=l&&h.bind.bind(v,v),f=l?p:function(e){return function(){return v.apply(e,arguments)}},_=f,m=_({}.toString),g=_("".slice),y=function(e){return g(m(e),8,-1)},S=y,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,A=T.IS_HTMLDDA?function(e){return"function"==typeof e||e===I}:function(e){return"function"==typeof e},R={},w=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),C=o,x=Function.prototype.call,P=C?x.bind(x):function(){return x.apply(x,arguments)},O={},D={}.propertyIsEnumerable,M=Object.getOwnPropertyDescriptor,N=M&&!D.call({1:2},1);O.f=N?function(e){var t=M(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},X=z,K=TypeError,q=function(e){if(X(e))throw K("Can't call method on "+e);return e},Y=H,W=q,Q=function(e){return Y(W(e))},J=A,Z=T.all,$=T.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:J(e)||e===Z}:function(e){return"object"==typeof e?null!==e:J(e)},ee={},te=ee,re=n,ne=A,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")||"",ue=n,ce=se,de=ue.process,le=ue.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&&ce&&(!(L=ce.match(/Edge\/(\d+)/))||L[1]>=74)&&(L=ce.match(/Chrome\/(\d+)/))&&(U=+L[1]);var pe=U,fe=pe,_e=i,me=!!Object.getOwnPropertySymbols&&!_e((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&fe&&fe<41})),ge=me&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ye=oe,Se=A,be=ae,Ee=Object,ke=ge?function(e){return"symbol"==typeof e}:function(e){var t=ye("Symbol");return Se(t)&&be(t.prototype,Ee(e))},Te=String,Ie=function(e){try{return Te(e)}catch(t){return"Object"}},Ae=A,Re=Ie,we=TypeError,Ce=function(e){if(Ae(e))return e;throw we(Re(e)+" is not a function")},xe=Ce,Pe=z,Oe=function(e,t){var r=e[t];return Pe(r)?void 0:xe(r)},De=P,Me=A,Ne=$,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=q,Xe=Object,Ke=function(e){return Xe(ze(e))},qe=Ke,Ye=E({}.hasOwnProperty),We=Object.hasOwn||function(e,t){return Ye(qe(e),t)},Qe=E,Je=0,Ze=Math.random(),$e=Qe(1..toString),et=function(e){return"Symbol("+(void 0===e?"":e)+")_"+$e(++Je+Ze,36)},tt=n,rt=Ue.exports,nt=We,it=et,ot=me,at=ge,st=rt("wks"),ut=tt.Symbol,ct=ut&&ut.for,dt=at?ut:ut&&ut.withoutSetter||it,lt=function(e){if(!nt(st,e)||!ot&&"string"!=typeof st[e]){var t="Symbol."+e;ot&&nt(ut,e)?st[e]=ut[e]:st[e]=at&&ct?ct(t):dt(t)}return st[e]},ht=P,vt=$,pt=ke,ft=Oe,_t=function(e,t){var r,n;if("string"===t&&Me(r=e.toString)&&!Ne(n=De(r,e)))return n;if(Me(r=e.valueOf)&&!Ne(n=De(r,e)))return n;if("string"!==t&&Me(r=e.toString)&&!Ne(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)||pt(e))return e;var r,n=ft(e,gt);if(n){if(void 0===t&&(t="default"),r=ht(n,e,t),!vt(r)||pt(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=yt(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):{}},At=It,Rt=!w&&!i((function(){return 7!=Object.defineProperty(At("div"),"a",{get:function(){return 7}}).a})),wt=w,Ct=P,xt=O,Pt=V,Ot=Q,Dt=bt,Mt=We,Nt=Rt,Lt=Object.getOwnPropertyDescriptor;R.f=wt?Lt:function(e,t){if(e=Ot(e),t=Dt(t),Nt)try{return Lt(e,t)}catch(r){}if(Mt(e,t))return Pt(!Ct(xt.f,e,t),e[t])};var Ut=i,Vt=A,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",Xt=Bt,Kt=Ce,qt=o,Yt=E(E.bind),Wt=function(e,t){return Kt(e),void 0===t?e:qt?Yt(e,t):function(){return e.apply(t,arguments)}},Qt={},Jt=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=Rt,ir=Jt,or=tr,ar=bt,sr=TypeError,ur=Object.defineProperty,cr=Object.getOwnPropertyDescriptor,dr="enumerable",lr="configurable",hr="writable";Qt.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=cr(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 ur(e,t,r)}:ur:function(e,t,r){if(or(e),t=ar(t),or(r),nr)try{return ur(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=Qt,pr=V,fr=w?function(e,t,r){return vr.f(e,t,pr(1,r))}:function(e,t,r){return e[t]=r,e},_r=n,mr=d,gr=E,yr=A,Sr=R.f,br=Xt,Er=ee,kr=Wt,Tr=fr,Ir=We,Ar=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},Rr=function(e,t){var r,n,i,o,a,s,u,c,d=e.target,l=e.global,h=e.stat,v=e.proto,p=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)&&p&&Ir(p,i),a=f[i],r&&(s=e.dontCallGetSet?(c=Sr(p,i))&&c.value:p[i]),o=r&&s?s:t[i],r&&typeof a==typeof o||(u=e.bind&&r?kr(o,_r):e.wrap&&r?Ar(o):v&&yr(o)?gr(o):o,(e.sham||o&&o.sham||a&&a.sham)&&Tr(u,"sham",!0),Tr(f,i,u),v&&(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)},Pr=function(e){var t=+e;return t!=t||0===t?0:xr(t)},Or=Pr,Dr=Math.max,Mr=Math.min,Nr=function(e,t){var r=Or(e);return r<0?Dr(r+t,0):Mr(r,t)},Lr=Pr,Ur=Math.min,Vr=function(e){return e>0?Ur(Lr(e),9007199254740991):0},Fr=Vr,Br=function(e){return Fr(e.length)},jr=Q,Gr=Nr,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}},Xr={includes:zr(!0),indexOf:zr(!1)},Kr={},qr=We,Yr=Q,Wr=Xr.indexOf,Qr=Kr,Jr=E([].push),Zr=function(e,t){var r,n=Yr(e),i=0,o=[];for(r in n)!qr(Qr,r)&&qr(n,r)&&Jr(o,r);for(;t.length>i;)qr(n,r=t[i++])&&(~Wr(o,r)||Jr(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=Ke,on=rn;Rr({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 un="[object z]"===String(sn),cn=un,dn=A,ln=y,hn=lt("toStringTag"),vn=Object,pn="Arguments"==ln(function(){return arguments}()),fn=cn?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:pn?ln(t):"Object"==(n=ln(t))&&dn(t.callee)?"Arguments":n},_n=fn,mn=String,gn=function(e){if("Symbol"===_n(e))throw TypeError("Cannot convert a Symbol value to a string");return mn(e)},yn={},Sn=w,bn=Jt,En=Qt,kn=tr,Tn=Q,In=rn;yn.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 An,Rn=oe("document","documentElement"),wn=Ue.exports,Cn=et,xn=wn("keys"),Pn=function(e){return xn[e]||(xn[e]=Cn(e))},On=tr,Dn=yn,Mn=$r,Nn=Kr,Ln=Rn,Un=It,Vn=Pn("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{An=new ActiveXObject("htmlfile")}catch(n){}var e,t;Gn="undefined"!=typeof document?document.domain&&An?jn(An):((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(An);for(var r=Mn.length;r--;)delete Gn.prototype[Mn[r]];return Gn()};Nn[Vn]=!0;var Hn=Object.create||function(e,t){var r;return null!==e?(Fn.prototype=On(e),r=new Fn,Fn.prototype=null,r[Vn]=e):r=Gn(),void 0===t?r:Dn.f(r,t)},zn={},Xn=Zr,Kn=$r.concat("length","prototype");zn.f=Object.getOwnPropertyNames||function(e){return Xn(e,Kn)};var qn={},Yn=bt,Wn=Qt,Qn=V,Jn=function(e,t,r){var n=Yn(t);n in e?Wn.f(e,n,Qn(0,r)):e[n]=r},Zn=Nr,$n=Br,ei=Jn,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=Q,ai=zn.f,si=ni,ui="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];qn.f=function(e){return ui&&"Window"==ii(e)?function(e){try{return ai(e)}catch(t){return si(ui)}}(e):ai(oi(e))};var ci={};ci.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={},vi=lt;hi.f=vi;var pi,fi,_i,mi=ee,gi=We,yi=hi,Si=Qt.f,bi=function(e){var t=mi.Symbol||(mi.Symbol={});gi(t,e)||Si(t,e,{value:yi.f(e)})},Ei=P,ki=oe,Ti=lt,Ii=li,Ai=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})},Ri=fn,wi=un?{}.toString:function(){return"[object "+Ri(this)+"]"},Ci=un,xi=Qt.f,Pi=fr,Oi=We,Di=wi,Mi=lt("toStringTag"),Ni=function(e,t,r,n){if(e){var i=r?e:e.prototype;Oi(i,Mi)||xi(i,Mi,{configurable:!0,value:t}),n&&!Ci&&Pi(i,"toString",Di)}},Li=A,Ui=n.WeakMap,Vi=Li(Ui)&&/native code/.test(String(Ui)),Fi=Vi,Bi=n,ji=$,Gi=fr,Hi=We,zi=Ge,Xi=Pn,Ki=Kr,qi="Object already initialized",Yi=Bi.TypeError,Wi=Bi.WeakMap;if(Fi||zi.state){var Qi=zi.state||(zi.state=new Wi);Qi.get=Qi.get,Qi.has=Qi.has,Qi.set=Qi.set,pi=function(e,t){if(Qi.has(e))throw Yi(qi);return t.facade=e,Qi.set(e,t),t},fi=function(e){return Qi.get(e)||{}},_i=function(e){return Qi.has(e)}}else{var Ji=Xi("state");Ki[Ji]=!0,pi=function(e,t){if(Hi(e,Ji))throw Yi(qi);return t.facade=e,Gi(e,Ji,t),t},fi=function(e){return Hi(e,Ji)?e[Ji]:{}},_i=function(e){return Hi(e,Ji)}}var Zi={set:pi,get:fi,has:_i,enforce:function(e){return _i(e)?fi(e):pi(e,{})},getterFor:function(e){return function(t){var r;if(!ji(t)||(r=fi(t)).type!==e)throw Yi("Incompatible receiver, "+e+" required");return r}}},$i=y,eo=Array.isArray||function(e){return"Array"==$i(e)},to=A,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=A,uo=fn,co=io,lo=function(){},ho=[],vo=oe("Reflect","construct"),po=/^\s*(?:class|function)\b/,fo=oo(po.exec),_o=!po.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(uo(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return _o||!!fo(po,co(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=$,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},Ao=function(e,t){return new(Io(e))(0===t?0:t)},Ro=Wt,wo=H,Co=Ke,xo=Br,Po=Ao,Oo=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(u,c,d,l){for(var h,v,p=Co(u),f=wo(p),_=Ro(c,d),m=xo(f),g=0,y=l||Po,S=t?y(u,m):r||a?y(u,0):void 0;m>g;g++)if((s||g in f)&&(v=_(h=f[g],g,p),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:Oo(S,h)}else switch(e){case 4:return!1;case 7:Oo(S,h)}return o?-1:n||i?i:S}},Mo={forEach:Do(0),map:Do(1),filter:Do(2),some:Do(3),every:Do(4),find:Do(5),findIndex:Do(6),filterReject:Do(7)},No=Rr,Lo=n,Uo=P,Vo=E,Fo=w,Bo=me,jo=i,Go=We,Ho=ae,zo=tr,Xo=Q,Ko=bt,qo=gn,Yo=V,Wo=Hn,Qo=rn,Jo=zn,Zo=qn,$o=ci,ea=R,ta=Qt,ra=yn,na=O,ia=li,oa=Ue.exports,aa=Kr,sa=et,ua=lt,ca=hi,da=bi,la=Ai,ha=Ni,va=Zi,pa=Mo.forEach,fa=Pn("hidden"),_a="Symbol",ma=va.set,ga=va.getterFor(_a),ya=Object.prototype,Sa=Lo.Symbol,ba=Sa&&Sa.prototype,Ea=Lo.TypeError,ka=Lo.QObject,Ta=ea.f,Ia=ta.f,Aa=Zo.f,Ra=na.f,wa=Vo([].push),Ca=oa("symbols"),xa=oa("op-symbols"),Pa=oa("wks"),Oa=!ka||!ka.prototype||!ka.prototype.findChild,Da=Fo&&jo((function(){return 7!=Wo(Ia({},"a",{get:function(){return Ia(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=Ta(ya,t);n&&delete ya[t],Ia(e,t,r),n&&e!==ya&&Ia(ya,t,n)}:Ia,Ma=function(e,t){var r=Ca[e]=Wo(ba);return ma(r,{type:_a,tag:e,description:t}),Fo||(r.description=t),r},Na=function(e,t,r){e===ya&&Na(xa,t,r),zo(e);var n=Ko(t);return zo(r),Go(Ca,n)?(r.enumerable?(Go(e,fa)&&e[fa][n]&&(e[fa][n]=!1),r=Wo(r,{enumerable:Yo(0,!1)})):(Go(e,fa)||Ia(e,fa,Yo(1,{})),e[fa][n]=!0),Da(e,n,r)):Ia(e,n,r)},La=function(e,t){zo(e);var r=Xo(t),n=Qo(r).concat(Ba(r));return pa(n,(function(t){Fo&&!Uo(Ua,r,t)||Na(e,t,r[t])})),e},Ua=function(e){var t=Ko(e),r=Uo(Ra,this,t);return!(this===ya&&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=Xo(e),n=Ko(t);if(r!==ya||!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=Aa(Xo(e)),r=[];return pa(t,(function(e){Go(Ca,e)||Go(aa,e)||wa(r,e)})),r},Ba=function(e){var t=e===ya,r=Aa(t?xa:Xo(e)),n=[];return pa(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]?qo(arguments[0]):void 0,t=sa(e),r=function(e){this===ya&&Uo(r,xa,e),Go(this,fa)&&Go(this[fa],t)&&(this[fa][t]=!1),Da(this,t,Yo(1,e))};return Fo&&Oa&&Da(ya,t,{configurable:!0,set:r}),Ma(t,e)},ia(ba=Sa.prototype,"toString",(function(){return ga(this).tag})),ia(Sa,"withoutSetter",(function(e){return Ma(sa(e),e)})),na.f=Ua,ta.f=Na,ra.f=La,ea.f=Va,Jo.f=Zo.f=Fa,$o.f=Ba,ca.f=function(e){return Ma(ua(e),e)},Fo&&Ia(ba,"description",{configurable:!0,get:function(){return ga(this).description}})),No({global:!0,constructor:!0,wrap:!0,forced:!Bo,sham:!Bo},{Symbol:Sa}),pa(Qo(Pa),(function(e){da(e)})),No({target:_a,stat:!0,forced:!Bo},{useSetter:function(){Oa=!0},useSimple:function(){Oa=!1}}),No({target:"Object",stat:!0,forced:!Bo,sham:!Fo},{create:function(e,t){return void 0===t?Wo(e):La(Wo(e),t)},defineProperty:Na,defineProperties:La,getOwnPropertyDescriptor:Va}),No({target:"Object",stat:!0,forced:!Bo},{getOwnPropertyNames:Fa}),la(),ha(Sa,_a),aa[fa]=!0;var ja=me&&!!Symbol.for&&!!Symbol.keyFor,Ga=Rr,Ha=oe,za=We,Xa=gn,Ka=Ue.exports,qa=ja,Ya=Ka("string-to-symbol-registry"),Wa=Ka("symbol-to-string-registry");Ga({target:"Symbol",stat:!0,forced:!qa},{for:function(e){var t=Xa(e);if(za(Ya,t))return Ya[t];var r=Ha("Symbol")(t);return Ya[t]=r,Wa[r]=t,r}});var Qa=Rr,Ja=We,Za=ke,$a=Ie,es=ja,ts=(0,Ue.exports)("symbol-to-string-registry");Qa({target:"Symbol",stat:!0,forced:!es},{keyFor:function(e){if(!Za(e))throw TypeError($a(e)+" is not a symbol");if(Ja(ts,e))return ts[e]}});var rs=E([].slice),ns=Rr,is=oe,os=d,as=P,ss=E,us=i,cs=eo,ds=A,ls=$,hs=ke,vs=rs,ps=me,fs=is("JSON","stringify"),_s=ss(/./.exec),ms=ss("".charAt),gs=ss("".charCodeAt),ys=ss("".replace),Ss=ss(1..toString),bs=/[\uD800-\uDFFF]/g,Es=/^[\uD800-\uDBFF]$/,ks=/^[\uDC00-\uDFFF]$/,Ts=!ps||us((function(){var e=is("Symbol")();return"[null]"!=fs([e])||"{}"!=fs({a:e})||"{}"!=fs(Object(e))})),Is=us((function(){return'"\\udf06\\ud834"'!==fs("\udf06\ud834")||'"\\udead"'!==fs("\udead")})),As=function(e,t){var r=vs(arguments),n=t;if((ls(t)||void 0!==e)&&!hs(e))return cs(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)},Rs=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(gs(e,0),16):e};fs&&ns({target:"JSON",stat:!0,arity:3,forced:Ts||Is},{stringify:function(e,t,r){var n=vs(arguments),i=os(Ts?As:fs,null,n);return Is&&"string"==typeof i?ys(i,bs,Rs):i}});var ws=ci,Cs=Ke;Rr({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,Ps=i,Os=pe,Ds=lt("species"),Ms=function(e){return Os>=51||!Ps((function(){var t=[];return(t.constructor={})[Ds]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Ns=Mo.filter;Rr({target:"Array",proto:!0,forced:!Ms("filter")},{filter:function(e){return Ns(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=Rr,Xs=i,Ks=Q,qs=R.f,Ys=w,Ws=Xs((function(){qs(1)}));zs({target:"Object",stat:!0,forced:!Ys||Ws,sham:!Ys},{getOwnPropertyDescriptor:function(e,t){return qs(Ks(e),t)}});var Qs=ee.Object,Js=Hs.exports=function(e,t){return Qs.getOwnPropertyDescriptor(e,t)};Qs.getOwnPropertyDescriptor.sham&&(Js.sham=!0);var Zs,$s,eu,tu=Hs.exports,ru={},nu=w,iu=We,ou=Function.prototype,au=nu&&Object.getOwnPropertyDescriptor,su=iu(ou,"name"),uu={EXISTS:su,PROPER:su&&"something"===function(){}.name,CONFIGURABLE:su&&(!nu||nu&&au(ou,"name").configurable)},cu=!i((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),du=We,lu=A,hu=Ke,vu=cu,pu=Pn("IE_PROTO"),fu=Object,_u=fu.prototype,mu=vu?fu.getPrototypeOf:function(e){var t=hu(e);if(du(t,pu))return t[pu];var r=t.constructor;return lu(r)&&t instanceof r?r.prototype:t instanceof fu?_u:null},gu=i,yu=A,Su=$,bu=Hn,Eu=mu,ku=li,Tu=lt("iterator"),Iu=!1;[].keys&&("next"in(eu=[].keys())?($s=Eu(Eu(eu)))!==Object.prototype&&(Zs=$s):Iu=!0);var Au=!Su(Zs)||gu((function(){var e={};return Zs[Tu].call(e)!==e}));yu((Zs=Au?{}:bu(Zs))[Tu])||ku(Zs,Tu,(function(){return this}));var Ru={IteratorPrototype:Zs,BUGGY_SAFARI_ITERATORS:Iu},wu=Ru.IteratorPrototype,Cu=Hn,xu=V,Pu=Ni,Ou=ru,Du=function(){return this},Mu=function(e,t,r,n){var i=t+" Iterator";return e.prototype=Cu(wu,{next:xu(+!n,r)}),Pu(e,i,!1,!0),Ou[i]=Du,e},Nu=A,Lu=String,Uu=TypeError,Vu=E,Fu=tr,Bu=function(e){if("object"==typeof e||Nu(e))return e;throw Uu("Can't set "+Lu(e)+" as a prototype")},ju=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=Vu(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),t=r instanceof Array}catch(n){}return function(r,n){return Fu(r),Bu(n),t?e(r,n):r.__proto__=n,r}}():void 0),Gu=Rr,Hu=P,zu=uu,Xu=Mu,Ku=mu,qu=Ni,Yu=li,Wu=ru,Qu=Ru,Ju=zu.PROPER,Zu=Qu.BUGGY_SAFARI_ITERATORS,$u=lt("iterator"),ec="keys",tc="values",rc="entries",nc=function(){return this},ic=function(e,t,r,n,i,o,a){Xu(r,t,n);var s,u,c,d=function(e){if(e===i&&f)return f;if(!Zu&&e in v)return v[e];switch(e){case ec:case tc:case rc:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,v=e.prototype,p=v[$u]||v["@@iterator"]||i&&v[i],f=!Zu&&p||d(i),_="Array"==t&&v.entries||p;if(_&&(s=Ku(_.call(new e)))!==Object.prototype&&s.next&&(qu(s,l,!0,!0),Wu[l]=nc),Ju&&i==tc&&p&&p.name!==tc&&(h=!0,f=function(){return Hu(p,this)}),i)if(u={values:d(tc),keys:o?f:d(ec),entries:d(rc)},a)for(c in u)(Zu||h||!(c in v))&&Yu(v,c,u[c]);else Gu({target:t,proto:!0,forced:Zu||h},u);return a&&v[$u]!==f&&Yu(v,$u,f,{name:i}),Wu[t]=f,u},oc=function(e,t){return{value:e,done:t}},ac=Q,sc=function(){},uc=ru,cc=Zi,dc=(Qt.f,ic),lc=oc,hc="Array Iterator",vc=cc.set,pc=cc.getterFor(hc);dc(Array,"Array",(function(e,t){vc(this,{type:hc,target:ac(e),index:0,kind:t})}),(function(){var e=pc(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,lc(void 0,!0)):lc("keys"==r?n:"values"==r?t[n]:[n,t[n]],!1)}),"values");uc.Arguments=uc.Array;sc(),sc(),sc();var fc={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},_c=n,mc=fn,gc=fr,yc=ru,Sc=lt("toStringTag");for(var bc in fc){var Ec=_c[bc],kc=Ec&&Ec.prototype;kc&&mc(kc)!==Sc&&gc(kc,Sc,bc),yc[bc]=yc.Array}var Tc=i,Ic=function(e,t){var r=[][e];return!!r&&Tc((function(){r.call(null,t||function(){return 1},1)}))},Ac=Mo.forEach,Rc=Ic("forEach")?[].forEach:function(e){return Ac(this,e,arguments.length>1?arguments[1]:void 0)};Rr({target:"Array",proto:!0,forced:[].forEach!=Rc},{forEach:Rc});var wc=Us("Array").forEach,Cc=fn,xc=We,Pc=ae,Oc=wc,Dc=Array.prototype,Mc={DOMTokenList:!0,NodeList:!0},Nc=function(e){var t=e.forEach;return e===Dc||Pc(Dc,e)&&t===Dc.forEach||xc(Mc,Cc(e))?Oc:t},Lc=oe,Uc=zn,Vc=ci,Fc=tr,Bc=E([].concat),jc=Lc("Reflect","ownKeys")||function(e){var t=Uc.f(Fc(e)),r=Vc.f;return r?Bc(t,r(e)):t},Gc=jc,Hc=Q,zc=R,Xc=Jn;Rr({target:"Object",stat:!0,sham:!w},{getOwnPropertyDescriptors:function(e){for(var t,r,n=Hc(e),i=zc.f,o=Gc(n),a={},s=0;o.length>s;)void 0!==(r=i(n,t=o[s++]))&&Xc(a,t,r);return a}});var Kc=ee.Object.getOwnPropertyDescriptors,qc={exports:{}},Yc=Rr,Wc=w,Qc=yn.f;Yc({target:"Object",stat:!0,forced:Object.defineProperties!==Qc,sham:!Wc},{defineProperties:Qc});var Jc=ee.Object,Zc=qc.exports=function(e,t){return Jc.defineProperties(e,t)};Jc.defineProperties.sham&&(Zc.sham=!0);var $c=qc.exports,ed={exports:{}},td=Rr,rd=w,nd=Qt.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;function sd(e,t,r){return t in e?ad(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ud(e,t){var r=an(e);if(xs){var n=xs(e);t&&(n=Gs(n).call(n,(function(t){return tu(e,t).enumerable}))),r.push.apply(r,n)}return r}function cd(e){for(var t=1;t<arguments.length;t++){var r,n,i=null!=arguments[t]?arguments[t]:{};t%2?Nc(r=ud(Object(i),!0)).call(r,(function(t){sd(e,t,i[t])})):Kc?$c(e,Kc(i)):Nc(n=ud(Object(i))).call(n,(function(t){ad(e,t,tu(i,t))}))}return e}var dd=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}(dd||{}),ld=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}(ld||{}),hd=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}(hd||{}),vd=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(vd||{}),pd=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(pd||{}),fd=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(fd||{}),_d=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(_d||{}),md=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(md||{}),gd=function(e){return e[e.RENDER_MODE_HIDDEN=0]="RENDER_MODE_HIDDEN",e[e.RENDER_MODE_FIT=1]="RENDER_MODE_FIT",e}(gd||{}),yd=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(yd||{}),Sd=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(Sd||{}),bd=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}(bd||{}),Ed=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}(Ed||{}),kd=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(kd||{}),Td=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(Td||{}),Id=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(Id||{}),Ad=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}(Ad||{}),Rd=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(Rd||{}),wd=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}(wd||{}),Cd=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(Cd||{}),xd=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}(xd||{}),Pd=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(Pd||{}),Od=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}(Od||{}),Dd=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}(Dd||{}),Md=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}(Md||{}),Nd=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(Nd||{}),Ld=function(e){return e.H264="H264",e.H265="H265",e}(Ld||{}),Ud=function(e){return e[e.ASR_ONLY=0]="ASR_ONLY",e[e.ASR_AND_TRANSLATION=1]="ASR_AND_TRANSLATION",e}(Ud||{}),Vd=function(e){return e[e.STARTED=0]="STARTED",e[e.STOPPED=1]="STOPPED",e[e.ERROR=2]="ERROR",e}(Vd||{}),Fd=Object.freeze(Object.defineProperty({__proto__:null,VideoSourceType:dd,AudioSourceType:ld,UserOfflineReason:hd,ChannelProfile:vd,SubscribeMode:pd,SubscribeState:fd,PublishState:_d,MirrorMode:md,VideoRenderMode:gd,StreamIndex:yd,MediaType:Sd,StreamRemoveReason:bd,ConnectionState:Ed,MirrorType:kd,LogChannel:Td,USER_ONLINE_STATUS:Id,PublicStreamType:Ad,PublicInterpolationMode:Rd,SubscribeFallbackOption:wd,RemoteUserPriority:Cd,NetworkQuality:xd,FallbackOrRecoverReason:Pd,RoomProfileType:Od,AudioProfileType:Dd,RTCAutoPlayPolicy:Md,AAC_PROFILE:Nd,TRANSCODING_VIDEO_CODEC:Ld,SUBTITLE_MODE:Ud,SubtitleEventType:Vd},Symbol.toStringTag,{value:"Module"})),Bd=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}(Bd||{}),jd=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(jd||{}),Gd=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}(Gd||{}),Hd=Object.freeze(Object.defineProperty({__proto__:null,AudioMixingDualMonoMode:Bd,AudioMixingType:jd,AudioMixingState:Gd},Symbol.toStringTag,{value:"Module"})),zd=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}(zd||{});function Xd(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,n.key,n)}}function Kd(e,t,r){return t&&Xd(e.prototype,t),r&&Xd(e,r),ad(e,"prototype",{writable:!1}),e}function qd(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Yd=TypeError,Wd=function(e){if(e>9007199254740991)throw Yd("Maximum allowed index exceeded");return e},Qd=Rr,Jd=i,Zd=eo,$d=$,el=Ke,tl=Br,rl=Wd,nl=Jn,il=Ao,ol=Ms,al=pe,sl=lt("isConcatSpreadable"),ul=al>=51||!Jd((function(){var e=[];return e[sl]=!1,e.concat()[0]!==e})),cl=ol("concat"),dl=function(e){if(!$d(e))return!1;var t=e[sl];return void 0!==t?!!t:Zd(e)};Qd({target:"Array",proto:!0,arity:1,forced:!ul||!cl},{concat:function(e){var t,r,n,i,o,a=el(this),s=il(a,0),u=0;for(t=-1,n=arguments.length;t<n;t++)if(dl(o=-1===t?a:arguments[t]))for(i=tl(o),rl(u+i),r=0;r<i;r++,u++)r in o&&nl(s,u,o[r]);else rl(u+1),nl(s,u++,o);return s.length=u,s}}),bi("asyncIterator"),bi("hasInstance"),bi("isConcatSpreadable"),bi("iterator"),bi("match"),bi("matchAll"),bi("replace"),bi("search"),bi("species"),bi("split");var ll=Ai;bi("toPrimitive"),ll();var hl=oe,vl=Ni;bi("toStringTag"),vl(hl("Symbol"),"Symbol"),bi("unscopables"),Ni(n.JSON,"JSON",!0);var pl=ee.Symbol;bi("asyncDispose"),bi("dispose"),bi("matcher"),bi("metadataKey"),bi("observable"),bi("metadata"),bi("patternMatch"),bi("replaceAll");var fl=pl,_l=E,ml=Pr,gl=gn,yl=q,Sl=_l("".charAt),bl=_l("".charCodeAt),El=_l("".slice),kl=function(e){return function(t,r){var n,i,o=gl(yl(t)),a=ml(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=bl(o,a))<55296||n>56319||a+1===s||(i=bl(o,a+1))<56320||i>57343?e?Sl(o,a):n:e?El(o,a,a+2):i-56320+(n-55296<<10)+65536}},Tl={codeAt:kl(!1),charAt:kl(!0)},Il=Tl.charAt,Al=gn,Rl=Zi,wl=ic,Cl=oc,xl="String Iterator",Pl=Rl.set,Ol=Rl.getterFor(xl);wl(String,"String",(function(e){Pl(this,{type:xl,string:Al(e),index:0})}),(function(){var e,t=Ol(this),r=t.string,n=t.index;return n>=r.length?Cl(void 0,!0):(e=Il(r,n),t.index+=e.length,Cl(e,!1))}));var Dl=hi.f("iterator");function Ml(e){return(Ml="function"==typeof fl&&"symbol"==typeof Dl?function(e){return typeof e}:function(e){return e&&"function"==typeof fl&&e.constructor===fl&&e!==fl.prototype?"symbol":typeof e})(e)}Rr({target:"Object",stat:!0,sham:!w},{create:Hn});var Nl=ee.Object,Ll=function(e,t){return Nl.create(e,t)},Ul=Ke,Vl=mu,Fl=cu;Rr({target:"Object",stat:!0,forced:i((function(){Vl(1)})),sham:!Fl},{getPrototypeOf:function(e){return Vl(Ul(e))}});var Bl=ee.Object.getPrototypeOf;Rr({target:"Object",stat:!0},{setPrototypeOf:ju});var jl=ee.Object.setPrototypeOf,Gl=We,Hl=jc,zl=R,Xl=Qt,Kl=Error,ql=E("".replace),Yl=String(Kl("zxcasd").stack),Wl=/\n\s*at [^:]*:[^\n]*/,Ql=Wl.test(Yl),Jl=$,Zl=fr,$l=ru,eh=lt("iterator"),th=Array.prototype,rh=function(e){return void 0!==e&&($l.Array===e||th[eh]===e)},nh=fn,ih=Oe,oh=z,ah=ru,sh=lt("iterator"),uh=function(e){if(!oh(e))return ih(e,sh)||ih(e,"@@iterator")||ah[nh(e)]},ch=P,dh=Ce,lh=tr,hh=Ie,vh=uh,ph=TypeError,fh=function(e,t){var r=arguments.length<2?vh(e):t;if(dh(r))return lh(ch(r,e));throw ph(hh(e)+" is not iterable")},_h=P,mh=tr,gh=Oe,yh=function(e,t,r){var n,i;mh(e);try{if(!(n=gh(e,"return"))){if("throw"===t)throw r;return r}n=_h(n,e)}catch(o){i=!0,n=o}if("throw"===t)throw r;if(i)throw n;return mh(n),r},Sh=Wt,bh=P,Eh=tr,kh=Ie,Th=rh,Ih=Br,Ah=ae,Rh=fh,wh=uh,Ch=yh,xh=TypeError,Ph=function(e,t){this.stopped=e,this.result=t},Oh=Ph.prototype,Dh=function(e,t,r){var n,i,o,a,s,u,c,d=r&&r.that,l=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),v=!(!r||!r.IS_ITERATOR),p=!(!r||!r.INTERRUPTED),f=Sh(t,d),_=function(e){return n&&Ch(n,"normal",e),new Ph(!0,e)},m=function(e){return l?(Eh(e),p?f(e[0],e[1],_):f(e[0],e[1])):p?f(e,_):f(e)};if(h)n=e.iterator;else if(v)n=e;else{if(!(i=wh(e)))throw xh(kh(e)+" is not iterable");if(Th(i)){for(o=0,a=Ih(e);a>o;o++)if((s=m(e[o]))&&Ah(Oh,s))return s;return new Ph(!1)}n=Rh(e,i)}for(u=h?e.next:n.next;!(c=bh(u,n)).done;){try{s=m(c.value)}catch(g){Ch(n,"throw",g)}if("object"==typeof s&&s&&Ah(Oh,s))return s}return new Ph(!1)},Mh=gn,Nh=V,Lh=!i((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",Nh(1,7)),7!==e.stack)})),Uh=Rr,Vh=ae,Fh=mu,Bh=ju,jh=function(e,t,r){for(var n=Hl(t),i=Xl.f,o=zl.f,a=0;a<n.length;a++){var s=n[a];Gl(e,s)||r&&Gl(r,s)||i(e,s,o(t,s))}},Gh=Hn,Hh=fr,zh=V,Xh=function(e,t){if(Ql&&"string"==typeof e&&!Kl.prepareStackTrace)for(;t--;)e=ql(e,Wl,"");return e},Kh=function(e,t){Jl(t)&&"cause"in t&&Zl(e,"cause",t.cause)},qh=Dh,Yh=function(e,t){return void 0===e?arguments.length<2?"":t:Mh(e)},Wh=Lh,Qh=lt("toStringTag"),Jh=Error,Zh=[].push,$h=function(e,t){var r,n=arguments.length>2?arguments[2]:void 0,i=Vh(ev,this);Bh?r=Bh(Jh(),i?Fh(this):ev):(r=i?this:Gh(ev),Hh(r,Qh,"Error")),void 0!==t&&Hh(r,"message",Yh(t)),Wh&&Hh(r,"stack",Xh(r.stack,1)),Kh(r,n);var o=[];return qh(e,Zh,{that:o}),Hh(r,"errors",o),r};Bh?Bh($h,Jh):jh($h,Jh,{name:!0});var ev=$h.prototype=Gh(Jh.prototype,{constructor:zh(1,$h),message:zh(1,""),name:zh(1,"AggregateError")});Uh({global:!0,constructor:!0,arity:2},{AggregateError:$h});var tv,rv,nv,iv,ov="process"==y(n.process),av=oe,sv=Qt,uv=w,cv=lt("species"),dv=function(e){var t=av(e),r=sv.f;uv&&t&&!t[cv]&&r(t,cv,{configurable:!0,get:function(){return this}})},lv=ae,hv=TypeError,vv=function(e,t){if(lv(t,e))return e;throw hv("Incorrect invocation")},pv=yo,fv=Ie,_v=TypeError,mv=function(e){if(pv(e))return e;throw _v(fv(e)+" is not a constructor")},gv=tr,yv=mv,Sv=z,bv=lt("species"),Ev=function(e,t){var r,n=gv(e).constructor;return void 0===n||Sv(r=gv(n)[bv])?t:yv(r)},kv=TypeError,Tv=function(e,t){if(e<t)throw kv("Not enough arguments");return e},Iv=/(?:ipad|iphone|ipod).*applewebkit/i.test(se),Av=n,Rv=d,wv=Wt,Cv=A,xv=We,Pv=i,Ov=Rn,Dv=rs,Mv=It,Nv=Tv,Lv=Iv,Uv=ov,Vv=Av.setImmediate,Fv=Av.clearImmediate,Bv=Av.process,jv=Av.Dispatch,Gv=Av.Function,Hv=Av.MessageChannel,zv=Av.String,Xv=0,Kv={},qv="onreadystatechange";try{tv=Av.location}catch(eX){}var Yv=function(e){if(xv(Kv,e)){var t=Kv[e];delete Kv[e],t()}},Wv=function(e){return function(){Yv(e)}},Qv=function(e){Yv(e.data)},Jv=function(e){Av.postMessage(zv(e),tv.protocol+"//"+tv.host)};Vv&&Fv||(Vv=function(e){Nv(arguments.length,1);var t=Cv(e)?e:Gv(e),r=Dv(arguments,1);return Kv[++Xv]=function(){Rv(t,void 0,r)},rv(Xv),Xv},Fv=function(e){delete Kv[e]},Uv?rv=function(e){Bv.nextTick(Wv(e))}:jv&&jv.now?rv=function(e){jv.now(Wv(e))}:Hv&&!Lv?(iv=(nv=new Hv).port2,nv.port1.onmessage=Qv,rv=wv(iv.postMessage,iv)):Av.addEventListener&&Cv(Av.postMessage)&&!Av.importScripts&&tv&&"file:"!==tv.protocol&&!Pv(Jv)?(rv=Jv,Av.addEventListener("message",Qv,!1)):rv=qv in Mv("script")?function(e){Ov.appendChild(Mv("script")).onreadystatechange=function(){Ov.removeChild(this),Yv(e)}}:function(e){setTimeout(Wv(e),0)});var Zv,$v,ep,tp,rp,np,ip,op,ap={set:Vv,clear:Fv},sp=n,up=/ipad|iphone|ipod/i.test(se)&&void 0!==sp.Pebble,cp=/web0s(?!.*chrome)/i.test(se),dp=n,lp=Wt,hp=R.f,vp=ap.set,pp=Iv,fp=up,_p=cp,mp=ov,gp=dp.MutationObserver||dp.WebKitMutationObserver,yp=dp.document,Sp=dp.process,bp=dp.Promise,Ep=hp(dp,"queueMicrotask"),kp=Ep&&Ep.value;kp||(Zv=function(){var e,t;for(mp&&(e=Sp.domain)&&e.exit();$v;){t=$v.fn,$v=$v.next;try{t()}catch(eX){throw $v?tp():ep=void 0,eX}}ep=void 0,e&&e.enter()},pp||mp||_p||!gp||!yp?!fp&&bp&&bp.resolve?((ip=bp.resolve(void 0)).constructor=bp,op=lp(ip.then,ip),tp=function(){op(Zv)}):mp?tp=function(){Sp.nextTick(Zv)}:(vp=lp(vp,dp),tp=function(){vp(Zv)}):(rp=!0,np=yp.createTextNode(""),new gp(Zv).observe(np,{characterData:!0}),tp=function(){np.data=rp=!rp}));var Tp=kp||function(e){var t={fn:e,next:void 0};ep&&(ep.next=t),$v||($v=t,tp()),ep=t},Ip=n,Ap=function(e){try{return{error:!1,value:e()}}catch(eX){return{error:!0,value:eX}}},Rp=function(){this.head=null,this.tail=null};Rp.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 wp=Rp,Cp=n.Promise,xp="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Pp=!xp&&!ov&&"object"==typeof window&&"object"==typeof document,Op=n,Dp=Cp,Mp=A,Np=Xt,Lp=io,Up=lt,Vp=Pp,Fp=xp,Bp=pe,jp=Dp&&Dp.prototype,Gp=Up("species"),Hp=!1,zp=Mp(Op.PromiseRejectionEvent),Xp={CONSTRUCTOR:Np("Promise",(function(){var e=Lp(Dp),t=e!==String(Dp);if(!t&&66===Bp)return!0;if(!jp.catch||!jp.finally)return!0;if(!Bp||Bp<51||!/native code/.test(e)){var r=new Dp((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[Gp]=n,!(Hp=r.then((function(){}))instanceof n))return!0}return!t&&(Vp||Fp)&&!zp})),REJECTION_EVENT:zp,SUBCLASSING:Hp},Kp={},qp=Ce,Yp=TypeError,Wp=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw Yp("Bad Promise constructor");t=e,r=n})),this.resolve=qp(t),this.reject=qp(r)};Kp.f=function(e){return new Wp(e)};var Qp,Jp,Zp=Rr,$p=ov,ef=n,tf=P,rf=li,nf=Ni,of=dv,af=Ce,sf=A,uf=$,cf=vv,df=Ev,lf=ap.set,hf=Tp,vf=function(e,t){var r=Ip.console;r&&r.error&&(1==arguments.length?r.error(e):r.error(e,t))},pf=Ap,ff=wp,_f=Zi,mf=Cp,gf=Xp,yf=Kp,Sf="Promise",bf=gf.CONSTRUCTOR,Ef=gf.REJECTION_EVENT,kf=_f.getterFor(Sf),Tf=_f.set,If=mf&&mf.prototype,Af=mf,Rf=If,wf=ef.TypeError,Cf=ef.document,xf=ef.process,Pf=yf.f,Of=Pf,Df=!!(Cf&&Cf.createEvent&&ef.dispatchEvent),Mf="unhandledrejection",Nf=function(e){var t;return!(!uf(e)||!sf(t=e.then))&&t},Lf=function(e,t){var r,n,i,o=t.value,a=1==t.state,s=a?e.ok:e.fail,u=e.resolve,c=e.reject,d=e.domain;try{s?(a||(2===t.rejection&&jf(t),t.rejection=1),!0===s?r=o:(d&&d.enter(),r=s(o),d&&(d.exit(),i=!0)),r===e.promise?c(wf("Promise-chain cycle")):(n=Nf(r))?tf(n,r,u,c):u(r)):c(o)}catch(eX){d&&!i&&d.exit(),c(eX)}},Uf=function(e,t){e.notified||(e.notified=!0,hf((function(){for(var r,n=e.reactions;r=n.get();)Lf(r,e);e.notified=!1,t&&!e.rejection&&Ff(e)})))},Vf=function(e,t,r){var n,i;Df?((n=Cf.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),ef.dispatchEvent(n)):n={promise:t,reason:r},!Ef&&(i=ef["on"+e])?i(n):e===Mf&&vf("Unhandled promise rejection",r)},Ff=function(e){tf(lf,ef,(function(){var t,r=e.facade,n=e.value;if(Bf(e)&&(t=pf((function(){$p?xf.emit("unhandledRejection",n,r):Vf(Mf,r,n)})),e.rejection=$p||Bf(e)?2:1,t.error))throw t.value}))},Bf=function(e){return 1!==e.rejection&&!e.parent},jf=function(e){tf(lf,ef,(function(){var t=e.facade;$p?xf.emit("rejectionHandled",t):Vf("rejectionhandled",t,e.value)}))},Gf=function(e,t,r){return function(n){e(t,n,r)}},Hf=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,Uf(e,!0))},zf=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw wf("Promise can't be resolved itself");var n=Nf(t);n?hf((function(){var r={done:!1};try{tf(n,t,Gf(zf,r,e),Gf(Hf,r,e))}catch(eX){Hf(r,eX,e)}})):(e.value=t,e.state=1,Uf(e,!1))}catch(eX){Hf({done:!1},eX,e)}}};bf&&(Rf=(Af=function(e){cf(this,Rf),af(e),tf(Qp,this);var t=kf(this);try{e(Gf(zf,t),Gf(Hf,t))}catch(eX){Hf(t,eX)}}).prototype,(Qp=function(e){Tf(this,{type:Sf,done:!1,notified:!1,parent:!1,reactions:new ff,rejection:!1,state:0,value:void 0})}).prototype=rf(Rf,"then",(function(e,t){var r=kf(this),n=Pf(df(this,Af));return r.parent=!0,n.ok=!sf(e)||e,n.fail=sf(t)&&t,n.domain=$p?xf.domain:void 0,0==r.state?r.reactions.add(n):hf((function(){Lf(n,r)})),n.promise})),Jp=function(){var e=new Qp,t=kf(e);this.promise=e,this.resolve=Gf(zf,t),this.reject=Gf(Hf,t)},yf.f=Pf=function(e){return e===Af||undefined===e?new Jp(e):Of(e)}),Zp({global:!0,constructor:!0,wrap:!0,forced:bf},{Promise:Af}),nf(Af,Sf,!1,!0),of(Sf);var Xf=lt("iterator"),Kf=!1;try{var qf=0,Yf={next:function(){return{done:!!qf++}},return:function(){Kf=!0}};Yf[Xf]=function(){return this},Array.from(Yf,(function(){throw 2}))}catch(eX){}var Wf=function(e,t){if(!t&&!Kf)return!1;var r=!1;try{var n={};n[Xf]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(eX){}return r},Qf=Cp,Jf=Xp.CONSTRUCTOR||!Wf((function(e){Qf.all(e).then(void 0,(function(){}))})),Zf=P,$f=Ce,e_=Kp,t_=Ap,r_=Dh;Rr({target:"Promise",stat:!0,forced:Jf},{all:function(e){var t=this,r=e_.f(t),n=r.resolve,i=r.reject,o=t_((function(){var r=$f(t.resolve),o=[],a=0,s=1;r_(e,(function(e){var u=a++,c=!1;s++,Zf(r,t,e).then((function(e){c||(c=!0,o[u]=e,--s||n(o))}),i)})),--s||n(o)}));return o.error&&i(o.value),r.promise}});var n_=Rr,i_=Xp.CONSTRUCTOR;Cp&&Cp.prototype,n_({target:"Promise",proto:!0,forced:i_,real:!0},{catch:function(e){return this.then(void 0,e)}});var o_=P,a_=Ce,s_=Kp,u_=Ap,c_=Dh;Rr({target:"Promise",stat:!0,forced:Jf},{race:function(e){var t=this,r=s_.f(t),n=r.reject,i=u_((function(){var i=a_(t.resolve);c_(e,(function(e){o_(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var d_=P,l_=Kp;Rr({target:"Promise",stat:!0,forced:Xp.CONSTRUCTOR},{reject:function(e){var t=l_.f(this);return d_(t.reject,void 0,e),t.promise}});var h_=tr,v_=$,p_=Kp,f_=function(e,t){if(h_(e),v_(t)&&t.constructor===e)return t;var r=p_.f(e);return(0,r.resolve)(t),r.promise},__=Rr,m_=Cp,g_=Xp.CONSTRUCTOR,y_=f_,S_=oe("Promise"),b_=!g_;__({target:"Promise",stat:!0,forced:true},{resolve:function(e){return y_(b_&&this===S_?m_:this,e)}});var E_=P,k_=Ce,T_=Kp,I_=Ap,A_=Dh;Rr({target:"Promise",stat:!0},{allSettled:function(e){var t=this,r=T_.f(t),n=r.resolve,i=r.reject,o=I_((function(){var r=k_(t.resolve),i=[],o=0,a=1;A_(e,(function(e){var s=o++,u=!1;a++,E_(r,t,e).then((function(e){u||(u=!0,i[s]={status:"fulfilled",value:e},--a||n(i))}),(function(e){u||(u=!0,i[s]={status:"rejected",reason:e},--a||n(i))}))})),--a||n(i)}));return o.error&&i(o.value),r.promise}});var R_=P,w_=Ce,C_=oe,x_=Kp,P_=Ap,O_=Dh,D_="No one promise resolved";Rr({target:"Promise",stat:!0},{any:function(e){var t=this,r=C_("AggregateError"),n=x_.f(t),i=n.resolve,o=n.reject,a=P_((function(){var n=w_(t.resolve),a=[],s=0,u=1,c=!1;O_(e,(function(e){var d=s++,l=!1;u++,R_(n,t,e).then((function(e){l||c||(c=!0,i(e))}),(function(e){l||c||(l=!0,a[d]=e,--u||o(new r(a,D_)))}))})),--u||o(new r(a,D_))}));return a.error&&o(a.value),n.promise}});var M_=Rr,N_=Cp,L_=i,U_=oe,V_=A,F_=Ev,B_=f_,j_=N_&&N_.prototype;M_({target:"Promise",proto:!0,real:!0,forced:!!N_&&L_((function(){j_.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=F_(this,U_("Promise")),r=V_(e);return this.then(r?function(r){return B_(t,e()).then((function(){return r}))}:e,r?function(r){return B_(t,e()).then((function(){throw r}))}:e)}});var G_=ee.Promise,H_=Kp,z_=Ap;Rr({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=H_.f(this),r=z_(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var X_=G_,K_=Rr,q_=eo,Y_=E([].reverse),W_=[1,2];K_({target:"Array",proto:!0,forced:String(W_)===String(W_.reverse())},{reverse:function(){return q_(this)&&(this.length=this.length),Y_(this)}});var Q_=Us("Array").reverse,J_=ae,Z_=Q_,$_=Array.prototype,em=function(e){var t=e.reverse;return e===$_||J_($_,e)&&t===$_.reverse?Z_:t},tm=Rr,rm=eo,nm=yo,im=$,om=Nr,am=Br,sm=Q,um=Jn,cm=lt,dm=rs,lm=Ms("slice"),hm=cm("species"),vm=Array,pm=Math.max;tm({target:"Array",proto:!0,forced:!lm},{slice:function(e,t){var r,n,i,o=sm(this),a=am(o),s=om(e,a),u=om(void 0===t?a:t,a);if(rm(o)&&(r=o.constructor,(nm(r)&&(r===vm||rm(r.prototype))||im(r)&&null===(r=r[hm]))&&(r=void 0),r===vm||void 0===r))return dm(o,s,u);for(n=new(void 0===r?vm:r)(pm(u-s,0)),i=0;s<u;s++,i++)s in o&&um(n,i,o[s]);return n.length=i,n}});var fm=Us("Array").slice,_m=ae,mm=fm,gm=Array.prototype,ym=function(e){var t=e.slice;return e===gm||_m(gm,e)&&t===gm.slice?mm:t};function Sm(){Sm=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=ad||function(e,t,r){e[t]=r.value},i="function"==typeof fl?fl:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return ad(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(R){u=function(e,t,r){return e[t]=r}}function c(e,t,r,i){var o=t&&t.prototype instanceof h?t:h,a=Ll(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(R){return{type:"throw",arg:R}}}e.wrap=c;var l={};function h(){}function v(){}function p(){}var f={};u(f,o,(function(){return this}));var _=Bl&&Bl(Bl(I([])));_&&_!==t&&r.call(_,o)&&(f=_);var m=p.prototype=h.prototype=Ll(f);function g(e){var t;Nc(t=["next","throw","return"]).call(t,(function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){function i(n,o,a,s){var u=d(e[n],e,o);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==Ml(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){c.value=e,a(c)}),(function(e){return i("throw",e,a,s)}))}s(u.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 u=d(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function b(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=d(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(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"}],Nc(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:A}}function A(){return{value:void 0,done:!0}}return v.prototype=p,n(m,"constructor",{value:p,configurable:!0}),n(p,"constructor",{value:v,configurable:!0}),v.displayName=u(p,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 jl?jl(e,p):(e.__proto__=p,u(e,s,"GeneratorFunction")),e.prototype=Ll(m),e},e.awrap=function(e){return{__await:e}},g(y.prototype),u(y.prototype,a,(function(){return this})),e.AsyncIterator=y,e.async=function(t,r,n,i,o){void 0===o&&(o=X_);var a=new y(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(m),u(m,s,"Generator"),u(m,o,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return em(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,Nc(t=this.tryEntries).call(t,k),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+ym(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"),u=r.call(o,"finallyLoc");if(s&&u){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(!u)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 bm(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(eX){return void r(eX)}s.done?t(u):X_.resolve(u).then(n,i)}function Em(e){return function(){var t=this,r=arguments;return new X_((function(n,i){var o=e.apply(t,r);function a(e){bm(o,n,i,a,s,"next",e)}function s(e){bm(o,n,i,a,s,"throw",e)}a(void 0)}))}}var km=Us("Array").concat,Tm=ae,Im=km,Am=Array.prototype,Rm=function(e){var t=e.concat;return e===Am||Tm(Am,e)&&t===Am.concat?Im:t},wm="\t\n\v\f\r                 \u2028\u2029\ufeff",Cm=q,xm=gn,Pm=E("".replace),Om="[\t\n\v\f\r                 \u2028\u2029\ufeff]",Dm=RegExp("^"+Om+Om+"*"),Mm=RegExp(Om+Om+"*$"),Nm=function(e){return function(t){var r=xm(Cm(t));return 1&e&&(r=Pm(r,Dm,"")),2&e&&(r=Pm(r,Mm,"")),r}},Lm={start:Nm(1),end:Nm(2),trim:Nm(3)},Um=n,Vm=i,Fm=E,Bm=gn,jm=Lm.trim,Gm=wm,Hm=Um.parseInt,zm=Um.Symbol,Xm=zm&&zm.iterator,Km=/^[+-]?0x/i,qm=Fm(Km.exec),Ym=8!==Hm(Gm+"08")||22!==Hm(Gm+"0x16")||Xm&&!Vm((function(){Hm(Object(Xm))}))?function(e,t){var r=jm(Bm(e));return Hm(r,t>>>0||(qm(Km,r)?16:10))}:Hm;Rr({global:!0,forced:parseInt!=Ym},{parseInt:Ym});var Wm=ee.parseInt,Qm={exports:{}},Jm=i((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),Zm=i,$m=$,eg=y,tg=Jm,rg=Object.isExtensible,ng=Zm((function(){rg(1)}))||tg?function(e){return!!$m(e)&&((!tg||"ArrayBuffer"!=eg(e))&&(!rg||rg(e)))}:rg,ig=!i((function(){return Object.isExtensible(Object.preventExtensions({}))})),og=Rr,ag=E,sg=Kr,ug=$,cg=We,dg=Qt.f,lg=zn,hg=qn,vg=ng,pg=ig,fg=!1,_g=et("meta"),mg=0,gg=function(e){dg(e,_g,{value:{objectID:"O"+mg++,weakData:{}}})},yg=Qm.exports={enable:function(){yg.enable=function(){},fg=!0;var e=lg.f,t=ag([].splice),r={};r[_g]=1,e(r).length&&(lg.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===_g){t(n,i,1);break}return n},og({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:hg.f}))},fastKey:function(e,t){if(!ug(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!cg(e,_g)){if(!vg(e))return"F";if(!t)return"E";gg(e)}return e[_g].objectID},getWeakData:function(e,t){if(!cg(e,_g)){if(!vg(e))return!0;if(!t)return!1;gg(e)}return e[_g].weakData},onFreeze:function(e){return pg&&fg&&vg(e)&&!cg(e,_g)&&gg(e),e}};sg[_g]=!0;var Sg=Rr,bg=n,Eg=Qm.exports,kg=i,Tg=fr,Ig=Dh,Ag=vv,Rg=A,wg=$,Cg=Ni,xg=Qt.f,Pg=Mo.forEach,Og=w,Dg=Zi.set,Mg=Zi.getterFor,Ng=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=bg[e],u=s&&s.prototype,c={};if(Og&&Rg(s)&&(o||u.forEach&&!kg((function(){(new s).entries().next()})))){var d=(n=t((function(t,r){Dg(Ag(t,d),{type:e,collection:new s}),null!=r&&Ig(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,l=Mg(e);Pg(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in u)||o&&"clear"==e||Tg(d,e,(function(r,n){var i=l(this).collection;if(!t&&o&&!wg(r))return"get"==e&&void 0;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||xg(d,"size",{configurable:!0,get:function(){return l(this).collection.size}})}else n=r.getConstructor(t,e,i,a),Eg.enable();return Cg(n,e,!1,!0),c[e]=n,Sg({global:!0,forced:!0},c),o||r.setStrong(n,e,i),n},Lg=li,Ug=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:Lg(e,n,t[n],r);return e},Vg=Qt.f,Fg=Hn,Bg=Ug,jg=Wt,Gg=vv,Hg=z,zg=Dh,Xg=ic,Kg=oc,qg=dv,Yg=w,Wg=Qm.exports.fastKey,Qg=Zi.set,Jg=Zi.getterFor,Zg={getConstructor:function(e,t,r,n){var i=e((function(e,i){Gg(e,o),Qg(e,{type:t,index:Fg(null),first:void 0,last:void 0,size:0}),Yg||(e.size=0),Hg(i)||zg(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=Jg(t),s=function(e,t,r){var n,i,o=a(e),s=u(e,t);return s?s.value=r:(o.last=s={index:i=Wg(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),Yg?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},u=function(e,t){var r,n=a(e),i=Wg(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key==t)return r};return Bg(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,Yg?e.size=0:this.size=0},delete:function(e){var t=this,r=a(t),n=u(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),Yg?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=jg(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!!u(this,e)}}),Bg(o,r?{get:function(e){var t=u(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)}}),Yg&&Vg(o,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=Jg(t),o=Jg(n);Xg(e,t,(function(e,t){Qg(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)?Kg("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,Kg(void 0,!0))}),r?"entries":"values",!r,!0),qg(t)}};Ng("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Zg);var $g=ee.Map,ey=Wt,ty=P,ry=Ce,ny=mv,iy=z,oy=Dh,ay=[].push,sy=function(e){var t,r,n,i,o=arguments.length,a=o>1?arguments[1]:void 0;return ny(this),(t=void 0!==a)&&ry(a),iy(e)?new this:(r=[],t?(n=0,i=ey(a,o>2?arguments[2]:void 0),oy(e,(function(e){ty(ay,r,i(e,n++))}))):oy(e,ay,{that:r}),new this(r))};Rr({target:"Map",stat:!0,forced:!0},{from:sy});var uy=rs,cy=function(){return new this(uy(arguments))};Rr({target:"Map",stat:!0,forced:!0},{of:cy});var dy=P,ly=Ce,hy=tr,vy=function(){for(var e,t=hy(this),r=ly(t.delete),n=!0,i=0,o=arguments.length;i<o;i++)e=dy(r,t,arguments[i]),n=n&&e;return!!n};Rr({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:vy});var py=P,fy=Ce,_y=tr,my=function(e,t){var r,n,i=_y(this),o=fy(i.get),a=fy(i.has),s=fy(i.set);return py(a,i,e)?(r=py(o,i,e),"update"in t&&(r=t.update(r,e,i),py(s,i,e,r)),r):(n=t.insert(e,i),py(s,i,e,n),n)};Rr({target:"Map",proto:!0,real:!0,forced:!0},{emplace:my});var gy=fh,yy=tr,Sy=Wt,by=gy,Ey=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=yy(this),r=by(t),n=Sy(e,arguments.length>1?arguments[1]:void 0);return!Ey(r,(function(e,r,i){if(!n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var ky=oe,Ty=Wt,Iy=P,Ay=Ce,Ry=tr,wy=Ev,Cy=gy,xy=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=Ry(this),r=Cy(t),n=Ty(e,arguments.length>1?arguments[1]:void 0),i=new(wy(t,ky("Map"))),o=Ay(i.set);return xy(r,(function(e,r){n(r,e,t)&&Iy(o,i,e,r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var Py=tr,Oy=Wt,Dy=gy,My=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=Py(this),r=Dy(t),n=Oy(e,arguments.length>1?arguments[1]:void 0);return My(r,(function(e,r,i){if(n(r,e,t))return i(r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var Ny=tr,Ly=Wt,Uy=gy,Vy=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=Ny(this),r=Uy(t),n=Ly(e,arguments.length>1?arguments[1]:void 0);return Vy(r,(function(e,r,i){if(n(r,e,t))return i(e)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var Fy=Rr,By=P,jy=Ce,Gy=fh,Hy=Dh,zy=E([].push);Fy({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){jy(t);var r=Gy(e),n=new this,i=jy(n.has),o=jy(n.get),a=jy(n.set);return Hy(r,(function(e){var r=t(e);By(i,n,r)?zy(By(o,n,r),e):By(a,n,r,[e])}),{IS_ITERATOR:!0}),n}});var Xy=tr,Ky=gy,qy=function(e,t){return e===t||e!=e&&t!=t},Yy=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return Yy(Ky(Xy(this)),(function(t,r,n){if(qy(r,e))return n()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var Wy=P,Qy=Dh,Jy=Ce;Rr({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new this;Jy(t);var n=Jy(r.set);return Qy(e,(function(e){Wy(n,r,t(e),e)})),r}});var Zy=tr,$y=gy,eS=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){return eS($y(Zy(this)),(function(t,r,n){if(r===e)return n(t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var tS=oe,rS=Wt,nS=P,iS=Ce,oS=tr,aS=Ev,sS=gy,uS=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=oS(this),r=sS(t),n=rS(e,arguments.length>1?arguments[1]:void 0),i=new(aS(t,tS("Map"))),o=iS(i.set);return uS(r,(function(e,r){nS(o,i,n(r,e,t),r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var cS=oe,dS=Wt,lS=P,hS=Ce,vS=tr,pS=Ev,fS=gy,_S=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=vS(this),r=fS(t),n=dS(e,arguments.length>1?arguments[1]:void 0),i=new(pS(t,cS("Map"))),o=hS(i.set);return _S(r,(function(e,r){lS(o,i,e,n(r,e,t))}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var mS=Ce,gS=tr,yS=Dh;Rr({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=gS(this),r=mS(t.set),n=arguments.length,i=0;i<n;)yS(arguments[i++],r,{that:t,AS_ENTRIES:!0});return t}});var SS=tr,bS=Ce,ES=gy,kS=Dh,TS=TypeError;Rr({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=SS(this),r=ES(t),n=arguments.length<2,i=n?void 0:arguments[1];if(bS(e),kS(r,(function(r,o){n?(n=!1,i=o):i=e(i,o,r,t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),n)throw TS("Reduce of empty map with no initial value");return i}});var IS=tr,AS=Wt,RS=gy,wS=Dh;Rr({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=IS(this),r=RS(t),n=AS(e,arguments.length>1?arguments[1]:void 0);return wS(r,(function(e,r,i){if(n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var CS=P,xS=tr,PS=Ce,OS=TypeError;Rr({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=xS(this),n=PS(r.get),i=PS(r.has),o=PS(r.set),a=arguments.length;PS(t);var s=CS(i,r,e);if(!s&&a<3)throw OS("Updating absent value");var u=s?CS(n,r,e):PS(a>2?arguments[2]:void 0)(e,r);return CS(o,r,e,t(u,e,r)),r}});var DS=P,MS=Ce,NS=A,LS=tr,US=TypeError,VS=function(e,t){var r,n=LS(this),i=MS(n.get),o=MS(n.has),a=MS(n.set),s=arguments.length>2?arguments[2]:void 0;if(!NS(t)&&!NS(s))throw US("At least one callback required");return DS(o,n,e)?(r=DS(i,n,e),NS(t)&&(r=t(r),DS(a,n,e,r))):NS(s)&&(r=s(),DS(a,n,e,r)),r};Rr({target:"Map",proto:!0,real:!0,forced:!0},{upsert:VS}),Rr({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:VS});var FS=$g,BS=Ce,jS=Ke,GS=H,HS=Br,zS=TypeError,XS=function(e){return function(t,r,n,i){BS(r);var o=jS(t),a=GS(o),s=HS(o),u=e?s-1:0,c=e?-1:1;if(n<2)for(;;){if(u in a){i=a[u],u+=c;break}if(u+=c,e?u<0:s<=u)throw zS("Reduce of empty array with no initial value")}for(;e?u>=0:s>u;u+=c)u in a&&(i=r(i,a[u],u,o));return i}},KS={left:XS(!1),right:XS(!0)}.left,qS=pe,YS=ov;Rr({target:"Array",proto:!0,forced:!Ic("reduce")||!YS&&qS>79&&qS<83},{reduce:function(e){var t=arguments.length;return KS(this,e,t,t>1?arguments[1]:void 0)}});var WS=Us("Array").reduce,QS=ae,JS=WS,ZS=Array.prototype,$S=function(e){var t=e.reduce;return e===ZS||QS(ZS,e)&&t===ZS.reduce?JS:t},eb=w,tb=E,rb=P,nb=i,ib=rn,ob=ci,ab=O,sb=Ke,ub=H,cb=Object.assign,db=Object.defineProperty,lb=tb([].concat),hb=!cb||nb((function(){if(eb&&1!==cb({b:1},cb(db({},"a",{enumerable:!0,get:function(){db(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!=cb({},e)[r]||ib(cb({},t)).join("")!=n}))?function(e,t){for(var r=sb(e),n=arguments.length,i=1,o=ob.f,a=ab.f;n>i;)for(var s,u=ub(arguments[i++]),c=o?lb(ib(u),o(u)):ib(u),d=c.length,l=0;d>l;)s=c[l++],eb&&!rb(a,u,s)||(r[s]=u[s]);return r}:cb,vb=hb;Rr({target:"Object",stat:!0,arity:2,forced:Object.assign!==vb},{assign:vb});var pb=ee.Object.assign,fb=$,_b=y,mb=lt("match"),gb=function(e){var t;return fb(e)&&(void 0!==(t=e[mb])?!!t:"RegExp"==_b(e))},yb=TypeError,Sb=function(e){if(gb(e))throw yb("The method doesn't accept regular expressions");return e},bb=lt("match"),Eb=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[bb]=!1,"/./"[e](t)}catch(n){}}return!1},kb=Rr,Tb=E;R.f;var Ib=Vr,Ab=gn,Rb=Sb,wb=q,Cb=Eb,xb=Tb("".endsWith),Pb=Tb("".slice),Ob=Math.min;kb({target:"String",proto:!0,forced:!Cb("endsWith")},{endsWith:function(e){var t=Ab(wb(this));Rb(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:Ob(Ib(r),n),o=Ab(e);return xb?xb(t,o,i):Pb(t,i-o.length,i)===o}});var Db=Us("String").endsWith,Mb=ae,Nb=Db,Lb=String.prototype,Ub=function(e){var t=e.endsWith;return"string"==typeof e||e===Lb||Mb(Lb,e)&&t===Lb.endsWith?Nb:t},Vb=!0,Fb=!0;function Bb(e,t,r){var n=e.match(t);return n&&n.length>=r&&Wm(n[r],10)}function jb(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 FS),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 Gb(e){return"boolean"!=typeof e?new Error("Argument type: "+Ml(e)+". Please use a boolean."):(Vb=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function Hb(e){return"boolean"!=typeof e?new Error("Argument type: "+Ml(e)+". Please use a boolean."):(Fb=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function zb(){if("object"===("undefined"==typeof window?"undefined":Ml(window))){if(Vb)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function Xb(e,t){Fb&&console.warn(e+" is deprecated, please use "+t+" instead.")}function Kb(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=Bb(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=Bb(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=Bb(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}function qb(e){return"[object Object]"===Object.prototype.toString.call(e)}function Yb(e){var t;return qb(e)?$S(t=an(e)).call(t,(function(t,r){var n=qb(e[r]),i=n?Yb(e[r]):e[r],o=n&&!an(i).length;return void 0===i||o?t:pb(t,sd({},r,i))}),{}):e}function Wb(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),an(t).forEach((function(n){Ub(n).call(n,"Id")?Wb(e,e.get(t[n]),r):Ub(n).call(n,"Ids")&&t[n].forEach((function(t){Wb(e,e.get(t),r)}))})))}function Qb(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new FS;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&&Wb(e,r,i)}))})),i}var Jb=Rr,Zb=Mo.find,$b="find",eE=!0;$b in[]&&Array(1).find((function(){eE=!1})),Jb({target:"Array",proto:!0,forced:eE},{find:function(e){return Zb(this,e,arguments.length>1?arguments[1]:void 0)}});var tE=Us("Array").find,rE=ae,nE=tE,iE=Array.prototype,oE=function(e){var t=e.find;return e===iE||rE(iE,e)&&t===iE.find?nE:t},aE=Rr,sE=Xr.indexOf,uE=Ic,cE=E([].indexOf),dE=!!cE&&1/cE([1],1,-0)<0,lE=uE("indexOf");aE({target:"Array",proto:!0,forced:dE||!lE},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return dE?cE(this,e,t)||0:sE(this,e,t)}});var hE=Us("Array").indexOf,vE=ae,pE=hE,fE=Array.prototype,_E=function(e){var t=e.indexOf;return e===fE||vE(fE,e)&&t===fE.indexOf?pE:t},mE=w,gE=eo,yE=TypeError,SE=Object.getOwnPropertyDescriptor,bE=mE&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(eX){return eX instanceof TypeError}}(),EE=Ie,kE=TypeError,TE=function(e,t){if(!delete e[t])throw kE("Cannot delete property "+EE(t)+" of "+EE(e))},IE=Rr,AE=Ke,RE=Nr,wE=Pr,CE=Br,xE=bE?function(e,t){if(gE(e)&&!SE(e,"length").writable)throw yE("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},PE=Wd,OE=Ao,DE=Jn,ME=TE,NE=Ms("splice"),LE=Math.max,UE=Math.min;IE({target:"Array",proto:!0,forced:!NE},{splice:function(e,t){var r,n,i,o,a,s,u=AE(this),c=CE(u),d=RE(e,c),l=arguments.length;for(0===l?r=n=0:1===l?(r=0,n=c-d):(r=l-2,n=UE(LE(wE(t),0),c-d)),PE(c+r-n),i=OE(u,n),o=0;o<n;o++)(a=d+o)in u&&DE(i,o,u[a]);if(i.length=n,r<n){for(o=d;o<c-n;o++)s=o+r,(a=o+n)in u?u[s]=u[a]:ME(u,s);for(o=c;o>c-n+r;o--)ME(u,o-1)}else if(r>n)for(o=c-n;o>d;o--)s=o+r-1,(a=o+n-1)in u?u[s]=u[a]:ME(u,s);for(o=0;o<r;o++)u[o+d]=arguments[o+2];return xE(u,c-n+r),i}});var VE=Us("Array").splice,FE=ae,BE=VE,jE=Array.prototype,GE=function(e){var t=e.splice;return e===jE||FE(jE,e)&&t===jE.splice?BE:t},HE=Mo.map;Rr({target:"Array",proto:!0,forced:!Ms("map")},{map:function(e){return HE(this,e,arguments.length>1?arguments[1]:void 0)}});var zE=Us("Array").map,XE=ae,KE=zE,qE=Array.prototype,YE=function(e){var t=e.map;return e===qE||XE(qE,e)&&t===qE.map?KE:t},WE=ee,QE=d;WE.JSON||(WE.JSON={stringify:JSON.stringify});var JE=function(e,t,r){return QE(WE.JSON.stringify,null,arguments)},ZE=JE,$E=Xr.includes;Rr({target:"Array",proto:!0,forced:i((function(){return!Array(1).includes()}))},{includes:function(e){return $E(this,e,arguments.length>1?arguments[1]:void 0)}});var ek=Us("Array").includes,tk=Rr,rk=Sb,nk=q,ik=gn,ok=Eb,ak=E("".indexOf);tk({target:"String",proto:!0,forced:!ok("includes")},{includes:function(e){return!!~ak(ik(nk(this)),ik(rk(e)),arguments.length>1?arguments[1]:void 0)}});var sk=Us("String").includes,uk=ae,ck=ek,dk=sk,lk=Array.prototype,hk=String.prototype,vk=function(e){var t=e.includes;return e===lk||uk(lk,e)&&t===lk.includes?ck:"string"==typeof e||e===hk||uk(hk,e)&&t===hk.includes?dk:t},pk=zb;function fk(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==Ml(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"===Ml(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()+ym(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=Rm(t=r.optional||[]).call(t,e.advanced));return r},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(ZE(e)))&&"object"===Ml(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(ZE(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===Ml(e.video)){var a=e.video.facingMode;a=a&&("object"===Ml(a)?a:{ideal:a});var s,u=t.version<66;if(a&&("user"===a.exact||"environment"===a.exact||"user"===a.ideal||"environment"===a.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||u))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=oE(t).call(t,(function(e){return s.some((function(t){var r;return vk(r=e.label.toLowerCase()).call(r,t)}))}));return!r&&t.length&&vk(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),pk("chrome: "+ZE(e)),i(e)}));e.video=n(e.video)}return pk("chrome: "+ZE(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 X_.reject(o(e))}))}))}}}}function _k(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function mk(e){if("object"===Ml(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=oE(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=oE(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 jb(e,"track",(function(e){return e.transceiver||ad(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function gk(e){if("object"===Ml(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||[],ym(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=_E(t=this._senders).call(t,e);-1!==i&&GE(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=oE(r=t._senders).call(r,(function(t){return t.track===e}));o&&GE(n=t._senders).call(n,_E(i=t._senders).call(i,o),1)}))}}else if("object"===Ml(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 yk(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=ym(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 FS(YE(t=an(e)).call(t,(function(t){return[t,e[t]]})))};if(arguments.length>=2){var u=function(e){i(s(a(e)))};return t.apply(this,[u,n])}return new X_((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function Sk(e){if("object"===Ml(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 Qb(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}),jb(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 Qb(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?X_.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():X_.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function bk(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e,t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},YE(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===_E(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(oE(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===_E(o).call(o,e)}));this._shimmedLocalStreams[e.id]=Rm(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=_E(n=t._shimmedLocalStreams[r]).call(n,e);-1!==o&&GE(i=t._shimmedLocalStreams[r]).call(i,o,1);1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function Ek(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return bk(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},YE(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(oE(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=ym([]).call(arguments,1);if(1!==s.length||!oE(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 u=oE(i=this.getSenders()).call(i,(function(e){return e.track===t}));if(u)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var c=this._streams[r.id];if(c)c.addTrack(t),X_.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 oE(o=this.getSenders()).call(o,(function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=sd({},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]=u(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};var a=tu(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;oE(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 u(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 kk(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=sd({},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 Tk(e,t){jb(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 Ik=Object.freeze(Object.defineProperty({__proto__:null,shimMediaStream:_k,shimOnTrack:mk,shimGetSendersWithDtmf:gk,shimGetStats:yk,shimSenderReceiverGetStats:Sk,shimAddTrackRemoveTrackWithNative:bk,shimAddTrackRemoveTrack:Ek,shimPeerConnection:kk,fixNegotiationNeeded:Tk,shimGetUserMedia:fk,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"}));Rr({target:"Array",stat:!0},{isArray:eo});var Ak=ee.Array.isArray;function Rk(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 wk=uh,Ck=tr,xk=yh,Pk=Wt,Ok=P,Dk=Ke,Mk=function(e,t,r,n){try{return n?t(Ck(r)[0],r[1]):t(r)}catch(eX){xk(e,"throw",eX)}},Nk=rh,Lk=yo,Uk=Br,Vk=Jn,Fk=fh,Bk=uh,jk=Array,Gk=function(e){var t=Dk(e),r=Lk(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,u,c,d,l,h=Bk(t),v=0;if(!h||this===jk&&Nk(h))for(a=Uk(t),s=r?new this(a):jk(a);a>v;v++)l=o?i(t[v],v):t[v],Vk(s,v,l);else for(d=(c=Fk(t,h)).next,s=r?new this:[];!(u=Ok(d,c)).done;v++)l=o?Mk(c,i,[u.value,v],!0):u.value,Vk(s,v,l);return s.length=v,s},Hk=Gk;Rr({target:"Array",stat:!0,forced:!Wf((function(e){Array.from(e)}))},{from:Hk});var zk=ee.Array.from;function Xk(e,t){var r;if(e){if("string"==typeof e)return Rk(e,t);var n=ym(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?zk(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Rk(e,t):void 0}}function Kk(e){return function(e){if(Ak(e))return Rk(e)}(e)||function(e){if(void 0!==fl&&null!=wk(e)||null!=e["@@iterator"])return zk(e)}(e)||Xk(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,Yk=i,Wk=gn,Qk=Lm.trim,Jk=E("".charAt),Zk=qk.parseFloat,$k=qk.Symbol,eT=$k&&$k.iterator,tT=1/Zk("\t\n\v\f\r                 \u2028\u2029\ufeff-0")!=-1/0||eT&&!Yk((function(){Zk(Object(eT))}))?function(e){var t=Qk(Wk(e)),r=Zk(t);return 0===r&&"-"==Jk(t,0)?-0:r}:Zk;Rr({global:!0,forced:parseFloat!=tT},{parseFloat:tT});var rT=ee.parseFloat;function nT(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){Xb("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"===Ml(e)&&"object"===Ml(e.audio)&&(e=JSON.parse(ZE(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"===Ml(e)&&(e=JSON.parse(ZE(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function iT(e){"object"===Ml(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 oT(e,t){if("object"===Ml(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=sd({},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=ym(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,pb({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function aT(e){if("object"===Ml(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):X_.resolve(new FS)}}}function sT(e){if("object"===Ml(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}),jb(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function uT(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;Xb("removeStream","removeTrack"),this.getSenders().forEach((function(r){var n;r.track&&vk(n=e.getTracks()).call(n,r.track)&&t.removeTrack(r)}))})}function cT(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function dT(e){if("object"===Ml(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=Kk(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&&!(rT(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(rT(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 lT(e){if("object"===Ml(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=Rm(e=[]).call(e,this.sendEncodings||[{}]));return r})}}function hT(e){if("object"===Ml(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?X_.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function vT(e){if("object"===Ml(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?X_.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var pT=Object.freeze(Object.defineProperty({__proto__:null,shimOnTrack:iT,shimPeerConnection:oT,shimSenderGetStats:aT,shimReceiverGetStats:sT,shimRemoveStream:uT,shimRTCDataChannel:cT,shimAddTransceiver:dT,shimGetParameters:lT,shimCreateOffer:hT,shimCreateAnswer:vT,shimGetUserMedia:nT,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,X_.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}},Symbol.toStringTag,{value:"Module"}));function fT(e){if("object"===Ml(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=[]),vk(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?vk(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=_E(t=this._localStreams).call(t,e);if(-1!==i){GE(r=this._localStreams).call(r,i,1);var o=e.getTracks();this.getSenders().forEach((function(e){vk(o).call(o,e.track)&&n.removeTrack(e)}))}})}}function _T(e){if("object"===Ml(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=[]),!vk(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=[]),!(_E(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 mT(e){if("object"===Ml(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),X_.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),X_.resolve()):i};var s=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),X_.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),X_.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),X_.resolve()):n},t.addIceCandidate=s}}function gT(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(yT(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function yT(e){return e&&void 0!==e.video?pb({},e,{video:Yb(e.video)}):e}function ST(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")?(Xb("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(ZE(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 bT(e){"object"===Ml(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 ET(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=oE(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=oE(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 kT(e){"object"!==Ml(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var TT=Object.freeze(Object.defineProperty({__proto__:null,shimLocalStreamsAPI:fT,shimRemoteStreamsAPI:_T,shimCallbacksAPI:mT,shimGetUserMedia:gT,shimConstraints:yT,shimRTCIceServerUrls:ST,shimTrackEventTransceiver:bT,shimCreateOfferLegacy:ET,shimAudioContext:kT},Symbol.toStringTag,{value:"Module"})),IT=uu.PROPER,AT=i,RT=wm,wT=Lm.trim;Rr({target:"String",proto:!0,forced:function(e){return AT((function(){return!!RT[e]()||"​…᠎"!=="​…᠎"[e]()||IT&&RT[e].name!==e}))}("trim")},{trim:function(){return wT(this)}});var CT,xT,PT=Us("String").trim,OT=ae,DT=PT,MT=String.prototype,NT=function(e){var t=e.trim;return"string"==typeof e||e===MT||OT(MT,e)&&t===MT.trim?DT:t},LT={exports:{}};CT=LT,(xT={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}}).localCName=xT.generateIdentifier(),xT.splitLines=function(e){var t;return YE(t=NT(e).call(e).split("\n")).call(t,(function(e){return NT(e).call(e)}))},xT.splitSections=function(e){var t=e.split("\nm=");return YE(t).call(t,(function(e,t){var r;return NT(r=t>0?"m="+e:e).call(r)+"\r\n"}))},xT.getDescription=function(e){var t=xT.splitSections(e);return t&&t[0]},xT.getMediaSections=function(e){var t=xT.splitSections(e);return t.shift(),t},xT.matchPrefix=function(e,t){var r;return Gs(r=xT.splitLines(e)).call(r,(function(e){return 0===_E(e).call(e,t)}))},xT.parseCandidate=function(e){for(var t,r={foundation:(t=0===_E(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:Wm(t[3],10),ip:t[4],address:t[4],port:Wm(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=Wm(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},xT.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(" ")},xT.parseIceOptions=function(e){return e.substr(14).split(" ")},xT.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:Wm(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=Wm(t[1],10),r.channels=3===t.length?Wm(t[2],10):1,r.numChannels=r.channels,r},xT.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"},xT.parseExtmap=function(e){var t,r=e.substr(9).split(" ");return{id:Wm(r[0],10),direction:_E(t=r[0]).call(t,"/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},xT.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},xT.parseFmtp=function(e){for(var t,r={},n=e.substr(_E(e).call(e," ")+1).split(";"),i=0;i<n.length;i++){var o,a;t=NT(o=n[i]).call(o).split("="),r[NT(a=t[0]).call(a)]=t[1]}return r},xT.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},xT.parseRtcpFb=function(e){var t=e.substr(_E(e).call(e," ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},xT.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},xT.parseSsrcMedia=function(e){var t=_E(e).call(e," "),r={ssrc:Wm(e.substr(7,t-7),10)},n=_E(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},xT.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:YE(t).call(t,(function(e){return Wm(e,10)}))}},xT.getMid=function(e){var t=xT.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},xT.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},xT.getDtlsParameters=function(e,t){var r=xT.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:YE(r).call(r,xT.parseFingerprint)}},xT.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},xT.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:Wm(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:ym(t).call(t,3)}},xT.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===Ml(e.keyParams)?xT.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},xT.parseCryptoKeyParams=function(e){if(0!==_E(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}},xT.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},xT.getCryptoParameters=function(e,t){var r=xT.matchPrefix(e+t,"a=crypto:");return YE(r).call(r,xT.parseCryptoLine)},xT.getIceParameters=function(e,t){var r=xT.matchPrefix(e+t,"a=ice-ufrag:")[0],n=xT.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},xT.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},xT.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=xT.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],o=xT.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(o){var a,s=xT.parseRtpMap(o),u=xT.matchPrefix(e,"a=fmtp:"+i+" ");switch(s.parameters=u.length?xT.parseFmtp(u[0]):{},s.rtcpFeedback=YE(a=xT.matchPrefix(e,"a=rtcp-fb:"+i+" ")).call(a,xT.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return xT.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(xT.parseExtmap(e))})),t},xT.writeRtpDescription=function(e,t){var r,n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=YE(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+=xT.writeRtpMap(e),n+=xT.writeFmtp(e),n+=xT.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+=xT.writeExtmap(e)})),n},xT.parseRtpEncodingParameters=function(e){var t,r,n,i,o,a,s=[],u=xT.parseRtpParameters(e),c=-1!==_E(t=u.fecMechanisms).call(t,"RED"),d=-1!==_E(r=u.fecMechanisms).call(r,"ULPFEC"),l=Gs(n=YE(i=xT.matchPrefix(e,"a=ssrc:")).call(i,(function(e){return xT.parseSsrcMedia(e)}))).call(n,(function(e){return"cname"===e.attribute})),h=l.length>0&&l[0].ssrc,v=YE(o=xT.matchPrefix(e,"a=ssrc-group:FID")).call(o,(function(e){var t=e.substr(17).split(" ");return YE(t).call(t,(function(e){return Wm(e,10)}))}));v.length>0&&v[0].length>1&&v[0][0]===h&&(a=v[0][1]),u.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:h,codecPayloadType:Wm(e.parameters.apt,10)};h&&a&&(t.rtx={ssrc:a}),s.push(t),c&&((t=JSON.parse(ZE(t))).fec={ssrc:h,mechanism:d?"red+ulpfec":"red"},s.push(t))}})),0===s.length&&h&&s.push({ssrc:h});var p,f,_=xT.matchPrefix(e,"b=");return _.length&&(_=0===_E(p=_[0]).call(p,"b=TIAS:")?Wm(_[0].substr(7),10):0===_E(f=_[0]).call(f,"b=AS:")?1e3*Wm(_[0].substr(5),10)*.95-16e3:void 0,s.forEach((function(e){e.maxBitrate=_}))),s},xT.parseRtcpParameters=function(e){var t,r,n={},i=Gs(t=YE(r=xT.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return xT.parseSsrcMedia(e)}))).call(t,(function(e){return"cname"===e.attribute}))[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);var o=xT.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=o.length>0,n.compound=0===o.length;var a=xT.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},xT.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},xT.parseMsid=function(e){var t,r,n,i=xT.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(n=i[0].substr(7).split(" "))[0],track:n[1]};var o=Gs(t=YE(r=xT.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return xT.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},xT.parseSctpDescription=function(e){var t,r=xT.parseMLine(e),n=xT.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=Wm(n[0].substr(19),10)),isNaN(t)&&(t=65536);var i=xT.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:Wm(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};var o=xT.matchPrefix(e,"a=sctpmap:");if(o.length>0){var a=o[0].substr(10).split(" ");return{port:Wm(a[0],10),protocol:a[1],maxMessageSize:t}}},xT.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("")},xT.generateSessionId=function(){return Math.random().toString().substr(2,21)},xT.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||xT.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},xT.getDirection=function(e,t){for(var r=xT.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?xT.getDirection(t):"sendrecv"},xT.getKind=function(e){return xT.splitLines(e)[0].split(" ")[0].substr(2)},xT.isRejected=function(e){return"0"===e.split(" ",2)[1]},xT.parseMLine=function(e){var t=xT.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:Wm(t[1],10),protocol:t[2],fmt:ym(t).call(t,3).join(" ")}},xT.parseOLine=function(e){var t=xT.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:Wm(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},xT.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=xT.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},CT.exports=xT;var UT=LT.exports,VT=e({__proto__:null,default:UT},[LT.exports]);function FT(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){var r;if("object"===Ml(e)&&e.candidate&&0===_E(r=e.candidate).call(r,"a=")&&((e=JSON.parse(ZE(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=UT.parseCandidate(e.candidate),o=pb(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,jb(e,"icecandidate",(function(t){return t.candidate&&ad(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function BT(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||jb(e,"icecandidate",(function(e){if(e.candidate){var t=UT.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function jT(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=UT.splitSections(e.sdp);return t.shift(),t.some((function(e){var t,r=UT.parseMLine(e);return r&&"application"===r.kind&&-1!==_E(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=Wm(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=UT.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=Wm(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 u,c=n(arguments[0]),d=i(c),l=o(arguments[0],c);u=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 u}}),this._sctp=h}return a.apply(this,arguments)}}}function GT(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,this),e},jb(e,"datachannel",(function(e){return r(e.channel,e.target),e}))}function r(e,t){var r=e.send;e.send=function(){var n=arguments[0],i=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}}function HT(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 zT(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!==_E(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"!==NT(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 XT(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?X_.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),X_.resolve())})}}function KT(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"!==Ml(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:FT,shimRTCIceCandidateRelayProtocol:BT,shimMaxMessageSize:jT,shimSendThrowTypeError:GT,shimConnectionState:HT,removeExtmapAllowMixed:zT,shimAddIceCandidateNullOrEmpty:XT,shimParameterlessSetLocalDescription:KT},Symbol.toStringTag,{value:"Module"}));function YT(e,t){var r=void 0!==fl&&wk(e)||e["@@iterator"];if(!r){if(Ak(e)||(r=Xk(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 WT(e,t){return function(e){if(Ak(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==fl&&wk(e)||e["@@iterator"];if(null!=r){var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(u){s=!0,i=u}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}}(e,t)||Xk(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 QT(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}!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=zb,i=Kb(t),o={browserDetails:i,commonShim:qT,extractVersion:Bb,disableLog:Gb,disableWarnings:Hb,sdp:VT};switch(i.browser){case"chrome":if(!Ik||!kk||!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=Ik,XT(t,i),KT(t),fk(t,i),_k(t),kk(t,i),mk(t),Ek(t,i),gk(t),yk(t),Sk(t),Tk(t,i),FT(t),BT(t),HT(t),jT(t,i),GT(t),zT(t,i);break;case"firefox":if(!pT||!oT||!r.shimFirefox)return n("Firefox shim is not included in this adapter release."),o;n("adapter.js shimming firefox."),o.browserShim=pT,XT(t,i),KT(t),nT(t,i),oT(t,i),iT(t),uT(t),aT(t),sT(t),cT(t),dT(t),lT(t),hT(t),vT(t),FT(t),HT(t),jT(t,i),GT(t);break;case"safari":if(!TT||!r.shimSafari)return n("Safari shim is not included in this adapter release."),o;n("adapter.js shimming safari."),o.browserShim=TT,XT(t,i),KT(t),ST(t),ET(t),mT(t),fT(t),_T(t),bT(t),gT(t),kT(t),FT(t),BT(t),jT(t,i),GT(t),zT(t,i);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window});var JT=We,ZT=function(e){return void 0!==e&&(JT(e,"value")||JT(e,"writable"))},$T=P,eI=$,tI=tr,rI=ZT,nI=R,iI=mu;Rr({target:"Reflect",stat:!0},{get:function e(t,r){var n,i,o=arguments.length<3?t:arguments[2];return tI(t)===o?t[r]:(n=nI.f(t,r))?rI(n)?n.value:void 0===n.get?void 0:$T(n.get,o):eI(i=iI(t))?e(i,r,o):void 0}});var oI=ee.Reflect.get,aI=E,sI=Ce,uI=$,cI=We,dI=rs,lI=o,hI=Function,vI=aI([].concat),pI=aI([].join),fI={},_I=function(e,t,r){if(!cI(fI,t)){for(var n=[],i=0;i<t;i++)n[i]="a["+i+"]";fI[t]=hI("C,a","return new C("+pI(n,",")+")")}return fI[t](e,r)},mI=lI?hI.bind:function(e){var t=sI(this),r=t.prototype,n=dI(arguments,1),i=function(){var r=vI(n,dI(arguments));return this instanceof i?_I(t,r.length,r):t.apply(e,r)};return uI(r)&&(i.prototype=r),i},gI=mI;Rr({target:"Function",proto:!0,forced:Function.bind!==gI},{bind:gI});var yI=Us("Function").bind,SI=ae,bI=yI,EI=Function.prototype,kI=function(e){var t=e.bind;return e===EI||SI(EI,e)&&t===EI.bind?bI:t};function TI(e){var t;return(TI=jl?kI(t=Bl).call(t):function(e){return e.__proto__||Bl(e)})(e)}function II(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=TI(e)););return e}function AI(){var e;"undefined"!=typeof Reflect&&oI?AI=kI(e=oI).call(e):AI=function(e,t,r){var n=II(e,t);if(n){var i=tu(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}};return AI.apply(this,arguments)}function RI(e,t){var r;return(RI=jl?kI(r=jl).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function wI(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Ll(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),ad(e,"prototype",{writable:!1}),t&&RI(e,t)}var CI=Rr,xI=d,PI=mI,OI=mv,DI=tr,MI=$,NI=Hn,LI=i,UI=oe("Reflect","construct"),VI=Object.prototype,FI=[].push,BI=LI((function(){function e(){}return!(UI((function(){}),[],e)instanceof e)})),jI=!LI((function(){UI((function(){}))})),GI=BI||jI;CI({target:"Reflect",stat:!0,forced:GI,sham:GI},{construct:function(e,t){OI(e),DI(t);var r=arguments.length<3?e:OI(arguments[2]);if(jI&&!BI)return UI(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 xI(FI,n,t),new(xI(PI,e,n))}var i=r.prototype,o=NI(MI(i)?i:VI),a=xI(e,o,t);return MI(a)?a:o}});var HI=ee.Reflect.construct;function zI(e,t){if(t&&("object"===Ml(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return QT(e)}function XI(e){var t=function(){if("undefined"==typeof Reflect||!HI)return!1;if(HI.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(HI(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=TI(e);if(t){var i=TI(this).constructor;r=HI(n,arguments,i)}else r=n.apply(this,arguments);return zI(this,r)}}var KI=Us("Array").values,qI=fn,YI=We,WI=ae,QI=KI,JI=Array.prototype,ZI={DOMTokenList:!0,NodeList:!0},$I=function(e){var t=e.values;return e===JI||WI(JI,e)&&t===JI.values||YI(ZI,qI(e))?QI:t},eA=ni,tA=Math.floor,rA=function(e,t){var r=e.length,n=tA(r/2);return r<8?nA(e,t):iA(e,rA(eA(e,0,n),t),rA(eA(e,n),t),t)},nA=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},iA=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},oA=rA,aA=se.match(/firefox\/(\d+)/i),sA=!!aA&&+aA[1],uA=/MSIE|Trident/.test(se),cA=se.match(/AppleWebKit\/(\d+)\./),dA=!!cA&&+cA[1],lA=Rr,hA=E,vA=Ce,pA=Ke,fA=Br,_A=TE,mA=gn,gA=i,yA=oA,SA=Ic,bA=sA,EA=uA,kA=pe,TA=dA,IA=[],AA=hA(IA.sort),RA=hA(IA.push),wA=gA((function(){IA.sort(void 0)})),CA=gA((function(){IA.sort(null)})),xA=SA("sort"),PA=!gA((function(){if(kA)return kA<70;if(!(bA&&bA>3)){if(EA)return!0;if(TA)return TA<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++)IA.push({k:t+n,v:r})}for(IA.sort((function(e,t){return t.v-e.v})),n=0;n<IA.length;n++)t=IA[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));lA({target:"Array",proto:!0,forced:wA||!CA||!xA||!PA},{sort:function(e){void 0!==e&&vA(e);var t=pA(this);if(PA)return void 0===e?AA(t):AA(t,e);var r,n,i=[],o=fA(t);for(n=0;n<o;n++)n in t&&RA(i,t[n]);for(yA(i,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:mA(t)>mA(r)?1:-1}}(e)),r=fA(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)_A(t,n++);return t}});var OA=Us("Array").sort,DA=ae,MA=OA,NA=Array.prototype,LA=function(e){var t=e.sort;return e===NA||DA(NA,e)&&t===NA.sort?MA:t},UA=Rr,VA=Mo.findIndex,FA="findIndex",BA=!0;FA in[]&&Array(1).findIndex((function(){BA=!1})),UA({target:"Array",proto:!0,forced:BA},{findIndex:function(e){return VA(this,e,arguments.length>1?arguments[1]:void 0)}});var jA=Us("Array").findIndex,GA=ae,HA=jA,zA=Array.prototype,XA=function(e){var t=e.findIndex;return e===zA||GA(zA,e)&&t===zA.findIndex?HA:t},KA=Rr,qA=E;R.f;var YA=Vr,WA=gn,QA=Sb,JA=q,ZA=Eb,$A=qA("".startsWith),eR=qA("".slice),tR=Math.min;KA({target:"String",proto:!0,forced:!ZA("startsWith")},{startsWith:function(e){var t=WA(JA(this));QA(e);var r=YA(tR(arguments.length>1?arguments[1]:void 0,t.length)),n=WA(e);return $A?$A(t,n,r):eR(t,r,r+n.length)===n}});var rR=Us("String").startsWith,nR=ae,iR=rR,oR=String.prototype,aR=function(e){var t=e.startsWith;return"string"==typeof e||e===oR||nR(oR,e)&&t===oR.startsWith?iR:t},sR=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.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.ROOM_FORBIDDEN="ROOM_FORBIDDEN",e.USER_FORBIDDEN="USER_FORBIDDEN",e}(sR||{}),uR=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}(uR||{}),cR=Kd((function e(t,r,n){qd(this,e),sd(this,"code",void 0),sd(this,"message",void 0),sd(this,"error",void 0),this.code=t,this.message=r,this.error=n})),dR=w,lR=E,hR=rn,vR=Q,pR=lR(O.f),fR=lR([].push),_R=function(e){return function(t){for(var r,n=vR(t),i=hR(n),o=i.length,a=0,s=[];o>a;)r=i[a++],dR&&!pR(n,r)||fR(s,e?[r,n[r]]:n[r]);return s}},mR={entries:_R(!0),values:_R(!1)}.entries;Rr({target:"Object",stat:!0},{entries:function(e){return mR(e)}});var gR=ee.Object.entries,yR=Pr,SR=gn,bR=q,ER=RangeError,kR=E,TR=Vr,IR=gn,AR=function(e){var t=SR(bR(this)),r="",n=yR(e);if(n<0||n==1/0)throw ER("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},RR=q,wR=kR(AR),CR=kR("".slice),xR=Math.ceil,PR=function(e){return function(t,r,n){var i,o,a=IR(RR(t)),s=TR(r),u=a.length,c=void 0===n?" ":IR(n);return s<=u||""==c?a:((o=wR(c,xR((i=s-u)/c.length))).length>i&&(o=CR(o,0,i)),e?a+o:o+a)}},OR={start:PR(!1),end:PR(!0)},DR=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(se),MR=OR.end;Rr({target:"String",proto:!0,forced:DR},{padEnd:function(e){return MR(this,e,arguments.length>1?arguments[1]:void 0)}});var NR=Us("String").padEnd,LR=ae,UR=NR,VR=String.prototype,FR=function(e){var t=e.padEnd;return"string"==typeof e||e===VR||LR(VR,e)&&t===VR.padEnd?UR:t},BR=Ym;Rr({target:"Number",stat:!0,forced:Number.parseInt!=BR},{parseInt:BR});var jR=ee.Number.parseInt,GR=Math.log,HR=Math.LOG10E;Rr({target:"Math",stat:!0},{log10:Math.log10||function(e){return GR(e)*HR}});var zR,XR=ee.Math.log10,KR=new Uint8Array(16);function qR(){if(!zR&&!(zR="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 zR(KR)}var YR=/^(?:[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 WR(e){return"string"==typeof e&&YR.test(e)}for(var QR=[],JR=0;JR<256;++JR)QR.push((JR+256).toString(16).substr(1));function ZR(e,t,r){var n=(e=e||{}).random||(e.rng||qR)();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=(QR[e[t+0]]+QR[e[t+1]]+QR[e[t+2]]+QR[e[t+3]]+"-"+QR[e[t+4]]+QR[e[t+5]]+"-"+QR[e[t+6]]+QR[e[t+7]]+"-"+QR[e[t+8]]+QR[e[t+9]]+"-"+QR[e[t+10]]+QR[e[t+11]]+QR[e[t+12]]+QR[e[t+13]]+QR[e[t+14]]+QR[e[t+15]]).toLowerCase();if(!WR(r))throw TypeError("Stringified UUID is invalid");return r}(n)}var $R=function(){return"undefined"==typeof window},ew={};!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=ym(Array.prototype).call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==Ml(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 Rm([]).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)}(ew);var tw={},rw={},nw={},iw=ew;function ow(e){for(var t=e.length;--t>=0;)e[t]=0}var aw=256,sw=286,uw=30,cw=15,dw=[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],lw=[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],hw=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],vw=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],pw=new Array(576);ow(pw);var fw=new Array(60);ow(fw);var _w=new Array(512);ow(_w);var mw=new Array(256);ow(mw);var gw=new Array(29);ow(gw);var yw,Sw,bw,Ew=new Array(uw);function kw(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 Tw(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Iw(e){return e<256?_w[e]:_w[256+(e>>>7)]}function Aw(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function Rw(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,Aw(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 ww(e,t,r){Rw(e,r[2*t],r[2*t+1])}function Cw(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function xw(e,t,r){var n,i,o=new Array(16),a=0;for(n=1;n<=cw;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]=Cw(o[s]++,s))}}function Pw(e){var t;for(t=0;t<sw;t++)e.dyn_ltree[2*t]=0;for(t=0;t<uw;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 Ow(e){e.bi_valid>8?Aw(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 Dw(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 Mw(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&Dw(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!Dw(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function Nw(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?ww(e,i,t):(ww(e,(o=mw[i])+aw+1,t),0!==(a=dw[o])&&Rw(e,i-=gw[o],a),ww(e,o=Iw(--n),r),0!==(a=lw[o])&&Rw(e,n-=Ew[o],a))}while(s<e.last_lit);ww(e,256,t)}function Lw(e,t){var r,n,i,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,u=t.stat_desc.elems,c=-1;for(e.heap_len=0,e.heap_max=573,r=0;r<u;r++)0!==o[2*r]?(e.heap[++e.heap_len]=c=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=c<2?++c:0)]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=a[2*i+1]);for(t.max_code=c,r=e.heap_len>>1;r>=1;r--)Mw(e,o,r);i=u;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Mw(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++,Mw(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,u=t.dyn_tree,c=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,p=t.stat_desc.max_length,f=0;for(o=0;o<=cw;o++)e.bl_count[o]=0;for(u[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)(o=u[2*u[2*(n=e.heap[r])+1]+1]+1)>p&&(o=p,f++),u[2*n+1]=o,n>c||(e.bl_count[o]++,a=0,n>=v&&(a=h[n-v]),s=u[2*n],e.opt_len+=s*(o+a),l&&(e.static_len+=s*(d[2*n+1]+a)));if(0!==f){do{for(o=p-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[p]--,f-=2}while(f>0);for(o=p;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>c||(u[2*i+1]!==o&&(e.opt_len+=(o-u[2*i+1])*u[2*i],u[2*i+1]=o),n--)}}(e,t),xw(o,c,e.bl_count)}function Uw(e,t,r){var n,i,o=-1,a=t[1],s=0,u=7,c=4;for(0===a&&(u=138,c=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++s<u&&i===a||(s<c?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?(u=138,c=3):i===a?(u=6,c=3):(u=7,c=4))}function Vw(e,t,r){var n,i,o=-1,a=t[1],s=0,u=7,c=4;for(0===a&&(u=138,c=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++s<u&&i===a)){if(s<c)do{ww(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(ww(e,i,e.bl_tree),s--),ww(e,16,e.bl_tree),Rw(e,s-3,2)):s<=10?(ww(e,17,e.bl_tree),Rw(e,s-3,3)):(ww(e,18,e.bl_tree),Rw(e,s-11,7));s=0,o=i,0===a?(u=138,c=3):i===a?(u=6,c=3):(u=7,c=4)}}ow(Ew);var Fw=!1;function Bw(e,t,r,n){Rw(e,0+(n?1:0),3),function(e,t,r,n){Ow(e),n&&(Aw(e,r),Aw(e,~r)),iw.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}nw._tr_init=function(e){Fw||(!function(){var e,t,r,n,i,o=new Array(16);for(r=0,n=0;n<28;n++)for(gw[n]=r,e=0;e<1<<dw[n];e++)mw[r++]=n;for(mw[r-1]=n,i=0,n=0;n<16;n++)for(Ew[n]=i,e=0;e<1<<lw[n];e++)_w[i++]=n;for(i>>=7;n<uw;n++)for(Ew[n]=i<<7,e=0;e<1<<lw[n]-7;e++)_w[256+i++]=n;for(t=0;t<=cw;t++)o[t]=0;for(e=0;e<=143;)pw[2*e+1]=8,e++,o[8]++;for(;e<=255;)pw[2*e+1]=9,e++,o[9]++;for(;e<=279;)pw[2*e+1]=7,e++,o[7]++;for(;e<=287;)pw[2*e+1]=8,e++,o[8]++;for(xw(pw,287,o),e=0;e<uw;e++)fw[2*e+1]=5,fw[2*e]=Cw(e,5);yw=new kw(pw,dw,257,sw,cw),Sw=new kw(fw,lw,0,uw,cw),bw=new kw(new Array(0),hw,0,19,7)}(),Fw=!0),e.l_desc=new Tw(e.dyn_ltree,yw),e.d_desc=new Tw(e.dyn_dtree,Sw),e.bl_desc=new Tw(e.bl_tree,bw),e.bi_buf=0,e.bi_valid=0,Pw(e)},nw._tr_stored_block=Bw,nw._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<aw;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),Lw(e,e.l_desc),Lw(e,e.d_desc),a=function(e){var t;for(Uw(e,e.dyn_ltree,e.l_desc.max_code),Uw(e,e.dyn_dtree,e.d_desc.max_code),Lw(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*vw[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?Bw(e,t,r,n):4===e.strategy||o===i?(Rw(e,2+(n?1:0),3),Nw(e,pw,fw)):(Rw(e,4+(n?1:0),3),function(e,t,r,n){var i;for(Rw(e,t-257,5),Rw(e,r-1,5),Rw(e,n-4,4),i=0;i<n;i++)Rw(e,e.bl_tree[2*vw[i]+1],3);Vw(e,e.dyn_ltree,t-1),Vw(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),Nw(e,e.dyn_ltree,e.dyn_dtree)),Pw(e),n&&Ow(e)},nw._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*(mw[r]+aw+1)]++,e.dyn_dtree[2*Iw(t)]++),e.last_lit===e.lit_bufsize-1},nw._tr_align=function(e){Rw(e,2,3),ww(e,256,pw),function(e){16===e.bi_valid?(Aw(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 jw=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 Gw=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 Hw,zw=function(e,t,r,n){var i=Gw,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},Xw={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"},Kw=ew,qw=nw,Yw=jw,Ww=zw,Qw=Xw,Jw=-2,Zw=258,$w=262,eC=103,tC=113,rC=666;function nC(e,t){return e.msg=Qw[t],t}function iC(e){return(e<<1)-(e>4?9:0)}function oC(e){for(var t=e.length;--t>=0;)e[t]=0}function aC(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(Kw.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 sC(e,t){qw._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,aC(e.strm)}function uC(e,t){e.pending_buf[e.pending++]=t}function cC(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function dC(e,t){var r,n,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,u=e.strstart>e.w_size-$w?e.strstart-(e.w_size-$w):0,c=e.window,d=e.w_mask,l=e.prev,h=e.strstart+Zw,v=c[o+a-1],p=c[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(c[(r=t)+a]===p&&c[r+a-1]===v&&c[r]===c[o]&&c[++r]===c[o+1]){o+=2,r++;do{}while(c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&o<h);if(n=Zw-(h-o),o=h-Zw,n>a){if(e.match_start=t,a=n,n>=s)break;v=c[o+a-1],p=c[o+a]}}}while((t=l[t&d])>u&&0!=--i);return a<=e.lookahead?a:e.lookahead}function lC(e){var t,r,n,i,o,a,s,u,c,d,l=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=l+(l-$w)){Kw.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,u=e.strstart+e.lookahead,c=i,d=void 0,(d=a.avail_in)>c&&(d=c),r=0===d?0:(a.avail_in-=d,Kw.arraySet(s,a.input,a.next_in,d,u),1===a.state.wrap?a.adler=Yw(a.adler,s,d,u):2===a.state.wrap&&(a.adler=Ww(a.adler,s,d,u)),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<$w&&0!==e.strm.avail_in)}function hC(e,t){for(var r,n;;){if(e.lookahead<$w){if(lC(e),e.lookahead<$w&&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-$w&&(e.match_length=dC(e,r)),e.match_length>=3)if(n=qw._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=qw._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(sC(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(sC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(sC(e,!1),0===e.strm.avail_out)?1:2}function vC(e,t){for(var r,n,i;;){if(e.lookahead<$w){if(lC(e),e.lookahead<$w&&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-$w&&(e.match_length=dC(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=qw._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&&(sC(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=qw._tr_tally(e,0,e.window[e.strstart-1]))&&sC(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=qw._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(sC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(sC(e,!1),0===e.strm.avail_out)?1:2}function pC(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 fC(){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 Kw.Buf16(1146),this.dyn_dtree=new Kw.Buf16(122),this.bl_tree=new Kw.Buf16(78),oC(this.dyn_ltree),oC(this.dyn_dtree),oC(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Kw.Buf16(16),this.heap=new Kw.Buf16(573),oC(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Kw.Buf16(573),oC(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:tC,e.adler=2===t.wrap?0:1,t.last_flush=0,qw._tr_init(t),0):nC(e,Jw)}function mC(e){var t,r=_C(e);return 0===r&&((t=e.state).window_size=2*t.w_size,oC(t.head),t.max_lazy_match=Hw[t.level].max_lazy,t.good_match=Hw[t.level].good_length,t.nice_match=Hw[t.level].nice_length,t.max_chain_length=Hw[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 gC(e,t,r,n,i,o){if(!e)return Jw;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 nC(e,Jw);8===n&&(n=9);var s=new fC;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 Kw.Buf8(2*s.w_size),s.head=new Kw.Buf16(s.hash_size),s.prev=new Kw.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new Kw.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,mC(e)}Hw=[new pC(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(lC(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,sC(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-$w&&(sC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(sC(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(sC(e,!1),e.strm.avail_out),1)})),new pC(4,4,8,4,hC),new pC(4,5,16,8,hC),new pC(4,6,32,32,hC),new pC(4,4,16,16,vC),new pC(8,16,32,32,vC),new pC(8,16,128,128,vC),new pC(8,32,128,256,vC),new pC(32,128,258,1024,vC),new pC(32,258,258,4096,vC)],rw.deflateInit=function(e,t){return gC(e,t,8,15,8,0)},rw.deflateInit2=gC,rw.deflateReset=mC,rw.deflateResetKeep=_C,rw.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?Jw:(e.state.gzhead=t,0):Jw},rw.deflate=function(e,t){var r,n,i,o;if(!e||!e.state||t>5||t<0)return e?nC(e,Jw):Jw;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===rC&&4!==t)return nC(e,0===e.avail_out?-5:Jw);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,uC(n,31),uC(n,139),uC(n,8),n.gzhead?(uC(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)),uC(n,255&n.gzhead.time),uC(n,n.gzhead.time>>8&255),uC(n,n.gzhead.time>>16&255),uC(n,n.gzhead.time>>24&255),uC(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),uC(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(uC(n,255&n.gzhead.extra.length),uC(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Ww(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(uC(n,0),uC(n,0),uC(n,0),uC(n,0),uC(n,0),uC(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),uC(n,3),n.status=tC);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=tC,cC(n,a),0!==n.strstart&&(cC(n,e.adler>>>16),cC(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=Ww(e.adler,n.pending_buf,n.pending-i,i)),aC(e),i=n.pending,n.pending!==n.pending_buf_size));)uC(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=Ww(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=Ww(e.adler,n.pending_buf,n.pending-i,i)),aC(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,uC(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=Ww(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=Ww(e.adler,n.pending_buf,n.pending-i,i)),aC(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,uC(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=Ww(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=eC)}else n.status=eC;if(n.status===eC&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&aC(e),n.pending+2<=n.pending_buf_size&&(uC(n,255&e.adler),uC(n,e.adler>>8&255),e.adler=0,n.status=tC)):n.status=tC),0!==n.pending){if(aC(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&iC(t)<=iC(r)&&4!==t)return nC(e,-5);if(n.status===rC&&0!==e.avail_in)return nC(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&n.status!==rC){var s=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(lC(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=qw._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(sC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(sC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(sC(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<=Zw){if(lC(e),e.lookahead<=Zw&&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+Zw;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=Zw-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=qw._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=qw._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(sC(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(sC(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(sC(e,!1),0===e.strm.avail_out)?1:2}(n,t):Hw[n.level].func(n,t);if(3!==s&&4!==s||(n.status=rC),1===s||3===s)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===s&&(1===t?qw._tr_align(n):5!==t&&(qw._tr_stored_block(n,0,0,!1),3===t&&(oC(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),aC(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(uC(n,255&e.adler),uC(n,e.adler>>8&255),uC(n,e.adler>>16&255),uC(n,e.adler>>24&255),uC(n,255&e.total_in),uC(n,e.total_in>>8&255),uC(n,e.total_in>>16&255),uC(n,e.total_in>>24&255)):(cC(n,e.adler>>>16),cC(n,65535&e.adler)),aC(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)},rw.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==eC&&t!==tC&&t!==rC?nC(e,Jw):(e.state=null,t===tC?nC(e,-3):0):Jw},rw.deflateSetDictionary=function(e,t){var r,n,i,o,a,s,u,c,d=t.length;if(!e||!e.state)return Jw;if(2===(o=(r=e.state).wrap)||1===o&&42!==r.status||r.lookahead)return Jw;for(1===o&&(e.adler=Yw(e.adler,t,d,0)),r.wrap=0,d>=r.w_size&&(0===o&&(oC(r.head),r.strstart=0,r.block_start=0,r.insert=0),c=new Kw.Buf8(r.w_size),Kw.arraySet(c,t,d-r.w_size,r.w_size,0),t=c,d=r.w_size),a=e.avail_in,s=e.next_in,u=e.input,e.avail_in=d,e.next_in=0,e.input=t,lC(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,lC(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=u,e.avail_in=a,r.wrap=o,0},rw.deflateInfo="pako deflate (from Nodeca project)";var yC={},SC=ew,bC=!0,EC=!0;try{String.fromCharCode.apply(null,[0])}catch(tX){bC=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(tX){EC=!1}for(var kC=new SC.Buf8(256),TC=0;TC<256;TC++)kC[TC]=TC>=252?6:TC>=248?5:TC>=240?4:TC>=224?3:TC>=192?2:1;function IC(e,t){if(t<65534&&(e.subarray&&EC||!e.subarray&&bC))return String.fromCharCode.apply(null,SC.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}kC[254]=kC[254]=1,yC.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 SC.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},yC.buf2binstring=function(e){return IC(e,e.length)},yC.binstring2buf=function(e){for(var t=new SC.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},yC.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=kC[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 IC(s,n)},yC.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+kC[e[r]]>t?r:t};var AC=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},RC=rw,wC=ew,CC=yC,xC=Xw,PC=AC,OC=Object.prototype.toString;function DC(e){if(!(this instanceof DC))return new DC(e);this.options=wC.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 PC,this.strm.avail_out=0;var r=RC.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==r)throw new Error(xC[r]);if(t.header&&RC.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?CC.string2buf(t.dictionary):"[object ArrayBuffer]"===OC.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(r=RC.deflateSetDictionary(this.strm,n)))throw new Error(xC[r]);this._dict_set=!0}}function MC(e,t){var r=new DC(t);if(r.push(e,!0),r.err)throw r.msg||xC[r.err];return r.result}DC.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=CC.string2buf(e):"[object ArrayBuffer]"===OC.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 wC.Buf8(o),i.next_out=0,i.avail_out=o),1!==(r=RC.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(CC.buf2binstring(wC.shrinkBuf(i.output,i.next_out))):this.onData(wC.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=RC.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==n||(this.onEnd(0),i.avail_out=0,!0)},DC.prototype.onData=function(e){this.chunks.push(e)},DC.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=wC.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},tw.Deflate=DC,tw.deflate=MC,tw.deflateRaw=function(e,t){return(t=t||{}).raw=!0,MC(e,t)},tw.gzip=function(e,t){return(t=t||{}).gzip=!0,MC(e,t)};var NC={},LC=tr,UC=P,VC=We,FC=ae,BC=function(){var e=LC(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},jC=RegExp.prototype,GC=ae,HC=function(e){var t=e.flags;return void 0!==t||"flags"in jC||VC(e,"flags")||!FC(jC,e)?t:UC(BC,e)},zC=RegExp.prototype,XC=function(e){return e===zC||GC(zC,e)?HC(e):e.flags},KC={},qC=ew,YC=15,WC=[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],QC=[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],JC=[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],ZC=[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],$C=ew,ex=jw,tx=zw,rx=function(e,t){var r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A;r=e.state,n=e.next_in,I=e.input,i=n+(e.avail_in-5),o=e.next_out,A=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),u=r.dmax,c=r.wsize,d=r.whave,l=r.wnext,h=r.window,v=r.hold,p=r.bits,f=r.lencode,_=r.distcode,m=(1<<r.lenbits)-1,g=(1<<r.distbits)-1;e:do{p<15&&(v+=I[n++]<<p,p+=8,v+=I[n++]<<p,p+=8),y=f[v&m];t:for(;;){if(v>>>=S=y>>>24,p-=S,0===(S=y>>>16&255))A[o++]=65535&y;else{if(!(16&S)){if(0==(64&S)){y=f[(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)&&(p<S&&(v+=I[n++]<<p,p+=8),b+=v&(1<<S)-1,v>>>=S,p-=S),p<15&&(v+=I[n++]<<p,p+=8,v+=I[n++]<<p,p+=8),y=_[v&g];r:for(;;){if(v>>>=S=y>>>24,p-=S,!(16&(S=y>>>16&255))){if(0==(64&S)){y=_[(65535&y)+(v&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(E=65535&y,p<(S&=15)&&(v+=I[n++]<<p,(p+=8)<S&&(v+=I[n++]<<p,p+=8)),(E+=v&(1<<S)-1)>u){e.msg="invalid distance too far back",r.mode=30;break e}if(v>>>=S,p-=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+=c-S,S<b){b-=S;do{A[o++]=h[k++]}while(--S);k=o-E,T=A}}else if(l<S){if(k+=c+l-S,(S-=l)<b){b-=S;do{A[o++]=h[k++]}while(--S);if(k=0,l<b){b-=S=l;do{A[o++]=h[k++]}while(--S);k=o-E,T=A}}}else if(k+=l-S,S<b){b-=S;do{A[o++]=h[k++]}while(--S);k=o-E,T=A}for(;b>2;)A[o++]=T[k++],A[o++]=T[k++],A[o++]=T[k++],b-=3;b&&(A[o++]=T[k++],b>1&&(A[o++]=T[k++]))}else{k=o-E;do{A[o++]=A[k++],A[o++]=A[k++],A[o++]=A[k++],b-=3}while(b>2);b&&(A[o++]=A[k++],b>1&&(A[o++]=A[k++]))}break}}break}}while(n<i&&o<s);n-=b=p>>3,v&=(1<<(p-=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=p},nx=function(e,t,r,n,i,o,a,s){var u,c,d,l,h,v,p,f,_,m=s.bits,g=0,y=0,S=0,b=0,E=0,k=0,T=0,I=0,A=0,R=0,w=null,C=0,x=new qC.Buf16(16),P=new qC.Buf16(16),O=null,D=0;for(g=0;g<=YC;g++)x[g]=0;for(y=0;y<n;y++)x[t[r+y]]++;for(E=m,b=YC;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<=YC;g++)if(I<<=1,(I-=x[g])<0)return-1;if(I>0&&(0===e||1!==b))return-1;for(P[1]=0,g=1;g<YC;g++)P[g+1]=P[g]+x[g];for(y=0;y<n;y++)0!==t[r+y]&&(a[P[t[r+y]]++]=y);if(0===e?(w=O=a,v=19):1===e?(w=WC,C-=257,O=QC,D-=257,v=256):(w=JC,O=ZC,v=-1),R=0,y=0,g=S,h=o,k=E,T=0,d=-1,l=(A=1<<E)-1,1===e&&A>852||2===e&&A>592)return 1;for(;;){p=g-T,a[y]<v?(f=0,_=a[y]):a[y]>v?(f=O[D+a[y]],_=w[C+a[y]]):(f=96,_=0),u=1<<g-T,S=c=1<<k;do{i[h+(R>>T)+(c-=u)]=p<<24|f<<16|_|0}while(0!==c);for(u=1<<g-1;R&u;)u>>=1;if(0!==u?(R&=u-1,R+=u):R=0,y++,0==--x[g]){if(g===b)break;g=t[r+a[y]]}if(g>E&&(R&l)!==d){for(0===T&&(T=E),h+=S,I=1<<(k=g-T);k+T<b&&!((I-=x[k+T])<=0);)k++,I<<=1;if(A+=1<<k,1===e&&A>852||2===e&&A>592)return 1;i[d=R&l]=E<<24|k<<16|h-o|0}}return 0!==R&&(i[h+R]=g-T<<24|64<<16|0),s.bits=E,0},ix=-2,ox=12,ax=30;function sx(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function ux(){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 $C.Buf16(320),this.work=new $C.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function cx(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 $C.Buf32(852),t.distcode=t.distdyn=new $C.Buf32(592),t.sane=1,t.back=-1,0):ix}function dx(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,cx(e)):ix}function lx(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)?ix:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,dx(e))):ix}function hx(e,t){var r,n;return e?(n=new ux,e.state=n,n.window=null,0!==(r=lx(e,t))&&(e.state=null),r):ix}var vx,px,fx=!0;function _x(e){if(fx){var t;for(vx=new $C.Buf32(512),px=new $C.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(nx(1,e.lens,0,288,vx,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;nx(2,e.lens,0,32,px,0,e.work,{bits:5}),fx=!1}e.lencode=vx,e.lenbits=9,e.distcode=px,e.distbits=5}function mx(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 $C.Buf8(o.wsize)),n>=o.wsize?($C.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),$C.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?($C.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}KC.inflateReset=dx,KC.inflateReset2=lx,KC.inflateResetKeep=cx,KC.inflateInit=function(e){return hx(e,15)},KC.inflateInit2=hx,KC.inflate=function(e,t){var r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A=0,R=new $C.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 ix;(r=e.state).mode===ox&&(r.mode=13),a=e.next_out,i=e.output,u=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,c=r.hold,d=r.bits,l=s,h=u,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--,c+=n[o++]<<d,d+=8}if(2&r.wrap&&35615===c){r.check=0,R[0]=255&c,R[1]=c>>>8&255,r.check=tx(r.check,R,2,0),c=0,d=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",r.mode=ax;break}if(8!=(15&c)){e.msg="unknown compression method",r.mode=ax;break}if(d-=4,E=8+(15&(c>>>=4)),0===r.wbits)r.wbits=E;else if(E>r.wbits){e.msg="invalid window size",r.mode=ax;break}r.dmax=1<<E,e.adler=r.check=1,r.mode=512&c?10:ox,c=0,d=0;break;case 2:for(;d<16;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if(r.flags=c,8!=(255&XC(r))){e.msg="unknown compression method",r.mode=ax;break}if(57344&XC(r)){e.msg="unknown header flags set",r.mode=ax;break}r.head&&(r.head.text=c>>8&1),512&XC(r)&&(R[0]=255&c,R[1]=c>>>8&255,r.check=tx(r.check,R,2,0)),c=0,d=0,r.mode=3;case 3:for(;d<32;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}r.head&&(r.head.time=c),512&XC(r)&&(R[0]=255&c,R[1]=c>>>8&255,R[2]=c>>>16&255,R[3]=c>>>24&255,r.check=tx(r.check,R,4,0)),c=0,d=0,r.mode=4;case 4:for(;d<16;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}r.head&&(r.head.xflags=255&c,r.head.os=c>>8),512&XC(r)&&(R[0]=255&c,R[1]=c>>>8&255,r.check=tx(r.check,R,2,0)),c=0,d=0,r.mode=5;case 5:if(1024&XC(r)){for(;d<16;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}r.length=c,r.head&&(r.head.extra_len=c),512&XC(r)&&(R[0]=255&c,R[1]=c>>>8&255,r.check=tx(r.check,R,2,0)),c=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&XC(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)),$C.arraySet(r.head.extra,n,o,v,E)),512&XC(r)&&(r.check=tx(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&XC(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&XC(r)&&(r.check=tx(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&XC(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&XC(r)&&(r.check=tx(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&XC(r)){for(;d<16;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if(c!==(65535&r.check)){e.msg="header crc mismatch",r.mode=ax;break}c=0,d=0}r.head&&(r.head.hcrc=XC(r)>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=ox;break;case 10:for(;d<32;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}e.adler=r.check=sx(c),c=0,d=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=a,e.avail_out=u,e.next_in=o,e.avail_in=s,r.hold=c,r.bits=d,2;e.adler=r.check=1,r.mode=ox;case ox:if(5===t||6===t)break e;case 13:if(r.last){c>>>=7&d,d-=7&d,r.mode=27;break}for(;d<3;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}switch(r.last=1&c,d-=1,3&(c>>>=1)){case 0:r.mode=14;break;case 1:if(_x(r),r.mode=20,6===t){c>>>=2,d-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=ax}c>>>=2,d-=2;break;case 14:for(c>>>=7&d,d-=7&d;d<32;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",r.mode=ax;break}if(r.length=65535&c,c=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>u&&(v=u),0===v)break e;$C.arraySet(i,n,o,v,a),s-=v,o+=v,u-=v,a+=v,r.length-=v;break}r.mode=ox;break;case 17:for(;d<14;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if(r.nlen=257+(31&c),c>>>=5,d-=5,r.ndist=1+(31&c),c>>>=5,d-=5,r.ncode=4+(15&c),c>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=ax;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;d<3;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}r.lens[w[r.have++]]=7&c,c>>>=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=nx(0,r.lens,0,19,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid code lengths set",r.mode=ax;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=(A=r.lencode[c&(1<<r.lenbits)-1])>>>16&255,g=65535&A,!((_=A>>>24)<=d);){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if(g<16)c>>>=_,d-=_,r.lens[r.have++]=g;else{if(16===g){for(I=_+2;d<I;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if(c>>>=_,d-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=ax;break}E=r.lens[r.have-1],v=3+(3&c),c>>>=2,d-=2}else if(17===g){for(I=_+3;d<I;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}d-=_,E=0,v=3+(7&(c>>>=_)),c>>>=3,d-=3}else{for(I=_+7;d<I;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}d-=_,E=0,v=11+(127&(c>>>=_)),c>>>=7,d-=7}if(r.have+v>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=ax;break}for(;v--;)r.lens[r.have++]=E}}if(r.mode===ax)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=ax;break}if(r.lenbits=9,T={bits:r.lenbits},k=nx(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=ax;break}if(r.distbits=6,r.distcode=r.distdyn,T={bits:r.distbits},k=nx(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=ax;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(s>=6&&u>=258){e.next_out=a,e.avail_out=u,e.next_in=o,e.avail_in=s,r.hold=c,r.bits=d,rx(e,h),a=e.next_out,i=e.output,u=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,c=r.hold,d=r.bits,r.mode===ox&&(r.back=-1);break}for(r.back=0;m=(A=r.lencode[c&(1<<r.lenbits)-1])>>>16&255,g=65535&A,!((_=A>>>24)<=d);){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if(m&&0==(240&m)){for(y=_,S=m,b=g;m=(A=r.lencode[b+((c&(1<<y+S)-1)>>y)])>>>16&255,g=65535&A,!(y+(_=A>>>24)<=d);){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}c>>>=y,d-=y,r.back+=y}if(c>>>=_,d-=_,r.back+=_,r.length=g,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=ox;break}if(64&m){e.msg="invalid literal/length code",r.mode=ax;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--,c+=n[o++]<<d,d+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=(A=r.distcode[c&(1<<r.distbits)-1])>>>16&255,g=65535&A,!((_=A>>>24)<=d);){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if(0==(240&m)){for(y=_,S=m,b=g;m=(A=r.distcode[b+((c&(1<<y+S)-1)>>y)])>>>16&255,g=65535&A,!(y+(_=A>>>24)<=d);){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}c>>>=y,d-=y,r.back+=y}if(c>>>=_,d-=_,r.back+=_,64&m){e.msg="invalid distance code",r.mode=ax;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--,c+=n[o++]<<d,d+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=ax;break}r.mode=25;case 25:if(0===u)break e;if(v=h-u,r.offset>v){if((v=r.offset-v)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=ax;break}v>r.wnext?(v-=r.wnext,p=r.wsize-v):p=r.wnext-v,v>r.length&&(v=r.length),f=r.window}else f=i,p=a-r.offset,v=r.length;v>u&&(v=u),u-=v,r.length-=v;do{i[a++]=f[p++]}while(--v);0===r.length&&(r.mode=21);break;case 26:if(0===u)break e;i[a++]=r.length,u--,r.mode=21;break;case 27:if(r.wrap){for(;d<32;){if(0===s)break e;s--,c|=n[o++]<<d,d+=8}if(h-=u,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=XC(r)?tx(r.check,i,h,a-h):ex(r.check,i,h,a-h)),h=u,(XC(r)?c:sx(c))!==r.check){e.msg="incorrect data check",r.mode=ax;break}c=0,d=0}r.mode=28;case 28:if(r.wrap&&XC(r)){for(;d<32;){if(0===s)break e;s--,c+=n[o++]<<d,d+=8}if(c!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=ax;break}c=0,d=0}r.mode=29;case 29:k=1;break e;case ax:k=-3;break e;case 31:return-4;default:return ix}return e.next_out=a,e.avail_out=u,e.next_in=o,e.avail_in=s,r.hold=c,r.bits=d,(r.wsize||h!==e.avail_out&&r.mode<ax&&(r.mode<27||4!==t))&&mx(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=XC(r)?tx(r.check,i,h,e.next_out-h):ex(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===ox?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===h||4===t)&&0===k&&(k=-5),k},KC.inflateEnd=function(e){if(!e||!e.state)return ix;var t=e.state;return t.window&&(t.window=null),e.state=null,0},KC.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?ix:(r.head=t,t.done=!1,0):ix},KC.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?ix:11===r.mode&&ex(1,t,n,0)!==r.check?-3:mx(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,0):ix},KC.inflateInfo="pako inflate (from Nodeca project)";var gx={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 yx=KC,Sx=ew,bx=yC,Ex=gx,kx=Xw,Tx=AC,Ix=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},Ax=Object.prototype.toString;function Rx(e){if(!(this instanceof Rx))return new Rx(e);this.options=Sx.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 Tx,this.strm.avail_out=0;var r=yx.inflateInit2(this.strm,t.windowBits);if(r!==Ex.Z_OK)throw new Error(kx[r]);if(this.header=new Ix,yx.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=bx.string2buf(t.dictionary):"[object ArrayBuffer]"===Ax.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=yx.inflateSetDictionary(this.strm,t.dictionary))!==Ex.Z_OK))throw new Error(kx[r])}function wx(e,t){var r=new Rx(t);if(r.push(e,!0),r.err)throw r.msg||kx[r.err];return r.result}Rx.prototype.push=function(e,t){var r,n,i,o,a,s=this.strm,u=this.options.chunkSize,c=this.options.dictionary,d=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?Ex.Z_FINISH:Ex.Z_NO_FLUSH,"string"==typeof e?s.input=bx.binstring2buf(e):"[object ArrayBuffer]"===Ax.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 Sx.Buf8(u),s.next_out=0,s.avail_out=u),(r=yx.inflate(s,Ex.Z_NO_FLUSH))===Ex.Z_NEED_DICT&&c&&(r=yx.inflateSetDictionary(this.strm,c)),r===Ex.Z_BUF_ERROR&&!0===d&&(r=Ex.Z_OK,d=!1),r!==Ex.Z_STREAM_END&&r!==Ex.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==Ex.Z_STREAM_END&&(0!==s.avail_in||n!==Ex.Z_FINISH&&n!==Ex.Z_SYNC_FLUSH)||("string"===this.options.to?(i=bx.utf8border(s.output,s.next_out),o=s.next_out-i,a=bx.buf2string(s.output,i),s.next_out=o,s.avail_out=u-o,o&&Sx.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(Sx.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!==Ex.Z_STREAM_END);return r===Ex.Z_STREAM_END&&(n=Ex.Z_FINISH),n===Ex.Z_FINISH?(r=yx.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Ex.Z_OK):n!==Ex.Z_SYNC_FLUSH||(this.onEnd(Ex.Z_OK),s.avail_out=0,!0)},Rx.prototype.onData=function(e){this.chunks.push(e)},Rx.prototype.onEnd=function(e){e===Ex.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Sx.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},NC.Inflate=Rx,NC.inflate=wx,NC.inflateRaw=function(e,t){return(t=t||{}).raw=!0,wx(e,t)},NC.ungzip=wx;var Cx={};(0,ew.assign)(Cx,tw,NC,gx);var xx,Px=Cx,Ox="BytePlusRTC",Dx=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},Mx=function(){function e(t){qd(this,e),sd(this,"storeName",void 0),sd(this,"pendingList",[]),this.storeName=t,!$R()&&Dx()&&this._checkAndCreateStore(t)}var t,r;return Kd(e,[{key:"_checkAndCreateStore",value:function(t,r){var n=this;e.db&&e.db.close();var i=r?Dx().open(Ox,r):Dx().open(Ox);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=Em(Sm().mark((function e(t){var r,i,o,a;return Sm().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 X_((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=Em(Sm().mark((function e(t,r){var n;return Sm().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 X_((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=Em(Sm().mark((function e(t){var r;return Sm().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 X_((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}();sd(Mx,"db",void 0),sd(Mx,"state","init");var Nx,Lx={product_line:"rtc",report_version:"5",os:"web",user_agent:$R()?"":null===(xx=navigator)||void 0===xx?void 0:xx.userAgent,platform:"web",product:"webrtc",app_state:"active"},Ux="ReportErrorBuffer",Vx=function(){function e(){qd(this,e),sd(this,"_buffer",new Mx(Ux))}var t,r;return Kd(e,[{key:"set",value:(r=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._buffer.put(t,Ux);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"get",value:(t=Em(Sm().mark((function e(){var t;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.prev=1,e.next=4,this._buffer.get(Ux);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}(),Fx=function(){function e(){var t=this;qd(this,e),sd(this,"report_common",Lx),sd(this,"dataBuffer",[]),sd(this,"posting",!1),sd(this,"sucSendTimer",void 0),sd(this,"preSucTime",0),sd(this,"errSendTimer",void 0),sd(this,"errSendDelay",100),sd(this,"errSendBuffer",void 0),sd(this,"_logServerUrl",void 0),sd(this,"_retryCount",0),$R()||(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 Kd(e,[{key:"setUrl",value:function(e){this._logServerUrl=e}},{key:"setCommonStats",value:function(e){this.report_common=pb(this.report_common,e)}},{key:"enableErrorBuffer",value:function(){this.errSendBuffer=new Vx,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=Rm(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||GE(r=this.dataBuffer).call(r,0,4e3),header:cd(cd({},this.report_common),{},{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,u;if(e||(i.posting=!1),200===a.status||304===a.status)try{r=JSON.parse(a.responseText)}catch(eX){n=eX}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;pP(Rm(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===(u=i.errSendBuffer)||void 0===u||u.set(Kk(i.dataBuffer)),t?i._send():i._errSend()}},a.open("POST",this._logServerUrl,!0),e||(this.posting=!0),!$R()&&vk(n=location.search).call(n,"_rtc_debug_"))a.send(ZE(o));else{var s=Px.gzip(ZE(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=Em(Sm().mark((function e(){var t,r,n=this;return Sm().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}(),Bx=new Fx,jx=function(){function e(t){qd(this,e),sd(this,"report_id",0),sd(this,"modify_ids",{}),this.id=t}return Kd(e,[{key:"report",value:function(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=cd(cd(cd({event_key:e,report_id:this.report_id++,rtc_timestamp:Date.now()},this.modify_ids),t),{},{common_extra_info:ZE(i)});(Bx.push(o),$R())||(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,this.id,o))}},{key:"set",value:function(e){this.modify_ids=pb(this.modify_ids,e)}},{key:"destroy",value:function(){}}]),e}(),Gx=Us("Array").keys,Hx=fn,zx=We,Xx=ae,Kx=Gx,qx=Array.prototype,Yx={DOMTokenList:!0,NodeList:!0},Wx=function(e){var t=e.keys;return e===qx||Xx(qx,e)&&t===qx.keys||zx(Yx,Hx(e))?Kx:t},Qx="@byted/ve-rtc",Jx="@byted/ve-rtc-cache-size",Zx=function(){function e(){qd(this,e),sd(this,"storeKey",void 0),sd(this,"logLevel",void 0),sd(this,"LogfileSize",void 0),sd(this,"db",void 0),sd(this,"logId",void 0),sd(this,"cacheLog",void 0),sd(this,"cachedSize",void 0),sd(this,"preCacheTime",void 0),sd(this,"timer",void 0),sd(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 Kd(e,[{key:"_createStore",value:function(){var e=this;if(!$R()&&window.indexedDB){var t=indexedDB.open("@byted/ve-rtc");t.onupgradeneeded=function(){t.result.createObjectStore(Qx);try{localStorage.removeItem(Jx)}catch(eX){}},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(Jx);if(t)this.cachedSize=+t;else $I(this).call(this).then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(eX){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(Jx,"".concat(this.cachedSize))}catch(eX){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(Qx,e).objectStore(Qx)}},{key:"set",value:function(e){var t=this;return new X_((function(r,n){if("none"===t.logLevel)return r();var i;if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+=Rm(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,u,c,d,l=Rm(i="".concat(a.result||"")).call(i,t.cacheLog),h=e?Rm(s=Rm(u="".concat(l?"\n\n":"")).call(u,t.logId,": ")).call(s,e):"";o.put(Rm(c="".concat(l)).call(c,h),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize([Rm(d="".concat(t.cacheLog)).call(d,h)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(p){var v;if(!e)return n(p);t.cacheLog+=Rm(v="\n\n".concat(t.logId,": ")).call(v,e),t.logId++,n(p)}},a.onerror=function(r){var i;if(!e)return n(r);t.cacheLog+=Rm(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new X_((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 X_((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 Wx(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 X_((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 X_((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,"+(t||""),r.click()}))}}]),e}(),$x=new Zx,eP="[VERTC]",tP=["#0050b3","#0050b3","#0050b3","#0050b3","#0050b3"],rP="undefined"!=typeof window&&vk(Nx=window.location.search).call(Nx,"_rtc_debug_"),nP=function(){function e(t,r,n){qd(this,e),sd(this,"_indent",void 0),sd(this,"_module",void 0),sd(this,"_id",void 0),this._module=t,this._indent=r}return Kd(e,[{key:"print",value:function(e){for(var t,r,n,i,o,a,s,u=arguments.length,c=new Array(u>1?u-1:0),d=1;d<u;d++)c[d-1]=arguments[d];var l=c.shift();try{var h,v,p,f,_=Rm(h=[]).call(h,c),m="".concat(l).replace(/\%o/gi,(function(){var e=_.shift();return ZE(e)}));$x.set(Rm(v=Rm(p=Rm(f="".concat(eP,"[").concat(this._module,".")).call(f,e,"] ")).call(p,m," ")).call(v,YE(_).call(_,(function(e){return ZE(e)})).join(", ")))}catch(eX){}if(rP){for(var g="",y=0;y<this._indent;y++)g+=" ";(t=console).log.apply(t,Rm(r=[Rm(n=Rm(i=Rm(o=Rm(a=Rm(s="%c".concat(iP(),"-")).call(s,eP)).call(a,g,"[")).call(o,this._module,".")).call(i,e,"] ")).call(n,l),"color:".concat(tP[this._indent],";")]).call(r,c))}}}]),e}(),iP=function(){var e=new Date;return e.toTimeString().split(" ")[0]+":"+e.getMilliseconds()},oP=new nP("MessageReportor",1),aP=function(){function e(t){qd(this,e),sd(this,"_preTime",Date.now()),sd(this,"_one2oneNum",0),sd(this,"_one2manyNum",0),sd(this,"_one2oneMsgCache",new FS),sd(this,"_one2manyMsgCache",new FS),sd(this,"roomId",""),sd(this,"userId",""),sd(this,"rtsSessionId",""),this.id=t}return Kd(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,cd({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,cd(cd({},r),t))}},{key:"cacheCustomMsg",value:function(t){var r;this._one2manyMsgCache.set(t.msg_id,cd({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,cd(cd({},r),t))}},{key:"reportP2PMsg",value:function(e){var t,r=this._one2oneMsgCache.get(e);r&&(oP.print("reportP2PMsg",r.type,ZE(r)),null===(t=mP(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportOne2ManyMsg",value:function(e){var t,r=this._one2manyMsgCache.get(e);r&&(oP.print("reportOne2ManyMsg",r.type,ZE(r)),null===(t=mP(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)||"",oP.print("reportMsgRecv",t.type,ZE(t)),null===(n=mP(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}();sd(aP,"config",void 0);var sP=new FS,uP={_cache:sP,setConfig:function(e){oP.print("setConfig","get config: "+ZE(e)),aP.config=e},setRtsSessionId:function(e,t){var r=sP.get(e);r&&(r.rtsSessionId=t)},createRTSMsgReportor:function(e){var t=sP.get(e)||new aP(e);return sP.set(e,t),t},destroyRTSMsgReportor:function(e){var t=sP.get(e);t&&(t.destroy(),sP.delete(e))},setRoomId:function(e,t){var r=sP.get(e);r&&(r.roomId=t||"")},setUserId:function(e,t){var r=sP.get(e);r&&(r.userId=t||"")},samplingP2PMsg:function(e,t){var r=sP.get(e);if(null!=r&&r.needReport("one2one")){var n,i=Rm(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&&t.report_msg_id&&(null===(n=sP.get(e))||void 0===n||n.updateP2PMsg(Rm(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&&t.report_msg_id){var n,i,o=sP.get(e);null==o||o.updateP2PMsg(Rm(n="".concat(t.from)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportP2PMsg(Rm(i="".concat(t.from)).call(i,t.report_msg_id))}},samplingOne2ManyMsg:function(e,t,r){var n,i=sP.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:Rm(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&&t.report_msg_id){var n,i=sP.get(e),o=t.to?"one2one":"one2many";null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Rm(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&&t.report_msg_id){var n,i,o=sP.get(e);if(o)null==o||o.updateOne2ManyMsg(Rm(n="".concat(t.clientId)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportOne2ManyMsg(Rm(i="".concat(t.clientId)).call(i,t.report_msg_id))}},updateOne2ManyMsgReq:function(e,t,r){if(t.enable_report&&t.report_msg_id){var n,i=sP.get(e);if(i)i.updateOne2ManyMsg(Rm(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&&t.report_msg_id){var n,i=sP.get(e);null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Rm(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})}}},cP=function(){function e(t){qd(this,e),sd(this,"_timer",void 0),sd(this,"userMessage",{}),sd(this,"roomMessage",{}),this.id=t,this._setTimer()}return Kd(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=mP(this.id))||void 0===e||e.report("rtc_message_statistics",{dc_user_message:YE(t=an(this.userMessage)).call(t,(function(e){return n.userMessage[e]})),dc_room_message:YE(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[Rm(r="".concat(t,"-")).call(r,e)]||(this.userMessage[Rm(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: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[Rm(n="".concat(t,"-")).call(n,e)].dc_send_total++,r)&&this.userMessage[Rm(i="".concat(t,"-")).call(i,e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){var r;this._checkInitUserMessage(e,t),this.userMessage[Rm(r="".concat(t,"-")).call(r,e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n,i=this.userMessage[Rm(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)&&(vk(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[Rm(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: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}(),dP=function(e){Bx.setCommonStats(e)},lP=function(e){Bx.setUrl(e)},hP=new jx("global"),vP=function(e,t,r){hP.report("rtc_sdk_api_call",{sdk_api_name:e,error_code:t,message:r})},pP=function(e,t,r){hP.report("rtc_error",{message:e,error_code:t},r)},fP=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;hP.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)},_P=new FS,mP=function(e){return _P.get(e)};function gP(){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,u,c=this.engineId||this.id,d={};(t.forEach((function(e,t){d[e]=o[t]})),"joinRoom"===r)&&(null===(s=mP(c))||void 0===s||s.set({room_id:o[1],user_id:null===(u=o[2])||void 0===u?void 0:u.userId}));null===(e=mP(c))||void 0===e||e.report("rtc_sdk_api_call",{sdk_api_name:r,message:ZE(bP(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 yP(c,r,[e||{}]),e})).catch((function(e){throw yP(c,r,e.message,e.code),e})):(yP(c,r,[l||{}]),l)}}}}var yP=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:ZE(Array.isArray(r)?bP(r):r)};o&&(a.room_id=o),null===(n=mP(e))||void 0===n||n.report("rtc_sdk_callback",a)},SP=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=mP(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 bP(e){return YE(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 u,c,d,l,h=new DataView(o),v=YE(u=zk({length:5})).call(u,(function(e,t){return h.getUint8(t)})),p=YE(c=YE(d=zk({length:5})).call(d,(function(e,t){return a-1-t})).reverse()).call(c,(function(e){return h.getUint8(e)}));s=Rm(l=[]).call(l,Kk(v),["..."],Kk(p))}else s=zk(new Uint8Array(o));return Rm(n=Rm(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return YE(t).call(t,e);if(vk(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 EP,kP,TP,IP,AP,RP,wP,CP,xP=function(e){var t,r=mP(e.engineId),n={keys:Wx(e),labelSelector:"",sdkVersion:e.sdkVersion,deviceType:"web",appId:e.appId},i=YE(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:ZE(n),elapse:0,host:i.join(","),type:"request",config_id:"",enable_cloud_proxy:!1});var o=YE(i).call(i,function(){var e=Em(Sm().mark((function e(t,r){var i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"POST",body:ZE(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 X_((function(e){(function(e){return new X_((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:ZE(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})}))}))},PP=new TextDecoder,OP=new TextEncoder,DP=function(){return ZR()},MP=function(){return Date.now()};function NP(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 u=new e(t),c=0,d=0,l=n;d<l.length;d++){var h=l[d];u.set(h,c),c+=h.length}return u}var LP=function(){return"undefined"==typeof window},UP=function(){function e(){qd(this,e)}var t,r;return Kd(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=gR(t);n<i.length;n++){var o=WT(i[n],2),a=o[0],s=o[1];null!==s&&"object"===Ml(s)?e.merge(t[a],r[a]):void 0!==r[a]&&(t[a]=r[a])}}},{key:"ab2str",value:function(e){return PP.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 OP.encode(e).buffer}},{key:"ab2b64str",value:(r=Em(Sm().mark((function e(t){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new X_((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=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch("data:application/octet;base64,"+t).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();function VP(){var e="none";return LP()||(null!==window.navigator.userAgent.match("Firefox")?e="mozilla":null!==window.navigator.userAgent.match("Chrome")?(e="chrome-stable",null!==window.navigator.userAgent.match("Electron")&&(e="electron")):(null!==window.navigator.userAgent.match("Safari")||null!==window.navigator.userAgent.match("AppleWebKit"))&&(e="safari")),e}var FP=function(){if("chrome-stable"===VP()){var e=window.navigator.userAgent.match(/Chrome\/([\d.]+)/);if(e&&e.length>1)if(Number(e[1].split(".")[0])<114)return!0}return!1}(),BP="mozilla"===VP(),jP="safari"===VP(),GP=0,HP=!LP()&&(null===(EP=navigator.userAgent.match(/version\/(\d+)/i))||void 0===EP?void 0:EP[1]);jP&&HP&&(GP=+HP);var zP=!LP()&&(null===(kP=navigator.userAgent.match(/Firefox\/(\d+)/i))||void 0===kP?void 0:kP[1]);BP&&zP&&(GP=+zP);var XP=GP,KP=GP,qP=!LP()&&!!/(iPhone|iPad|iPod)/i.exec(navigator.userAgent);!LP()&&/(iPhone|iPod)/i.exec(navigator.userAgent);var YP=!LP()&&(!!/(iPad)/i.exec(navigator.userAgent)||/Macintosh/i.test(navigator.userAgent)&&"ontouchend"in document),WP=!LP()&&/MicroMessenger/i.test(navigator.userAgent),QP=!LP()&&/Android/i.test(navigator.userAgent),JP=!LP()&&vk(TP=navigator.userAgent.toLowerCase()).call(TP,"mobile"),ZP=0,$P=!LP()&&(null===(IP=navigator.userAgent.match(/chrome\/(\d+)/i))||void 0===IP?void 0:IP[1]);$P&&(ZP=+$P);var eO=ZP,tO=null!==(AP=!LP()&&(null===(RP=navigator.userAgent.match(/ ([\d_]+) like Mac OS X/i))||void 0===RP||null===(wP=RP[1])||void 0===wP?void 0:YE(CP=wP.split("_")).call(CP,(function(e){return Wm(e)}))))&&void 0!==AP?AP:[],rO=!LP()&&/CriOS/i.test(navigator.userAgent);function nO(){for(var e,t,r=(+FR(e=ym(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=FR(r).call(r,28,"1").split(""),i=[];n.length;)i.push(GE(n).call(n,0,7));return YE(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return jR(r+e.join(""),2)}))}!LP()&&/SM-\w+/i.test(navigator.userAgent);var iO=function(){return Math.floor(65535*Math.random())};function oO(e){return"string"==typeof e&&_E(e).call(e,"__web__rtc__rtt__")>-1}var aO=function(){var e=Em(Sm().mark((function e(){var t,r,n,i=arguments;return Sm().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)}}(),sO=function(e){return new X_((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 uO(e){return+Math.max(-127,10*XR(Math.pow(e/255,2))).toFixed(2)}function cO(e){return(e&Sd.AUDIO)===Sd.AUDIO}function dO(e){return(e&Sd.VIDEO)===Sd.VIDEO}function lO(e){var t={};return an(e).forEach((function(r){"object"===Ml(e[r])?t[r]=lO(e[r]):aR(r).call(r,"_")||(t[r]=e[r])})),t}function hO(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 vO(e){return null==e?"undefined | null":"string"==typeof e?e:ZE({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function pO(e){return void 0===e}function fO(e){return function(t,r,n){var i=n.value;n.value=function(){var t;console.warn(Rm(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 _O(e){console.warn("[RTC WebSDK]: "+e)}function mO(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 gO="BytePlus",yO="RTC_DEVICE_ID",SO="RTC_ACCESS_NODE",bO="RTC_ACCESS_URLS",EO="ENGINE_WEB_CONFIG",kO=function(){function e(){qd(this,e)}return Kd(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,ZE(n)),!0}catch(i){return!1}}},{key:"delete",value:function(e){try{return localStorage.removeItem(e),!0}catch(t){return!1}}}]),e}(),TO=function(e){wI(r,e);var t=XI(r);function r(){return qd(this,r),t.apply(this,arguments)}return Kd(r,[{key:"getDeviceId",value:function(){if(LP())return"";var e=this.get(yO);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 dP({device_id:e}),this.set(yO,e),e}},{key:"getAccessNode",value:function(e){var t;return this.get(Rm(t="".concat(SO,"_").concat(e,"-")).call(t,gO))}},{key:"setAccessNode",value:function(e,t,r){var n;return this.set(Rm(n="".concat(SO,"_").concat(e,"-")).call(n,gO),t,1e3*r)}},{key:"clearAccessNode",value:function(e){var t;this.delete(Rm(t="".concat(SO,"_").concat(e,"-")).call(t,gO))}},{key:"getAccessUrls",value:function(){return this.get("".concat(bO,"-").concat(gO))}},{key:"setAccessUrls",value:function(e){var t=YE(e).call(e,(function(e){var t,r=e.host,n=e.path;return Rm(t="https://".concat(r)).call(t,n)}));return this.set("".concat(bO,"-").concat(gO),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(bO,"-").concat(gO))}},{key:"getEngineWebConfig",value:function(e,t){var r,n,i,o=Rm(r=Rm(n="".concat(e,"_")).call(n,t,"_")).call(r,this.getDeviceId()),a=this.get(EO);return(null==a||null===(i=oE(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=Rm(n=Rm(i="".concat(e,"_")).call(i,t,"_")).call(n,this.getDeviceId()),a=this.get(EO)||[];return(a=Gs(a).call(a,(function(e){return e.key!==o}))).push({key:o,config:r}),this.set(EO,ym(a).call(a,-5))}}}]),r}(kO),IO=new TO,AO="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function RO(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://"+e),"".concat(e,"/dispatch/v1/AccessInfo?Action=GetAccessInfo")}var wO="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",CO="rtc.rtcplus.com".split(","),xO={VERSION:"4.52.5",ICE_CONFIG_REQUEST_URLS_INTERNAL:YE(AO).call(AO,RO),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:wO,CONFIG_REQUEST_DOMAINS:CO,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,ENABLE_REPORT_ERROR_BUFFER:!1,PUB_SUB_MODE:"recv_and_send"};function PO(e,t){var r;if(vP("setParameter",0,Rm(r="key: ".concat(e,", value: ")).call(r,t)),"VERSION"!==e){if("ICE_CONFIG_REQUEST_URLS"===e)return"string"==typeof t&&(t=[t]),void(xO.ICE_CONFIG_REQUEST_URLS=YE(t).call(t,RO));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(xO.FORCE_ENABLED_REPORT_CALLBACKS=t);if("LOG_SERVER_URL"===e){var n=t===Td.overseas?"https://web-log-report.rtcplus.com/video/v1/webrtc_log/":t===Td.domestic?wO:"string"==typeof t?t:void 0;n&&(xO.LOG_SERVER_URL=n,lP(n))}else if("OVERSEA"===e)return dP({extra_is_oversea:t?"1":"0"}),void(xO.OVERSEA=t);"DEVICE_ID"===e&&IO.setDeviceId(t),"ENABLE_REPORT_ERROR_BUFFER"===e&&t&&Bx.enableErrorBuffer(),xO[e]=t}else dP({product:t});else dP({platform:t})}}function OO(e){return"DEVICE_ID"===e?IO.getDeviceId():xO[e]}function DO(e,t,r){var n,i,o,a,s,u,c,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)||Rd.PREV_FRAME,canvas:{bgColor:(null===(u=r.layout)||void 0===u?void 0:u.backgroundColor)||"#000000",bgImage:(null===(c=r.layout)||void 0===c?void 0:c.backgroundImage)||""},regions:(null===(d=r.layout)||void 0===d||null===(l=d.regions)||void 0===l?void 0:YE(l).call(l,(function(e){return{roomId:e.roomId,userId:e.userId,alterImage:e.alertImage||"",alpha:!e.alpha||+e.alpha>1||+e.alpha<=0?1:+e.alpha,x:!e.x||+e.x>=1||+e.x<0?0:+e.x,y:!e.y||+e.y>=1||+e.y<0?0:+e.y,w:!e.w||+e.w>1||+e.w<=0?1:+e.w,h:!e.h||+e.h>1||+e.h<=0?1:+e.h,zorder:!e.zorder||+e.zorder<0||+e.zorder>100?0:+e.zorder,renderMode:void 0===e.renderMode?1:e.renderMode,streamType:e.isScreenStream?1:0,mediaType:e.mediaType||0,sourceCrop:e.sourceCrop}})))||[]}}}}var MO={width:640,height:480,frameRate:15,maxKbps:600},NO={width:1920,height:1080,frameRate:15,maxKbps:3e3};function LO(e,t){if("boolean"!=typeof e)throw new cR(sR.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}function UO(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 cR(sR.INVALID_PARAMS,Rm(i=Rm(o="Invalid ".concat(t,": the value range is [")).call(o,r,", ")).call(i,n,"]. integer only"));throw a}}function VO(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 cR(sR.INVALID_PARAMS,"".concat(t," cannot be empty"));if(!zO(e,i,o))throw new cR(sR.INVALID_PARAMS,Rm(r=Rm(n="Invalid ".concat(t,": The value should be string type. Length of the string: [")).call(n,i,",")).call(r,o,"]"))}function FO(e,t,r){var n;if(!vk(r).call(r,e))throw new cR(sR.INVALID_PARAMS,Rm(n="Invalid ".concat(t,": The value can only be set as ")).call(n,ZE(r)))}function BO(e){if(!(e instanceof MediaStreamTrack))throw new cR(sR.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}function jO(e,t){if(XO(e))throw new cR(sR.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function GO(e,t){if(!(e instanceof ArrayBuffer))throw new cR(sR.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function HO(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 zO(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 XO(e){return null==e}function KO(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new cR(sR.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function qO(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new cR(sR.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function YO(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new cR(sR.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function WO(e){jO(e,"userInfo"),qO(e.userId),XO(e.extraInfo)||VO(e.extraInfo,"userInfo.extraInfo",1,200)}function QO(e){jO(e,"roomConfig"),LO(e.isAutoPublish,"roomConfig.isAutoPublish"),LO(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),LO(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo"),XO(e.roomProfileType)||FO(e.roomProfileType,"roomConfig",[Od.communication,Od.chat,Od.chatRoom,Od.coHost,Od.meeting,Od.classRoom])}function JO(e){jO(e,"videoPlayerOption")}function ZO(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 cR(sR.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:UP.str2ab(ZE(e)))||void 0===t?void 0:t.byteLength)>1e3*r)throw new cR(sR.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function $O(e){var t,r=OO("FORCE_ENABLED_REPORT_CALLBACKS");return!(null==r||!vk(r).call(r,e))||!vk(t=[zd.onRemoteStreamStats,zd.onLocalStreamStats,zd.onAudioVolumeIndication,zd.onLocalAudioPropertiesReport,zd.onRemoteAudioPropertiesReport]).call(t,e)}function eD(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new cR(sR.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}function tD(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 cR(sR.INVALID_PARAMS,"".concat(t," is not a valid ConstrainULong"))}}function rD(e){var t,r=YT(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;UO(null==n?void 0:n.maxKbps,"maxKbps"),tD(null==n?void 0:n.width,"width"),tD(null==n?void 0:n.height,"height"),tD(null==n?void 0:n.frameRate,"frameRate")}}catch(i){r.e(i)}finally{r.f()}}function nD(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 UO(e,t,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),e=(e=e>r?e:r)<n?e:n}var iD={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),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],s]:e._events[u].push(s):(e._events[u]=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?ym(n).call(n,1):n);return xs?Rm(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 u,c,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(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];d.fn.apply(d.context,u)}else{var h,v=d.length;for(c=0;c<v;c++)switch(d[c].once&&this.removeListener(e,d[c].fn,void 0,!0),l){case 1:d[c].fn.call(d[c].context);break;case 2:d[c].fn.call(d[c].context,t);break;case 3:d[c].fn.call(d[c].context,t,n);break;case 4:d[c].fn.call(d[c].context,t,n,i);break;default:if(!u)for(h=1,u=new Array(l-1);h<l;h++)u[h-1]=arguments[h];d[c].fn.apply(d[c].context,u)}}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 u=0,c=[],d=s.length;u<d;u++)(s[u].fn!==t||i&&!s[u].once||n&&s[u].context!==n)&&c.push(s[u]);c.length?this._events[o]=1===c.length?c[0]:c: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}(iD);var oD=iD.exports,aD=new nP("VERTC",0),sD=function(e){wI(r,e);var t=XI(r);function r(){return qd(this,r),t.apply(this,arguments)}return Kd(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=AI(TI(r.prototype),"emit",this)).call.apply(n,Rm(i=[this,e]).call(i,a))}catch(eX){return aD.print("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,eX),console.error(eX),Boolean(t)}}}]),r}(iD.exports.EventEmitter),uD=P,cD=tr,dD=$,lD=ZT,hD=Qt,vD=R,pD=mu,fD=V;Rr({target:"Reflect",stat:!0,forced:i((function(){var e=function(){},t=hD.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],u=vD.f(cD(t),r);if(!u){if(dD(o=pD(t)))return e(o,r,n,s);u=fD(0)}if(lD(u)){if(!1===u.writable||!dD(s))return!1;if(i=vD.f(s,r)){if(i.get||i.set||!1===i.writable)return!1;i.value=n,hD.f(s,r,i)}else hD.f(s,r,fD(0,n))}else{if(void 0===(a=u.set))return!1;uD(a,s,n)}return!0}});var _D=ee.Reflect.set;function mD(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],_E(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],_E(t).call(t,r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var gD,yD=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}(yD||{}),SD=function(e){return e.PushLimitWarn="PushLimitWarn",e}(SD||{}),bD=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}(bD||{}),ED=function(e){return e.RSCP="RSCP",e.RTT="RTT",e.SSC="SSC",e}(ED||{}),kD=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e}(kD||{}),TD=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(TD||{}),ID=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(ID||{}),AD=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(AD||{}),RD=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}(RD||{}),wD=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}(wD||{}),CD=(sd(gD={},0,[0,"success"]),sd(gD,1,[sR.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),sd(gD,2,[sR.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),sd(gD,3,[sR.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),sd(gD,4,[sR.USER_MESSAGE_NO_RECEIVER,"cannot find relay path."]),sd(gD,5,[sR.USER_MESSAGE_EXCEED_QPS,"cannot find relay path."]),sd(gD,17,[sR.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),sd(gD,18,[sR.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),sd(gD,100,[sR.USER_MESSAGE_NOT_JOIN,"not join room"]),sd(gD,105,[sR.USER_MESSAGE_NOT_LOGIN,"not login."]),sd(gD,106,[sR.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),sd(gD,1e3,[sR.USER_MESSAGE_UNKNOWN,"unknown."]),gD),xD=["msg"],PD=new nP("DataChannelSignaling",3),OD=["onSpeakerChange"],DD=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}(DD||{}),MD=function(e){wI(a,e);var t,r,n,i,o=XI(a);function a(e,t){var r;return qd(this,a),sd(QT(r=o.call(this)),"_singlingCache",new FS),sd(QT(r),"_p2pCache",new FS),sd(QT(r),"_rttIds",{}),sd(QT(r),"_p2pMessageId",0),sd(QT(r),"_clearDataChannelListener",void 0),sd(QT(r),"_monitor",void 0),r.id=e,r._dataChannel=t,r._clearDataChannelListener=r._handleHandler(),r._monitor=mP(e),window.__rtc_mock_signaling__=r.emit.bind(QT(r)),r}return Kd(a,[{key:"destroy",value:function(){this._dataChannel&&(this._clearDataChannelListener(),this._dataChannel.close()),this._singlingCache.clear(),this._p2pCache.clear(),this._p2pMessageId=0,this._rttIds={}}},{key:"sendSignaling",value:function(e,t,r){var n,i=this;return null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:ZE(t),signaling_event:"call-".concat(e),signaling_type:"Send",stream_id:t.streamId,stream_user_id:t.streamUserId,direction:"up"}),new X_((function(n,o){var a,s=i._genHeader(r);s.id=nO();var u=s.id.join("-"),c="customMessage"===e;c&&uP.samplingOne2ManyMsg(i.id,+s.id.join(""),t);var d=setTimeout((function(){i._singlingCache.delete(u),o(new cR(sR.TIME_OUT,"".concat(e," message time out"))),c&&uP.updateOne2ManyMsgAck(i.id,t,999)}),6e4);i._singlingCache.set(u,{signalingType:e,success:function(e){clearTimeout(d),n(e),c&&uP.updateOne2ManyMsgAck(i.id,t,0)},error:function(e){clearTimeout(d),o(e),c&&uP.updateOne2ManyMsgAck(i.id,t,e.code)}}),PD.print("Signal",Rm(a=">>>>>> [".concat(e,"][")).call(a,u,"]"),t),i._sendMessage(e,s,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(i=Em(Sm().mark((function e(t,r){var n,i,o;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,i=mD(t,xD),o=n instanceof ArrayBuffer,e.t0=this,e.t1=uP,e.t2=this.id,e.t3=cd,e.t4=cd({ver:1,id:this._p2pMessageId++,time:Date.now(),dir:AD.SEND,type:RD.P2P,err:wD.SUCCESS},i),e.t5={},e.t6=o,!o){e.next=15;break}return e.next=12,UP.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 oO(e.msg)?this._rttIds[e.id]=e.id:e.dir===AD.SEND&&PD.print("_sendP2PMessage [DC Signaling p2p >>]",ZE(e)),new X_((function(n,i){var o=t._genHeader(cd(cd({needAck:!0,functionType:1},r),{},{id:nO()}));if(e.dir===AD.SEND){var a=setTimeout((function(){t._p2pCache.delete(e.id),i(new cR(sR.USER_MESSAGE_TIMEOUT,"P2P message timeout")),uP.updateP2PMsgAck(t.id,e,999)}),12e3);t._p2pCache.set(e.id,{success:function(r,i){clearTimeout(a),n(i),uP.updateP2PMsgAck(t.id,e,0)},error:function(r){var n;clearTimeout(a),uP.updateP2PMsgAck(t.id,e,r.err);var o=WT(CD[r.err]||[sR.USER_MESSAGE_UNKNOWN,Rm(n="err: ".concat(r.err,", msg: ")).call(n,r.msg)],2),s=o[0],u=o[1];i({err:r.err,code:s,message:r.msg||u})}})}try{t._sendMessage("p2p",o,e)}catch(s){throw s.code===sR.SIGNALING_CHANNEL_NOT_OPEN&&(s.code=sR.USER_MESSAGE_BROKEN),s}}))}},{key:"_sendMessage",value:function(e,t,r){var n;if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new cR(sR.SIGNALING_CHANNEL_NOT_OPEN,"DataChannel not open");var i=t.version+(+t.zip<<5)+(+t.encrypt<<6),o=+t.needAck+(+t.direction<<1)+(+t.functionType<<2)+(+t.binary<<6),a=UP.str2ab(ZE([e,r])),s=NP(Uint8Array,Rm(n=[i,o]).call(n,Kk(t.id||[])),new Uint8Array(a));this._dataChannel.send(s.buffer),"p2p"===e?uP.updateP2PMsgReq(this.id,r,s.buffer.byteLength):"customMessage"===e&&uP.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=zk(ym(t).call(t,2,r))}return{header:o,data:ym(t).call(t,r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n,i,o=this._genHeader({needAck:!0,direction:1,id:YE(n=e.split("-")).call(n,(function(e){return+e}))});vk(OD).call(OD,t)||PD.print("Signal",Rm(i=">>>>>> [".concat(t,"-res][")).call(i,e,"]"));this._sendMessage("".concat(t,"-res"),o,r)}},{key:"_handleMessage",value:(n=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d;return Sm().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 Px.Inflate).push(o,!0),o=s.result),u=UP.ab2str(o),c=[],e.prev=8,c=JSON.parse(u),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,c,u,n,r),e.abrupt("break",26);case 21:return this.C2C(c,n,r),e.abrupt("break",26);case 23:return this.C2GW(a,c,u),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=Em(Sm().mark((function e(t,r,n,i,o){var a,s,u,c,d;return Sm().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(c=r[0],r=r[1],vk(OD).call(OD,c)||PD.print("Signal","<<<<<< ".concat(c),r,s),this._feedbackSignaling(s,c,c===bD.ON_CUSTOM_MESSAGE?cd(cd({},r),{},{message:""}):""),!r.binary||"string"!=typeof r.message){e.next=14;break}return e.next=13,UP.b64str2ab(r.message);case 13:r.message=e.sent;case 14:d=Date.now(),this.emit(c,cd({},r)),c===bD.ON_CUSTOM_MESSAGE&&uP.reportOne2ManyMsgRecv(this.id,r,{msg_size:i,recv_msg_ts:o,fwd_msg_ts:d}),null===(u=this._monitor)||void 0===u||u.report("rtc_signaling",{error_code:0,message:n,signaling_event:"on-".concat(c),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=Em(Sm().mark((function e(t,r,n){var i,o,a,s,u,c,d,l,h,v,p,f,_;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Array.isArray(t)&&(t=t[1]),u=null===(i=t)||void 0===i?void 0:i.id,this._rttIds[u]||(null===(o=t)||void 0===o?void 0:o.dir)===AD.FEEDBACK||oO(null===(a=t)||void 0===a?void 0:a.msg)?delete this._rttIds[u]:PD.print("Signal","<<<<<< p2p response",t),e.t0=t.dir,e.next=e.t0===AD.SEND?6:e.t0===AD.FEEDBACK?46:48;break;case 6:if(c=Date.now(),oO(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,p=d.to,f=d.from,_=""===v?l?bD.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:bD.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:l?bD.USER_BINARY_MESSAGE_RECEIVED:bD.USER_MESSAGE_RECEIVED,p){e.next=27;break}if(e.t1=this,e.t2=bD.ON_CUSTOM_MESSAGE,e.t3=f,e.t4=l,!l){e.next=21;break}return e.next=18,UP.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=cd,e.t11=cd({},t),e.t12={},!l){e.next=38;break}return e.next=35,UP.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(cd(cd({},t),{},{dir:AD.FEEDBACK,msg:""})),uP.reportP2PMsgRecv(this.id,t,{msg_size:r,recv_msg_ts:n,fwd_msg_ts:c}),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=WT(t,2),a=o[0],s=o[1],u=void 0===s?{}:s;if("RXMediaMsg"===a){var c,d=u.type,l=u.data;switch(null===(c=this._monitor)||void 0===c||c.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 v=JSON.parse(l);v.length&&this.emit(d,v[0])}catch(f){}break;case"SSC":try{var p=JSON.parse(l);p.length&&this.emit(d,p[0])}catch(f){}}}}}},{key:"_handleHandler",value:function(){var e=this,t=function(t){PD.print("_handleHandler","dataChannel close",t),e.emit("close",t)},r=function(t){PD.print("_handleHandler","dataChannel error",t),e.emit("close",t)},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 cd({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),PD.print("Signal",Rm(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===wD.SUCCESS?t.success(e.id,e):t.error(e))}}]),a}(iD.exports.EventEmitter),ND=function(){function e(){qd(this,e),sd(this,"xhr",void 0),sd(this,"isSending",void 0),sd(this,"timeout",void 0),this.isSending=!1}return Kd(e,[{key:"ajax",value:function(e){var t=this,r=e.method,n=e.url,i=e.body,o=void 0===i?{}:i,a=e.headers,s=void 0===a?{}:a,u=e.stringify,c=void 0===u||u;return new X_((function(e,i){t.isSending=!0;var a=new XMLHttpRequest;a.open(r,n,!0);for(var u=0,d=gR(s);u<d.length;u++){var l=WT(d[u],2),h=l[0],v=l[1];a.setRequestHeader(h,v)}a.onreadystatechange=function(){if(4===a.readyState)if(t.isSending=!1,200===a.status)e(JSON.parse(a.responseText));else{var r=a.statusText,n=a.status;if(a.responseText)try{var o=JSON.parse(a.responseText);o.errMessage&&(r=o.errMessage),o.code&&(n=o.code)}catch(s){}i({message:r,code:n})}},a.onabort=function(){i({code:0,message:"Request abort"})},a.onerror=function(e){t.isSending=!1,i({code:-1,message:a.responseText||"unknown"})},t.timeout&&(a.timeout=t.timeout),c&&(o=ZE(o)),a.send(o),t.xhr=a}))}},{key:"get",value:function(e,t){return this.ajax({method:"GET",url:e,headers:t})}},{key:"post",value:function(e,t,r,n){return this.ajax({method:"POST",url:e,body:t,headers:r,stringify:n})}},{key:"abort",value:function(){var e;null===(e=this.xhr)||void 0===e||e.abort()}}]),e}(),LD=new nP("ICE Request",3),UD=function(){function e(t){qd(this,e),sd(this,"_request",void 0),sd(this,"_monitor",void 0),this.id=t,this._request=new ND,this._monitor=mP(this.id)}var t,r,n;return Kd(e,[{key:"getAccessNode",value:(n=Em(Sm().mark((function e(t,r,n,i,o){var a;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(a=IO.getAccessNode(t))){e.next=9;break}if(this.getAccessNodeFromServer(t,r,n,i,o),SP(this.id,"es.R.node.cache",a),!Array.isArray(a)){e.next=8;break}return e.abrupt("return",X_.resolve(a));case 8:return e.abrupt("return",X_.resolve([a]));case 9:return e.abrupt("return",this.getAccessNodeFromServer(t,r,n,i,o));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i,o){return n.apply(this,arguments)})},{key:"getAccessNodeFromServer",value:(r=Em(Sm().mark((function e(t,r,n,i,o){var a,s,u,c,d=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=IO.getAccessUrls(),c=!0,SP(this.id,"es.R.req.cache.urls",u),(null===(a=u)||void 0===a?void 0:a.length)>0||(u=xO.ICE_CONFIG_REQUEST_URLS,c=!1,SP(this.id,"es.R.req.external.urls",u)),(null===(s=u)||void 0===s?void 0:s.length)>0||(u=xO.ICE_CONFIG_REQUEST_URLS_INTERNAL,c=!1,SP(this.id,"es.R.req.internal.urls",u)),e.abrupt("return",this.getICEConfigFromServer(u,t,r,n,i,o).then((function(e){var r=e.nodes;return IO.setAccessNode(t,r,e.ttl||11200),e.dispatchDomains&&IO.setAccessUrls(e.dispatchDomains),r})).catch((function(e){if(c)return SP(d.id,"es.R.req.fallback",""),IO.clearAccessUrls(),d.getAccessNodeFromServer(t,r,n,i);throw e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"getICEConfigFromServer",value:(t=Em(Sm().mark((function e(t,r,n,i,o,a){var s,u,c,d,l,h=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u={appID:r,deviceID:IO.getDeviceId(),connectSessionID:DP(),os:"web",sdkVersion:xO.VERSION,isOversea:xO.OVERSEA,expectedAddr:OO("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:o,expectedIDC:a},n&&i&&(u.feedbackInfo=[{feedbackIP:null===(c=i.publicIPs[0])||void 0===c?void 0:c.ip,feedbackReason:{type:"NODE_CHANGED",reason:n}}],delete u.expectedAddr),d=Date.now(),null===(s=this._monitor)||void 0===s||s.report("rtc_get_access",{error_code:0,message:ZE(u),elapse:0,type:"request",host:t.join(","),connect_session_id:u.connectSessionID}),l=YE(t).call(t,function(){var e=Em(Sm().mark((function e(t,r){var n,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,h._request.post(t,u);case 3:n=e.sent,e.next=9;break;case 6:throw e.prev=6,e.t0=e.catch(0),new cR(sR.ICE_SERVER_WRONG,"get ICE config failed",e.t0);case 9:if(200===n.code){e.next=11;break}throw new cR(sR.ICE_SERVER_WRONG,"get ICE config failed",{server_code:n.code,message:ZE(n)});case 11:if(i=n.nodes[0]){e.next=14;break}throw new cR(sR.ICE_SERVER_WRONG,"ICE config server return empty nodes",{code:n.code,message:ZE(n)});case 14:return e.abrupt("return",{result:n,firstNode:i,index:r});case 15:case"end":return e.stop()}}),e,null,[[0,6]])})));return function(t,r){return e.apply(this,arguments)}}()),e.abrupt("return",sO(l).then((function(e){var r,n=e.result;e.firstNode;var i=e.index;return null===(r=h._monitor)||void 0===r||r.report("rtc_get_access",{error_code:200,message:ZE(n),elapse:Date.now()-d,type:"response",host:t[i],connect_session_id:u.connectSessionID}),n})).catch((function(e){var r,n,i,o=null===(r=e[0])||void 0===r?void 0:r.error;throw null===(n=h._monitor)||void 0===n||n.report("rtc_get_access",{error_code:+((null==o?void 0:o.code)||(null==o?void 0:o.server_code)),message:null===(i=e[0])||void 0===i?void 0:i.message,elapse:Date.now()-d,type:"response",host:t.join(","),connect_session_id:u.connectSessionID},{error:ZE(o)}),e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,r,n,i,o,a){return t.apply(this,arguments)})},{key:"abort",value:function(){this._request.isSending&&(LD.print("abort","HTTP Request of [getICEConfigFromServer] abort"),this._request.abort())}}]),e}(),VD=hi.f("asyncIterator");function FD(e){var t,r,n,i=2;for(void 0!==fl&&(r=VD,n=Dl);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new BD(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function BD(e){function t(e){if(Object(e)!==e)return X_.reject(new TypeError(e+" is not an object."));var t=e.done;return X_.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(BD=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?X_.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?X_.reject(e):t(r.apply(this.s,arguments))}},new BD(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}];Ng("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Zg);var GD=ee.Set;Rr({target:"Set",stat:!0,forced:!0},{from:sy}),Rr({target:"Set",stat:!0,forced:!0},{of:cy});var HD=P,zD=Ce,XD=tr,KD=function(){for(var e=XD(this),t=zD(e.add),r=0,n=arguments.length;r<n;r++)HD(t,e,arguments[r]);return e};Rr({target:"Set",proto:!0,real:!0,forced:!0},{addAll:KD}),Rr({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:vy});var qD=fh,YD=tr,WD=Wt,QD=qD,JD=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=YD(this),r=QD(t),n=WD(e,arguments.length>1?arguments[1]:void 0);return!JD(r,(function(e,r){if(!n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var ZD=oe,$D=P,eM=Ce,tM=tr,rM=Ev,nM=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){var t=tM(this),r=new(rM(t,ZD("Set")))(t),n=eM(r.delete);return nM(e,(function(e){$D(n,r,e)})),r}});var iM=oe,oM=P,aM=Ce,sM=tr,uM=Wt,cM=Ev,dM=qD,lM=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=sM(this),r=dM(t),n=uM(e,arguments.length>1?arguments[1]:void 0),i=new(cM(t,iM("Set"))),o=aM(i.add);return lM(r,(function(e){n(e,e,t)&&oM(o,i,e)}),{IS_ITERATOR:!0}),i}});var hM=tr,vM=Wt,pM=qD,fM=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=hM(this),r=pM(t),n=vM(e,arguments.length>1?arguments[1]:void 0);return fM(r,(function(e,r){if(n(e,e,t))return r(e)}),{IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var _M=oe,mM=P,gM=Ce,yM=tr,SM=Ev,bM=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){var t=yM(this),r=new(SM(t,_M("Set"))),n=gM(t.has),i=gM(r.add);return bM(e,(function(e){mM(n,t,e)&&mM(i,r,e)})),r}});var EM=P,kM=Ce,TM=tr,IM=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){var t=TM(this),r=kM(t.has);return!IM(e,(function(e,n){if(!0===EM(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var AM=oe,RM=P,wM=Ce,CM=A,xM=tr,PM=fh,OM=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){var t=PM(this),r=xM(e),n=r.has;return CM(n)||(r=new(AM("Set"))(e),n=wM(r.has)),!OM(t,(function(e,t){if(!1===RM(n,r,e))return t()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var DM=P,MM=Ce,NM=tr,LM=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){var t=NM(this),r=MM(t.has);return!LM(e,(function(e,n){if(!1===DM(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var UM=Rr,VM=tr,FM=gn,BM=qD,jM=Dh,GM=E([].join),HM=[].push;UM({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=VM(this),r=BM(t),n=void 0===e?",":FM(e),i=[];return jM(r,HM,{that:i,IS_ITERATOR:!0}),GM(i,n)}});var zM=oe,XM=Wt,KM=P,qM=Ce,YM=tr,WM=Ev,QM=qD,JM=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=YM(this),r=QM(t),n=XM(e,arguments.length>1?arguments[1]:void 0),i=new(WM(t,zM("Set"))),o=qM(i.add);return JM(r,(function(e){KM(o,i,n(e,e,t))}),{IS_ITERATOR:!0}),i}});var ZM=Ce,$M=tr,eN=qD,tN=Dh,rN=TypeError;Rr({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=$M(this),r=eN(t),n=arguments.length<2,i=n?void 0:arguments[1];if(ZM(e),tN(r,(function(r){n?(n=!1,i=r):i=e(i,r,r,t)}),{IS_ITERATOR:!0}),n)throw rN("Reduce of empty set with no initial value");return i}});var nN=tr,iN=Wt,oN=qD,aN=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=nN(this),r=oN(t),n=iN(e,arguments.length>1?arguments[1]:void 0);return aN(r,(function(e,r){if(n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var sN=oe,uN=P,cN=Ce,dN=tr,lN=Ev,hN=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){var t=dN(this),r=new(lN(t,sN("Set")))(t),n=cN(r.delete),i=cN(r.add);return hN(e,(function(e){uN(n,r,e)||uN(i,r,e)})),r}});var vN=oe,pN=Ce,fN=tr,_N=Ev,mN=Dh;Rr({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){var t=fN(this),r=new(_N(t,vN("Set")))(t);return mN(e,pN(r.add),{that:r}),r}});var gN=GD,yN=new FS,SN=function(){var e=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new X_((function(e,r){var n=OO("STATS_SCALLBACK_SUPPORT");if("chrome-stable"===VP()&&void 0===window.InstallTrigger&&FP&&n)try{t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!vk(TN).call(TN,e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(cd(cd({},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(eX){r(eX)}else e({all:[],getTrackStats:function(){return[]}})})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),bN=function(){var e=Em(Sm().mark((function e(t){var r,n,i,o,a,s;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getStats();case 2:return i=e.sent,o={all:[]},a=new FS,i.forEach((function(e){var t=a.get(e.type)||new FS;t.set(e.id,e),a.set(e.type,t),o.all.push(e)})),s=function(e,t){e.forEach((function(e){var r,n,i,o,s,u,c=e.codecId,d=e.transportId,l=e.trackId,h=e.playoutId;if(null===(r=a.get(kN.codec))||void 0===r||r.forEach((function(e){e.id===c&&t.add(e)})),null===(n=a.get(kN.transport))||void 0===n||n.forEach((function(e){e.id===d&&(s=e,t.add(e))})),null===(i=a.get(kN.track))||void 0===i||i.forEach((function(e){e.id===l&&t.add(e)})),null===(o=a.get(kN.mediaPlayout))||void 0===o||o.forEach((function(e){e.id===h&&t.add(e)})),s){var v,p,f=s,_=f.localCertificateId,m=f.remoteCertificateId,g=f.selectedCandidatePairId;null===(v=a.get(kN.certificate))||void 0===v||v.forEach((function(e){(e.id===_||e.id===m)&&t.add(e)})),null===(p=a.get(kN.candidatePair))||void 0===p||p.forEach((function(e){e.id===g&&(u=e,t.add(e))}))}if(u){var y,S,b=u,E=b.localCandidateId,k=b.remoteCandidateId;null===(y=a.get(kN.localCandidate))||void 0===y||y.forEach((function(e){e.id===E&&t.add(e)})),null===(S=a.get(kN.remoteCandidate))||void 0===S||S.forEach((function(e){e.id===k&&t.add(e)}))}}))},null===(r=a.get(kN.mediaSource))||void 0===r||r.forEach((function(e){var t,r=new gN;r.add(e);var n=[];null===(t=a.get(kN.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=a.get(kN.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),s(n,r),o[e.trackIdentifier]=zk(r)})),null===(n=a.get(kN.inboundRtp))||void 0===n||n.forEach((function(e){var t,r=new gN;r.add(e),null===(t=a.get(kN.remoteOutboundRtp))||void 0===t||t.forEach((function(t){t.localId===e.id&&r.add(t)})),s([e],r);var n,i=e.trackIdentifier;i||(null===(n=a.get(kN.track))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(i=t.trackIdentifier)})));o[i]=zk(r)})),e.abrupt("return",o);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),EN=function(){var e=Em(Sm().mark((function e(t,r,n){var i,o,a,s,u,c;return Sm().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(!BP&&!jP){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=yN.get(t))||Date.now()-a.timestamp>150)&&(a={timestamp:Date.now(),statsPromise:bN(t),extraStatsPromise:SN(t)},yN.set(t,a)),e.next=14,a.statsPromise;case 14:if(s=e.sent,u=(i?s[i]:s.all)||[],n){e.next=21;break}return e.next=19,a.extraStatsPromise;case 19:c=e.sent,u=Rm(u).call(u,(i?c.getTrackStats(i):c.all)||[]);case 21:return e.abrupt("return",u);case 22:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}();VP();var kN=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}(kN||{}),TN=["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"],IN=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!LP()&&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,LN();case 5:if(e.t0=e.sent,!e.t0){e.next=10;break}return e.next=9,NN();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)}}(),AN=function(){var e=Em(Sm().mark((function e(t){var r,n,i,o,a,s;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t||"recv_and_send",n=[],e.next=4,LN();case 4:return i=e.sent,e.next=7,NN();case 7:return o=e.sent,e.next=10,VN();case 10:return a=e.sent,e.next=13,UN();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)}}(),RN=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",ZE(xN));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),wN=function(){var e=Em(Sm().mark((function e(){var t;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,AN();case 2:return t=e.sent,e.abrupt("return",YE(t).call(t,(function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),CN={},xN={};function PN(e){var t;if(oE(t=["level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f","profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1","packetization-mode=1;profile-level-id=42e01f;level-asymmetry-allowed=1"]).call(t,(function(t){return null==e?void 0:vk(e).call(e,t)}))){for(var r=navigator.userAgent.toLowerCase(),n=!1,i=0,o=["miuibrowser"];i<o.length;i++){var a=o[i];vk(r).call(r,a)&&(n=!0)}return!n}return!1}var ON=function(){var e=Em(Sm().mark((function e(t){var r,n;return Sm().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)}}(),DN=function(){var e=Em(Sm().mark((function e(){var t,r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ON("sendonly");case 2:if(r=e.sent,!vk(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,ON("sendonly");case 6:r=e.sent;case 7:return CN.h264encode=PN(r),xN.h264encode=r,CN.vp8encode=_E(r).call(r,"vp8")>-1,xN.vp8encode="same as h264encode",e.abrupt("return",CN);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),MN=function(){var e=Em(Sm().mark((function e(){var t,r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ON("recvonly");case 2:if(r=e.sent,!vk(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,ON("recvonly");case 6:r=e.sent;case 7:return CN.h264decode=PN(r),xN.h264decode=r,CN.vp8decode=_E(r).call(r,"vp8")>-1,xN.vp8decode="same as h264decode",e.abrupt("return",CN);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),NN=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==CN.h264encode){e.next=10;break}return e.prev=1,e.next=4,DN();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),xN.h264encode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",CN.h264encode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),LN=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==CN.h264decode){e.next=10;break}return e.prev=1,e.next=4,MN();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),xN.h264decode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",CN.h264decode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),UN=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==CN.vp8encode){e.next=10;break}return e.prev=1,e.next=4,DN();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),xN.vp8encode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",CN.vp8encode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),VN=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==CN.vp8decode){e.next=10;break}return e.prev=1,e.next=4,MN();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),xN.vp8decode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",CN.vp8decode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),FN=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},BN=function(){return 12!==XP},jN={},GN={},HN={exports:{}},zN=HN.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(zN).forEach((function(e){zN[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=HN.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=ym(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 u=n[t][o];if(u.reg.test(i))return r(u,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 $S(t=e.split(/;\s?/)).call(t,o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){var t;return YE(t=e.toString().split(" ")).call(t,Number)},e.parseRemoteCandidates=function(e){for(var r,n=[],i=YE(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 YE(t=e.split(" ")).call(t,(function(e){var t;return $S(t=e.substring(1,e.length-1).split(",")).call(t,o,{})}))},e.parseSimulcastStreamList=function(e){var r;return YE(r=e.split(";")).call(r,(function(e){var r;return YE(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}}))}))}}(GN);var XN=HN.exports,KN=/%[sdv%]/g,qN=function(e){var t=1,r=arguments,n=r.length;return e.replace(KN,(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""}}))},YN=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 qN.apply(null,n)},WN=["v","o","s","i","u","e","p","c","b","t","r","z","a"],QN=["i","c","b","a"],JN=GN,ZN=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||WN,n=t.innerOrder||QN,i=[];return r.forEach((function(t){XN[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(YN(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(YN(t,r,e))}))}))})),e.media.forEach((function(e){i.push(YN("m",XN.m[0],e)),n.forEach((function(t){XN[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(YN(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(YN(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"};jN.write=ZN,jN.parse=JN.parse,jN.parseParams=JN.parseParams,jN.parseFmtpConfig=JN.parseFmtpConfig,jN.parsePayloads=JN.parsePayloads,jN.parseRemoteCandidates=JN.parseRemoteCandidates,jN.parseImageAttributes=JN.parseImageAttributes,jN.parseSimulcastStreamList=JN.parseSimulcastStreamList;var $N=new nP("FirefoxHandler",3),eL=Math.pow(2,32),tL="kp34Za0H+aVf862l",rL="o/i14u9pJrxRKAsu";function nL(e){return e>eL-18?($N.print("generateAllSsrc","reset start id",e),nL(e=e-eL+1e4+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var iL=function(e,t,r){var n,i,o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:rL;return[{id:r,attribute:"cname",value:a},{id:r,attribute:"msid",value:Rm(n=Rm(i="".concat(e," ")).call(i,e,"-")).call(n,t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:Rm(o="".concat(e,"-")).call(o,t)}]},oL=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],u=n.cname,c=n.flexfec;c&&s.push(a);var d,l=$S(s).call(s,(function(t,r){return Rm(t).call(t,iL(e,"video",r,u))}),[]),h=[{semantics:"FID",ssrcs:Rm(r="".concat(i," ")).call(r,o)}];c&&h.push({semantics:"FEC-FR",ssrcs:Rm(d="".concat(i," ")).call(d,a)});return{ssrcs:l,ssrcGroups:h}};function aL(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.bundleOnly,e}var sL=function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=cd(cd({},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,jN.write(i)};function uL(e,t){return cL.apply(this,arguments)}function cL(){return(cL=Em(Sm().mark((function e(t,r){var n,i,o,a,s;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},i=r.publicIPs,o=r.certFingerprint,a=r.iceParams,s=r.iceConfig,n.fingerprint={type:"sha-256",hash:o},n.icePwd=a.serverIcePwd,e.next=6,lL(a.serverIceUfrag);case 6:return n.iceUfrag=e.sent,n.candidates=dL(i,s),n.setup="active",n.iceOptions="renomination",e.abrupt("return",n);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function dL(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(cd(cd({},o),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){i.push(cd(cd({},o),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),i}var lL=function(){var e=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u;return Sm().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,UP.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=NP(Uint8Array,n,i,o,a),e.next=15,UP.ab2b64str(s.buffer);case 15:return u=e.sent,e.abrupt("return",u);case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),hL=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=YT(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o,a,s,u=n.value;if(vk(o=u.config).call(o,"level-asymmetry-allowed=1")&&vk(a=u.config).call(a,"packetization-mode=1")&&vk(s=u.config).call(s,"profile-level-id=42e01f")){r=u.payload;break}}}catch(p){i.e(p)}finally{i.f()}for(var c=0;c<e.rtp.length;c++){var d=e.rtp[c];if("H264"===t){if(d.payload===r){var l;e.rtp.unshift(GE(l=e.rtp).call(l,c,1)[0]);break}}else if(d.codec===t){var h;e.rtp.unshift(GE(h=e.rtp).call(h,c,1)[0]);break}}var v=[];e.rtp.forEach((function(e){return v.push(e.payload)})),e.payloads=v.join(" ")}},vL=new nP("BasicHandler",3),pL={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",encodedInsertableStreams:!!FN()||void 0},fL=function(e){wI(o,e);var t,r,n,i=XI(o);function o(e){var t;return qd(this,o),sd(QT(t=i.call(this)),"_peerConnection",void 0),sd(QT(t),"_dataChannel",void 0),sd(QT(t),"_context",void 0),sd(QT(t),"id",void 0),sd(QT(t),"_monitor",void 0),sd(QT(t),"_offerIce",{}),sd(QT(t),"_answerIce",{}),sd(QT(t),"_initSctpEvents",!1),sd(QT(t),"_nextSsrc",Math.floor(Math.random()*eL+1e4)),sd(QT(t),"_aSendonlyAnswerTpl",void 0),sd(QT(t),"_vSendonlyAnswerTpl",void 0),sd(QT(t),"_enableSubFlexfec",!1),sd(QT(t),"audioTrack4ff",void 0),sd(QT(t),"_connectionId",void 0),t.id=e.id,t._monitor=mP(t.id),t._peerConnection=new RTCPeerConnection(pL),t._dataChannel=t._peerConnection.createDataChannel("signaling",{negotiated:!0,id:100}),t._context=e,t._dataChannel.binaryType="arraybuffer",t._peerConnection.ontrack=function(e){var r,n,i,o,a=null===(r=e.streams)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.id;vL.print("constructor",Rm(i=Rm(o="pc.ontrack ".concat(e.track.kind," ")).call(o,e.track.id," ")).call(i,a)),"ff-stream"===a&&(t.audioTrack4ff=e.track),t.emit("ontrack",e)},t._peerConnection.onconnectionstatechange=function(e){var r;vL.print("constructor",Rm(r="onconnectionstatechange ".concat(t._peerConnection.iceConnectionState," -> ")).call(r,t._peerConnection.connectionState)),"failed"!==t._peerConnection.iceConnectionState&&"closed"!==t._peerConnection.iceConnectionState&&"failed"!==t._peerConnection.connectionState||t.emit("disconnect")},t._peerConnection.oniceconnectionstatechange=function(){var e=t._peerConnection.iceConnectionState;t._report("rtc_pre_ice_state",{message:e,ice_state:e.toUpperCase()})},t}return Kd(o,[{key:"getConnectionId",value:function(){return this._connectionId}},{key:"disconnect",value:function(){this._peerConnection.close(),this._dataChannel.close(),this._peerConnection.ontrack=null}},{key:"destroy",value:function(){vL.print("destroy"),this.disconnect(),this._context=void 0}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"_simulcast",value:function(e,t,r,n,i){var o,a,s,u=[];1===e.videoEncodeConfig.length?(u=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),vL.print("simulcast() ","simulcastLayers: %o",u)):(u=YE(o=ym(a=ym(s=e.videoEncodeConfig).call(s,1)).call(a,1-i)).call(o,(function(e){var r=mO(e.width),n=t.width/r;return{width:r,height:Math.floor(t.height/n),scaleResolutionDownBy:n,frameRate:mO(e.frameRate)||15,maxkbps:e.maxKbps||600}})),vL.print("simulcast() ","simulcastLayers2: %o",u));var c=[!0];u.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)}),c.push(!0)})),this._context&&(this._context.activeSimStreams=c)}},{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]},u={direction:"sendonly",streams:[t]},c=[],d=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var l=null==r?void 0:r.getTrack(),h=cd({},MO);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 p=null==e?void 0:e.videoEncodeConfig[0],f={maxBitrate:1e3*p.maxKbps,rid:"0"};if(e.prevBitrate=p.maxKbps,u.sendEncodings=[f],c.push({width:h.width,height:h.height,framerate:h.frameRate,maxkbps:p.maxKbps,rid:"0"}),!BP&&i){var _,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(vL.print("simulcast() ","maxLayers: %o",g),g>1)this._simulcast(e,cd(cd({},h),{},{maxKbps:p.maxKbps}),u,c,g),null!==(_=this._context)&&void 0!==_&&null!==(m=_.serverConfig)&&void 0!==m&&m.simulcastOnDemand&&(d=YE(c).call(c,(function(e,t){return cd(cd({},e),{},{video_index:t,sub_index:t})})))}}vL.print("publish videoTransceiverInit videoDescriptions","",u,c);var y=null==n?void 0:n.getTrack("preprocessing");(null==n?void 0:n.mixType)!==jd.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",ZE({aTrack:vO(y),vTrack:vO(S),audioTransceiverInit:s,videoTransceiverInit:u}))}catch(eX){}return{semantics:"unified-plan",videoDescriptions:c,subVideoDescriptions:d,audioTransceiverInit:{track:y,init:s},videoTransceiverInit:{track:S,init:u}}}},{key:"updateMaxBitrate",value:function(e){var t,r,n,i;vL.print("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 vL.print("updateMaxBitrate()","no change");e.prevBitrate=s}var u=null===(i=a.sender)||void 0===i?void 0:i.getParameters();if(u){var c;u.encodings=null==u||null===(c=u.encodings)||void 0===c?void 0:YE(c).call(c,(function(t){var r,n=+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(u);try{this._reportRtcInvokeStatus("Handler.updateScaleResolutionDownBy",ZE(u.encodings))}catch(eX){}}}else vL.print("updateMaxBitrate()","no pub")}},{key:"getStats",value:function(e,t){return EN(this._peerConnection,e,t)}},{key:"setLocalDescription",value:(n=Em(Sm().mark((function e(t,r){var n,i,o,a=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=MP(),e.prev=1,e.next=4,this._peerConnection.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:MP()-n},{type:"offer"}),this._initSctpEvents||(this._initSctpEvents=!0,(o=null===(i=this._peerConnection)||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:MP()-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=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=MP(),e.prev=1,e.next=4,this._peerConnection.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:MP()-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:MP()-n},{type:"answer"});case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Em(Sm().mark((function e(){return Sm().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;jN.parse(e).media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r,n=null==e?void 0:oE(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&null!=e&&e.fmtp){var i,o=null==e?void 0:oE(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&&vk(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(vk(n=["vp8","h264"]).call(n,i.toLocaleLowerCase())){var a,s,u=oE(a=e.fmtp).call(a,(function(e){return e.payload===o}));if(u)u.config=Rm(s=[]).call(s,Kk(u.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,cd(cd({},t),{},{connection_id:this._connectionId}),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)}}]),o}(iD.exports.EventEmitter),_L=E,mL=Ug,gL=Qm.exports.getWeakData,yL=vv,SL=tr,bL=z,EL=$,kL=Dh,TL=We,IL=Zi.set,AL=Zi.getterFor,RL=Mo.find,wL=Mo.findIndex,CL=_L([].splice),xL=0,PL=function(e){return e.frozen||(e.frozen=new OL)},OL=function(){this.entries=[]},DL=function(e,t){return RL(e.entries,(function(e){return e[0]===t}))};OL.prototype={get:function(e){var t=DL(this,e);if(t)return t[1]},has:function(e){return!!DL(this,e)},set:function(e,t){var r=DL(this,e);r?r[1]=t:this.entries.push([e,t])},delete:function(e){var t=wL(this.entries,(function(t){return t[0]===e}));return~t&&CL(this.entries,t,1),!!~t}};var ML,NL={getConstructor:function(e,t,r,n){var i=e((function(e,i){yL(e,o),IL(e,{type:t,id:xL++,frozen:void 0}),bL(i)||kL(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=AL(t),s=function(e,t,r){var n=a(e),i=gL(SL(t),!0);return!0===i?PL(n).set(t,r):i[n.id]=r,e};return mL(o,{delete:function(e){var t=a(this);if(!EL(e))return!1;var r=gL(e);return!0===r?PL(t).delete(e):r&&TL(r,t.id)&&delete r[t.id]},has:function(e){var t=a(this);if(!EL(e))return!1;var r=gL(e);return!0===r?PL(t).has(e):r&&TL(r,t.id)}}),mL(o,r?{get:function(e){var t=a(this);if(EL(e)){var r=gL(e);return!0===r?PL(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}},LL=n,UL=E,VL=Ug,FL=Qm.exports,BL=Ng,jL=NL,GL=$,HL=ng,zL=Zi.enforce,XL=Vi,KL=!LL.ActiveXObject&&"ActiveXObject"in LL,qL=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},YL=BL("WeakMap",qL,jL);if(XL&&KL){ML=jL.getConstructor(qL,"WeakMap",!0),FL.enable();var WL=YL.prototype,QL=UL(WL.delete),JL=UL(WL.has),ZL=UL(WL.get),$L=UL(WL.set);VL(WL,{delete:function(e){if(GL(e)&&!HL(e)){var t=zL(this);return t.frozen||(t.frozen=new ML),QL(this,e)||t.frozen.delete(e)}return QL(this,e)},has:function(e){if(GL(e)&&!HL(e)){var t=zL(this);return t.frozen||(t.frozen=new ML),JL(this,e)||t.frozen.has(e)}return JL(this,e)},get:function(e){if(GL(e)&&!HL(e)){var t=zL(this);return t.frozen||(t.frozen=new ML),JL(this,e)?ZL(this,e):t.frozen.get(e)}return ZL(this,e)},set:function(e,t){if(GL(e)&&!HL(e)){var r=zL(this);r.frozen||(r.frozen=new ML),JL(this,e)?$L(this,e,t):r.frozen.set(e,t)}else $L(this,e,t);return this}})}var eU=ee.WeakMap;Rr({target:"WeakMap",proto:!0,real:!0,forced:!0},{emplace:my}),Rr({target:"WeakMap",stat:!0,forced:!0},{from:sy}),Rr({target:"WeakMap",stat:!0,forced:!0},{of:cy}),Rr({target:"WeakMap",proto:!0,real:!0,forced:!0},{deleteAll:vy}),Rr({target:"WeakMap",proto:!0,real:!0,forced:!0},{upsert:VS});var tU=eU,rU=function(e){wI(v,e);var t,r,n,i,o,a,s,u,c,d,l,h=XI(v);function v(){var e,t,r;return qd(this,v),sd(QT(r=h.call(this)),"inited",!1),sd(QT(r),"deviceMap",{audioinput:new FS,audiooutput:new FS,videoinput:new FS}),sd(QT(r),"checkDeviceChangeTimer",null),sd(QT(r),"isSupportedPermissionsQuery",!1),sd(QT(r),"isGrantedMicrophonePermission",!1),sd(QT(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!LP()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(QT(r)),!LP()&&r.refreshDevices(),r}return Kd(v,[{key:"refreshDevices",value:(l=Em(Sm().mark((function e(){var t,r,n=this;return Sm().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,!BP){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=Em(Sm().mark((function e(){var t,r,n,i,o=this;return Sm().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:(c=Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=void 0,!BP){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=zk(Rm(t=[]).call(t,Kk($I(r=this.deviceMap.audioinput).call(r)),Kk($I(n=this.deviceMap.videoinput).call(n)),Kk($I(i=this.deviceMap.audiooutput).call(i)))),a.forEach((function(e){var t,r,n=u.deviceMap[e.kind].get(e.deviceId);u.deviceMap[e.kind].set(e.deviceId,e),n||(vk(t=e.kind).call(t,"video")?u.emit(zd.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):vk(r=e.kind).call(r,"audio")&&u.emit(zd.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),s.forEach((function(e){var t,r;oE(a).call(a,(function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(u.deviceMap[e.kind].delete(e.deviceId),vk(t=e.kind).call(t,"video")?u.emit(zd.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):vk(r=e.kind).call(r,"audio")&&u.emit(zd.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"getUserMedia",value:(u=Em(Sm().mark((function e(t){var r;return Sm().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 u.apply(this,arguments)})},{key:"checkPermissionsByDevices",value:(s=Em(Sm().mark((function e(){var t,r;return Sm().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=Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u=this,c=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=c.length>0&&void 0!==c[0]?c[0]:{},n=r.audio,i=r.video,o=r.force,n||i||(n=!0,i=!0),a={audio:!1,video:!1},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:case 26: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 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=33;break}return e.next=33,navigator.mediaDevices.getUserMedia({audio:n,video:i}).then((function(e){e&&(e.getTracks().forEach((function(e){return e.stop()})),n&&(a.audio=!0,u.isGrantedMicrophonePermission=!0),i&&(a.video=!0,u.isGrantedCameraPermission=!0))})).catch((function(){}));case 33:return e.next=35,this.refreshDevices();case 35:return e.abrupt("return",a);case 36:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"enumerateDevices",value:(o=Em(Sm().mark((function e(){var t,r,n,i;return Sm().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",zk(Rm(t=[]).call(t,Kk($I(r=this.deviceMap.audioinput).call(r)),Kk($I(n=this.deviceMap.videoinput).call(n)),Kk($I(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=Em(Sm().mark((function e(){var t;return Sm().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",zk($I(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=Em(Sm().mark((function e(){var t;return Sm().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",zk($I(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=Em(Sm().mark((function e(){var t;return Sm().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",zk($I(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=Em(Sm().mark((function e(t){var r;return Sm().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",oE(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}(sD),nU=new rU;!LP()&&(window.__rtc_dd__=nU);var iU=new nP("AudioContext",1),oU=function(){function e(){var t=this;qd(this,e),sd(this,"_audioContextInstance",void 0),sd(this,"_contextStuckAt",0);var r=0;LP()||setInterval((function(){if(t._audioContextInstance){var e=t._audioContextInstance.currentTime;t._contextStuckAt?t._contextStuckAt!==e&&(t._contextStuckAt=0,iU.print("currentTime resume"),fP("currentTime resume","")):e&&r===e&&(t._contextStuckAt=e,iU.print("currentTime stuck",t._contextStuckAt),t._audioContextInstance.suspend(),t._audioContextInstance.resume(),fP("AudioContext currentTime stuck",t._contextStuckAt)),r=e}}),3e3)}return Kd(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;iU.print("state change",null===(t=e._audioContextInstance)||void 0===t?void 0:t.state),"interrupted"===(null===(r=e._audioContextInstance)||void 0===r?void 0:r.state)&&e._audioContextInstance.resume()}}return this._audioContextInstance}}]),e}(),aU=function(){function e(t){qd(this,e),sd(this,"_ctx",void 0),sd(this,"_analyserNode",void 0),sd(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 Kd(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=Em(Sm().mark((function e(){var t;return Sm().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 oU,uU=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}(uU||{}),cU=function(){function e(t){qd(this,e),sd(this,"_plugins",new FS),this.id=t}var t;return Kd(e,[{key:"register",value:function(e){var t=this._plugins.get(e.type)||[];if(XA(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 oE(r=this._plugins.get(e)||[]).call(r,(function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=Em(Sm().mark((function e(t){var r,n,i,o,a;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this._plugins.get(1)||[],n=t.getTrack(),i=YT(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}(),dU=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(dU||{}),lU=new nP("VERTC",0),hU=new tU,vU=function(e){wI(r,e);var t=XI(r);function r(e,n){var i;return qd(this,r),sd(QT(i=t.call(this)),"sourceType",1),sd(QT(i),"mediaType",void 0),sd(QT(i),"_trackId",void 0),sd(QT(i),"_ac",void 0),sd(QT(i),"_sourceNode",void 0),sd(QT(i),"_gainNode",void 0),sd(QT(i),"_destNode",void 0),sd(QT(i),"_channelCount",void 0),i._trackId=e,i.mediaType=n,"audio"===n&&BN()&&!OO("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 Kd(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,!BN()||OO("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:"destory",value:function(){var e,t,r,n;null===(e=this._sourceNode)||void 0===e||e.mediaStream.getTracks().forEach((function(e){e.stop()})),null===(t=this._destNode)||void 0===t||t.stream.getTracks().forEach((function(e){e.stop()})),null===(r=this._sourceNode)||void 0===r||r.disconnect(),null===(n=this._gainNode)||void 0===n||n.disconnect(),delete this._sourceNode,delete this._gainNode,delete this._destNode}}]),r}(sD),pU=function(e){wI(n,e);var t,r=XI(n);function n(e,t,i){var o;return qd(this,n),sd(QT(o=r.call(this,t,i)),"_mediaTrack",void 0),sd(QT(o),"_preProcessingTrack",void 0),sd(QT(o),"_originTrack",void 0),sd(QT(o),"handleTrackEnded",(function(){o.emit("track-ended",QT(o)),o.close()})),sd(QT(o),"handleMute",(function(){o.emit("track-mute",QT(o))})),sd(QT(o),"handleUnmute",(function(){o.emit("track-unmute",QT(o))})),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o._initListeners(),o}return Kd(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=Em(Sm().mark((function e(t){var r;return Sm().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.destory():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}(vU),fU=function(e){wI(r,e);var t=XI(r);function r(e,n,i){var o;return qd(this,r),sd(QT(o=t.call(this,n,i)),"_mediaTrack",void 0),sd(QT(o),"_originTrack",void 0),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o}return Kd(r,[{key:"getTrack",value:function(){return this._mediaTrack}},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){return this.destory()}}]),r}(vU),_U=function(e){wI(n,e);var t,r=XI(n);function n(e,t){var i;return qd(this,n),sd(QT(i=r.call(this,e,t,"video")),"resolution",void 0),sd(QT(i),"dummy",!1),i.resolution={width:0,height:0},i}return Kd(n,[{key:"updateVideoCaptureConfig",value:(t=Em(Sm().mark((function e(t){var r,n;return Sm().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 lU.print("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=cd({},t)).contentHint,BP&&(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&&vk(t=["text","motion","detail"]).call(t,e)&&(this._mediaTrack.contentHint=e)}}]),n}(pU),mU=function(e){wI(n,e);var t,r=XI(n);function n(e,t){var i;return qd(this,n),sd(QT(i=r.call(this,e,t,"audio")),"audioCaptureConfig",void 0),sd(QT(i),"_audioLevelFetcher",void 0),sd(QT(i),"mixedAudioTrack",void 0),sd(QT(i),"mixType",jd.PLAYOUT_AND_PUBLISH),i}return Kd(n,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new aU(this.getTrack("preprocessing"))),this._audioLevelFetcher.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=Em(Sm().mark((function e(){var t;return Sm().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 lU.print("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}(pU),gU=function(e){wI(r,e);var t=XI(r);function r(e,n){return qd(this,r),t.call(this,e,n,"video")}return Kd(r)}(fU),yU=function(e){wI(r,e);var t=XI(r);function r(e,n){var i;return qd(this,r),sd(QT(i=t.call(this,e,n,"audio")),"_audioLevelFetcher",void 0),i}return Kd(r,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new aU(this.getTrack())),this._audioLevelFetcher.getAudioLevel()}}]),r}(fU),SU=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"streamIndex",yd.STREAM_INDEX_MAIN),n}return Kd(r)}(mU),bU=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"streamIndex",yd.STREAM_INDEX_MAIN),n}return Kd(r)}(_U),EU=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"streamIndex",yd.STREAM_INDEX_MAIN),sd(QT(n),"sourceType",0),n}return Kd(r)}(_U),kU=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"streamIndex",yd.STREAM_INDEX_MAIN),sd(QT(n),"sourceType",0),n}return Kd(r)}(mU),TU=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"streamIndex",yd.STREAM_INDEX_SCREEN),n}return Kd(r)}(_U),IU=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"streamIndex",yd.STREAM_INDEX_SCREEN),n}return Kd(r)}(mU),AU=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"streamIndex",yd.STREAM_INDEX_SCREEN),sd(QT(n),"sourceType",0),n}return Kd(r)}(_U),RU=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"streamIndex",yd.STREAM_INDEX_SCREEN),sd(QT(n),"sourceType",0),n}return Kd(r)}(mU);function wU(e,t){return CU.apply(this,arguments)}function CU(){return(CU=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new bU(t,DP())).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 xU(e,t){return PU.apply(this,arguments)}function PU(){return(PU=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new TU(t,DP())).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 OU(e,t){return DU.apply(this,arguments)}function DU(){return(DU=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d;return Sm().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=mP(r.id),e.prev=2,lU.print("createCameraVideoTrack","constraints:",t),null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o}),s=MP(),BP&&(t.frameRate={ideal:30,max:30}),e.next=9,nU.getUserMedia({video:t});case 9:i=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:o,reason:"success",elapse:MP()-s}),e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(2),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}),new cR(sR.GET_VIDEO_TRACK_FAILED,Rm(u="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(u,e.t0.message||"unknown message","."),e.t0);case 17:return c=i.getVideoTracks()[0],hU.set(c,i),d=new bU(c,DP()),e.next=22,d.generatePreProcessingTrack(r);case 22:return e.abrupt("return",d);case 23:case"end":return e.stop()}}),e,null,[[2,13]])})))).apply(this,arguments)}function MU(e,t){return NU.apply(this,arguments)}function NU(){return(NU=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return lU.print("createMicrophoneAudioTrack","constraints:",t),o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=mP(r.id),e.prev=3,null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o}),s=MP(),(u=r.getPluginByName(uU.PRE_PROCESSING,"RTCAIAnsExtension"))&&(u.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=10,nU.getUserMedia({audio: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:MP()-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}),new cR(sR.GET_AUDIO_TRACK_FAILED,Rm(c="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(c,e.t0.message||"unknown message","."),e.t0);case 18:return d=i.getAudioTracks()[0],hU.set(d,i),l=new SU(d,DP()),e.next=23,l.generatePreProcessingTrack(r);case 23:return e.abrupt("return",l);case 24:case"end":return e.stop()}}),e,null,[[3,14]])})))).apply(this,arguments)}function LU(){return UU.apply(this,arguments)}function UU(){return UU=Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u,c,d,l=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=l.length>0&&void 0!==l[0]&&l[0],r=l.length>1?l[1]:void 0,n=l.length>2?l[2]:void 0,lU.print("createScreenTracks","withAudio: %o, constraints: %o",t,n),o=mP(r.id),e.prev=5,null==o||o.report("rtc_video_capture_event",{event_type:"start",media_device_id:"screen"}),a=MP(),e.next=10,navigator.mediaDevices.getDisplayMedia({video:!(n&&(!jP||16!==XP))||n,audio:!!t&&{channelCount:2,noiseSuppression:!1,echoCancellation:!1,autoGainControl:!1}});case 10:i=e.sent,null==o||o.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:"screen",reason:"success",elapse:MP()-a}),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(5),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}),new cR(sR.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 18:return s=i.getVideoTracks()[0],u=new TU(s,DP()),e.next=22,u.generatePreProcessingTrack(r);case 22:if(!(c=i.getAudioTracks()[0])){e.next=28;break}return d=new IU(c,DP()),e.next=27,d.generatePreProcessingTrack(r);case 27:return e.abrupt("return",[u,d]);case 28:return e.abrupt("return",[u,void 0]);case 29:case"end":return e.stop()}}),e,null,[[5,14]])}))),UU.apply(this,arguments)}function VU(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:DP();return new yU(e,t)}function FU(e,t){return BU.apply(this,arguments)}function BU(){return(BU=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new EU(t,DP()),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 jU(e,t){return GU.apply(this,arguments)}function GU(){return(GU=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new kU(t,DP()),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 HU(e,t){return zU.apply(this,arguments)}function zU(){return(zU=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new AU(t,DP()),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 XU(e,t){return KU.apply(this,arguments)}function KU(){return(KU=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new RU(t,DP()),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 qU=mU,YU=yU,WU=function(e){return e[e.NONE=0]="NONE",e}(WU||{}),QU=function(){function e(){qd(this,e)}return Kd(e,null,[{key:"getNalunits",value:function(t){if(t.length-t.position<4)return[];var r=t.position;return 1===t.getInt32(r)||0===t.getInt16(r)&&1===t.getInt8(r+2)?e.getAnnexbNals(t):e.getAvccNals(t)}},{key:"getAnnexbNals",value:function(t){for(var r=[],n=e.getHeaderPositionAnnexB(t),i=n.pos,o=i;i<t.length-4;){var a,s,u=new Uint8Array(ym(a=t.buffer).call(a,i,i+n.headerLength));n.pos===t.position&&t.skip(n.headerLength),o=(n=e.getHeaderPositionAnnexB(t)).pos;var c={header:u,body:new Uint8Array(ym(s=t.buffer).call(s,i+u.byteLength,o)),type:-1};e.analyseNal(c),c.type<=9&&0!==c.type&&r.push(c),t.skip(o-t.position),i=o}return r}},{key:"getAvccNals",value:function(t){for(var r=[];t.position<t.length-4;){var n=t.getInt32(t.position);if(!(t.length-t.position>=n))break;var i,o,a=new Uint8Array(ym(i=t.buffer).call(i,t.position,t.position+4));t.skip(4);var s=new Uint8Array(ym(o=t.buffer).call(o,t.position,t.position+n));t.skip(n);var u={header:a,body:s,type:-1};e.analyseNal(u),u.type<=9&&0!==u.type&&r.push(u)}return r}},{key:"analyseNal",value: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}}},{key:"getHeaderPositionAnnexB",value: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}}}]),e}(),JU=function(){function e(t){qd(this,e),sd(this,"_position",0),sd(this,"_dataview",void 0),this._dataview=new DataView(t)}return Kd(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}(),ZU=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(ZU||{}),$U=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),eV=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]),tV=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 rV(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function nV(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 iV=function(){function e(){qd(this,e)}return Kd(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?$U:eV,s=rV(e.byteLength+a.byteLength),u=tV(e);return new Uint8Array(Rm(t=[]).call(t,Kk(n),Kk(i),Kk(o),Kk(s),Kk(a),Kk(u),[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=ym(e).call(e,0,e.length-1));if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=WT(nV(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=eV.byteLength&&i>=eV.byteLength&&ym(t).call(t,r,r+eV.byteLength).toString()===eV.toString()?(r+=eV.byteLength,o=1):t.byteLength>=eV.byteLength&&i>=eV.byteLength&&ym(t).call(t,r,r+$U.byteLength).toString()===$U.toString()&&(r+=$U.byteLength,o=0),{type:o,payload:ym(t).call(t,r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new FS,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=WT(nV(e.payload,r),2),i=n[0];r=n[1];var o,a=WT(nV(e.payload,r),2),s=a[0];if(r=a[1],t.get(i)||!(s<=e.payload.byteLength-r))break;t.set(i,ym(o=e.payload).call(o,r,r+s)),r+=s}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=YT(e);try{for(n.s();!(t=n.n()).done;){var i=WT(t.value,2),o=i[0],a=i[1],s=rV(o),u=rV(a.byteLength);r.push(s,u,a)}}catch(l){n.e(l)}finally{n.f()}var c=$S(r).call(r,(function(e,t){return e+t.byteLength}),0),d=new Uint8Array(c);return $S(r).call(r,(function(e,t){return d.set(t,e),e+t.byteLength}),0),d}}]),e}(),oV=function(){function e(t){qd(this,e),sd(this,"player",void 0),sd(this,"_timer",void 0),sd(this,"handler",void 0),sd(this,"_monitor",void 0),this.id=t,this._monitor=mP(t)}return Kd(e,[{key:"setVar",value:function(e){this.handler=e}},{key:"clearTimer",value:function(){this._timer&&(clearTimeout(this._timer),delete this._timer,SP(this.id,"del_media_statistics_timer","".concat((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(){SP(this.id,"media_statistics_destroy","".concat((new Error).stack),0,"".concat(this._stream.streamId)),this.clearTimer()}}]),e}(),aV=function(e){wI(i,e);var t,r,n=XI(i);function i(e,t){var r;return qd(this,i),sd(QT(r=n.call(this,e)),"_context",void 0),r._stream=t,r}return Kd(i,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t,r){var n,i,o,a=this;if(!this._timer){this.setVar(t),this._context=r;var s={audio:{},video:{}},u=this._stream,c=null===(n=u.audioTrack)||void 0===n?void 0:n.getTrack("preprocessing"),d=null===(i=u.videoTrack)||void 0===i?void 0:i.getTrack("preprocessing");this.getAudioStats(c,s,null===(o=u.audioTrack)||void 0===o?void 0:o.getAudioLevel()),this.getVideoStats(d,s);var l=function(){var e=Em(Sm().mark((function e(){var t,r,n,i,o,c,d;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=u.audioTrack)||void 0===t?void 0:t.getTrack("preprocessing"),o=null===(r=u.videoTrack)||void 0===r?void 0:r.getTrack("preprocessing"),e.next=4,a.getAudioStats(i,s,null===(n=u.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return c=e.sent,e.next=7,a.getVideoStats(o,s);case 7:return d=e.sent,e.abrupt("return",{audioStats:c,videoStats:d,isScreen:u.isScreen});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),h=function(){var t=Em(Sm().mark((function t(){var r;return Sm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,l();case 2:r=t.sent,e(r),a._timer=setTimeout(h,2e3);case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();this._timer=setTimeout(h,2e3)}}},{key:"unpublish",value:function(){this.clearTimer()}},{key:"getAudioStats",value:(r=Em(Sm().mark((function e(t,r,n){var i,o,a,s,u,c,d,l,h,v,p,f,_;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o={},a={timestamp:Date.now()},s=this._stream,u=s.streamId,c=s.audioMid,d=s.isScreen,l=s.pubAttributes,h=s.pubAudio,v=s.audioTrack,p={media_type:"audio",is_screen:!!d,direction:"up",stream_id:u,vid:c,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:l.localaudio?"capture_state_on":"capture_state_off",mute_state:h?"mute_state_off":"mute_state_on"},v&&(p.playback_volume=v.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",o);case 7:return e.next=9,this.handler.getStats(t);case 9:if((f=e.sent).length){e.next=12;break}return e.abrupt("return",o);case 12:if(f.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,i=e.bytesSent,s=e.clockRate,u=e.roundTripTime,c=e.channels,d=e.audioLevel;e.googRtt;var l=e.mimeType,h=e.availableIncomingBitrate,v=e.availableOutgoingBitrate,f=e.bytesReceived,_=e.nominated,m=e.id,g=e.currentRoundTripTime,y=e.state,S=e.writable,b=e.requestsReceived,E=e.responsesReceived,k=e.requestsSent,T=e.consentRequestsSent,I=e.responsesSent,A=e.jitter,R=e.candidateType,w=e.ip,C=e.address,x=e.networkType,P=e.port,O=e.protocol,D=e.nackCount,M=e.retransmittedBytesSent,N=e.retransmittedPacketsSent,L=e.audioInputLevel,U=e.ssrc,V=e.totalAudioEnergy,F=e.totalSamplesDuration,B=e.mediaType,j=e.fractionLost;"outbound-rtp"===t?(a.packetsSent=r,a.bytesSent=i,p.bytes=i,p.packetsSent=r,p.nackCount=D,p.ssrc=U,p.retransmitted_bytes_sent=M,p.retransmitted_packets_sent=N,a.retransmittedBytesSent=M,a.retransmittedPacketsSent=N):"remote-inbound-rtp"===t?(a.packetsLost=n,p.packetsLost=n,p.net_jitter=1e3*A,o.rtt=1e3*u,p.rtt=o.rtt,o._fractionLost=j||0):"codec"===t?(o.recordSampleRate=s,o.numChannels=c,p.codecName=l):"media-source"===t&&void 0!==d?(p.audio_level=d?-10*XR(Math.pow(d,2)):d,p.volume=255*d,p.total_audio_energy=V,p.totalInputDuration=F):"ssrc"===t&&"audio"===B?p.send_level=L:"candidate-pair"===t?(p.ice_available_incoming_bitrate=h,p.ice_available_outgoing_bitrate=v,p.ice_bytes_received=f,p.ice_bytes_sent=i,p.ice_nominated=+_,p.ice_pair_id=m,p.ice_pair_rtt=g,p.ice_pair_state=y,p.ice_pair_writable=S,p.recv_ping_requests=b,p.recv_ping_responses=E,p.sent_ping_requests_before_first_response=k,p.sent_ping_requests_total=k+(T||0),p.sent_ping_responses=I):"local-candidate"===t?(p.local_candidate_type=R,p.local_ip=w||C,p.local_network_type=x,p.local_port=P,p.protocol=O):"remote-candidate"===t&&(p.remote_candidate_type=R,p.remote_ip=w||C,p.remote_port=P);var G=OO("STATS_SCALLBACK_SUPPORT");FP&&G||"media-source"===t&&(p.send_level=d)})),void 0===p.volume&&void 0!==n&&(p.volume=n,p.audio_level=n?-10*XR(Math.pow(n/255,2)):n),(_=r.audio).timestamp){e.next=18;break}return r.audio=a,e.abrupt("return",this.filterIllegal(o));case 18:return void 0!==a.packetsLost&&(o.audioLossRate=(a.packetsLost-_.packetsLost)/(a.packetsSent-_.packetsSent),o.audioLossRate=Number.isNaN(o.audioLossRate)?0:o.audioLossRate,p.fraction_lost=o.audioLossRate),o.statsInterval=a.timestamp-_.timestamp,p.stats_interval=o.statsInterval,o.sendKBitrate=(a.bytesSent-_.bytesSent||0)/o.statsInterval*8,p.mediaBitratebps=Math.round(1e3*o.sendKBitrate),p.bandwidth=Math.round(p.mediaBitratebps/1024),void 0!==a.retransmittedBytesSent&&(p.retransmitBitratebps=(a.retransmittedBytesSent-_.retransmittedBytesSent||0)/o.statsInterval),r.audio=a,null===(i=this._monitor)||void 0===i||i.report("rtc_media_statistics",p),o._retransmittedRate=(a.retransmittedPacketsSent-_.retransmittedPacketsSent)/(a.packetsSent-_.packetsSent),void 0===o.audioLossRate&&(o.audioLossRate=o._retransmittedRate,p.fraction_lost=o.audioLossRate),o._fractionLost=Math.max(o._fractionLost,o.audioLossRate),e.abrupt("return",this.filterIllegal(o));case 31:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S;return Sm().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,u=o.isScreen,c=o.pubAttributes,d=o.enableSimulcast,l=o.pubVideo,e.t0=cd,e.t1={media_type:"video",is_screen:!!u,direction:"up",stream_id:a,vid:s,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:c.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,n.isScreen=u,e.next=16,this.handler.getStats(t);case 16:if((v=e.sent).length){e.next=19;break}return e.abrupt("return",n);case 19:if(p=0,v.forEach((function(e){var o=e.type,a=e.framesEncoded,s=e.packetsLost,u=e.bytesSent,c=e.framesSent,l=e.retransmittedBytesSent,v=e.totalPacketSendDelay,f=e.totalEncodeTime,_=e.firCount,m=e.targetBitrate,g=e.roundTripTime,y=e.mimeType,S=e.frameWidth,b=e.frameHeight,E=e.packetsSent,k=e.googActualEncBitrate,T=e.googAvailableReceiveBandwidth,I=e.googAvailableSendBandwidth,A=e.googAvgEncodeMs,R=e.googBucketDelay,w=e.googEncodeUsagePercent,C=e.googFrameRateInput,x=e.availableIncomingBitrate,P=e.availableOutgoingBitrate,O=e.bytesReceived,D=e.nominated,M=e.id,N=e.currentRoundTripTime,L=e.state,U=e.writable,V=e.candidateType,F=e.ip,B=e.address,j=e.networkType,G=e.port,H=e.nackCount,z=e.pliCount,X=e.protocol,K=e.qpSum,q=e.requestsReceived,Y=e.responsesReceived,W=e.googRetransmitBitrate,Q=e.requestsSent,J=e.consentRequestsSent,Z=e.responsesSent,$=e.ssrc,ee=e.googTargetEncBitrate,te=e.googTransmitBitrate,re=e.retransmittedPacketsSent,ne=e.encoderImplementation,ie=e.jitter,oe=e.rid,ae=e.fractionLost,se=e.googAdaptationChanges,ue=e.qualityLimitationReason,ce=e.qualityLimitationDurations,de=e.googFirsReceived,le=e.googFrameRateSent,he=e.keyFramesEncoded;"outbound-rtp"===o?(d&&(oe?i.simulcast[oe]=e:i.simulcast[p]=e,p++),i.framesEncoded=a||i.framesEncoded||0,h.key_frames_encoded=he||0,i.bytesSent=u||i.bytesSent||0,i.framesSent=c||i.framesSent||0,h.bytes=u||h.bytes||0,i.packetsSent=E||i.packetsSent||0,h.packetsSent=E||h.packetsSent||0,h.nackCount=H||h.nackCount||0,h.pli_count=z||h.pli_count||0,h.qp_sum=K||h.qp_sum||0,h.ssrc=$||h.ssrc||0,h.retransmitted_packets_sent=re,i.retransmittedPacketsSent=re,i.retransmittedBytesSent=l,h.encoder_implementation=ne,h.qualityLimitationReason=ue,h.qualityLimitationDurations=ce,void 0!==S&&((!n.encodedFrameWidth||S>n.encodedFrameWidth)&&(n.encodedFrameWidth=S),(!n.encodedFrameHeight||b>n.encodedFrameHeight)&&(n.encodedFrameHeight=b),h.frame_size_height=b,h.frame_size_width=S)):"track"===o?(n.encodedFrameWidth=S,n.encodedFrameHeight=b,h.frame_size_height=b,h.frame_size_width=S):"remote-inbound-rtp"===o?(i.packetsLost=s,n.rtt=1e3*g,h.rtt=n.rtt,h.jitter=ie,h.packetsLost=s,n._fractionLost=ae||0):"codec"===o?(n.codecType=y,h.codecName=y):"candidate-pair"===o?(h.ice_available_incoming_bitrate=x,h.ice_available_outgoing_bitrate=P,h.ice_bytes_received=O,h.ice_bytes_sent=u,h.ice_nominated=+D,h.ice_pair_id=M,h.ice_pair_rtt=N,h.ice_pair_state=L,h.ice_pair_writable=U,h.recv_ping_requests=q,h.recv_ping_responses=Y,h.sent_ping_requests_before_first_response=Q,h.sent_ping_requests_total=Q+J,h.sent_ping_responses=Z):"local-candidate"===o?(h.local_candidate_type=V,h.local_ip=F||B,h.local_network_type=j,h.local_port=G,h.protocol=X):"remote-candidate"===o?(h.remote_candidate_type=V,h.remote_ip=F||B,h.remote_port=G):"VideoBwe"===o?(h.encBitratebps=k,h.available_receive_bandwidth=T,h.available_send_bandwidth=I,h.bucket_delay=R,h.retransmitBitratebps=W,h.targetEncBitratebps=ee,h.transmit_bitrate=te,n._sendBandWidth=+I):"ssrc"===o&&(h.avg_encode_ms=A,h.encodeUsage=w,h.frame_rate_input=C,h.orignal_input_Framerate=+C,h.ddaptationChanges=se,h.firsReceived=de,h.frameRateSent=le);var ve=OO("STATS_SCALLBACK_SUPPORT");if(!FP||!ve){var pe=r.video,fe=i.timestamp-pe.timestamp;if("outbound-rtp"===o){var _e=u-pe.bytesSent,me=l-pe.retransmittedBytesSent;h.encBitratebps=Math.round(8e3*(_e-me)/fe),h.bucket_delay=v/E,h.retransmitBitratebps=Math.round(8e3*me/fe),h.targetEncBitratebps=m,h.transmit_bitrate=Math.round(1e3*(u-pe.bytesSent)*8/fe),h.avg_encode_ms=1e3*f/a,h.firsReceived=_+z}else"candidate-pair"===o&&(h.available_send_bandwidth=P,n._sendBandWidth=P);if(t){var ge=null==t?void 0:t.getSettings().frameRate;h.orignal_input_Framerate=ge,h.frameRateSent=t.getSettings().frameRate}}})),(f=r.video).timestamp){e.next=25;break}return r.video=i,e.abrupt("return",this.filterIllegal(n));case 25: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=[],y=!1,LA(_).call(_,(function(e,t){return+e-+t})).forEach((function(e){var t=i.simulcast[e],r=t.frameWidth,o=t.frameHeight,a=t.bytesSent,s=t.framesEncoded,u=t.framesSent,c=t.packetsLost,d=t.packetsSent,l=t.qualityLimitationReason,v=t.qualityLimitationDurations,p=t.qualityLimitationResolutionChanges,_=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(p));var S=f.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),S){var b=(a-S.bytesSent||0)/n.statsInterval;h.sim_enc_bps.push(Math.round(8e3*b)),h.sim_enc_bandwidth.push(Math.round(8e3*b/1024));var E=1e3*(s-S.framesEncoded)/n.statsInterval;h.sim_enc_framerate.push(Math.round(E)),h.sim_rids.push(e);var k=void 0!==u?u-S.framesSent:s-S.framesEncoded,T=1e3*k/n.statsInterval;h.sim_sent_framerate.push(Math.round(T));var I=(c-S.packetsLost)/(d-S.packetsSent);n._retransmittedRate=(_-S.retransmittedPacketsSent)/(d-S.packetsSent),I=Number.isNaN(I)?0:I,h.sim_fraction_lost.push(I),h.sim_keyencoded.push(m-S.pliCount>0),h.sim_retransmittedRate.push(n._retransmittedRate),r>0&&!y&&(n.sentKBitrate=8*b,n.encoderOutputFrameRate=E,n.encodedFrameCount=k,n.sentFrameRate=T,n.videoLossRate=I,y=!0)}})),null===(g=this._monitor)||void 0===g||g.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),null===(S=this._monitor)||void 0===S||S.report("rtc_media_statistics",h)),r.video=i,n._fractionLost=Math.max(n._fractionLost,n.videoLossRate),e.abrupt("return",this.filterIllegal(n));case 32:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}(oV),sV=function(e){wI(o,e);var t,r,n,i=XI(o);function o(e,t){var r;return qd(this,o),sd(QT(r=i.call(this,e)),"isPaused",void 0),sd(QT(r),"pauseStart",void 0),sd(QT(r),"pauseDuration",void 0),sd(QT(r),"_audioStallCount",void 0),sd(QT(r),"_setAudioStallCount",void 0),sd(QT(r),"_audioStallTimer",void 0),sd(QT(r),"_audioStallInterval",void 0),sd(QT(r),"_audioStallRatio",void 0),sd(QT(r),"_videoInWaiting",void 0),sd(QT(r),"_context",void 0),r._stream=t,r._videoInWaiting=!1,r.pauseDuration=0,r}return Kd(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=Em(Sm().mark((function e(t,r,n){var i,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S=this;return Sm().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 this.setVar(r),this._context=n,this._audioStallInterval=o.audioStallInterval||100,this._audioStallRatio=o.audioStallRatio||.6,u={audio:{},video:{}},c=this._stream,d=null===(i=c.audioTrack)||void 0===i?void 0:i.getOrgTrack(),l=null===(a=c.videoTrack)||void 0===a?void 0:a.getTrack(),this.getRemoteVideoStats(l,u),e.next=13,this.getRemoteAudioStats(d,u,null===(s=this._stream.audioTrack)||void 0===s?void 0:s.getAudioLevel());case 13:this.delStatsEvtInterval(),h=0,v=0,f=[],_=0,m=MP(),this._setAudioStallCount=function(){if(xO.AUDIO_STALL&&S._audioStallInterval>0&&void 0!==u.audio.concealedSamples){var e=u.audio.concealedSamples,t=u.audio.totalSamplesReceived;m=MP();var r={isStall:!1,counted:!1,diff:0},n=.5*S._audioStallInterval;S._audioStallCount=Em(Sm().mark((function i(){var o,a,s,u,d,l,p,g,y,b,E,k,T,I,A,R,w;return Sm().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=c.hasAudio,s=c.subAudio,a&&s){i.next=7;break}return r.isStall=!1,r.counted=!1,f.push({reason:Rm(u="hasAudio: ".concat(a,", subAudio: ")).call(u,s)}),m=MP(),i.abrupt("return",{stall_count:h,stall_duration:v,stall_list:f,stats_count:_});case 7:return d=null===(o=c.audioTrack)||void 0===o?void 0:o.getOrgTrack(),l=Date.now(),i.next=11,S.handler.getStats(d,!0);case 11:if(p=i.sent,g=Date.now(),y=MP(),!((b=y-m)<n)){i.next=18;break}return f.push({diff:b,start:m,end:y,get_stats_cost:g-l,get_stats_start:l,get_stats_end:g,reason:Rm(E="diff(".concat(b,") < minInterval(")).call(E,n,")")}),i.abrupt("return",{stall_count:h,stall_duration:v,stall_list:f,stats_count:_});case 18:if(k=p.length,T=oE(p).call(p,(function(e){return"inbound-rtp"===e.type}))){i.next=23;break}return f.push({diff:b,start:m,end:y,get_stats_cost:g-l,get_stats_start:l,get_stats_end:g,reason:k?"no inbound-rtp":"no report"}),i.abrupt("return",{stall_count:h,stall_duration:v,stall_list:f,stats_count:_});case 23:return I=T.concealedSamples,A=T.totalSamplesReceived,w=A-t,(R=I-e)>=0&&w>=0&&R>=S._audioStallRatio*w?(f.push({concealed:R,received:w,diff:b,start:m,end:y,get_stats_cost:g-l,get_stats_start:l,get_stats_end:g,is_stall:!0}),r.isStall?(r.counted?v+=b:(v=v+r.diff+b,h++),r.counted=!0):b>=200?(v+=b,h++,r.counted=!0):(r.counted=!1,r.diff=b),r.isStall=!0):(f.push({concealed:R,received:w,diff:b,start:m,end:y,get_stats_cost:g-l,get_stats_start:l,get_stats_end:g}),r.isStall=!1,r.counted=!1),e=I,t=A,m=y,_++,i.abrupt("return",{stall_count:h,stall_duration:v,stall_list:f,stats_count:_});case 32:case"end":return i.stop()}}),i)}))),p=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!S._audioStallCount&&S._setAudioStallCount&&S._setAudioStallCount(),!S._audioStallCount){e.next=6;break}return e.next=4,S._audioStallCount();case 4:S._audioStallTimer&&clearTimeout(S._audioStallTimer),S._audioStallTimer=setTimeout(p,S._audioStallInterval);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),S._audioStallTimer&&clearTimeout(S._audioStallTimer),S._audioStallTimer=setTimeout(p,S._audioStallInterval)}},this._setAudioStallCount(),g=function(){var e=Em(Sm().mark((function e(){var t,r,n,i,o,a,s;return Sm().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,S.getRemoteAudioStats(i,u,null===(n=S._stream.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return a=e.sent,h=0,v=0,f=[],_=0,e.next=11,S.getRemoteVideoStats(o,u);case 11:return s=e.sent,e.abrupt("return",{audioStats:a,videoStats:s,isScreen:c.isScreen,userId:c.userId});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),y=function(){var e=Em(Sm().mark((function e(){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,g();case 2:r=e.sent,t(r),p&&(m=MP(),S._audioStallTimer&&clearTimeout(S._audioStallTimer),S._audioStallTimer=setTimeout(p,S._audioStallInterval)),S._timer&&clearTimeout(S._timer),S._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 25:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"delStatsEvtInterval",value:function(){AI(TI(o.prototype),"clearTimer",this).call(this),clearTimeout(this._audioStallTimer),this._audioStallCount=void 0,this._setAudioStallCount=void 0,this.pauseDuration=0}},{key:"unsubscribe",value:function(){this.delStatsEvtInterval(),this._videoInWaiting=!1}},{key:"getRemoteAudioStats",value:(r=Em(Sm().mark((function e(t,r,n){var i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o={},a={},s=this._stream,u=s.streamId,c=s.userId,d=s.isScreen,l=s.audioMid,h=s.subMediaType,v=s._attributes,p=s.virtual,f=s.audioTrack,_={media_type:"audio",is_screen:!!d,direction:"down",stream_id:u,stream_user_id:c,vid:l,audio_mux:p,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:cO(h)?"mute_state_off":"mute_state_on",remote_user_capture_state:v.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:v.localaudio&&v.audiostream?"mute_state_off":"mute_state_on"},f&&(_.playback_volume=f.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",o);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",o);case 12:if(m.forEach((function(e){var t=e.type,r=e.packetsLost,i=e.packetsReceived,s=e.bytesReceived,c=e.jitterBufferDelay,d=e.jitterBufferEmittedCount,l=e.clockRate,h=e.channels,v=e.totalSamplesReceived,p=e.concealedSamples,f=e.silentConcealedSamples,m=e.concealmentEvents,g=e.totalRoundTripTime,y=e.packetsDiscarded,S=e.state,b=e.currentRoundTripTime,E=e.audioLevel,k=e.totalAudioEnergy,T=e.totalSamplesDuration,A=e.mimeType,R=e.googDecodingNormal,w=e.googDecodingMuted,C=e.availableIncomingBitrate,x=e.availableOutgoingBitrate,P=e.bytesSent,O=e.nominated,D=e.id,M=e.writable,N=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,X=e.requestsSent,K=e.consentRequestsSent,q=e.responsesSent,Y=e.ssrc;e.kind;var W=e.nackCount,Q=e.lastPacketReceivedTimestamp,J=e.concealmentevents,Z=e.fecPacketsReceived;if("inbound-rtp"===t)a.packetsLost=r,a.packetsReceived=i,_.packetsReceived=i,_.packetsDiscarded=y,_.nackCount=W,_.lastPacketReceivedTimestamp=Q,_.concealmentevents=J,a.bytesReceived=s,void 0!==c&&(o.jitterBufferDelay=c/d*1e3,_.average_jitter_buffer_delay_ms=o.jitterBufferDelay),void 0!==v&&(a.totalSamplesReceived=v,o.concealedSamples=p,a.concealedSamples=p,a.silentConcealedSamples=f,_.concealedSamples=p,o.concealmentEvents=m,_.totalSamplesReceived=v),void 0!==Z&&(_.fec_packets_received=Z,a.fecPacketsReceived=Z),_.jitter=1e3*N,_.ssrc=Y,void 0!==E&&0!==E?(_.audio_level=E?-10*XR(Math.pow(E,2)):E,_.volume=255*E):(_.volume=null!=n?n:255*E,_.audio_level=n?-10*XR(Math.pow(n/255,2)):n),void 0!==k&&(_.total_audio_energy=k),void 0!==T&&(_.totalAudioDuration=T);else if("codec"===t)o.recordSampleRate=l,h&&(o.numChannels=h),_.codecName=A;else if("candidate-pair"===t){var $,ee,te;_.ice_available_incoming_bitrate=C,_.ice_available_outgoing_bitrate=x,_.ice_bytes_received=s,_.ice_bytes_sent=P,_.ice_nominated=+O,_.ice_pair_id=D,_.ice_pair_rtt=b,_.rtt=1e3*b,_.rtt&&null!==($=I._context)&&void 0!==$&&null!==(ee=$.streamRTT)&&void 0!==ee&&null!==(te=ee[u])&&void 0!==te&&te.audio&&(_.total_rtt_ms=_.rtt+I._context.streamRTT[u].audio),_.ice_pair_state=S,_.ice_pair_writable=M,_.recv_ping_requests=H,_.recv_ping_responses=z,_.sent_ping_requests_before_first_response=X,_.sent_ping_requests_total=X+(K||0),_.sent_ping_responses=q,"succeeded"===S&&(o.rtt=1e3*b,o.total_rtt=1e3*g)}else"track"===t&&void 0!==E?(0===E&&0!==n?(_.volume=n,_.audio_level=n?-10*XR(Math.pow(n/255,2)):n):(_.audio_level=E?-10*XR(Math.pow(E,2)):E,_.volume=255*E),_.total_audio_energy=k,_.totalAudioDuration=T):"ssrc"===t?(_.decodingNormal=R,_.recvAudioLevel=G,_.decodingMuted=w):"local-candidate"===t?(_.local_candidate_type=L,_.local_ip=U||V,_.local_network_type=F,_.local_port=B,_.protocol=j):"remote-candidate"===t&&(_.remote_candidate_type=L,_.remote_ip=U||V,_.remote_port=B)})),(g=r.audio).timestamp){e.next=18;break}return a.timestamp=Date.now(),r.audio=a,e.abrupt("return",this.filterIllegal(o));case 18:if(y={},void 0!==a.concealedSamples&&(_.interval_concealed_samples=a.concealedSamples-g.concealedSamples,_.interval_samples_received=a.totalSamplesReceived-g.totalSamplesReceived,_.interval_silent_concealed_samples=a.silentConcealedSamples-g.silentConcealedSamples),!(this._audioStallInterval>0&&void 0!==g.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:S=e.sent,b=S.stall_count,E=S.stall_duration,k=S.stall_list,T=S.stats_count,y.stall_list=k,y.stats_count=T,_.concealedSamples===_.interval_concealed_samples&&_.totalSamplesReceived===_.interval_samples_received?(_.stall_count=0,_.stall_duration=0):(_.stall_count=b,_.stall_duration=E),o.stallCount=_.stall_count,o.stallDuration=_.stall_duration;case 36:return a.timestamp=Date.now(),o.audioLossRate=(a.packetsLost-g.packetsLost)/(a.packetsReceived-g.packetsReceived+(a.packetsLost-g.packetsLost)),o.audioLossRate=Number.isNaN(o.audioLossRate)?0:o.audioLossRate,_.packetsLost=Math.round(a.packetsLost-g.packetsLost),_.fraction_lost=o.audioLossRate,o.statsInterval=a.timestamp-g.timestamp,_.stats_interval=o.statsInterval,o.receivedKBitrate=(a.bytesReceived-g.bytesReceived||0)/o.statsInterval*8,_.bandwidth=Math.round(1e3*o.receivedKBitrate/1024),void 0!==a.concealedSamples&&(o.receivedSampleRate=1e3*_.interval_samples_received/o.statsInterval),void 0!==a.fecPacketsReceived&&(_.fecBitratebps=(a.fecPacketsReceived-g.fecPacketsReceived||0)/o.statsInterval),_.average_jitter_buffer_delay_ms&&_.total_rtt_ms&&(o.e2eDelay=_.average_jitter_buffer_delay_ms+_.total_rtt_ms),r.audio=a,null===(i=this._monitor)||void 0===i||i.report("rtc_media_statistics",_,y),e.abrupt("return",this.filterIllegal(o));case 51:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h,v,p,f,_=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={},o={timestamp:Date.now()},a=this._stream,s=a.streamId,u=a.userId,c=a.isScreen,d=a.subMediaType,l=a._attributes,e.t0=cd,e.t1={media_type:"video",is_screen:!!c,direction:"down",stream_id:s,stream_user_id:u,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:dO(d)?"mute_state_off":"mute_state_on",remote_user_capture_state:l.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:l.localvideo&&l.videostream?"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",i);case 11:return i.isScreen=c,e.next=14,this.handler.getStats(t);case 14:if((v=e.sent).length){e.next=17;break}return e.abrupt("return",i);case 17:if(v.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,a=e.packetsLost,u=e.packetsReceived,c=e.bytesReceived,d=e.framesDecoded,l=e.jitterBufferDelay,v=e.jitterBufferEmittedCount,p=e.mimeType,f=e.firCount,m=e.availableIncomingBitrate,g=e.availableOutgoingBitrate,y=e.bytesSent,S=e.nominated,b=e.id,E=e.currentRoundTripTime,k=e.state,T=e.writable,I=e.candidateType,A=e.ip,R=e.address,w=e.networkType,C=e.port,x=e.nackCount,P=e.pliCount,O=e.protocol,D=e.requestsReceived,M=e.responsesReceived,N=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;if("inbound-rtp"===t)o.packetsLost=a,h.packetsLost=a,o.packetsReceived=u,h.packetsReceived=u,o.bytesReceived=c,h.bytes=c,o.framesDecoded=d,o.totalDecodeTime=G,void 0!==l&&(o.jitterBufferDelay=l/v*1e3,h.average_jitter_buffer_delay_ms=o.jitterBufferDelay),h.fir_count=f,h.nackCount=x,o.nackCount=x,h.pli_count=P,h.ssrc=V,h.jitter=F,h.framesReceived=B,o.framesReceived=B,h.framesDecoded=d,h.key_frames_decoded=j,h.decoder_name=H,h.last_packet_received_timestamp=z,void 0!==n&&(i.width=n,h.frame_size_width=n,i.height=r,h.frame_size_height=r);else if("track"===t&&void 0!==n)i.width=n,h.frame_size_width=n,i.height=r,h.frame_size_height=r,void 0!==B&&(h.framesReceived=B,o.framesReceived=B);else if("codec"===t)h.codecName=p;else if("candidate-pair"===t){var X,K,q;h.ice_available_incoming_bitrate=m,h.ice_available_outgoing_bitrate=g,h.ice_bytes_received=c,h.ice_bytes_sent=y,h.ice_nominated=+S,h.ice_pair_id=b,h.ice_pair_rtt=E,h.rtt=1e3*E,h.rtt&&null!==(X=_._context)&&void 0!==X&&null!==(K=X.streamRTT)&&void 0!==K&&null!==(q=K[s])&&void 0!==q&&q.video&&(h.total_rtt_ms=h.rtt+_._context.streamRTT[s].video),i.rtt=h.rtt,h.ice_pair_state=k,h.ice_pair_writable=T,h.recv_ping_requests=D,h.recv_ping_responses=M,h.sent_ping_requests_before_first_response=N,h.sent_ping_requests_total=N+(L||0),h.sent_ping_responses=U}else"local-candidate"===t?(h.local_candidate_type=I,h.local_ip=A||R,h.local_network_type=w,h.local_port=C,h.protocol=O):"remote-candidate"===t&&(h.remote_candidate_type=I,h.remote_ip=A||R,h.remote_port=C)})),(p=r.video).timestamp){e.next=22;break}return r.video=o,e.abrupt("return",this.filterIllegal(i));case 22:return i.videoLossRate=(o.packetsLost-p.packetsLost)/(o.packetsReceived-p.packetsReceived+(o.packetsLost-p.packetsLost)),p.totalDecodeTime&&p.framesDecoded&&o.framesDecoded!==p.framesDecoded&&(h.decode_elapse_per_frame=+((o.totalDecodeTime-p.totalDecodeTime)/(o.framesDecoded-p.framesDecoded)*1e3).toFixed(2)),i._retransmittedRate=(o.nackCount-p.nackCount)/(o.packetsReceived-p.packetsReceived+(o.packetsLost-p.packetsLost)),i.videoLossRate=Number.isNaN(i.videoLossRate)?0:i.videoLossRate,h.fraction_lost=i.videoLossRate,i.statsInterval=o.timestamp-p.timestamp,h.stats_interval=i.statsInterval,i.receivedKBitrate=(o.bytesReceived-p.bytesReceived||0)/i.statsInterval*8,h.bitrate=Math.round(1e3*i.receivedKBitrate),h.bandwidth=Math.round(h.bitrate/1024),i.decoderOutputFrameRate=1e3*(o.framesDecoded-p.framesDecoded)/i.statsInterval,i.receivedFrameRate=1e3*(o.framesReceived-p.framesReceived)/i.statsInterval,h.frame_rate_decoded=Math.round(i.decoderOutputFrameRate),h.frame_rate_received=Math.round(i.receivedFrameRate),h.average_jitter_buffer_delay_ms&&h.total_rtt_ms&&(i.e2eDelay=h.average_jitter_buffer_delay_ms+h.total_rtt_ms),r.video=o,this.processStall(this._stream,h,i,c),this.isPaused?(f=o.timestamp-(this.pauseStart||0),h.pause_duration=this.pauseDuration+(f>500?f:0),this.pauseStart=o.timestamp):h.pause_duration=this.pauseDuration,h.pause_duration=Math.min(h.stall_duration||h.stuck_length||0,h.pause_duration),this.pauseDuration=0,null===(n=this._monitor)||void 0===n||n.report("rtc_media_statistics",h),e.abrupt("return",this.filterIllegal(i));case 44: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(){AI(TI(o.prototype),"destroy",this).call(this),this.delStatsEvtInterval(),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}(oV);sd(sV,"audioStallInterval",void 0),sd(sV,"audioStallRatio",void 0);var uV,cV,dV,lV=new nP("Stream",0),hV=function(e){wI(r,e);var t=XI(r);function r(){var e,n;qd(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return sd(QT(n=t.call.apply(t,Rm(e=[this]).call(e,o))),"videoDom",void 0),n}return Kd(r,[{key:"requestVideoFrameCallback",value:function(){var e=this;return new X_((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 Rm(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(){this.statsReport.destroy()}}]),r}(sD),vV=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}(vV||{}),pV=function(e){wI(r,e);var t=XI(r);function r(e){var n;return qd(this,r),sd(QT(n=t.call(this)),"isScreen",!1),sd(QT(n),"stream",void 0),sd(QT(n),"streamId",void 0),sd(QT(n),"audioMid",void 0),sd(QT(n),"videoMid",void 0),sd(QT(n),"seiList",[]),sd(QT(n),"videoTrack",void 0),sd(QT(n),"audioTrack",void 0),sd(QT(n),"videoTransceiver",void 0),sd(QT(n),"audioTransceiver",void 0),sd(QT(n),"videoEncodeConfig",[MO]),sd(QT(n),"subVideoDescriptions",[]),sd(QT(n),"enableSimulcast",!1),sd(QT(n),"observer",void 0),sd(QT(n),"statsReport",void 0),sd(QT(n),"prevBitrate",0),sd(QT(n),"pubAudio",!1),sd(QT(n),"pubVideo",!1),sd(QT(n),"pubAttributes",void 0),n.engineId=e,n.stream=new MediaStream,n.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1},n.statsReport=new aV(e,QT(n)),n}return Kd(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:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.sender){var t=this.videoTransceiver.sender;if(FN()){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=iV.generateSEI(n.content),a=new Uint8Array(o.byteLength+t.data.byteLength);if(0===n.repeatCount)GE(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 lV.print("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 lV.print("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){var e;SP(this.engineId,"localstream_clean","".concat((new Error).stack),0,this.streamId||""),this.audioMid=void 0,this.videoMid=void 0,this.videoTransceiver=void 0,this.audioTransceiver=void 0,null===(e=this.observer)||void 0===e||e.reset(),this.stopReport(),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}(hV),fV=function(e){wI(r,e);var t=XI(r);function r(e,n,i,o,a){var s;return qd(this,r),sd(QT(s=t.call(this)),"streamId",void 0),sd(QT(s),"userId",void 0),sd(QT(s),"isScreen",void 0),sd(QT(s),"hasVideo",void 0),sd(QT(s),"hasAudio",void 0),sd(QT(s),"_attributes",void 0),sd(QT(s),"streamState",void 0),sd(QT(s),"observer",void 0),sd(QT(s),"statsReport",void 0),sd(QT(s),"subVideo",void 0),sd(QT(s),"subAudio",void 0),sd(QT(s),"subMediaType",void 0),sd(QT(s),"subLayer",void 0),sd(QT(s),"audioMid",void 0),sd(QT(s),"videoMid",void 0),sd(QT(s),"_sequenceId",void 0),sd(QT(s),"stream",void 0),sd(QT(s),"videoTrack",void 0),sd(QT(s),"audioTrack",void 0),sd(QT(s),"videoTransceiver",void 0),sd(QT(s),"audioTransceiver",void 0),sd(QT(s),"recordedVideoFrames",void 0),sd(QT(s),"stillExist",void 0),sd(QT(s),"originalMediaType",void 0),sd(QT(s),"priority",void 0),sd(QT(s),"originalStreamIndex",0),sd(QT(s),"virtual",void 0),s.engineId=e,s.virtual=!1,s.userId=n,s.isScreen=o,s.streamId=i,s.hasAudio=a.audiostream&&a.localaudio,s.hasVideo=a.videostream&&a.localvideo,s._attributes=a,s.subVideo=!1,s.subAudio=!1,s._sequenceId=0,s.subMediaType=WU.NONE,s.subLayer={spatialLayer:0,spatialSubLayer:-1},s.streamState=0,s.statsReport=new sV(e,QT(s)),s}return Kd(r,[{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:"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}},{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){QU.getNalunits(new JU(t.data)).forEach((function(t){if(t.sei){var r=iV.decodeSeiBody(t.body);r&&r.type!==ZU.internal&&e.safeEmit("onSEIMessage",r.payload)}})),r.enqueue(t)}})).pipeTo(n)}else lV.print("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){t.enqueue(e)}})).pipeTo(r)}else lV.print("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r,n,i,o,a;try{var s;SP(this.engineId,"Stream.ontrack",ZE({uid:this.userId,streamId:this.streamId,streams:$S(s=e.streams).call(s,(function(e,t){return e+(null==(r=t)?"undefined | null":"string"==typeof r?r:ZE({id:r.id,active:r.active}));var r}),""),transceiver:(i=e.transceiver,null==i?"undefined | null":"string"==typeof i?i:ZE({currentDirection:i.currentDirection,direction:i.direction,mid:i.mid,stopped:i.stopped,receiver:(a=i.receiver,null==a?"undefined | null":"string"==typeof a?a:ZE({track:vO(a.track)})),sender:(o=i.sender,null==o?"undefined | null":"string"==typeof o?o:ZE({track:vO(o.track)}))})),track:vO(e.track)}),0,this.streamId||"")}catch(eX){}if(null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&vk(n).call(n,this.streamId)){var u,c=e.track;"video"===(null==c?void 0:c.kind)?this._setVideoTrack(c):"audio"===(null===(u=e.track)||void 0===u?void 0:u.kind)&&this._setAudioTrack(c),this._setStream(e.streams[0])}this.safeEmit("ontrack",e)}},{key:"clean",value:function(){var e,t,r;lV.print("clean",Rm(e="exec stream.clean ".concat(this.streamId," ")).call(e,this.userId)),SP(this.engineId,"remotestream_clean","".concat((new Error).stack),0,this.streamId),this.subAudio=!1,this.subVideo=!1,this.audioMid=void 0,this.videoMid=void 0,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.videoTransceiver=void 0,this.audioTransceiver=void 0,this.recordedVideoFrames=void 0,null===(r=this.observer)||void 0===r||r.reset(),this.stopReport(),delete this.priority}},{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=VU(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]:DP();return new gU(e,t)}(e),this.emit("ontrack",this.videoTrack))}},{key:"_getSubLayerBySpatialLayer",value:function(e){var t=this._attributes,r=t.videoDescriptions,n=t.subVideoDescriptions,i=void 0===n?[]:n,o=r[e],a=o.width,s=o.height,u=oE(i).call(i,(function(e){return e.width===a&&e.height===s}));return{spatialLayer:e,spatialSubLayer:(null==u?void 0:u.sub_index)||-1}}}]),r}(hV),_V=new nP("queue",4),mV=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(mV||{}),gV=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}(gV||{}),yV=(sd(uV={},"publish","unpublish"),sd(uV,"subscribe","unsubscribe"),sd(uV,"pushtrack","removetrack"),uV),SV=(sd(cV={},"publish",0),sd(cV,"subscribe",0),sd(cV,"pushtrack",0),sd(cV,"unpublish",1),sd(cV,"unsubscribe",1),sd(cV,"removetrack",1),cV),bV=function(e){wI(r,e);var t=XI(r);function r(){var e;return qd(this,r),sd(QT(e=t.call(this)),"_queue",void 0),e._queue=[],e}return Kd(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!==yV[t.action]||(n=t.streamId,_V.print("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;eO&&eO>=86&&eO<=92&&(t=Math.min(this._queue.length,5));for(var r=SV[this._queue[0].action],n=1;n<t;n++){var i;if(SV[this._queue[n].action]!==r)return{sdpStrategy:r,items:GE(i=this._queue).call(i,0,n)}}return{sdpStrategy:r,items:GE(e=this._queue).call(e,0,t)}}}]),r}(oD),EV=new nP("ChromeHandler",3),kV=FN(),TV=function(e){wI(l,e);var t,r,n,i,o,a,s,u,c,d=XI(l);function l(e){var t;return qd(this,l),sd(QT(t=d.call(this,e)),"name","chrome"),sd(QT(t),"_queueBusy",!1),sd(QT(t),"_sdpQueue",void 0),sd(QT(t),"_aSendonlyOfferTpl",void 0),sd(QT(t),"_vSendonlyOfferTpl",void 0),sd(QT(t),"_aRecvonlyOfferTpl",void 0),sd(QT(t),"_vRecvonlyOfferTpl",void 0),sd(QT(t),"_mid",10),sd(QT(t),"_offerSession",void 0),sd(QT(t),"_answerSession",void 0),sd(QT(t),"_offerMlines",[]),sd(QT(t),"_answerMlines",[]),sd(QT(t),"_inactiveMlineIndex",[]),sd(QT(t),"_mlinesCache",{}),t._sdpQueue=new bV,t._sdpQueue.on("start",(function(){t._queueBusy||"stable"!==t._peerConnection.signalingState||(EV.print("dequeue start"),t.dequeue())})),t}return Kd(l,[{key:"connect",value:(c=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return EV.print("connect","invoke connect"),this._offerIce={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=4,uL(this.id,t);case 4:return this._answerIce=e.sent,this._connectionId=this._answerIce.iceUfrag,e.next=8,this._peerConnection.createOffer();case 8:return i=e.sent,o=jN.parse(i.sdp),a=WT(o.media,1),s=a[0],this._offerIce.fingerprint=o.fingerprint||s.fingerprint,delete o.media,this._offerSession=cd({},o),this._answerSession=cd({},o),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),this._offerMlines=[cd(cd(cd({},s),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[cd(cd(cd({},s),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription(),e.next=22,new X_((function(e,t){u._dataChannel.onopen=function(){EV.print("connect","dataChannel open"),u._reportRtcInvokeStatus("es.dc.open",""),e("")},u._dataChannel.onerror=function(e){u._report("rtc_signaling_msg_error",{error_code:e.error.sdpLineNumber,message:e.error.errorDetail,reason:"invalid data"}),u._reportRtcInvokeStatus("es.dc.error",""),t(e)},u._dataChannel.onclose=function(e){u._reportRtcInvokeStatus("es.dc.close",""),t(e)},u._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==u._peerConnection.iceConnectionState&&"closed"!==u._peerConnection.iceConnectionState&&"failed"!==u._peerConnection.connectionState||t(e)}))}));case 22:return EV.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 24:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"disconnect",value:function(){this._peerConnection.close(),this._dataChannel.close(),this._peerConnection.ontrack=null}},{key:"destroy",value:function(){AI(TI(l.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(u=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A,R,w,C,x,P,O,D,M,N,L,U,V,F;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=t.stream,d=t.enableSimulcast,h=AI(TI(l.prototype),"internalPublish",this).call(this,t),v=h.videoDescriptions,p=h.subVideoDescriptions,f=h.audioTransceiverInit,_=h.videoTransceiverInit,m=nL(this._nextSsrc),this._nextSsrc=m.next,g="".concat(this._mid++),y="".concat(this._mid++),S=cd(cd(cd({},this._aSendonlyOfferTpl),this._offerIce),{},{mid:g,msid:Rm(r="".concat(c.id," ")).call(r,c.id,"-audio"),ssrcs:iL(c.id,"audio",m.audio,tL)}),b=cd(cd(cd({},this._vSendonlyOfferTpl),this._offerIce),{},{mid:y,msid:Rm(n="".concat(c.id," ")).call(n,c.id,"-video")}),d?(EV.print("subVideoDesc","desc: %o ",p),delete b.ssrcGroups,delete b.ssrcs,E=[],b.rids=YE(v).call(v,(function(e){var t=e.rid;return E.unshift(t),{id:t,direction:"send"}})),b.simulcast={dir1:"send",list1:E.join(";")}):(k=oL(c.id,m,{cname:tL}),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!==(R=XA(A=S.rtp).call(A,(function(e){return"red"===e.codec})))&&(C=GE(w=S.rtp).call(w,R,1),x=WT(C,1),P=x[0],S.rtp.unshift(P)),O=[],S.rtp.forEach((function(e){return O.push(e.payload)})),S.payloads=O.join(" ")),null!==(a=this._context)&&void 0!==a&&null!==(s=a.serverConfig)&&void 0!==s&&s.videoCodec&&hL(b,null===(D=this._context)||void 0===D||null===(M=D.serverConfig)||void 0===M?void 0:M.videoCodec),(jP||qP)&&Array.isArray(b.ext)&&(b.ext=Gs(N=b.ext).call(N,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&vk(t).call(t,"video-orientation"))}))),(L=null==S?void 0:oE(u=S.rtp).call(u,(function(e){return"opus"===e.codec})))&&S.fmtp&&(F=oE(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)),d||jP||this.addBitrateLimit(b,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[S,b],e.abrupt("return",{partialSdp:sL(this._offerSession,S,b),audioMid:g,videoMid:y,type:"incroffer",semantics:"unified-plan",videoDescriptions:v,subVideoDescriptions:p,audioTransceiverInit:f,videoTransceiverInit:_});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"subscribe",value:(s=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A,R,w,C,x,P,O,D=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(EV.print("subscribe"),a="incroffer",s="unified-plan",this._aRecvonlyOfferTpl&&this._vRecvonlyOfferTpl){e.next=9;break}return e.next=6,this._genOfferSdp();case 6:return u=e.sent,e.next=9,this.createAVMlineOfferTpl(u);case 9:if(c="",d="",l=!1,h=!1,v=void 0,p=void 0,this._mlinesCache[t.streamId]=[v,p],t.virtual?(c="".concat(this._mid++),l=!0):r.multiChatMode?(c="".concat(this._mid++),d="".concat(this._mid++),h=!0):(l=!0,h=!0,c="".concat(this._mid++),d="".concat(this._mid++)),c&&(v=cd(cd({},this._aRecvonlyOfferTpl),{},{mid:c})),l&&(this._mlinesCache[t.streamId][0]=v,f={track:"audio",init:{direction:"recvonly"}}),d&&(p=cd(cd({},this._vRecvonlyOfferTpl),{},{mid:d})),h&&(this._mlinesCache[t.streamId][1]=p,_={track:"video",init:{direction:"recvonly"}}),m=sL(this._offerSession,v,p),g=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._vSendonlyAnswerTpl){e.next=32;break}return g=nL(this._nextSsrc),this._nextSsrc=g.next,A=cd(cd(cd({},this._aSendonlyAnswerTpl),this._answerIce),{},{mid:c,msid:Rm(y=Rm(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:iL(t.streamId,"audio",g.audio)}),R=cd(cd(cd({},this._vSendonlyAnswerTpl),this._answerIce),{},{mid:d,msid:Rm(E=Rm(k="".concat(t.streamId)).call(k,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-video"," ")).call(E,t.streamId,"-video")},oL(t.streamId,g,{flexfec:this._enableSubFlexfec})),w=new X_((function(e){D._sdpQueue.enqueue({action:gV.subscribe,streamId:t.streamId,audioMid:c,videoMid:d,audioTransceiverInit:f,videoTransceiverInit:_,signalingAck:{sdp:jN.write(cd(cd({},D._answerSession),{},{media:[A,R]})),sequenceId:t.sequenceId?++t.sequenceId:0},stream:t,sdp:m,onSuccess:function(){EV.print("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:oE(i=n.rtp).call(i,(function(e){return"opus"===e.codec})))&&null!==(o=v)&&void 0!==o&&o.fmtp&&(O=null===(x=v)||void 0===x?void 0:oE(P=x.fmtp).call(P,(function(e){return e.payload===C.payload})))&&this._context&&(O.config+=";stereo=1;sprop-stereo=1"),e.abrupt("return",{partialSdp:m,audioMid:c,videoMid:d,type:a,semantics:s,audioTransceiverInit:f,videoTransceiverInit:_,allSsrc:g});case 35:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(EV.print("handleAck()","item: %o",t),!t.generatorSsrc){e.next=4;break}return EV.print("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 a.apply(this,arguments)})},{key:"dequeue",value:(o=Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u,c,d,l,h,v,p,f,_=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._queueBusy=!0,t=this._sdpQueue.dequeue(),EV.print("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!==mV.ADD){e.next=15;break}return e.delegateYield(Sm().mark((function e(){var t,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(t=cd({},_._answerIce)).candidates,s=!1,u=!1,e.prev=4,d=FD(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,u=n.audioTransceiverInit,c=n.videoTransceiverInit,d=n.signalingAck,l=n.stream,h=l instanceof fV;if(n.onSuccess&&a.push(n.onSuccess),h&&(null==d?void 0:d.sequenceId)<l.sequenceId)return"break";var v,p={},f={},m=jN.parse(d.sdp);Array.isArray(m.media)&&LA(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=cd(cd({},n),t)).type?(p=n).mid=e:(f=n).mid=r}));var g,y=l.streamId;if(s===gV.publish&&(y=null===(g=l.stream)||void 0===g?void 0:g.id),!_._mlinesCache[y])return"break";var S=WT(_._mlinesCache[y],2),b=S[0],E=S[1];if(u&&b){l.audioTransceiver=_._peerConnection.addTransceiver(u.track,u.init),_._reportRtcInvokeStatus("chromeHandler.addTrack",ZE({audioStreamTrack:vO(u.track)}));var k=_._inactiveMlineIndex.shift();k||(k=_._offerMlines.length),_._offerMlines[k]=cd({},b),_._answerMlines[k]=p,kV&&l.initAudioEncodedTransform()}if(c&&E){var T,I;l.videoTransceiver=_._peerConnection.addTransceiver(c.track,c.init),_._reportRtcInvokeStatus("chromeHandler.addTrack",ZE({videoStreamTrack:vO(c.track)}));var A,R,w=_._inactiveMlineIndex.shift();w||(w=_._offerMlines.length),_._offerMlines[w]=cd({},E),s===gV.publish&&null!==(T=_._context)&&void 0!==T&&null!==(I=T.serverConfig)&&void 0!==I&&I.videoCodec&&hL(f,null===(A=_._context)||void 0===A||null===(R=A.serverConfig)||void 0===R?void 0:R.videoCodec),_._answerMlines[w]=f,kV&&l.initVideoEncodedTransform()}i.push(l.streamId||""),o.push(h?l.userId:"local"),h&&(l.sequenceId=null==d?void 0:d.sequenceId),delete _._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),u=!0,c=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,!u){e.next=30;break}throw c;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!==gV.removetrack&&(f[r]=r),f[t]=t})),this._offerMlines=YE(h=this._offerMlines).call(h,(function(e,t){return f[e.mid]&&(e=aL(e),_._inactiveMlineIndex.push(t)),e})),LA(v=this._inactiveMlineIndex).call(v,(function(e,t){return e-t})),this._answerMlines=YE(p=this._answerMlines).call(p,(function(e){return f[e.mid]&&(e=aL(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(eX){}EV.print("dequeue","loop"),e.next=29;break;case 26:e.prev=26,e.t1=e.catch(6),EV.print("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 o.apply(this,arguments)})},{key:"setDescription",value:(i=Em(Sm().mark((function e(t){var r,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return EV.print("setDescription"),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=MP(),t&&this._report("rtc_begin_create_offer",{direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId}),e.next=10,this._peerConnection.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:MP()-n}),e.next=13,this.setLocalDescription(jN.write(this._offerSession),t);case 13:return e.next=15,this.setRemoteDescription(jN.write(this._answerSession),t);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getDefaultSdp",value:(n=Em(Sm().mark((function e(){var t,r,n,i;return Sm().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=jN.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(e.mid+""),!0)})),n.groups=[{mids:i.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:jN.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=Em(Sm().mark((function e(t){return Sm().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;jN.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=Em(Sm().mark((function e(){var t,r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,aO(!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 cR(sR.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)})}]),l}(fL),IV=new nP("FirefoxHandler",3),AV=function(e){wI(l,e);var t,r,n,i,o,a,s,u,c,d=XI(l);function l(){var e,t;qd(this,l);for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return sd(QT(t=d.call.apply(d,Rm(e=[this]).call(e,n))),"name","firefox"),sd(QT(t),"_aRecvonlyOfferTpl",void 0),t}return Kd(l,[{key:"connect",value:(c=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l,h=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IV.print("connect","invoke connect"),this._offerIce={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=4,uL(this.id,t);case 4:return this._answerIce=e.sent,this._connectionId=this._answerIce.iceUfrag,this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),this._peerConnection.addTransceiver("video",{direction:"recvonly"}),e.next=10,this._peerConnection.createOffer();case 10:return s=e.sent,u=jN.parse(s.sdp),c=WT(u.media,1),d=c[0],this._offerIce.fingerprint=u.fingerprint||d.fingerprint,u.media=YE(i=u.media).call(i,(function(e){return cd(cd({},e),h._offerIce)})),YE(o=u.media).call(o,(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===_E(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})))})),(l=cd({},u)).fingerprint=this._answerIce.fingerprint,l.media=YE(a=l.media).call(a,(function(e){return delete(e=cd(cd({},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=21,this.setLocalDescription(jN.write(u));case 21:return e.next=23,this.setRemoteDescription(jN.write(l));case 23:return e.next=25,new X_((function(e,t){h._dataChannel.onopen=function(){IV.print("connect","dataChannel open"),h._reportRtcInvokeStatus("es.dc.open",""),e("")},h._dataChannel.onerror=function(e){h._report("rtc_signaling_msg_error",{error_code:e.error.sdpLineNumber,message:e.error.errorDetail,reason:"invalid data"}),h._reportRtcInvokeStatus("es.dc.error",""),t(e)},h._dataChannel.onclose=function(e){h._reportRtcInvokeStatus("es.dc.close",""),t(e)},h._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==h._peerConnection.iceConnectionState&&"closed"!==h._peerConnection.iceConnectionState&&"failed"!==h._peerConnection.connectionState||t(e)}))}));case 25:return IV.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 27:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"publish",value:(u=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,h,v,p,f,_,m=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=AI(TI(l.prototype),"internalPublish",this).call(this,t),o=i.videoDescriptions,a=i.subVideoDescriptions,s=i.audioTransceiverInit,u=i.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(s.track,s.init),t.videoTransceiver=this._peerConnection.addTransceiver(u.track,u.init),c=MP(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:""}),e.next=7,this._peerConnection.createOffer();case 7:return d=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:MP()-c}),(h=jN.parse(d.sdp)).media=null===(r=h.media)||void 0===r?void 0:YE(r).call(r,(function(e){return cd(cd({},e),m._offerIce)})),e.next=13,this.setLocalDescription(jN.write(h));case 13:return v=t.audioTransceiver.mid,p=t.videoTransceiver.mid,f=null,_=null,h.media=null===(n=h.media)||void 0===n?void 0:YE(n).call(n,(function(e){if("".concat(e.mid)===v){var t,r,n=null===(t=f=e)||void 0===t?void 0:oE(r=t.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&f.fmtp){var i,o,a=oE(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)===p){var s,u,c,d;null!==(s=m._context)&&void 0!==s&&null!==(u=s.serverConfig)&&void 0!==u&&u.videoCodec&&hL(e,null===(c=m._context)||void 0===c||null===(d=c.serverConfig)||void 0===d?void 0:d.videoCodec),_=e}return e})),this.addBitrateLimit(_,t.videoEncodeConfig[0].maxKbps),e.next=21,this.setLocalDescription(jN.write(h));case 21:return e.abrupt("return",{partialSdp:sL(h,f,_,!1),audioMid:v,videoMid:p,type:"incroffer",semantics:"unified-plan",videoDescriptions:o,subVideoDescriptions:a,audioTransceiverInit:s,videoTransceiverInit:u});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"subscribe",value:(s=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A,R=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IV.print("subscribe()"),u="",c="",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"})),p=MP(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId}),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:MP()-p}),(_=jN.parse(f.sdp)).media=null===(n=_.media)||void 0===n?void 0:YE(n).call(n,(function(e){return cd(cd({},e),R._offerIce)})),YE(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===_E(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(jN.write(_),{streamId:t.streamId||"",streamUserId:t.userId});case 21:if(u=null===(o=t.audioTransceiver)||void 0===o?void 0:o.mid,c=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid,null===(s=_.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===u?h=e:"".concat(e.mid)===c&&(v=e)})),u&&h||(u="audio_".concat(c),h=cd(cd({},this._aRecvonlyOfferTpl),{},{mid:u})),t.audioMid=u,t.videoMid=c,m=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=36;break}return m=nL(this._nextSsrc),this._nextSsrc=m.next,I=cd(cd(cd({},this._aSendonlyAnswerTpl),this._answerIce),{},{mid:u,msid:Rm(g=Rm(y="".concat(t.streamId)).call(y,null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-audio"," ")).call(g,t.streamId,"-audio"),ssrcs:iL(t.streamId,"audio",m.audio)}),A=cd(cd(cd({},this._vSendonlyAnswerTpl),this._answerIce),{},{mid:c,msid:Rm(b=Rm(E="".concat(t.streamId)).call(E,null!==(k=this._context)&&void 0!==k&&k.avSync?"":"-video"," ")).call(b,t.streamId,"-video")},oL(t.streamId,m,{flexfec:this._enableSubFlexfec})),e.next=35,this._internalSetRemoteDescription([I,A],t);case 35:null===(T=m)||void 0===T||delete T.next;case 36:return e.abrupt("return",{partialSdp:sL(_,h,v,!1),audioMid:u,videoMid:c,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});case 37:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Em(Sm().mark((function e(t){var r,n,i,o;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==gV.unpublish&&i!==gV.unsubscribe&&i!==gV.removetrack){e.next=5;break}return e.next=4,this.close(n);case 4:return e.abrupt("return",n.streamId||"");case 5:if(!t.generatorSsrc){e.next=8;break}return IV.print("already set remote"),e.abrupt("return","");case 8:return o=jN.parse(null==r?void 0:r.sdp),e.next=11,this._internalSetRemoteDescription(o.media,n);case 11:return e.abrupt("return","");case 12:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(u=jN.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=cd(cd({},e),l._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type){if(r instanceof pV&&KP<=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}})),c=jN.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=YE(o=c.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),u.groups=c.groups,u.media=d,YE(a=u.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===_E(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(jN.write(u));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Em(Sm().mark((function e(){var t,r,n,i,o;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=jN.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(e.mid+""),!0)})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:jN.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=Em(Sm().mark((function e(t,r,n){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IV.print("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=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return IV.print("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 u=e.sent,(c=jN.parse(null==u?void 0:u.sdp)).media=YE(n=c.media).call(n,(function(e){return a[e.mid]&&(e=aL(e)),"inactive"!==e.direction&&s.push(e.mid),cd(cd({},e),h._offerIce)})),d=jN.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=YE(o=c.media).call(o,(function(e){return"inactive"===e.direction?e:l[e.mid]})),c.groups&&d.groups&&(c.groups[0].mids=s.join(" "),d.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(jN.write(c));case 17:return e.next=19,this.setRemoteDescription(jN.write(d));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Em(Sm().mark((function e(){return Sm().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;jN.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),l}(fL),RV=function(e){return BP?new AV(e):new TV(e)},wV=new nP("Locker",2),CV=1,xV=function(){function e(t){var r;qd(this,e),sd(this,"lockingPromise",X_.resolve()),sd(this,"locks",0),sd(this,"name",""),sd(this,"lockId",void 0),this.lockId=CV++,t&&(this.name=t),wV.print(Rm(r="[lock-".concat(this.name,"-")).call(r,this.lockId,"] is created."))}return Kd(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t,r,n=this;this.locks+=1,wV.print(Rm(e=Rm(t="[lock-".concat(this.name,"-")).call(t,this.lockId,"] locked, current queue ")).call(e,this.locks,"."));var i=new X_((function(e){r=function(){var t,r;n.locks-=1,wV.print(Rm(t=Rm(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}(),PV=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}(PV||{}),OV=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}(OV||{}),DV=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(DV||{}),MV=function(e){return e[e.SUB=0]="SUB",e[e.UNSUB=1]="UNSUB",e}(MV||{}),NV=(sd(dV={},Od.communication,[0]),sd(dV,Od.chat,[0]),sd(dV,Od.chatRoom,[1,"IES_chatroom"]),sd(dV,Od.coHost,[1,"IES_PK"]),sd(dV,Od.meeting,[16]),sd(dV,Od.classRoom,[0]),dV),LV=ad,UV=tu,VV=function(e,t,r,n){for(var i,o=n>1?void 0:n?UV(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&&LV(t,r,o),o},FV=new nP("MediaServerClient",2),BV=6e4,jV=function(e){return e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTED="connected",e.CONNECTING="connecting",e}(jV||{}),GV=function(e,t){FV.print(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)},HV=function(e){wI(k,e);var t,r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E=XI(k);function k(e){var t;return qd(this,k),sd(QT(t=E.call(this)),"id",void 0),sd(QT(t),"_token",void 0),sd(QT(t),"_appId",void 0),sd(QT(t),"_roomId",void 0),sd(QT(t),"_roomAttributes",void 0),sd(QT(t),"_clientId",void 0),sd(QT(t),"_businessId",void 0),sd(QT(t),"_userInfo",void 0),sd(QT(t),"_useCloudProxy",void 0),sd(QT(t),"_expectedIDC",void 0),sd(QT(t),"_authorization",void 0),sd(QT(t),"_sessionId",void 0),sd(QT(t),"_iceConfigRequestManager",void 0),sd(QT(t),"_ontrackCallbackMap",new FS),sd(QT(t),"_subResolves",{}),sd(QT(t),"supportConcurrent",!1),sd(QT(t),"_handler",void 0),sd(QT(t),"_pubSubLock",void 0),sd(QT(t),"_joinLeaveLock",void 0),sd(QT(t),"_state",void 0),sd(QT(t),"_dataChannelSignal",void 0),sd(QT(t),"_subConfig",{}),sd(QT(t),"_monitor",void 0),sd(QT(t),"_roomProfile",Od.communication),sd(QT(t),"_context",void 0),sd(QT(t),"_subStreamQueue",{}),t.id=e.id,t._monitor=mP(t.id),t._pubSubLock=new xV("pubSubLock"),t._joinLeaveLock=new xV("joinLeaveLock"),t._state="disconnected",t._roomAttributes={multiChatMode:!1,bigRoomMode:!1},t._context=e,t.on("SUB_END",(function(e){return t._handleSubStreamQueue(e)})),t}return Kd(k,[{key:"_addHandlerEvents",value:function(){var e,t=this;null===(e=this._handler)||void 0===e||e.once("disconnect",(function(){FV.print("emit ABNORMAL_DISCONNECTION ice"),t.safeEmit(kD.ABNORMAL_DISCONNECTION)}))}},{key:"_addSignalEventHandler",value:function(){var e,t=this;[bD.ON_ADD_STREAM,bD.ON_ADD_STREAM_LIST,bD.ON_REMOVE_STREAM,bD.ON_REMOVE_STREAM_LIST,bD.USER_CONNECTION,bD.USER_CONNECTION_LIST,bD.USER_DISCONNECTION,bD.USER_DISCONNECTION_LIST,bD.ON_UPDATE_STREAM_ATTRIBUTES,bD.ON_UPDATE_ROOM_ATTRIBUTES,bD.ON_PUSH_TRACK,bD.NODE_CHANGE,bD.ON_CUSTOM_MESSAGE,bD.USER_MESSAGE_RECEIVED,bD.USER_BINARY_MESSAGE_RECEIVED,bD.POST_PROCESSING_MESSAGE,bD.ON_USER_TOKEN_WILL_EXPIRE,bD.STREAM_CONTROL_MESSAGE,bD.ON_UPDATE_USER_ATTRIBUTES,bD.ON_SPEAKER_CHANGE,ED.RSCP,ED.RTT,ED.SSC,bD.ON_STREAM_FAILED].forEach((function(e){var r;null===(r=t._dataChannelSignal)||void 0===r||r.on(e,(function(r){t.safeEmit(e,r)}))})),null===(e=this._dataChannelSignal)||void 0===e||e.once("close",(function(){FV.print("emit ABNORMAL_DISCONNECTION datachannel"),t.safeEmit(kD.ABNORMAL_DISCONNECTION)}))}},{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(kD.ON_CONNECTION_STATE_CHANGE,{prev:this._state,next:e}),this._state=e)}},{key:"businessId",set:function(e){this._businessId=e}},{key:"connect",value:(b=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u=this,c=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=c.length>1&&void 0!==c[1]?c[1]:{},this.connectionState="connecting",this._appId=t,this._handler&&(this._removeSignalEventHandler(),this._handler.destroy()),!r.node){e.next=9;break}n=[r.node],SP(this.id,"es.join.nodeChange",r),e.next=18;break;case 9:return X_.resolve().then((function(){return u.emit("onGetIceConfigHook")})),this._iceConfigRequestManager=new UD(this.id),e.next=13,null===(i=this._iceConfigRequestManager)||void 0===i?void 0:i.getAccessNode(t,null==r?void 0:r.reason,null==r?void 0:r.feedbackNode,this._useCloudProxy,this._expectedIDC);case 13:if(n=e.sent){e.next=17;break}throw SP(this.id,"es.join.getNodeFailed",""),new cR(sR.ICE_SERVER_WRONG,"get ICE config failed");case 17:SP(this.id,"es.join.getNodeSuccess",n);case 18:return X_.resolve().then((function(){return u.emit("onEstablishConnectionHook")})),e.prev=19,a=!1,s=YE(n).call(n,(function(e){var t=RV(u._context);return t.connect(e).then((function(r){var i,s;u.emit("onConnectSuccessHook",null===(i=n)||void 0===i?void 0:i.length),a?t.destroy():(a=!0,o=r,u.safeEmit("prevIceNode",e),u._handler=t,u.supportConcurrent="chrome"===t.name,u._addHandlerEvents(),null===(s=u._monitor)||void 0===s||s.set({connection_id:t.getConnectionId()}))})).catch((function(e){throw t.destroy(),e}))})),e.next=24,sO(s);case 24:FV.print("connect","establish peerConnection success"),e.next=31;break;case 27:throw e.prev=27,e.t0=e.catch(19),this.connectionState="disconnected",new cR(sR.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed",e.t0);case 31:if(!o){e.next=37;break}this._dataChannelSignal=new MD(this.id,o),this._addSignalEventHandler(),this._dataChannelSignal.sendPingSignaling(),e.next=39;break;case 37:throw this.connectionState="disconnected",new cR(sR.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed");case 39:case"end":return e.stop()}}),e,this,[[19,27]])}))),function(e){return b.apply(this,arguments)})},{key:"join",value:(S=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g=this,y=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=y.length>1&&void 0!==y[1]?y[1]:{},i=y.length>2&&void 0!==y[2]&&y[2],o=y.length>3?y[3]:void 0,FV.print("join()","info: %o, params: %o, reconnect: %o, controlMessage: %o",t,n,i,o),this._appId=t.appId,this._token=t.token,this._roomId=t.roomId,this._clientId=t.userInfo.userId,this._businessId=t.userInfo.businessId,this._userInfo=t.userInfo,this._useCloudProxy=t.useCloudProxy,this._expectedIDC=t.expectedIDC,this._roomProfile=t.roomProfile,this._sessionId=n.sessionId,this._handler){e.next=17;break}return e.next=17,this.connect(this._appId,n);case 17:return e.t0=UP.token2auth(this._appId,this._roomId,this._clientId,this._token),e.t1=this._sessionId||"",e.t2=Date.now(),e.t3=o,e.t4={extra_info:this._userInfo.extraInfo,role:this._userInfo.role},e.next=24,null===(r=this._handler)||void 0===r?void 0:r.getDefaultSdp();case 24:return e.t5=e.sent,e.next=27,AN(OO("PUB_SUB_MODE"));case 27:return e.t6=e.sent,e.t7=window.navigator.userAgent,e.t8=xO.VERSION,e.t9=IO.getDeviceId(),e.t10=this._appId,e.t11=this._roomId,e.t12=this._clientId,e.t13=this._businessId,e.t14=this._useCloudProxy,e.t15=NV[this._roomProfile]?NV[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},a={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=40,e.t18=SP,e.t19=this.id,e.t20=ZE,e.next=46,RN();case 46:e.t21=e.sent,e.t22=OO("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=55;break;case 53:e.prev=53,e.t25=e.catch(40);case 55:return X_.resolve().then((function(){return g.emit("onSendingJoinMessageHook")})),e.prev=56,u=i?"reconnected":"joinRoom",e.next=60,this._dataChannelSignal.sendSignaling(u,a);case 60:return c=e.sent,FV.print("join","send join message success"),d=c.config||{},l=d.engine_WEB,this._authorization=a.Authorization,this.connectionState="connected",IO.setEngineWebConfig(this._appId,this._roomId,l),this._context&&(this._context.serverConfig={videoCodec:(null==l?void 0:l.video_codec)||"H264",audioRed:!(null==l||!l.pub_audio_red),muteReplaceUnsub:!(null===(h=c.config)||void 0===h||!h.mute_replace_unsub),simulcastOnDemand:!(BP||!1===(null===(v=c.config)||void 0===v||null===(p=v.engine_VPM)||void 0===p||null===(f=p.ondemand)||void 0===f?void 0:f.enable))},"boolean"==typeof(null==l?void 0:l.av_sync)&&(this._context.avSync=l.av_sync)),sV.audioStallConfig=l,null!=c&&null!==(s=c.relayMessage)&&void 0!==s&&s.sdp&&(null===(_=this._handler)||void 0===_||_.createAVMlineAnswerTpl(c.relayMessage.sdp)),e.abrupt("return",c);case 72:if(e.prev=72,e.t26=e.catch(56),this.connectionState="disconnected",m={461:sR.ROOM_FORBIDDEN,462:sR.USER_FORBIDDEN},!((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)){e.next=80;break}throw new cR(sR.INVALID_TOKEN,(null===e.t26||void 0===e.t26?void 0:e.t26.message)||"Invalid token");case 80:if(!m[null===e.t26||void 0===e.t26?void 0:e.t26.code]){e.next=82;break}throw new cR(m[null===e.t26||void 0===e.t26?void 0:e.t26.code],(null===e.t26||void 0===e.t26?void 0:e.t26.message)||m[null===e.t26||void 0===e.t26?void 0:e.t26.code]);case 82:if(200===(null===e.t26||void 0===e.t26?void 0:e.t26.code)){e.next=84;break}throw new cR(sR.JOIN_ROOM_FAILED,(null===e.t26||void 0===e.t26?void 0:e.t26.message)||"Join room failed");case 84:case"end":return e.stop()}}),e,this,[[40,53],[56,72]])}))),function(e){return S.apply(this,arguments)})},{key:"publish",value:(y=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FV.print("publish()","localStream: %o",t),r=t.videoTrack,n=t.audioTrack,i=MP(),o="",a="",e.prev=6,e.next=9,null===(s=this._handler)||void 0===s?void 0:s.publish(t);case 9:if(g=e.sent){e.next=12;break}throw new cR(sR.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 12:if("H264"!==(null===(u=this._context)||void 0===u||null===(c=u.serverConfig)||void 0===c?void 0:c.videoCodec)){e.next=18;break}return e.next=15,NN();case 15:if(e.sent){e.next=18;break}throw new cR(sR.PUBLISH_FAILED,"h264 is not supported");case 18:return o=g.audioMid,a=g.videoMid,t.pubAttributes={localaudio:!!n,localvideo:!!r,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(r instanceof EU),extaudio:!!(n instanceof kU)},y={attributes:cd({videoDescriptions:g.videoDescriptions},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:o,videoMid:a,sdpInfo:{msid:t.stream.id,type:g.type,sdp:g.partialSdp,semantics:g.semantics}},(S=t.enableSimulcast&&(null===(d=this._context)||void 0===d||null===(l=d.serverConfig)||void 0===l?void 0:l.simulcastOnDemand)&&(null===(h=g.subVideoDescriptions)||void 0===h?void 0:h.length))&&(y.attributes.subVideoDescriptions=g.subVideoDescriptions),e.next=26,null===(v=this._dataChannelSignal)||void 0===v?void 0:v.sendSignaling("publish",y);case 26:if(200===(null==(b=e.sent)?void 0:b.code)){e.next=29;break}throw new cR(sR.PUBLISH_FAILED,(null==b?void 0:b.message)||"publish failed");case 29:if(null===(p=this._monitor)||void 0===p||p.report("rtc_recv_answer",{error_code:0,answer_type:"incranswer",sequence_id:(null==b||null===(f=b.relayMessage)||void 0===f?void 0:f.sequenceId)||0,message:null==b||null===(_=b.relayMessage)||void 0===_?void 0:_.sdp,direction:"up",stream_id:"",stream_user_id:""}),E=new X_((function(e,r){var n,i,s;null===(n=I._handler)||void 0===n||n.handleAck({action:gV.publish,streamId:b.streamId,audioMid:o,videoMid:a,audioTransceiverInit:null==g?void 0:g.audioTransceiverInit,videoTransceiverInit:null==g?void 0:g.videoTransceiverInit,signalingAck:{sdp:null==b||null===(i=b.relayMessage)||void 0===i?void 0:i.sdp,sequenceId:null==b||null===(s=b.relayMessage)||void 0===s?void 0:s.sequenceId},sdp:g.sdp,stream:t,onSuccess:function(){FV.print("publish()","publish success"),e(0)}})})),e.t0=!BP,!e.t0){e.next=35;break}return e.next=35,E;case 35:return S&&this.emit(ED.RSCP,[{StreamIds:[t.stream.id],Metadata:{VideoIndex:0}}]),t.streamId=b.streamId,t.videoMid=a,t.audioMid=o,t.subVideoDescriptions=g.subVideoDescriptions,null===(m=this._monitor)||void 0===m||m.report("rtc_publish_stat",{result:"success",is_screen:"0",start:i,message:"unknown"}),t.statsReport.setLocalStreamStatsEvtInterval((function(e){return I.emit("onLocalStreamStats",e)}),this._handler,this._context),e.abrupt("return");case 45:return e.prev=45,e.t1=e.catch(6),e.t1 instanceof Error&&(null===(T=this._monitor)||void 0===T||T.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:i,message:e.t1.message})),e.next=50,null===(k=this._handler)||void 0===k?void 0:k.rollback(t.stream.id,t);case 50:throw e.t1;case 51:case"end":return e.stop()}}),e,this,[[6,45]])}))),function(e){return y.apply(this,arguments)})},{key:"updatePubTrack",value:(g=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A,R,w,C,x,P,O;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:FV.print("updatePubTrack()","localStream: %o",t),i=t.videoTrack,o=t.audioTrack,a=t.pubAudio,s=t.pubVideo,u=null==o?void 0:o.getTrack("preprocessing"),c=null==i?void 0:i.getTrack("preprocessing"),s&&c?null===(d=t.videoTransceiver)||void 0===d||d.sender.replaceTrack(c):null===(l=t.videoTransceiver)||void 0===l||l.sender.replaceTrack(null),null===(r=this._handler)||void 0===r||r.updateMaxBitrate(t),a&&u?(v=o.mixType,(p=o.mixedAudioTrack)&&v!==jd.PLAYOUT&&!0===u.enabled&&(u=p),null===(h=t.audioTransceiver)||void 0===h||h.sender.replaceTrack(u)):(null===(f=t.audioTransceiver)||void 0===f||f.sender.replaceTrack(null),SP(this.id,"MediaClient.updatePubTrack(audio)","null"));try{SP(this.id,"MediaClient.updatePubTrack",ZE({audioStreamTrack:vO(u),videoStreamTrack:vO(c)}))}catch(eX){}for(m={},g=0,y=gR(_={localaudio:!!o,localvideo:!!i,videostream:s,audiostream:a,extvideo:!!(i instanceof EU),extaudio:!!(o instanceof kU)});g<y.length;g++)S=WT(y[g],2),b=S[0],(E=S[1])!==oI(t.pubAttributes,b)&&_D(m,b,E);if(an(m).length){e.next=13;break}return e.abrupt("return");case 13:return t.observer&&(k=t.observer,T=m.audiostream,I=m.videostream,A=m.localaudio,R=m.localvideo,w=m.extaudio,C=m.extvideo,void 0!==R?void 0!==C?k.setPushVideo(C):k.setEnableVideo(R):void 0!==I&&k.setUnmuteVideo(I),void 0!==A?void 0!==w?k.setPushAudio(w):k.setEnableAudio(A):void 0!==T&&k.setUnmuteAudio(T)),t.pubAttributes=_,x={roomId:this._roomId,streamId:t.streamId,attributes:m},e.next=18,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateStreamAttributes",x);case 18:if(200===(null==(P=e.sent)?void 0:P.code)){e.next=21;break}throw new cR(sR.UPDATE_TRACK_FAILED,(null==P?void 0:P.message)||"update track failed");case 21:if(!BP){e.next=24;break}return e.next=24,null===(O=this._handler)||void 0===O?void 0:O.setCurrentDescription();case 24:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"updateToken",value:(m=Em(Sm().mark((function e(t){var r,n,i,o,a;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FV.print("updateToken()","newToken: %o",t),this._token=t,this._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._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 cR(sR.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 cR(sR.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 m.apply(this,arguments)})},{key:"unpublish",value:(_=Em(Sm().mark((function e(t){var r,n,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FV.print("unpublish()","localStream: %o",t),i={roomId:this._roomId,initStreamId:t.initStreamId,streamId:t.streamId},null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unpublish",i),e.next=5,null===(n=this._handler)||void 0===n?void 0:n.handleAck({action:gV.unpublish,audioMid:t.audioMid,videoMid:t.videoMid,stream:t,streamId:t.streamId});case 5:t.statsReport.unpublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"subscribe",value:(f=Em(Sm().mark((function e(t,r,n){var i=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new X_(function(){var e=Em(Sm().mark((function e(o,a){var s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A,R,w,C,x,P,O,D,M,N,L,U,V,F;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.streamState!==vV.SUB_ED){e.next=2;break}return e.abrupt("return",i._updateSubTrack(t,r,MV.SUB).then(o,a));case 2:if(t.streamState!==vV.SUB_ING){e.next=7;break}return i._subStreamQueue[t.streamId]||(i._subStreamQueue[t.streamId]=[]),FV.print("_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(FV.print("subscribe()","mediaType: %o",r),GV("subscribe()",t),t.streamState=vV.SUB_ING,u=!1,c=!1,cO(r)&&(c=!0),dO(r)&&(u=!0),u||!i.multiChatMode()){e.next=17;break}return t.streamState=vV.INIT,i.emit("SUB_END",t.streamId),e.abrupt("return",o(null));case 17:return d=MP(),l=t.subVideo,h=[],v=!i.multiChatMode(),i._subResolves[t.streamId]||(i._subResolves[t.streamId]=[]),h.push(new X_((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new cR(sR.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),BV);t.on("ontrack",(function r(i){"video"===i.mediaType&&(FV.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v&&h.push(new X_((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new cR(sR.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),BV);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(FV.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p=function(e){t.ontrack(e)},null===(s=i._handler)||void 0===s||s.on("ontrack",p),i._ontrackCallbackMap.set(t,p),e.prev=27,e.next=30,null===(f=i._handler)||void 0===f?void 0:f.subscribe(t,{multiChatMode:i.multiChatMode()});case 30:if(I=e.sent){e.next=33;break}throw new cR(sR.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 33:return A=I.audioMid,R=I.videoMid,t.subVideo=u,w={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},C={audio:!i.multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:R,audioMid:A,sdpInfo:{sdp:null==I?void 0:I.partialSdp,semantics:null==I?void 0:I.semantics,type:null==I?void 0:I.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!i.multiChatMode()||c,video:u},qualityLayer:w},extra:{enableSendRTT:!0}},x=i._context||{},P=x.subscribeFallbackOption,O=x.userPriority,"number"==typeof P&&(C.config.fallbackOption=P),null!=O&&O.has(t.userId)&&(C.config.priority=O.get(t.userId)),null!=I&&I.allSsrc&&(C.extra.subscribeSSRC=I.allSsrc),e.next=44,null===(_=i._dataChannelSignal)||void 0===_?void 0:_.sendSignaling("subscribe",C);case 44:if(200===(null==(D=e.sent)?void 0:D.code)){e.next=47;break}throw new cR(sR.SUBSCRIBE_FAILED,(null==D?void 0:D.message)||"subscribe failed");case 47:return M=null==D?void 0:D.relayMessage,N=M.audioMid,L=M.videoMid,sd(m={},A,N),sd(m,R,L),U=m,FV.print("sub midmap",t.userId,U),t.videoMid=R,t.audioMid=A,t.subMediaType=r,t.streamState=vV.SUB_ED,t.subLayer=w,null===(g=i._monitor)||void 0===g||g.report("rtc_recv_answer",{error_code:0,answer_type:"incranswer",sequence_id:(null==D||null===(y=D.relayMessage)||void 0===y?void 0:y.sequenceId)||0,message:null==D||null===(S=D.relayMessage)||void 0===S?void 0:S.sdp,direction:"down",stream_id:t.streamId,stream_user_id:t.userId}),e.next=58,null===(b=i._handler)||void 0===b?void 0:b.handleAck({action:gV.subscribe,streamId:t.streamId,audioMid:A,videoMid:R,audioTransceiverInit:null==I?void 0:I.audioTransceiverInit,videoTransceiverInit:null==I?void 0:I.videoTransceiverInit,signalingAck:{sdp:null==D||null===(E=D.relayMessage)||void 0===E?void 0:E.sdp,sequenceId:null==D||null===(k=D.relayMessage)||void 0===k?void 0:k.sequenceId},stream:t,sdp:I.sdp,generatorSsrc:!!I.allSsrc});case 58:return e.next=60,X_.all(h);case 60:i.multiChatMode()||(t.subAudio=c),null===(T=i._monitor)||void 0===T||T.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)}),i._handler,i._context),o(null),i.emit("SUB_END",t.streamId),e.next=76;break;case 67:return e.prev=67,e.t0=e.catch(27),e.t0 instanceof Error&&(null===(F=i._monitor)||void 0===F||F.report("rtc_subscribe_stat",{result:"fail",start:d,message:e.t0.message,stream_user_id:t.userId})),t.subVideo=l,t.streamState=vV.INIT,e.next=74,null===(V=i._handler)||void 0===V?void 0:V.rollback(t.streamId,t);case 74:a(e.t0),i.emit("SUB_END",t.streamId);case 76:case"end":return e.stop()}}),e,null,[[27,67]])})));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){FV.print("_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 FV.print("_subStreamQueue","streamId: %o, END",e)}},{key:"controlMessage",value:(p=Em(Sm().mark((function e(t){var r,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FV.print("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:(v=Em(Sm().mark((function e(t){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FV.print("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:(h=Em(Sm().mark((function e(t,r,n){return Sm().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 h.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(l=Em(Sm().mark((function e(t,r){var n,i,o;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FV.print("updateSubTrack()","subLayer: %o",r),t.subLayer.spatialLayer!==r.spatialLayer||t.subLayer.spatialSubLayer!==r.spatialSubLayer){e.next=4;break}return FV.print("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 cR(sR.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 l.apply(this,arguments)})},{key:"updateSubPriority",value:(d=Em(Sm().mark((function e(t,r){var n,i,o;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FV.print("updateSubPriority()","priority: %o",r),t.priority!==r){e.next=4;break}return FV.print("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 cR(sR.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 d.apply(this,arguments)})},{key:"_updateSubTrack",value:(c=Em(Sm().mark((function e(t,r,n){var i,o,a,s,u,c,d,l;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FV.print("updateSubTrack()","mediaType: %o",r),GV("updateSubTrack()",t),!this.multiChatMode()||r!==Sd.AUDIO){e.next=5;break}return FV.print("updateSubTrack","multiChatMode mediaType only audio"),e.abrupt("return",t);case 5:return a=0,a=n===MV.SUB?t.subMediaType|r:t.subMediaType-(t.subMediaType&r),FV.print("updateSubTrack","prev: %o, direction: %o, mediaType: %o, newMediaType: %o",t.subMediaType,n,r,a),t.subMediaType===a&&FV.print("updateSubTrack","mediaType no change"),s=!1,u=!1,cO(a)&&(u=!0),dO(a)&&(s=!0),c={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:s,audio:!!this.multiChatMode()||u}}},e.next=15,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("updateSubscribe",c);case 15:if(200===(null==(d=e.sent)?void 0:d.code)){e.next=18;break}throw new cR(sR.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(u),t.subAudio=u),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 c.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(u=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return FV.print("subscribe4pushTrack()","streamInfo: %o",r),GV("subscribe4pushTrack()",t),t.subAudio=!0,null===(n=t.observer)||void 0===n||n.setPushTrack(!0),e.next=6,null===(i=this._handler)||void 0===i?void 0:i.subscribe(t,{multiChatMode:this.multiChatMode()});case 6:if(s=e.sent){e.next=9;break}throw new cR(sR.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 9:return u=s.audioMid,c=s.videoMid,(d=[]).push(new X_((function(e,r){var n=setTimeout((function(){return r(new cR(sR.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),BV);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(FV.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),l=function(e){t.ontrack(e)},null===(o=this._handler)||void 0===o||o.on("ontrack",l),this._ontrackCallbackMap.set(t,l),e.next=18,null===(a=this._handler)||void 0===a?void 0:a.handleAck({action:gV.pushtrack,streamId:t.streamId,audioMid:u,videoMid:c,stream:t,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:null==r?void 0:r.message,sdp:s.sdp});case 18:return e.next=20,X_.all(d);case 20:this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return h.emit("onRemoteStreamStats",e)}),this._handler,this._context);case 21:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(s=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:GV("unsubscribe4removeTrack()",t),FV.print("unsubscribe4removeTrack()","sequenceId: ",r.sequenceId);case 2:case"end":return e.stop()}}),e)}))),function(e,t){return s.apply(this,arguments)})},{key:"unsubscribe",value:(a=Em(Sm().mark((function e(t,r){var n,i,o=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>2&&void 0!==o[2]&&o[2],GV("unsubscribe()",t),!n){e.next=4;break}return e.abrupt("return",this._unsubscribe(t,r));case 4:if(!this.multiChatMode()||!dO(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!==WU.NONE){e.next=9;break}return e.abrupt("return",this._unsubscribe(t,r));case 9:return e.abrupt("return",this._updateSubTrack(t,r,MV.UNSUB));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"_unsubscribe",value:(o=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u;return Sm().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,MV.UNSUB));case 2:return s={roomId:this._roomId,streamId:t.streamId,userId:t.userId},null===(n=this._dataChannelSignal)||void 0===n||n.sendSignaling("unsubscribe",s).catch((function(){})),t.streamState=vV.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=11,null===(a=this._handler)||void 0===a?void 0:a.handleAck({action:gV.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 11:u=e.sent,this._subResolves[u]&&this._subResolves[u].forEach((function(e){return e(0)})),FV.print("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"removeOnTrackListener",value:function(e){var t,r=this._ontrackCallbackMap.get(e);r&&(null===(t=this._handler)||void 0===t||t.off("ontrack",r),this._ontrackCallbackMap.delete(e))}},{key:"handleRemoveStream",value:(i=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(GV("handleRemoveStream()",t),t.subVideo=!1,t.streamState!==vV.INIT){e.next=4;break}return e.abrupt("return");case 4:this.unsubscribe(t,Sd.AUDIO_AND_VIDEO,!0);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"leave",value:(n=Em(Sm().mark((function e(){var t,r,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FV.print("leave()"),"connected"!==this.connectionState){e.next=22;break}return this.connectionState="disconnecting",t={Authorization:this._authorization,roomId:this._roomId,sessionId:this._sessionId},e.next=6,this._joinLeaveLock.lock();case 6:return r=e.sent,e.prev=7,e.next=10,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("leaveRoom",t);case 10:this.connectionState="disconnected",e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(7),this.connectionState="connected",e.t0;case 17:return e.prev=17,r(),e.finish(17);case 20:e.next=23;break;case 22:return e.abrupt("return",X_.reject(new cR(sR.NOT_CONNECTED_YET,"server not connected")));case 23:case"end":return e.stop()}}),e,this,[[7,13,17,20]])}))),function(){return n.apply(this,arguments)})},{key:"subscribePublicStream",value:(r=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g=this;return Sm().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 cR(sR.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return u=MP(),c=s.audioMid,d=s.videoMid,e.t0=this._appId,e.t1=t.streamId,e.t2=c,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,AN();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=xO.VERSION,e.t8=IO.getDeviceId(),e.t9=this._appId,e.t10=this._businessId,e.t11=this._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 X_((function(e,r){g._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new cR(sR.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),BV);t.on("ontrack",(function r(i){"video"===i.mediaType&&(FV.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v.push(new X_((function(e,r){g._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new cR(sR.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),BV);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(FV.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",p),this._ontrackCallbackMap.set(t,p),f=null==h?void 0:h.relayMessage,_=f.sequenceId,m=f.sdp,t.videoMid=d,t.audioMid=c,t.sequenceId=_,t.streamState=vV.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=44,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:gV.subscribe,streamId:t.streamId,audioMid:c,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,X_.all(v);case 46:null===(a=this._monitor)||void 0===a||a.report("rtc_subscribe_stat",{result:"success",start:u,message:"unknown",stream_user_id:t.userId}),this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return g.emit("onRemoteStreamStats",e)}),this._handler,this._context);case 48:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"unsubscribePublicStream",value:(t=Em(Sm().mark((function e(t){var r,n,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return GV("unsubscribePublicStream()",t),n={appId:this._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=vV.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._handler)||void 0===r?void 0:r.handleAck({action:gV.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 t.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r,n;FV.print("destroy()"),this._token=void 0,this._appId=void 0,this._roomId=void 0,this._clientId=void 0,this._authorization=void 0,this._sessionId=void 0,null===(e=this._handler)||void 0===e||e.destroy(),null===(t=this._monitor)||void 0===t||t.set({connection_id:""}),null===(r=this._dataChannelSignal)||void 0===r||r.destroy(),null===(n=this._iceConfigRequestManager)||void 0===n||n.abort(),this._handler=void 0,this._dataChannelSignal=void 0,this._iceConfigRequestManager=void 0,this._removeSignalEventHandler(),this.connectionState="disconnected",this.emit("INTERRUPT")}},{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._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:"multiChatMode",value:function(){var e;return null===(e=this._roomAttributes)||void 0===e?void 0:e.multiChatMode}},{key:"handler",get:function(){return this._handler}},{key:"roomAttributes",get:function(){return this._roomAttributes},set:function(e){this._roomAttributes=e}}]),k}(sD);function zV(e,t,r){var n=r.value;return r.value=Em(Sm().mark((function e(){var r,i,o,a=arguments;return Sm().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 cR(sR.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 7:case"end":return e.stop()}}),e,this)}))),r}function XV(e,t,r){var n=r.value;return r.value=Em(Sm().mark((function e(){var t,r,i,o,a=arguments;return Sm().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}VV([function(e,t,r){var n=r.value;return r.value=Em(Sm().mark((function e(){var t,r,i,o,a=this,s=arguments;return Sm().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 X_(function(){var e=Em(Sm().mark((function e(t,i){var s;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a.on("INTERRUPT",(function(){o=!0,i(new cR(sR.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}],HV.prototype,"join",1),VV([XV,zV],HV.prototype,"publish",1),VV([XV,zV],HV.prototype,"updatePubTrack",1),VV([XV,zV],HV.prototype,"unpublish",1),VV([XV,zV],HV.prototype,"subscribe",1),VV([zV],HV.prototype,"controlMessage",1),VV([zV],HV.prototype,"updateUserAttributes",1),VV([zV],HV.prototype,"updateSubTrack",1),VV([zV],HV.prototype,"updateSubTrackLayer",1),VV([zV],HV.prototype,"updateSubPriority",1),VV([XV,zV],HV.prototype,"subscribe4pushTrack",1),VV([XV,zV],HV.prototype,"unsubscribe4removeTrack",1),VV([XV,zV],HV.prototype,"unsubscribe",1),VV([zV],HV.prototype,"handleRemoveStream",1),VV([XV],HV.prototype,"subscribePublicStream",1),VV([XV],HV.prototype,"unsubscribePublicStream",1);var KV,qV=new nP("RecvFrameObserver",0),YV=function(e){wI(a,e);var t,r,n,i,o=XI(a);function a(e,t){var r;return qd(this,a),sd(QT(r=o.call(this)),"_audioEventSessionId",iO()),sd(QT(r),"_videoEventSessionId",iO()),sd(QT(r),"_handler",void 0),sd(QT(r),"_stream",void 0),sd(QT(r),"_firstAudioFrameTimer",void 0),sd(QT(r),"_firstVideoFrameTimer",void 0),sd(QT(r),"_transportDelayInterval",void 0),sd(QT(r),"_transportDelay",void 0),sd(QT(r),"_firstVideoFrameInterval",void 0),sd(QT(r),"_firstAudioFrameInterval",void 0),sd(QT(r),"_isScreen",!1),sd(QT(r),"_audioFirstFrameState",0),sd(QT(r),"_videoFirstFrameState",0),sd(QT(r),"_timeout",1e4),sd(QT(r),"_currentAudioRecv",{startTime:0,eventSessionId:0,type:"login"}),sd(QT(r),"_currentVideoRecv",{startTime:0,eventSessionId:0,type:"login"}),sd(QT(r),"_login",!1),sd(QT(r),"_unMuteAudio",!1),sd(QT(r),"_enableAudio",!1),sd(QT(r),"_unMuteVideo",!1),sd(QT(r),"_enableVideo",!1),sd(QT(r),"_remoteUnmuteAudio",!1),sd(QT(r),"_remoteUnmuteVideo",!1),sd(QT(r),"_audioExternal",!1),sd(QT(r),"_pushAudio",!1),sd(QT(r),"_videoExternal",!1),sd(QT(r),"_pushVideo",!1),sd(QT(r),"_autoSubscribeVideo",!1),sd(QT(r),"_autoSubscribeAudio",!1),sd(QT(r),"_autoSubscribe",!1),sd(QT(r),"_publishVideo",!1),sd(QT(r),"_publishAudio",!1),sd(QT(r),"_subscribeAudio",!1),sd(QT(r),"_subscribeVideo",!1),sd(QT(r),"_subscribe",!1),sd(QT(r),"_pushTrack",!1),sd(QT(r),"_multiChatMode",!1),sd(QT(r),"_monitor",void 0),r._stream=e,r._handler=t,r.getTransportDelay(),r._monitor=mP(e.engineId),r}return Kd(a,[{key:"beginRecvFrame",value:(i=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h,v,p,f,_=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:i=this._transportDelay,o=!0,_E(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},d={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===(u=this._stream)||void 0===u?void 0:u.userId,transport_delay:i},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){_.stopRecvFrame("audio","timeout"),_._firstAudioFrameInterval&&window.clearInterval(_._firstAudioFrameInterval)}),this._timeout),qV.print("rtcFirstFrameRecv",ZE(d)),null===(c=this._monitor)||void 0===c||c.report("rtc_first_frame",d),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},f={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),start:null===(h=this._currentVideoRecv)||void 0===h?void 0:h.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(v=this._stream)||void 0===v?void 0:v.userId,transport_delay:i},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u,c,d,l,h,v,p,f,m,g;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=null===(t=_._handler)||void 0===t?void 0:t.pc,!e.t0){e.next=5;break}return e.next=4,EN(null===(r=_._handler)||void 0===r?void 0:r.pc,null===(n=_._stream)||void 0===n||null===(i=n.videoTrack)||void 0===i?void 0:i.getTrack());case 4:e.t0=e.sent;case 5:return p=e.t0,f=oE(o=p||[]).call(o,(function(e){return"inbound-rtp"===e.type})),e.next=9,null===(a=_._stream)||void 0===a||null===(s=a.videoTransceiver)||void 0===s?void 0:s.receiver.getStats();case 9:m=e.sent,g=[],null==m||m.forEach((function(e){return g.push(e.type)})),null===(u=_._monitor)||void 0===u||u.report("rtc_invoke_status",{sdk_api_name:"first_video_frame_timeout",error_code:-1,message:ZE({reports:YE(p).call(p,(function(e){return e.type})),reports2:g,pc:(null===(c=_._handler)||void 0===c?void 0:c.pc)||null,track:(null===(d=_._stream)||void 0===d||null===(l=d.videoTrack)||void 0===l?void 0:l.getTrack().id)||null,framesReceived:null==f?void 0:f.framesReceived,packetsReceived:null==f?void 0:f.packetsReceived}),stream_id:(null===(h=_._stream)||void 0===h?void 0:h.streamId)||"",stream_user_id:null===(v=_._stream)||void 0===v?void 0:v.userId,elapse:0});case 13:case"end":return e.stop()}}),e)})))(),_.stopRecvFrame("video","timeout"),_._firstVideoFrameInterval&&window.clearInterval(_._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),qV.print("rtcFirstFrameRecv",ZE(f)),null===(p=this._monitor)||void 0===p||p.report("rtc_first_frame",f),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;if(1!==this._audioFirstFrameState)return;var s={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};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,qV.print("rtcFirstFrameRecv",ZE(s)),null===(a=this._monitor)||void 0===a||a.report("rtc_first_frame",s),this._audioFirstFrameState=2}else if("video"===e){var u,c,d,l,h;if(1!==this._videoFirstFrameState)return;var v={event_type:"recv_end",media_type:e,is_screen:!(null===(u=this._stream)||void 0===u||!u.isScreen),start:null===(c=this._currentVideoRecv)||void 0===c?void 0:c.startTime,reason:t,result:!1,stream_user_id:null===(d=this._stream)||void 0===d?void 0:d.userId,event_session_id:this._videoEventSessionId,type:null===(l=this._currentVideoRecv)||void 0===l?void 0:l.type};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,qV.print("rtcFirstFrameRecv",ZE(v)),null===(h=this._monitor)||void 0===h||h.report("rtc_first_frame",v),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g;return Sm().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:s=this._currentAudioRecv,u=s.type,c=s.startTime,_E(n=["login","unmute","subscribe","push_track"]).call(n,u)>=0&&(r=0),d={event_type:"recv_end",media_type:t,start:c,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:u,transport_delay:r},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),qV.print("rtcFirstFrameRecv",ZE(d)),null===(a=this._monitor)||void 0===a||a.report("rtc_first_frame",d),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:f=this._currentVideoRecv,_=f.type,m=f.startTime,_E(l=["login","unmute","subscribe","push_track"]).call(l,_)>=0&&(r=0),g={event_type:"recv_end",media_type:t,is_screen:!(null===(h=this._stream)||void 0===h||!h.isScreen),start:m,result:!0,stream_user_id:null===(v=this._stream)||void 0===v?void 0:v.userId,event_session_id:this._videoEventSessionId,type:_,transport_delay:r},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),qV.print("rtcFirstFrameRecv",ZE(g)),null===(p=this._monitor)||void 0===p||p.report("rtc_first_frame",g),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){var t;this._enableAudio!==e&&(this._enableAudio=e,this._enableAudio?this.beginRecvFrame("audio","enable"):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&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:"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(Em(Sm().mark((function n(){var i,o,a,s,u,c,d,l;return Sm().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,EN(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(u=e._stream)||void 0===u||null===(c=u.videoTrack)||void 0===c?void 0:c.getTrack());case 3:if(d=n.sent,!(l=oE(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(Em(Sm().mark((function n(){var i,o,a,s,u,c,d,l;return Sm().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,EN(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(u=e._stream)||void 0===u||null===(c=u.audioTrack)||void 0===c?void 0:c.getOrgTrack());case 3:if(d=n.sent,!(l=oE(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=Em(Sm().mark((function e(){var t=this;return Sm().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(Em(Sm().mark((function e(){return Sm().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=Em(Sm().mark((function e(){var t,r,n,i,o;return Sm().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,EN(null===(r=this._handler)||void 0===r?void 0:r.pc);case 3:n=e.sent,i=oE(n).call(n,(function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(o=oE(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:"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}(iD.exports.EventEmitter),WV=new nP("SendFrameObserver",0),QV=function(){function e(t,r){qd(this,e),sd(this,"_audioEventSessionId",iO()),sd(this,"_videoEventSessionId",iO()),sd(this,"_pcSessionId",void 0),sd(this,"_handler",void 0),sd(this,"_firstAudioFrameTimer",void 0),sd(this,"_firstVideoFrameTimer",void 0),sd(this,"_stream",void 0),sd(this,"_firstVideoFrameInterval",void 0),sd(this,"_firstAudioFrameInterval",void 0),sd(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:"login"}),sd(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:"login"}),sd(this,"_login",!1),sd(this,"_publisher",!1),sd(this,"_unMuteAudio",!1),sd(this,"_enableAudio",!1),sd(this,"_unMuteVideo",!1),sd(this,"_enableVideo",!1),sd(this,"_audioExternal",!1),sd(this,"_pushAudio",!1),sd(this,"_videoExternal",!1),sd(this,"_pushVideo",!1),sd(this,"_autoPublish",!1),sd(this,"_publish",!1),sd(this,"_timeout",1e4),sd(this,"_audioFirstFrameState",0),sd(this,"_videoFirstFrameState",0),sd(this,"_monitor",void 0),this._stream=t,this._handler=r,this._monitor=mP(t.engineId)}var t,r;return Kd(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if("audio"===e){var n,i,o;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var a={event_type:"begin_send",media_type:e,is_screen:!(null===(n=this._stream)||void 0===n||!n.isScreen),type:t,start:null===(i=this._currentAudioSend)||void 0===i?void 0:i.startTime,event_session_id:this._audioEventSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){r.stopSendFrame("audio","timeout"),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),WV.print("rtcFirstFrameSend",ZE(a)),null===(o=this._monitor)||void 0===o||o.report("rtc_first_frame",a),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 s,u,c;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var d={event_type:"begin_send",media_type:e,is_screen:!(null===(s=this._stream)||void 0===s||!s.isScreen),type:t,start:null===(u=this._currentVideoSend)||void 0===u?void 0:u.startTime,event_session_id:this._videoEventSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){r.stopSendFrame("video","timeout"),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),WV.print("rtcFirstFrameSend",ZE(d)),null===(c=this._monitor)||void 0===c||c.report("rtc_first_frame",d),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;if(1!==this._audioFirstFrameState)return;var a={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};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,WV.print("rtcFirstFrameSend",ZE(a)),null===(o=this._monitor)||void 0===o||o.report("rtc_first_frame",a),this._audioFirstFrameState=2}else if("video"===e){var s,u,c,d;if(1!==this._videoFirstFrameState)return;var l={event_type:"sent_end",media_type:e,start:null===(s=this._currentVideoSend)||void 0===s?void 0:s.startTime,is_screen:!(null===(u=this._stream)||void 0===u||!u.isScreen),reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(c=this._currentVideoSend)||void 0===c?void 0:c.type};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,WV.print("rtcFirstFrameSend",ZE(l)),null===(d=this._monitor)||void 0===d||d.report("rtc_first_frame",l),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if("audio"===e){var t,r;if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var n=this._currentAudioSend,i=n.type,o=n.startTime,a={event_type:"sent_end",media_type:e,is_screen:!(null===(t=this._stream)||void 0===t||!t.isScreen),start:o,result:!0,event_session_id:this._audioEventSessionId,type:i};delete this._currentAudioSend,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),WV.print("rtcFirstFrameSend",ZE(a)),null===(r=this._monitor)||void 0===r||r.report("rtc_first_frame",a),this._audioFirstFrameState=3}else if("video"===e){var s,u;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var c=this._currentVideoSend,d=c.type,l=c.startTime,h={event_type:"sent_end",media_type:e,is_screen:!(null===(s=this._stream)||void 0===s||!s.isScreen),start:l,result:!0,event_session_id:this._videoEventSessionId,type:d};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),WV.print("rtcFirstFrameSend",ZE(h)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",h),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,n,i;if(this._publish=e,e)(null===(t=this._stream)||void 0===t?void 0:t.videoTrack)&&(null===(r=this._stream)||void 0===r?void 0:r.pubVideo)&&this.beginSendFrame("video","publish"),(null===(n=this._stream)||void 0===n?void 0:n.audioTrack)&&(null===(i=this._stream)||void 0===i?void 0:i.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:"setExternalAudioSource",value:function(e){this._audioExternal!==e&&(this._audioExternal=e,e&&(this._audioSending&&this.stopSendFrame("audio","disable"),this._enableAudio=!1),e||(this._audioSending&&this.stopSendFrame("audio","stop_push"),this._pushAudio=!1))}},{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:"setExternalVideoSource",value:function(e){this._videoExternal!==e&&(this._videoExternal=e,e&&(this._videoSending&&this.stopSendFrame("video","disable"),this._enableVideo=!1),e||(this._videoSending&&this.stopSendFrame("video","stop_push"),this._pushVideo=!1))}},{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:"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=Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u;return Sm().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,EN(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,u=Gs(s).call(s,(function(e){return"outbound-rtp"===e.type})),e.abrupt("return",u);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=Em(Sm().mark((function e(){var t,r,n,i,o,a,s;return Sm().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,EN(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",oE(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(Em(Sm().mark((function n(){var i,o,a;return Sm().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||YE(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(Em(Sm().mark((function r(){var n;return Sm().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}(),JV=(sd(KV={},"audio",{delay:1200,stallRadio:.3}),sd(KV,"video",{delay:1200,stallRadio:.6}),sd(KV,"screen_audio",{delay:1600,stallRadio:.8}),sd(KV,"screen_video",{delay:1600,stallRadio:.8}),KV),ZV=function(){function e(){qd(this,e),sd(this,"_preUplinkStats",new FS),sd(this,"_preDownlinkStats",new FS),sd(this,"_timer",void 0),sd(this,"_delayTimer",void 0),sd(this,"_connectionState",jV.CONNECTED),sd(this,"reportor",void 0)}return Kd(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,u=t._fractionLost,c=t._retransmittedRate,d=this._getQosLevel(s,u||0,c||0),l=this._preUplinkStats.get(a)||[d];this._preUplinkStats.set(a,ym(i=Rm(o=[]).call(o,Kk(l),[d])).call(i,-2))}if(r.sentKBitrate>0&&r.rtt){var h,v,p=n?"screen_video":"video",f=r._fractionLost,_=r.rtt,m=r._sendBandWidth,g=r._retransmittedRate;0===m&&(f=Math.max(.65,f));var y=this._getQosLevel(_,f||0,g||0),S=this._preUplinkStats.get(p)||[y];this._preUplinkStats.set(p,ym(h=Rm(v=[]).call(v,Kk(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,u=e.videoStats,c=e.isScreen,d=e.userId;if(o)if(0===s.receivedKBitrate)r=xd.VBAD;else{var l=s.rtt,h=s.audioLossRate,v=s.stallDuration,p=s.statsInterval,f=s.e2eDelay,_=v/p,m=c?"screen_audio":"audio",g=this._getQosLevel(l,h||0,u._retransmittedRate||0),y=this._getDownlinkQoE(m,_,f);r=this._getNetworkQuality(g,y)}if(a)if(0===u.receivedKBitrate||0===u.rtt)n=xd.VBAD;else{var S=u.rtt,b=u.videoLossRate,E=u.stallDuration,k=u.statsInterval,T=u.e2eDelay,I=u._retransmittedRate,A=E/k,R=c?"screen_video":"video",w=this._getQosLevel(S,b||0,I||0),C=this._getDownlinkQoE(R,A,T);n=this._getNetworkQuality(w,C)}var x=r&&n?Math.ceil((r+n)/2):r||n;if(x){var P,O,D,M=Rm(P="".concat(d)).call(P,c?"_screen":""),N=this._preDownlinkStats.get(M)||[x];this._preDownlinkStats.set(M,ym(O=Rm(D=[]).call(D,Kk(N),[x])).call(O,-2)),this._startNetworkQualityReport()}}}},{key:"setConnectionState",value:function(e){this._connectionState=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=this;if(this._connectionState!==jV.CONNECTED)e=t=xd.VBAD;else{var n,i,o,a=this._getBetterQualityAndRemoveOldest("audio","up"),s=this._getBetterQualityAndRemoveOldest("video","up");e=a&&s?Math.ceil((a+s)/2):a||s||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||xd.EXCELLENT;var u=Gs(n=YE(i=zk(Wx(o=this._preDownlinkStats).call(o))).call(i,(function(e){return r._getBetterQualityAndRemoveOldest(e,"down")}))).call(n,(function(e){return e}));t=Math.ceil($S(u).call(u,(function(e,t){return t+e}),0)/u.length)||xd.UNKNOWN}"function"==typeof this.reportor&&this.reportor(e,t)}},{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=JV[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=xd.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,Kk(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&&cO(t)&&r.localaudio&&r.audiostream,videoActive:n&&dO(t)&&r.localvideo&&r.videostream}}}]),e}(),$V=function(){function e(t){qd(this,e),sd(this,"_timer",void 0),sd(this,"_remoteVideoSizeCache",{}),sd(this,"_remoteScreenSizeCache",{}),sd(this,"onchange",void 0),this._room=t,this._start()}return Kd(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,u=s[i]||{},c=u.width,d=void 0===c?0:c,l=u.height,h=void 0===l?0:l,v=a.getSettings(),p=v.width,f=void 0===p?0:p,_=v.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}(),eF=zk((new TextEncoder).encode("subt")),tF={1:sR.SUBTITLE_ERR_POSTPROCESS,2:sR.SUBTITLE_ERR_CONNECTION_ERROR,3:sR.SUBTITLE_ERR_PROCESS_ERROR},rF=new nP("SubtitleTool",1),nF=function(e){if(e.extraInfo)try{var t,r=JSON.parse(e.extraInfo);r.source_language&&_E(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))||"";_E(i=["zh","en","ja"]).call(i,o)>-1&&(e.extraInfo=ZE({source_language:o}))}},iF=function(){function e(t){var r,n,i;qd(this,e),sd(this,"_taskId",void 0),sd(this,"_appId",void 0),sd(this,"_roomId",void 0),sd(this,"_userId",void 0),sd(this,"onEvent",void 0),sd(this,"onMessage",void 0),sd(this,"_preConfig",void 0),sd(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 Kd(e,[{key:"start",value:(n=Em(Sm().mark((function e(t){var r=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rF.print("start","Invoke config: %o",t),FO(t.mode,"mode",[Ud.ASR_ONLY,Ud.ASR_AND_TRANSLATION]),t.mode!==Ud.ASR_AND_TRANSLATION||-1!==_E(aF).call(aF,t.targetLanguage||"")){e.next=4;break}throw new cR(sR.INVALID_PARAMS,"Invalid targetLanguage.");case 4:if(!this._taskId){e.next=6;break}throw new cR(sR.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:Vd.ERROR,errorCode:sR.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=Em(Sm().mark((function e(t){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(FO(t.mode,"mode",[Ud.ASR_ONLY,Ud.ASR_AND_TRANSLATION]),t.mode!==Ud.ASR_AND_TRANSLATION||-1!==_E(aF).call(aF,t.targetLanguage||"")){e.next=3;break}throw new cR(sR.INVALID_PARAMS,"Invalid targetLanguage.");case 3:if(!this._taskId){e.next=5;break}throw new cR(sR.SUBTITLE_ALREADY_ON,"Already started subtitle");case 5:if(this._taskId){e.next=7;break}throw new cR(sR.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;rF.print("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:Vd.STOPPED}),e._clearTimer()}))}},{key:"reconnect",value:(t=Em(Sm().mark((function e(){return Sm().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(){rF.print("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 cR(tF[r]||sR.SUBTITLE_ERR_UNKNOWN,n||"");null===(o=this.onEvent)||void 0===o||o.call(this,{event:Vd.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:Vd.STARTED}),this._clearTimer()}}},{key:"onMessageRecv",value:function(e){if(this._taskId&&this._preConfig){var t=oF(e);if(t&&t.length>0){var r,n=this._preConfig,i=n.mode,o=n.targetLanguage,a=[];if(t.forEach((function(e){i===Ud.ASR_ONLY?e.mode===i&&a.push(e):i===Ud.ASR_AND_TRANSLATION&&(e.language!==o&&e.mode!==Ud.ASR_ONLY||a.push(e),e.mode===Ud.ASR_ONLY&&e.language===o&&a.push(cd(cd({},e),{},{mode:Ud.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}(),oF=function(e){var t=e.message;if(t instanceof ArrayBuffer&&t.byteLength>8)try{var r=new DataView(t,0),n=0;if(eF.every((function(e){return r.getUint8(n++)===e}))){var i=r.getUint32(n);if(n+=4,i===r.byteLength-8){var o=UP.ab2str(ym(t).call(t,8)),a=JSON.parse(o),s=a.data;if("subtitle"===a.type)return s}}}catch(u){}return!1},aF=["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"],sF=new nP("Room",1),uF={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1,publishTime:0},cF=function(e){wI(A,e);var t,r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I=XI(A);function A(e,t){var r;return qd(this,A),sd(QT(r=I.call(this)),"id",void 0),sd(QT(r),"_mediaServerClient",void 0),sd(QT(r),"_localStream",void 0),sd(QT(r),"_localScreenStream",void 0),sd(QT(r),"_remoteUsers",new FS),sd(QT(r),"_remoteStreams",new FS),sd(QT(r),"_remoteStreamStreamIdUserIdMap",{}),sd(QT(r),"_virtualStreams",[]),sd(QT(r),"_joinResolveCallback",void 0),sd(QT(r),"_joinRejectCallback",void 0),sd(QT(r),"_getAccessNode",void 0),sd(QT(r),"_getAccessFeedback",void 0),sd(QT(r),"_getAccessFeedbackIceNode",void 0),sd(QT(r),"_reconnectTimer",void 0),sd(QT(r),"_isReconnecting",void 0),sd(QT(r),"_context",void 0),sd(QT(r),"_sessionId",void 0),sd(QT(r),"_reconnectRecord",void 0),sd(QT(r),"_connectionLostTimer",void 0),sd(QT(r),"_liveControlMessage",void 0),sd(QT(r),"_serverConfig",void 0),sd(QT(r),"_liveTranscodingOnceSucc",!1),sd(QT(r),"_roomConfig",void 0),sd(QT(r),"_roomInfo",void 0),sd(QT(r),"_userDuplicateLoginTimerMap",new FS),sd(QT(r),"_networkQualityManager",void 0),sd(QT(r),"_videoSizeObserver",void 0),sd(QT(r),"_hasPublished",!1),sd(QT(r),"_subtitleTool",void 0),sd(QT(r),"_csrcUserIdMap",void 0),sd(QT(r),"_publishOnDemandItem",void 0),sd(QT(r),"_publishOnDemandBusy",!1),sd(QT(r),"_monitor",void 0),r.id=t.id,r._roomConfig=e,r._mediaServerClient=new HV(t),r._reconnectRecord=new dF,r._addHandlerEventHandler(),r._isReconnecting=!1,r._networkQualityManager=new ZV,r._networkQualityManager.reportor=r._reportNetworkQuality.bind(QT(r)),r._videoSizeObserver=new $V(QT(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(QT(r)),r._context=t,r._csrcUserIdMap={},r._monitor=mP(r.id),r}return Kd(A,[{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,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A,R,w,C,x=this;null===(e=this._mediaServerClient)||void 0===e||e.on(bD.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on(bD.ON_ADD_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return x._onAddStream(e)}))})),null===(r=this._mediaServerClient)||void 0===r||r.on(bD.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(bD.ON_REMOVE_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return x._onRemoveStream(e)}))})),null===(i=this._mediaServerClient)||void 0===i||i.on(bD.USER_CONNECTION,this._onUserConnection.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(bD.USER_CONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return x._onUserConnection(e)}))})),null===(a=this._mediaServerClient)||void 0===a||a.on(bD.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(bD.USER_DISCONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return x._onUserDisconnection(e)}))})),null===(u=this._mediaServerClient)||void 0===u||u.on(bD.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(c=this._mediaServerClient)||void 0===c||c.on(bD.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(bD.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(bD.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(bD.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(bD.NODE_CHANGE,this._nodeChange.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(bD.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(bD.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(bD.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(bD.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(bD.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(bD.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(bD.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(b=this._mediaServerClient)||void 0===b||b.on(ED.RSCP,(function(e){!!oE(e).call(e,(function(e){var t,r,n;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:vk(t).call(t,null===(r=x._localStream)||void 0===r||null===(n=r.stream)||void 0===n?void 0:n.id)}))&&(x._publishOnDemandItem=e,x._onPublishOnDemand())})),null===(E=this._mediaServerClient)||void 0===E||E.on(ED.RTT,this._onRTT.bind(this)),null===(k=this._mediaServerClient)||void 0===k||k.on(ED.SSC,this._onSSC.bind(this)),null===(T=this._mediaServerClient)||void 0===T||T.on(kD.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(I=this._mediaServerClient)||void 0===I||I.on(kD.ABNORMAL_DISCONNECTION,this._handleAbnormalDisconnection.bind(this)),null===(A=this._mediaServerClient)||void 0===A||A.on(bD.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),null===(R=this._mediaServerClient)||void 0===R||R.on("onRemoteStreamStats",(function(e){x._networkQualityManager.updateDownlinkStats(e,x._findRemoteStreamByScreen(e.userId,e.isScreen)),x.emit(PV.ON_REMOTE_STREAM_STATS,lO(e))})),null===(w=this._mediaServerClient)||void 0===w||w.on("onLocalStreamStats",(function(e){x._networkQualityManager.updateUplinkStats(e),x.emit(PV.ON_LOCAL_STREAM_STATS,lO(e))})),null===(C=this._mediaServerClient)||void 0===C||C.on("prevIceNode",(function(e){x._getAccessFeedbackIceNode=e}))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(T=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.connect(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"join",value:(k=Em(Sm().mark((function e(t,r,n,i,o,a,s){var u,c=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(u=this._monitor)||void 0===u||u.set({rtc_app_id:t,room_id:r,user_id:i.userId}),sF.print("join()"),e.abrupt("return",new X_((function(e,u){var d,l,h,v=MP();c._joinResolveCallback=function(t){var r,n;null===(r=c._monitor)||void 0===r||r.report("join_room",{type:"end",start:v,result:!0,reason:""},{enable_cloud_proxy:null===(n=c._roomInfo)||void 0===n?void 0:n.useCloudProxy}),c._initSubtitleTool(),e(t)},c._joinRejectCallback=function(e){var t,r;Array.isArray(e)&&e.length&&(e=e[0]),null===(t=c._monitor)||void 0===t||t.report("join_room",{type:"end",start:v,result:!1,reason:e.message},{enable_cloud_proxy:null===(r=c._roomInfo)||void 0===r?void 0:r.useCloudProxy}),u(e)},c._liveControlMessage=o,c._roomInfo={appId:t,roomId:r,token:n,userInfo:i,useCloudProxy:a,roomProfile:c._roomConfig.roomProfileType,expectedIDC:s},c.setSessionId(),null===(d=c._monitor)||void 0===d||d.report("join_room",{type:"begin",start:v,result:!1,reason:""},{enable_cloud_proxy:null===(l=c._roomInfo)||void 0===l?void 0:l.useCloudProxy,expectedIDC:null===(h=c._roomInfo)||void 0===h?void 0:h.expectedIDC}),c._join(c._joinResolveCallback,c._joinRejectCallback,!1)})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i,o,a){return k.apply(this,arguments)})},{key:"_join",value:(E=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=l.length>2&&void 0!==l[2]&&l[2],i=MP(),sF.print("_join()"),e.prev=3,e.next=6,this._mediaServerClient.join(this._roomInfo,{node:this._getAccessNode,reason:this._getAccessFeedback,sessionId:this._sessionId,feedbackNode:this._getAccessFeedbackIceNode},n,this._liveControlMessage);case 6:d=e.sent,this._mediaServerClient.roomAttributes=d.roomAttributes,null!==(o=d.roomAttributes)&&void 0!==o&&o.multiChatMode&&this._handleFFAudioTrack(),this._reconnectRecord.clear(),this._joinResolveCallback=void 0,this._joinRejectCallback=void 0,this._getAccessFeedback=void 0,this._getAccessNode=void 0,"function"==typeof t&&t({users:d.clients,streams:d.streams}),this._isReconnecting=!1,null===(a=this._monitor)||void 0===a||a.set({rtc_vid:(null===(s=this._getAccessFeedbackIceNode)||void 0===s||null===(u=s.iceConfig)||void 0===u?void 0:u._abtest_vid)||""}),null===(c=this._monitor)||void 0===c||c.report("rtc_join_room",{error_code:0,deviceModel:"web",deviceManufacturer:"web",elapse:MP()-i}),this._onJoinSucc(d,n),e.next=27;break;case 21:if(e.prev=21,e.t0=e.catch(3),this._getAccessFeedback=void 0,this._getAccessNode=void 0,e.t0.code===sR.OPERATION_CANCEL||"function"!=typeof r){e.next=27;break}return e.abrupt("return",r(e.t0));case 27:case"end":return e.stop()}}),e,this,[[3,21]])}))),function(e,t){return E.apply(this,arguments)})},{key:"publishScreen",value:(b=Em(Sm().mark((function e(t,r,n,i,o){var a,s,u,c,d,l,h,v,p,f;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(sF.print("publishScreen()"),this._localScreenStream||(this._localScreenStream=new pV(this.id),this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new QV(this._localScreenStream,this._mediaServerClient.handler))),a=!1,s=!1,u=!1,c=!1,!this._localScreenStream.videoTrack&&r?(r instanceof EU&&(s=!0),a=!0):this._localScreenStream.videoTrack&&!r&&(a=!1),!this._localScreenStream.audioTrack&&n?(n instanceof kU&&(c=!0),u=!0):this._localScreenStream.audioTrack&&!n&&(u=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(cO(i)&&(this._localScreenStream.pubAudio=o===DV.PUB),dO(i)&&(this._localScreenStream.pubVideo=o===DV.PUB),sF.print("publishScreen mediaType","pubAudio: %o, pubVideo: %o",this._localScreenStream.pubAudio,this._localScreenStream.pubVideo)),this._localScreenStream.pubAudio||this._localScreenStream.pubVideo){e.next=18;break}if(null===(d=this._localScreenStream)||void 0===d||!d.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===(l=this._localScreenStream.observer)||void 0===l||l.setPublish(!0),e.next=22,this._mediaServerClient.publish(this._localScreenStream);case 22:e.next=28;break;case 24:return s?null===(h=this._localScreenStream.observer)||void 0===h||h.setPushVideo(a):null===(v=this._localScreenStream.observer)||void 0===v||v.setEnableVideo(a),c?null===(p=this._localScreenStream.observer)||void 0===p||p.setPushAudio(u):null===(f=this._localScreenStream.observer)||void 0===f||f.setEnableAudio(u),e.next=28,this.updatePubScreenTrack();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return b.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(S=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(sF.print("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 S.apply(this,arguments)})},{key:"unpublishScreen",value:(y=Em(Sm().mark((function e(){var t;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(sF.print("unpublish","Invoke unpublishScreen"),!this._localScreenStream){e.next=7;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.clean(),this._localScreenStream=void 0;case 7:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"liveControlMessage",value:(g=Em(Sm().mark((function e(t){var r,n=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sF.print("controlMessage","Invoke controlMessage"),null===(r=t.transcodeMeta)||void 0===r||r.layout.regions.forEach((function(e){n.roomInfo&&(e.roomID=n.roomInfo.roomId)})),this._liveControlMessage=t,e.next=5,this._mediaServerClient.controlMessage(t);case 5:"stopped"===t.action&&(delete this._liveControlMessage,this._liveTranscodingOnceSucc=!1),this._liveTranscodingOnceSucc=!0;case 7:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(m=Em(Sm().mark((function e(t){return Sm().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 m.apply(this,arguments)})},{key:"subtitleControlMessage",value:(_=Em(Sm().mark((function e(t){return Sm().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 _.apply(this,arguments)})},{key:"updateUserAttributes",value:(f=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sF.print("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 f.apply(this,arguments)})},{key:"publish",value:(p=Em(Sm().mark((function e(t,r,n,i,o,a){var s,u,c,d,l,h,v,p,f,_,m,g,y=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=y.length>6&&void 0!==y[6]&&y[6],sF.print("publish","Invoke publish"),u=!1,this._localStream||(this._localStream=new pV(this.id),this._mediaServerClient.handler&&(this._localStream.observer=new QV(this._localStream,this._mediaServerClient.handler)),u=!0),this._localStream.videoTrack=n,this._localStream.audioTrack=i,this._localStream.videoEncodeConfig=t,this._localStream.enableSimulcast=r,o&&(cO(o)&&(this._localStream.pubAudio=a===DV.PUB),dO(o)&&(this._localStream.pubVideo=a===DV.PUB),sF.print("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===(c=this._localStream.observer)||void 0===c||c.setLogin(!0):u&&(d=!!this._localStream.videoTrack,l=!!this._localStream.audioTrack,h=this._localStream.videoTrack instanceof EU,v=this._localStream.audioTrack instanceof kU,this._roomConfig.isAutoPublish&&!this._hasPublished?(d&&(h?null===(p=this._localStream.observer)||void 0===p||p.setPushVideo(!0):null===(f=this._localStream.observer)||void 0===f||f.setEnableVideo(!0)),l&&(v?null===(_=this._localStream.observer)||void 0===_||_.setPushAudio(!0):null===(m=this._localStream.observer)||void 0===m||m.setEnableAudio(!0))):null===(g=this._localStream.observer)||void 0===g||g.setPublish(!0)),e.next=16,this._mediaServerClient.publish(this._localStream);case 16:this._hasPublished=!0,this.emit(PV.ON_PUBLISH_RESULT,{isScreen:!1,state:_d.PUBLISH_SUCC}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(12),this.emit(PV.ON_PUBLISH_RESULT,{isScreen:!1,state:_d.PUBLISH_FAIL}),e.t0;case 24:e.next=28;break;case 26:return e.next=28,this.updatePubTrack();case 28:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e,t,r,n,i,o){return p.apply(this,arguments)})},{key:"updatePubTrack",value:(v=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(sF.print("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 v.apply(this,arguments)})},{key:"unpublish",value:(h=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(sF.print("unpublish","Invoke unpublish"),!this._localStream){e.next=6;break}return e.next=4,this._mediaServerClient.unpublish(this._localStream);case 4:this._localStream.clean(),this._localStream=void 0;case 6:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"subscribe",value:(l=Em(Sm().mark((function e(t,r,n){var i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sF.print("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 l.apply(this,arguments)})},{key:"updateSubTrack",value:(d=Em(Sm().mark((function e(t,r,n,i){var o,a;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(sF.print("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 d.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(c=Em(Sm().mark((function e(t,r){var n,i,o,a,s;return Sm().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 c.apply(this,arguments)})},{key:"_getSubLayer",value:function(e,t){for(var r,n,i,o,a,s=null==t?void 0:t.attributes,u=s.videoDescriptions,c=s.subVideoDescriptions,d=Array.isArray(c)?c:u,l=-1,h=e.width*e.height,v=0;v<(null==d?void 0:d.length);v++){var p,f;if(h>=(null===(p=d[v])||void 0===p?void 0:p.width)*(null===(f=d[v])||void 0===f?void 0:f.height)){l=v;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,g=(m-h)/(m-d[l].width*d[l].height);_=g<.1?d[l-1]:d[l],l=g<.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:(u=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sF.print("unsubscribe","Invoke unsubscribe"),e.next=3,this._mediaServerClient.unsubscribe(t,r);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"startSubtitle",value:(s=Em(Sm().mark((function e(t){return Sm().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 cR(sR.INVOKED_BEFORE_JOIN_ROOM,"join first");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"stopSubtitle",value:(a=Em(Sm().mark((function e(){var t;return Sm().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 a.apply(this,arguments)})},{key:"leave",value:(o=Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u,c,d,l,h=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=h.length>0&&void 0!==h[0]&&h[0],sF.print("leave","Invoke leave"),n=MP(),null===(t=this._subtitleTool)||void 0===t||t.destroy(),delete this._subtitleTool,e.prev=5,this._mediaServerClient.connectionState!==jV.CONNECTED&&this._joinRejectCallback&&this._joinRejectCallback(new Error("leave_room")),clearTimeout(this._reconnectTimer),s=YT($I(a=this._remoteStreams).call(a));try{for(s.s();!(u=s.n()).done;)c=u.value,Array.isArray(c)&&c.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=13,this._mediaServerClient.leave();case 13:this.destroy(),null===(i=this._monitor)||void 0===i||i.report("rtc_leave_room",{error_code:0,message:"",elapse:MP()-n}),null===(o=this._monitor)||void 0===o||o.set({room_id:"",user_id:"",rtc_session_id:"",rtc_vid:""}),e.next=26;break;case 18:if(e.prev=18,e.t0=e.catch(5),!r){e.next=24;break}throw e.t0;case 24:this.destroy();case 25:e.t0 instanceof Error&&(null===(l=this._monitor)||void 0===l||l.report("rtc_leave_room",{error_code:-1,message:e.t0.message,elapse:MP()-n}));case 26:case"end":return e.stop()}}),e,this,[[5,18]])}))),function(){return o.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&&null!=n&&n.has(e)&&r._mediaServerClient.updateSubPriority(t,n.get(e))}))}},{key:"destroy",value:function(){var e;sF.print("destroy","Invoke destroy"),SP(this.id,"room_destroy","".concat((new Error).stack)),null===(e=this._subtitleTool)||void 0===e||e.destroy(),delete this._subtitleTool,this._destroyAndInitMediaServerClient(),this._roomInfo=void 0,this._remoteUsers=new FS;var t,r,n,i=YT(this._remoteStreams);try{for(i.s();!(t=i.n()).done;){var o=WT(t.value,2)[1];Array.isArray(o)&&o.forEach((function(e){e&&e.clean()}))}}catch(a){i.e(a)}finally{i.f()}(this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new FS,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._reconnectRecord=new dF,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={}}},{key:"updateToken",value:(i=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return sF.print("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(PV.ON_ROOM_ERROR,{errorCode:sR.UPDATE_TOKEN_WITH_INVALID_TOKEN}),e.t0;case 11:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return i.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=ZR(),null===(e=this._monitor)||void 0===e||e.set({rtc_session_id:this._sessionId})}},{key:"sendRoomMessage",value:(n=Em(Sm().mark((function e(t){var r,n,i,o,a,s=arguments;return Sm().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,UP.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 n.apply(this,arguments)})},{key:"_destroyAndInitMediaServerClient",value:function(){sF.print("_destroyAndInitMediaServerClient()"),this._mediaServerClient&&(this._mediaServerClient.destroy(),this._removeHandlerEventHandler()),this._mediaServerClient=new HV(this._context),this._addHandlerEventHandler()}},{key:"_onJoinSucc",value:function(e,t){var r,n,i,o=this;sF.print("JoinSuccess()"),this._serverConfig=e.config;var a=[],s=[],u=[],c=[],d=[];null===(r=e.clientsDetail)||void 0===r||r.forEach((function(t){if(t.attributes&&(t.attributes.serverMuteVideo&&o.safeEmit(PV.ON_VIDEO_STREAM_BANNED,{uid:t.clientId,banned:1===t.attributes.serverMuteVideo}),t.attributes.serverMuteAudio&&o.safeEmit(PV.ON_AUDIO_STREAM_BANNED,{uid:t.clientId,banned:1===t.attributes.serverMuteAudio})),t.clientId!==e.clientId){var r=o._remoteUsers.get(t.clientId);r?r._stillExist=!0:a.push(t)}}));var l,h=YT($I(n=this._remoteUsers).call(n));try{for(h.s();!(l=h.n()).done;){var v=l.value;v._stillExist||s.push({clientId:v.userId}),delete v._stillExist}}catch(m){h.e(m)}finally{h.f()}e.streams.forEach((function(e){var t=o._findRemoteStreamByScreen(e.clientId,e.screen);t?(t.stillExist=!0,t.streamId=e.streamId,d.push(e)):c.push(e)}));var p,f=YT($I(i=this._remoteStreams).call(i));try{for(f.s();!(p=f.n()).done;){var _=p.value;Array.isArray(_)&&_.forEach((function(e){e.stillExist?delete e.stillExist:u.push({clientId:e.userId,streamId:e.streamId,message:yD.clientDisconnected})}))}}catch(m){f.e(m)}finally{f.f()}s.forEach((function(e){return o._onUserDisconnection(e)})),a.forEach((function(e){return o._onUserConnection(e)})),u.forEach((function(e){return o._onRemoveStream(e)})),c.forEach((function(e){return o._onAddStream(e,{fromSignal:!1})})),d.forEach((function(e){return o._onUpdateStreamAttributes(e)})),t&&this._handleSendOrRecvStreamAfterReconnect()}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e,t,r=this;this._localStream&&(this._localStream.clean(),this._mediaServerClient.publish(this._localStream).catch((function(e){}))),this._localScreenStream&&(this._localScreenStream.clean(),this._mediaServerClient.publish(this._localScreenStream).catch((function(e){})));var n,i=YT($I(t=this._remoteStreams).call(t));try{for(i.s();!(n=i.n()).done;){var o=n.value;Array.isArray(o)&&o.forEach(function(){var e=Em(Sm().mark((function e(t){var n,i,o,a;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasSubscribed){e.next=15;break}return t.resetHasSubscribed(),e.prev=2,sF.print(Rm(n="start resubscribe ".concat(t.userId," with ")).call(n,t.subMediaType)),e.next=6,r._mediaServerClient.subscribe(t,t.subMediaType);case 6:sF.print(Rm(i="success resubscribe ".concat(t.userId," with ")).call(i,t.subMediaType)),r.safeEmit(PV.RESUBSCRIBE,{stream:t}),e.next=15;break;case 10:e.prev=10,e.t0=e.catch(2),sF.print(Rm(o=Rm(a="failed resubscribe ".concat(t.userId," with ")).call(a,t.subMediaType,", error:")).call(o,e.t0)),t.clean(),null==t||t.resetHasSubscribed();case 15:case"end":return e.stop()}}),e,null,[[2,10]])})));return function(t){return e.apply(this,arguments)}}())}}catch(a){i.e(a)}finally{i.f()}null===(e=this._subtitleTool)||void 0===e||e.reconnect()}},{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=oE(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 fV(this.id,"ff-stream","ff-stream",!1,uF);s.virtual=!0,s.audioTransceiver=a,s.audioMid="0",s.audioTrack=VU(i),this._virtualStreams.push(s),this.safeEmit(PV.SUBSCRIBE_PUSH_TRACK,{stream:s})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?oE(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)?oE(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,u=void 0!==s&&s;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var c=this._roomConfig,d=c.isAutoSubscribeAudio,l=c.isAutoSubscribeVideo,h=this._findRemoteStreamByScreen(e.clientId,e.screen);if(h&&h.streamId!==e.streamId){var v,p=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,p||[])}var f=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,f)f.attributes=e.attributes;else if((f=new fV(this.id,e.clientId,e.streamId,e.screen,e.attributes)).virtual=u,this._initStreamListeners(f),!u){var _=this._remoteStreams.get(e.clientId);_?_.push(f):this._remoteStreams.set(e.clientId,[f])}if(this._mediaServerClient.handler&&(f.observer=new YV(f,this._mediaServerClient.handler)),!f.isScreen&&l){var m,g,y,S,b,E,k,T;if(a&&f.hasVideo)if(f.attributes.extvideo)null===(m=f.observer)||void 0===m||m.setExternalVideoSource(!0),null===(g=f.observer)||void 0===g||g.setPushVideo(!0);else null===(y=f.observer)||void 0===y||y.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(!0===i&&!1===a){var I,A=this._roomConfig,R=A.isAutoSubscribeAudio,w=A.isAutoSubscribeVideo;null===(I=f.observer)||void 0===I||I.setLogin(!0,{audio:!!R,video:!!w})}}return i&&this.safeEmit(bD.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,cd({},n)),this.safeEmit(bD.USER_CONNECTION,{userInfo:n}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(PV.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(PV.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,a=e.forbiddenTime;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var s=null;i===TD.kickedByAdmin?s=sR.KICKED_OUT:i===TD.onUserTokenDidExpire?s=sR.TOKEN_EXPIRED:i===TD.userDuplicateLogin&&(s=sR.DUPLICATE_LOGIN),o===ID.roomDismissByAdmin&&(s=sR.ROOM_DISMISS),s&&this.safeEmit(PV.ON_ROOM_ERROR,{errorCode:s,forbiddenTime:a})}else{var u=hd.DROPPED;i===TD.userLeave?u=hd.QUIT:i===TD.kickedByAdmin?u=hd.KICKED_BY_ADMIN:i===TD.roleChanged&&(u=hd.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){e.clean(),r._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:yD.clientDisconnected})})),r._remoteStreams.delete(n),r.safeEmit(PV.ON_USER_LEAVE,{userInfo:{userId:n},reason:u})};if(i===TD.userDuplicateLogin){var d=this._userDuplicateLoginTimerMap.get(n);d&&self.clearTimeout(d);var l=self.setTimeout(c,5e3);this._userDuplicateLoginTimerMap.set(n,l)}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=oE(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(bD.ON_REMOVE_STREAM,{stream:i,reason:e.message})})),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(PV.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(PV.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){var t;e.roomAttributes&&(this._mediaServerClient.roomAttributes=cd(cd({},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 u,c,d=s.attributes,l=cd(cd({},d),a),h=!1,v=l.localaudio!==d.localaudio,p=!1,f=!1,_=l.localvideo!==d.localvideo,m=!1,g=WU.NONE,y=WU.NONE;if(l.audiostream!==d.audiostream&&(h=l.localaudio,p=!!l.audiostream,l.audiostream?g|=Sd.AUDIO:y|=Sd.AUDIO),l.videostream!==d.videostream&&(f=l.localvideo,m=!!l.videostream,l.videostream?g|=Sd.VIDEO:y|=Sd.VIDEO),g&&this.safeEmit(PV.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:g,isScreen:s.isScreen,pubState:DV.PUB,remoteStream:s}),y&&this.safeEmit(PV.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:y,isScreen:s.isScreen,pubState:DV.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(PV.ON_USER_START_AUDIO_CAPTURE,{userId:i},s)}else{var T,I,A,R;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===(A=s.observer)||void 0===A||A.setExternalAudioSource(!1),null===(R=s.observer)||void 0===R||R.setEnableAudio(!1);!s.isScreen&&this.safeEmit(PV.ON_USER_STOP_AUDIO_CAPTURE,{userId:i})}if(l.localvideo!==d.localvideo)if(l.localvideo){var w,C,x,P;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===(P=s.observer)||void 0===P||P.setEnableVideo(!0);this.safeEmit(PV.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var O,D,M,N;if(l.extvideo)null===(O=s.observer)||void 0===O||O.setExternalVideoSource(!0),null===(D=s.observer)||void 0===D||D.setPushVideo(!1);else null===(M=s.observer)||void 0===M||M.setExternalVideoSource(!1),null===(N=s.observer)||void 0===N||N.setEnableVideo(!1);!s.isScreen&&this.safeEmit(PV.ON_USER_STOP_VIDEO_CAPTURE,{userId:i})}if(h&&!v)null===(u=s.observer)||void 0===u||u.setRemoteUnmuteAudio(p);if(f&&!_)null===(c=s.observer)||void 0===c||c.setRemoteUnmuteVideo(m)}}},{key:"_onPushTrack",value:function(e){var t,r=this;if(null!==(t=e.streamId)&&void 0!==t&&aR(t).call(t,"audio_mux")){var n=this._onAddStream(cd(cd({},e),{},{attributes:uF}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._mediaServerClient.subscribe4pushTrack(n,e).then((function(){r.safeEmit(PV.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){sF.print("subscribe","push track failed %o",e)}))}else{var i,o;null===(i=this._monitor)||void 0===i||i.report("rtc_error",{message:Rm(o="onPushTrack, userId: ".concat(e.clientId,", ")).call(o,e.streamId),error_code:-1001})}}},{key:"_onRemoveTrack",value:function(e){var t,r=e.clientId,n=e.streamId,i=e.message;sF.print("_onRemoveTrack","remove track: %o",r);var o=this._findRemoteStream(r,n);o&&(null===(t=this._mediaServerClient)||void 0===t||t.unsubscribe4removeTrack(o,i))}},{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}}},{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=WT(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&&LA(t).call(t,(function(e,t){return e.audioLevel-t.audioLevel})),t}},{key:"_nodeChange",value:function(e){var t,r,n=e.nodes,i=e.reason;IO.clearAccessNode(null===(t=this._roomInfo)||void 0===t?void 0:t.appId),this._destroyAndInitMediaServerClient(),Array.isArray(n)&&n.length?this._getAccessNode=n[0]:this._getAccessFeedback=i,null===(r=this._monitor)||void 0===r||r.report("rtc_node_change",{error_code:0,message:ZE(e),reason:ZE(i)}),this._joinResolveCallback&&this._joinRejectCallback?this._join(this._joinResolveCallback,this._joinRejectCallback):this._reconnect()}},{key:"_reconnect",value:function(){var e,t,r=this;this._isReconnecting=!0;var n,i=YT($I(t=this._remoteStreams).call(t));try{for(i.s();!(n=i.n()).done;){var o=n.value;Array.isArray(o)&&o.forEach((function(e){return e.clean()}))}}catch(a){i.e(a)}finally{i.f()}null===(e=this._monitor)||void 0===e||e.report("rtc_reconnect",{error_code:1002,message:"peerconnection reconnecting",reconnect_id:this._roomInfo.userInfo.userId,reconnect_type:"peerconnection"}),this._liveTranscodingOnceSucc||delete this._liveControlMessage,this._join((function(){var e;null===(e=r._monitor)||void 0===e||e.report("rtc_reconnected",{message:"peerconnection reconnected",reconnect_type:"peerconnection"})}),(function(e){r._reconnectRecord.record(e),r._reconnectRecord.shouldReconnect?(sF.print("Reconnecting error, will reconnect after 3s",e),r._reconnectTimer=window.setTimeout(r._reconnect.bind(r),3e3)):(r.safeEmit(PV.RECONNECT_FAILED),r.destroy())}),!0)}},{key:"_handleAbnormalDisconnection",value:function(){var e,t;sF.print("on ABNORMAL_DISCONNECTION"),null===(e=this.localStream)||void 0===e||e.stopReport(),null===(t=this.remoteStreams)||void 0===t||t.forEach((function(e){return null==e?void 0:e.forEach((function(e){return e.stopReport()}))})),this._destroyAndInitMediaServerClient(),navigator.onLine?this._reconnect():this._reconnectTimer=window.setTimeout(this._reconnect.bind(this),3e3)}},{key:"_onConnectionStateChange",value:function(e){var t,r=this;if(e.next===jV.DISCONNECTED)t=Ed.CONNECTION_STATE_DISCONNECTED;else if(e.next===jV.CONNECTED)clearTimeout(this._connectionLostTimer),t=this._isReconnecting?Ed.CONNECTION_STATE_RECONNECTED:Ed.CONNECTION_STATE_CONNECTED;else{if(e.next!==jV.CONNECTING)return;t=this._isReconnecting?Ed.CONNECTION_STATE_RECONNECTING:Ed.CONNECTION_STATE_CONNECTING}e.prev===jV.CONNECTED&&e.next===jV.DISCONNECTED&&(this._connectionLostTimer=window.setTimeout((function(){r.safeEmit(kD.ON_CONNECTION_STATE_CHANGE,{state:Ed.CONNECTION_STATE_LOST})}),1e4)),this._networkQualityManager.setConnectionState(e.next),this.safeEmit(kD.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(PV.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?yd.STREAM_INDEX_SCREEN:yd.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){this.safeEmit(bD.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(bD.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(bD.USER_BINARY_MESSAGE_RECEIVED,r)}},{key:"_initSubtitleTool",value:function(){var e=this;this._subtitleTool=new iF(this),this._subtitleTool.onEvent=function(t){e.emit(PV.ON_SUBTITLE_STATE_CHANGED,t)},this._subtitleTool.onMessage=function(t){e.emit(PV.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=OV.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=OV.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?OV.START_FAILED:OV.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?OV.STOP_FAILED:OV.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?OV.UPDATE_FAILED:OV.UPDATE_SUCCESS}this.safeEmit(bD.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(bD.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(bD.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onStreamFailed",value:(r=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l;return Sm().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(u=this._remoteStreamStreamIdUserIdMap[t.streamId],!(c=this._findRemoteStream(u,t.streamId))){e.next=20;break}return e.next=17,null===(d=this._mediaServerClient)||void 0===d?void 0:d.unsubscribe(c,Sd.AUDIO_AND_VIDEO);case 17:return e.next=19,null===(l=this._mediaServerClient)||void 0===l?void 0:l.subscribe(c,c.subMediaType,c.subLayer);case 19:this.safeEmit(PV.RESUBSCRIBE,{stream:c});case 20:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_onStreamControlMessage",value:function(e){var t,r;e.type===SD.PushLimitWarn&&(null!==(t=this._localStream)&&void 0!==t&&t.pubAudio||null!==(r=this._localStream)&&void 0!==r&&r.pubVideo||this.unpublish())}},{key:"_onPublishOnDemand",value:(t=Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u,c,d,l,h,v,p;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!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(a=this._publishOnDemandItem,this._publishOnDemandItem=void 0,a){e.next=6;break}return e.abrupt("return");case 6:if(null===(i=this._localStream)||void 0===i||!i.enableSimulcast||null===(o=this._localStream)||void 0===o||!o.videoTransceiver){e.next=16;break}return c=[],this._publishOnDemandBusy=!0,d=null===(s=this._localStream)||void 0===s?void 0:s.stream.id,l=null===(u=this._localStream)||void 0===u?void 0:u.videoTransceiver.sender,h=l.getParameters(),Array.isArray(h.encodings)&&Array.isArray(a)&&(p={},sF.print("_onPublishOnDemand exec","usedDescriptions: %o",a),a.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&vk(t).call(t,d)){var r=null==e?void 0:e.Metadata.VideoIndex;p[r]=!0}})),h.encodings=YE(v=h.encodings).call(v,(function(e){if(e.rid){p[e.rid]?e.active=!0:e.active=!1;var t=+e.rid;c[t]=e.active}return e})),this._context&&(this._context.activeSimStreams=c)),e.next=15,l.setParameters(h);case 15:this._publishOnDemandBusy=!1;case 16:this._onPublishOnDemand();case 17:case"end":return e.stop()}}),e,this)}))),function(){return t.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(PV.ON_SIMULCAST_SUBSCRIBE_FALLBACK,a)}},{key:"_reportNetworkQuality",value:function(e,t){this.emit(PV.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){var i;this.emit(PV.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:null===(i=this.roomInfo)||void 0===i?void 0:i.roomId,userId:e,streamIndex:t?yd.STREAM_INDEX_SCREEN:yd.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()}}]),A}(sD),dF=function(){function e(){qd(this,e),sd(this,"_all_201_count",void 0),sd(this,"_has_4xx",void 0),this._all_201_count=0,this._has_4xx=!1}return Kd(e,[{key:"shouldReconnect",get:function(){return!(this._all_201_count>=3||this._has_4xx)}},{key:"record",value:function(e){var t=!1,r=!1;if(Array.isArray(e)){var n=0;YE(e).call(e,(function(e){var t,i,o;400<=(null===(t=e.error)||void 0===t?void 0:t.code)&&(null===(i=e.error)||void 0===i?void 0:i.code)<500&&(r=!0),201===(null===(o=e.error)||void 0===o?void 0:o.code)&&n++})),n===e.length&&(t=!0),t&&this._all_201_count++,r&&(this._has_4xx=!0)}}},{key:"clear",value:function(){this._all_201_count=0,this._has_4xx=!1}}]),e}(),lF=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&&pb(r.style,t.style),t.attributes&&gR(t.attributes).forEach((function(e){var t=WT(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},hF=new nP("Player",0),vF=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],pF={playsinline:"","webkit-playsinline":""},fF={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},_F=function(e){wI(n,e);var t,r=XI(n);function n(e,t){var i;qd(this,n),sd(QT(i=r.call(this)),"_containerDom",void 0),sd(QT(i),"_videoDom",void 0),sd(QT(i),"__cumulativeTime",void 0),sd(QT(i),"userId",void 0),sd(QT(i),"renderMode",void 0),sd(QT(i),"mirrorType",kd.MIRROR_TYPE_NONE),sd(QT(i),"isScreen",void 0),sd(QT(i),"isLocal",void 0),sd(QT(i),"played",!1),sd(QT(i),"_needLoad",!1),sd(QT(i),"_emitPlayFailed",!1),sd(QT(i),"_videoContainer",void 0),sd(QT(i),"_safari15VideoTimer",void 0),sd(QT(i),"_monitor",void 0),sd(QT(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":hF.print("VideoPlayerPlaying","[userId-".concat(i.userId,"] video element playing"))}})),sd(QT(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&&rO&&!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:Rm(r="video autoplay failed, userId: ".concat(i.userId,", ")).call(r,e.name),error_code:-1e3}),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:Rm(s="video autoplay failed, userId: ".concat(i.userId,", ")).call(s,e.name),error_code:-1e3}))}))}})),i.engineId=e;var o=t.renderDom;i._monitor=mP(e);var a=t.userId;i.renderMode=void 0!==t.renderMode?t.renderMode:gd.RENDER_MODE_FIT;var s="string"==typeof o?document.getElementById(o):o;if(!s)throw new cR(sR.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=s,i.userId=a,i.isLocal=!!t.isLocal,i.isScreen=!!t.isScreen,i._initVideo(),i}return Kd(n,[{key:"_initVideo",value:function(){var e;this._videoDom||(this._videoDom=lF("video",{style:{width:"100%",height:"100%"},attributes:fF}),this._videoDom.id=Rm(e="".concat(this.userId,"_")).call(e,DP()),this.renderMode===gd.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this._videoDom.style.objectFit="cover",this.mirror(this.mirrorType===kd.MIRROR_TYPE_RENDER));this._videoContainer.appendChild(this._videoDom),this._containerDom.appendChild(this._videoContainer),this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._videoDom&&vF.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&&vF.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(jP){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,u=(a-t.__cumulativeTime)%2e3,c=u>1e3*r;null===(s=e.recordedVideoFrames)||void 0===s||s.push({playTime:a,isStall:c,stallCount:c?1:0,stallDuration:u})}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=MP();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=MP()-(e.statsReport.pauseStart||0);i>500&&(e.statsReport.pauseDuration+=i)}}}))}},{key:"playVideo",value:(t=Em(Sm().mark((function e(t,r){var n,i,o,a,s=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=this._videoDom,hF.print("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{SP(this.engineId,"playVideo","play video repeatedly",0,this.userId)}catch(eX){}return e.abrupt("return");case 5:o||(this._initVideo(),o=this._videoDom),hF.print("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&&xO.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(hF.print("Invoke VideoPlayer.manuallyPlay",this.userId,this.isScreen),this._emitPlayFailed=!1,!this._videoDom)throw new cR(sR.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||WP?this._videoDom.play():X_.resolve()}},{key:"mirror",value:function(e){var t;hF.print("mirror",Rm(t="".concat(this.userId," set mirror: ")).call(t,e)),this.mirrorType=e?kd.MIRROR_TYPE_RENDER:kd.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;(hF.print("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];hF.print("destroy","video player: ".concat(this.userId)),this.stop(e),AI(TI(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._videoDom&&delete this._videoDom,this._safari15VideoTimer&&(window.clearInterval(this._safari15VideoTimer),this._safari15VideoTimer=void 0)}},{key:"domElement",get:function(){return this._videoDom}}]),n}(iD.exports.EventEmitter),mF=function(e){wI(i,e);var t,r,n=XI(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,u=o.isScreen;if(qd(this,i),sd(QT(r=n.call(this)),"_containerDom",void 0),sd(QT(r),"_audioDom",void 0),sd(QT(r),"_fakeAudioDom",void 0),sd(QT(r),"userId",void 0),sd(QT(r),"muted",!1),sd(QT(r),"_emitPlayFailed",!1),sd(QT(r),"played",!1),sd(QT(r),"isScreen",void 0),sd(QT(r),"_wechatTimer",void 0),sd(QT(r),"_monitor",void 0),sd(QT(r),"_pasued",!0),sd(QT(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&&hF.print("AudioPlayerPlaying","[userId-".concat(r.userId,"] audio element playing")),"pause"===e.type&&(hF.print("AudioPlayerPause","[userId-".concat(r.userId,"] audio element pause")),r._pasued||r._internalPlay()),QP&&WP&&("canplay"===e.type?(clearTimeout(r._wechatTimer),r._wechatTimer=window.setTimeout((function(){r._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(r._wechatTimer)),r.emit("playback_event",i)})),sd(QT(r),"_internalPlay",(function(){var e,t;if(SP(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"),error_code:-1e3}));clearTimeout(s)}));a.then((function(){clearTimeout(s)}))}null!==(n=i)&&void 0!==n&&n.then&&(QP&&JP&&(i=i.then((function(){return new X_((function(e){setTimeout(Em(Sm().mark((function t(){var n;return Sm().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(){SP(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:Rm(n=Rm(i="audio autoplay failed, userId: ".concat(r.userId,": ")).call(i,e.message," ")).call(n,e.name),error_code:-1e3})})))}catch(l){var u,c,d;r._autoPlayError(l),null===(u=r._monitor)||void 0===u||u.report("rtc_error",{message:Rm(c=Rm(d="audio autoplay failed, userId: ".concat(r.userId,": ")).call(d,l.message," ")).call(c,l.name),error_code:-1e3})}})),r.engineId=e,a){var c=document.getElementById(a);if(!c)throw new cR(sR.CANT_FIND_DOM,"can't find dom");r._containerDom=c}else r._containerDom=document.body;return r.userId=t,r.muted=s,r.isScreen=u,r._monitor=mP(e),r._initAudio(),r}return Kd(i,[{key:"_initAudio",value:function(){var e;this._audioDom||(this._audioDom=lF("audio",{style:{display:"none"},attributes:pF}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id=Rm(e="".concat(this.userId,"_")).call(e,DP()),this._containerDom.appendChild(this._audioDom));this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&vF.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&&(vF.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=Em(Sm().mark((function e(t){var r,n,i,o,a,s=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(hF.print("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 YU?(this._fakeAudioDom=new Audio,this._fakeAudioDom.muted=!0,this._fakeAudioDom.srcObject=new MediaStream([t.getOrgTrack()]),a.addTrack(t.getTrack())):a.addTrack(t.getTrack("preprocessing")),QP&&JP&&(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 cR(sR.INVALID_PARAMS,"Player not found");this._pasued=!0,this._audioDom.pause()}},{key:"manuallyPlay",value:function(){var e,t=this;if(hF.print("Invoke AudioPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._audioDom)throw new cR(sR.INVALID_PARAMS,"Player not found");if(!this.played)return X_.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?X_.all(r):X_.resolve(n)).then((function(){t._pasued=!1}))}},{key:"setPlaybackDevice",value:(t=Em(Sm().mark((function e(t){var r,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return hF.print("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,nU.enumerateAudioPlaybackDevices();case 3:if(r=e.sent,n=YE(r).call(r,(function(e){return e.deviceId})),vk(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;hF.print("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(){hF.print("destroy","audio player: ".concat(this.userId)),this.stop(),AI(TI(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(this._audioDom.srcObject=null,delete this._audioDom)}}]),i}(iD.exports.EventEmitter);function gF(e,t,r,n){var i=function(){var e=Em(Sm().mark((function e(t,i){var o,a;return Sm().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:oE(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 _F&&o.videoTrack&&t.playVideo(o.videoTrack,o),t instanceof mF&&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))})),X_.all(o)}var yF="object"==typeof global&&global&&global.Object===Object&&global,SF="object"==typeof self&&self&&self.Object===Object&&self,bF=yF||SF||Function("return this")(),EF=bF.Symbol,kF=Object.prototype,TF=kF.hasOwnProperty,IF=kF.toString,AF=EF?EF.toStringTag:void 0;var RF=Object.prototype.toString;var wF=EF?EF.toStringTag:void 0;function CF(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":wF&&wF in Object(e)?function(e){var t=TF.call(e,AF),r=e[AF];try{e[AF]=void 0;var n=!0}catch(o){}var i=IF.call(e);return n&&(t?e[AF]=r:delete e[AF]),i}(e):function(e){return RF.call(e)}(e)}function xF(e){return null!=e&&"object"==typeof e}var PF=Array.isArray;function OF(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function DF(e){return e}function MF(e){if(!OF(e))return!1;var t=CF(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var NF,LF=bF["__core-js_shared__"],UF=(NF=/[^.]+$/.exec(LF&&LF.keys&&LF.keys.IE_PROTO||""))?"Symbol(src)_1."+NF:"";var VF=Function.prototype.toString;var FF=/^\[object .+?Constructor\]$/,BF=Function.prototype,jF=Object.prototype,GF=BF.toString,HF=jF.hasOwnProperty,zF=RegExp("^"+GF.call(HF).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function XF(e){return!(!OF(e)||(t=e,UF&&UF in t))&&(MF(e)?zF:FF).test(function(e){if(null!=e){try{return VF.call(e)}catch(t){}try{return e+""}catch(t){}}return""}(e));var t}function KF(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,WF,QF,JF=function(){try{var e=XF(t=function(e,t){return null==e?void 0:e[t]}(Object,"defineProperty"))?t:void 0;return e({},"",{}),e}catch(r){}var t}(),ZF=JF,$F=ZF?function(e,t){return ZF(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:DF,eB=(YF=$F,WF=0,QF=0,function(){var e=qF(),t=16-(e-QF);if(QF=e,t>0){if(++WF>=800)return arguments[0]}else WF=0;return YF.apply(void 0,arguments)}),tB=eB,rB=/^(?:0|[1-9]\d*)$/;function nB(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&rB.test(e))&&e>-1&&e%1==0&&e<t}function iB(e,t,r){"__proto__"==t&&ZF?ZF(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function oB(e,t){return e===t||e!=e&&t!=t}var aB=Object.prototype.hasOwnProperty;function sB(e,t,r){var n=e[t];aB.call(e,t)&&oB(n,r)&&(void 0!==r||t in e)||iB(e,t,r)}var uB=Math.max;function cB(e,t){return tB(function(e,t,r){return t=uB(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=uB(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),KF(e,this,s)}}(e,t,DF),e+"")}function dB(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function lB(e){return null!=e&&dB(e.length)&&!MF(e)}var hB=Object.prototype;function vB(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||hB)}function pB(e){return xF(e)&&"[object Arguments]"==CF(e)}var fB=Object.prototype,_B=fB.hasOwnProperty,mB=fB.propertyIsEnumerable,gB=pB(function(){return arguments}())?pB:function(e){return xF(e)&&_B.call(e,"callee")&&!mB.call(e,"callee")},yB=gB;var SB="object"==typeof exports&&exports&&!exports.nodeType&&exports,bB=SB&&"object"==typeof module&&module&&!module.nodeType&&module,EB=bB&&bB.exports===SB?bF.Buffer:void 0,kB=(EB?EB.isBuffer:void 0)||function(){return!1},TB={};TB["[object Float32Array]"]=TB["[object Float64Array]"]=TB["[object Int8Array]"]=TB["[object Int16Array]"]=TB["[object Int32Array]"]=TB["[object Uint8Array]"]=TB["[object Uint8ClampedArray]"]=TB["[object Uint16Array]"]=TB["[object Uint32Array]"]=!0,TB["[object Arguments]"]=TB["[object Array]"]=TB["[object ArrayBuffer]"]=TB["[object Boolean]"]=TB["[object DataView]"]=TB["[object Date]"]=TB["[object Error]"]=TB["[object Function]"]=TB["[object Map]"]=TB["[object Number]"]=TB["[object Object]"]=TB["[object RegExp]"]=TB["[object Set]"]=TB["[object String]"]=TB["[object WeakMap]"]=!1;var IB="object"==typeof exports&&exports&&!exports.nodeType&&exports,AB=IB&&"object"==typeof module&&module&&!module.nodeType&&module,RB=AB&&AB.exports===IB&&yF.process,wB=function(){try{var e=AB&&AB.require&&AB.require("util").types;return e||RB&&RB.binding&&RB.binding("util")}catch(t){}}(),CB=wB&&wB.isTypedArray,xB=CB?function(e){return function(t){return e(t)}}(CB):function(e){return xF(e)&&dB(e.length)&&!!TB[CF(e)]},PB=xB,OB=Object.prototype.hasOwnProperty;function DB(e,t){var r=PF(e),n=!r&&yB(e),i=!r&&!n&&kB(e),o=!r&&!n&&!i&&PB(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):[],u=s.length;for(var c in e)!t&&!OB.call(e,c)||a&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||nB(c,u))||s.push(c);return s}var MB=function(e,t){return function(r){return e(t(r))}}(Object.keys,Object),NB=MB,LB=Object.prototype.hasOwnProperty;function UB(e){return lB(e)?DB(e):function(e){if(!vB(e))return NB(e);var t=[];for(var r in Object(e))LB.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}var VB=Object.prototype.hasOwnProperty;function FB(e){if(!OF(e))return function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}(e);var t=vB(e),r=[];for(var n in e)("constructor"!=n||!t&&VB.call(e,n))&&r.push(n);return r}var BB,jB=(BB=function(e,t){!function(e,t,r,n){var i=!r;r||(r={});for(var o=-1,a=t.length;++o<a;){var s=t[o],u=n?n(r[s],e[s],s,r,e):void 0;void 0===u&&(u=e[s]),i?iB(r,s,u):sB(r,s,u)}}(t,function(e){return lB(e)?DB(e,!0):FB(e)}(t),e)},cB((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=BB.length>3&&"function"==typeof i?(n--,i):void 0,o&&function(e,t,r){if(!OF(r))return!1;var n=typeof t;return!!("number"==n?lB(r)&&nB(t,r.length):"string"==n&&t in r)&&oB(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&&BB(e,a,r,i)}return e})));function GB(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 HB(e){return null==e?[]:GB(e,UB(e))}var zB=i,XB=lt("iterator"),KB=!zB((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[XB]||"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})),qB=Qt,YB=E,WB=2147483647,QB=/[^\0-\u007E]/,JB=/[.\u3002\uFF0E\uFF61]/g,ZB="Overflow: input needs wider integers to process",$B=RangeError,ej=YB(JB.exec),tj=Math.floor,rj=String.fromCharCode,nj=YB("".charCodeAt),ij=YB([].join),oj=YB([].push),aj=YB("".replace),sj=YB("".split),uj=YB("".toLowerCase),cj=function(e){return e+22+75*(e<26)},dj=function(e,t,r){var n=0;for(e=r?tj(e/700):e>>1,e+=tj(e/t);e>455;)e=tj(e/35),n+=36;return tj(n+36*e/(e+38))},lj=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=nj(e,r++);if(i>=55296&&i<=56319&&r<n){var o=nj(e,r++);56320==(64512&o)?oj(t,((1023&i)<<10)+(1023&o)+65536):(oj(t,i),r--)}else oj(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&&oj(t,rj(n));var u=t.length,c=u;for(u&&oj(t,"-");c<i;){var d=WB;for(r=0;r<e.length;r++)(n=e[r])>=o&&n<d&&(d=n);var l=c+1;if(d-o>tj((WB-a)/l))throw $B(ZB);for(a+=(d-o)*l,o=d,r=0;r<e.length;r++){if((n=e[r])<o&&++a>WB)throw $B(ZB);if(n==o){for(var h=a,v=36;;){var p=v<=s?1:v>=s+26?26:v-s;if(h<p)break;var f=h-p,_=36-p;oj(t,rj(cj(p+f%_))),h=tj(f/_),v+=36}oj(t,rj(cj(h))),s=dj(a,l,c==u),a=0,c++}}a++,o++}return ij(t,"")},hj=Rr,vj=n,pj=P,fj=E,_j=w,mj=KB,gj=li,yj=Ug,Sj=Ni,bj=Mu,Ej=Zi,kj=vv,Tj=A,Ij=We,Aj=Wt,Rj=fn,wj=tr,Cj=$,xj=gn,Pj=Hn,Oj=V,Dj=fh,Mj=uh,Nj=Tv,Lj=oA,Uj=lt("iterator"),Vj="URLSearchParams",Fj="URLSearchParamsIterator",Bj=Ej.set,jj=Ej.getterFor(Vj),Gj=Ej.getterFor(Fj),Hj=Object.getOwnPropertyDescriptor,zj=function(e){if(!_j)return vj[e];var t=Hj(vj,e);return t&&t.value},Xj=zj("fetch"),Kj=zj("Request"),qj=zj("Headers"),Yj=Kj&&Kj.prototype,Wj=qj&&qj.prototype,Qj=vj.RegExp,Jj=vj.TypeError,Zj=vj.decodeURIComponent,$j=vj.encodeURIComponent,eG=fj("".charAt),tG=fj([].join),rG=fj([].push),nG=fj("".replace),iG=fj([].shift),oG=fj([].splice),aG=fj("".split),sG=fj("".slice),uG=/\+/g,cG=Array(4),dG=function(e){return cG[e-1]||(cG[e-1]=Qj("((?:%[\\da-f]{2}){"+e+"})","gi"))},lG=function(e){try{return Zj(e)}catch(eX){return e}},hG=function(e){var t=nG(e,uG," "),r=4;try{return Zj(t)}catch(eX){for(;r;)t=nG(t,dG(r--),lG);return t}},vG=/[!'()~]|%20/g,pG={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},fG=function(e){return pG[e]},_G=function(e){return nG($j(e),vG,fG)},mG=bj((function(e,t){Bj(this,{type:Fj,iterator:Dj(jj(e).entries),kind:t})}),"Iterator",(function(){var e=Gj(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),gG=function(e){this.entries=[],this.url=null,void 0!==e&&(Cj(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===eG(e,0)?sG(e,1):e:xj(e)))};gG.prototype={type:Vj,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,u=Mj(e);if(u)for(r=(t=Dj(e,u)).next;!(n=pj(r,t)).done;){if(o=(i=Dj(wj(n.value))).next,(a=pj(o,i)).done||(s=pj(o,i)).done||!pj(o,i).done)throw Jj("Expected sequence with length 2");rG(this.entries,{key:xj(a.value),value:xj(s.value)})}else for(var c in e)Ij(e,c)&&rG(this.entries,{key:c,value:xj(e[c])})},parseQuery:function(e){if(e)for(var t,r,n=aG(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=aG(t,"="),rG(this.entries,{key:hG(iG(r)),value:hG(tG(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],rG(r,_G(e.key)+"="+_G(e.value));return tG(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var yG=function(){kj(this,SG);var e=arguments.length>0?arguments[0]:void 0;Bj(this,new gG(e))},SG=yG.prototype;if(yj(SG,{append:function(e,t){Nj(arguments.length,2);var r=jj(this);rG(r.entries,{key:xj(e),value:xj(t)}),r.updateURL()},delete:function(e){Nj(arguments.length,1);for(var t=jj(this),r=t.entries,n=xj(e),i=0;i<r.length;)r[i].key===n?oG(r,i,1):i++;t.updateURL()},get:function(e){Nj(arguments.length,1);for(var t=jj(this).entries,r=xj(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){Nj(arguments.length,1);for(var t=jj(this).entries,r=xj(e),n=[],i=0;i<t.length;i++)t[i].key===r&&rG(n,t[i].value);return n},has:function(e){Nj(arguments.length,1);for(var t=jj(this).entries,r=xj(e),n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){Nj(arguments.length,1);for(var r,n=jj(this),i=n.entries,o=!1,a=xj(e),s=xj(t),u=0;u<i.length;u++)(r=i[u]).key===a&&(o?oG(i,u--,1):(o=!0,r.value=s));o||rG(i,{key:a,value:s}),n.updateURL()},sort:function(){var e=jj(this);Lj(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=jj(this).entries,n=Aj(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 mG(this,"keys")},values:function(){return new mG(this,"values")},entries:function(){return new mG(this,"entries")}},{enumerable:!0}),gj(SG,Uj,SG.entries,{name:"entries"}),gj(SG,"toString",(function(){return jj(this).serialize()}),{enumerable:!0}),Sj(yG,Vj),hj({global:!0,constructor:!0,forced:!mj},{URLSearchParams:yG}),!mj&&Tj(qj)){var bG=fj(Wj.has),EG=fj(Wj.set),kG=function(e){if(Cj(e)){var t,r=e.body;if(Rj(r)===Vj)return t=e.headers?new qj(e.headers):new qj,bG(t,"content-type")||EG(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),Pj(e,{body:Oj(0,xj(r)),headers:Oj(0,t)})}return e};if(Tj(Xj)&&hj({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return Xj(e,arguments.length>1?kG(arguments[1]):{})}}),Tj(Kj)){var TG=function(e){return kj(this,Yj),new Kj(e,arguments.length>1?kG(arguments[1]):{})};Yj.constructor=TG,TG.prototype=Yj,hj({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:TG})}}var IG,AG=Rr,RG=w,wG=KB,CG=n,xG=Wt,PG=E,OG=li,DG=function(e,t,r){return qB.f(e,t,r)},MG=vv,NG=We,LG=hb,UG=Gk,VG=ni,FG=Tl.codeAt,BG=function(e){var t,r,n=[],i=sj(aj(uj(e),JB,"."),".");for(t=0;t<i.length;t++)r=i[t],oj(n,ej(QB,r)?"xn--"+lj(r):r);return ij(n,".")},jG=gn,GG=Ni,HG=Tv,zG={URLSearchParams:yG,getState:jj},XG=Zi,KG=XG.set,qG=XG.getterFor("URL"),YG=zG.URLSearchParams,WG=zG.getState,QG=CG.URL,JG=CG.TypeError,ZG=CG.parseInt,$G=Math.floor,eH=Math.pow,tH=PG("".charAt),rH=PG(/./.exec),nH=PG([].join),iH=PG(1..toString),oH=PG([].pop),aH=PG([].push),sH=PG("".replace),uH=PG([].shift),cH=PG("".split),dH=PG("".slice),lH=PG("".toLowerCase),hH=PG([].unshift),vH="Invalid scheme",pH="Invalid host",fH="Invalid port",_H=/[a-z]/i,mH=/[\d+-.a-z]/i,gH=/\d/,yH=/^0x/i,SH=/^[0-7]+$/,bH=/^\d+$/,EH=/^[\da-f]+$/i,kH=/[\0\t\n\r #%/:<>?@[\\\]^|]/,TH=/[\0\t\n\r #/:<>?@[\\\]^|]/,IH=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,AH=/[\t\n\r]/g,RH=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)hH(t,e%256),e=$G(e/256);return nH(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+=iH(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},wH={},CH=LG({},wH,{" ":1,'"':1,"<":1,">":1,"`":1}),xH=LG({},CH,{"#":1,"?":1,"{":1,"}":1}),PH=LG({},xH,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),OH=function(e,t){var r=FG(e,0);return r>32&&r<127&&!NG(t,e)?e:encodeURIComponent(e)},DH={ftp:21,file:null,http:80,https:443,ws:80,wss:443},MH=function(e,t){var r;return 2==e.length&&rH(_H,tH(e,0))&&(":"==(r=tH(e,1))||!t&&"|"==r)},NH=function(e){var t;return e.length>1&&MH(dH(e,0,2))&&(2==e.length||"/"===(t=tH(e,2))||"\\"===t||"?"===t||"#"===t)},LH=function(e){return"."===e||"%2e"===lH(e)},UH={},VH={},FH={},BH={},jH={},GH={},HH={},zH={},XH={},KH={},qH={},YH={},WH={},QH={},JH={},ZH={},$H={},ez={},tz={},rz={},nz={},iz=function(e,t,r){var n,i,o,a=jG(e);if(t){if(i=this.parse(a))throw JG(i);this.searchParams=null}else{if(void 0!==r&&(n=new iz(r,!0)),i=this.parse(a,null,n))throw JG(i);(o=WG(new YG)).bindURL(this),this.searchParams=o}};iz.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,u=this,c=t||UH,d=0,l="",h=!1,v=!1,p=!1;for(e=jG(e),t||(u.scheme="",u.username="",u.password="",u.host=null,u.port=null,u.path=[],u.query=null,u.fragment=null,u.cannotBeABaseURL=!1,e=sH(e,IH,"")),e=sH(e,AH,""),n=UG(e);d<=n.length;){switch(i=n[d],c){case UH:if(!i||!rH(_H,i)){if(t)return vH;c=FH;continue}l+=lH(i),c=VH;break;case VH:if(i&&(rH(mH,i)||"+"==i||"-"==i||"."==i))l+=lH(i);else{if(":"!=i){if(t)return vH;l="",c=FH,d=0;continue}if(t&&(u.isSpecial()!=NG(DH,l)||"file"==l&&(u.includesCredentials()||null!==u.port)||"file"==u.scheme&&!u.host))return;if(u.scheme=l,t)return void(u.isSpecial()&&DH[u.scheme]==u.port&&(u.port=null));l="","file"==u.scheme?c=QH:u.isSpecial()&&r&&r.scheme==u.scheme?c=BH:u.isSpecial()?c=zH:"/"==n[d+1]?(c=jH,d++):(u.cannotBeABaseURL=!0,aH(u.path,""),c=tz)}break;case FH:if(!r||r.cannotBeABaseURL&&"#"!=i)return vH;if(r.cannotBeABaseURL&&"#"==i){u.scheme=r.scheme,u.path=VG(r.path),u.query=r.query,u.fragment="",u.cannotBeABaseURL=!0,c=nz;break}c="file"==r.scheme?QH:GH;continue;case BH:if("/"!=i||"/"!=n[d+1]){c=GH;continue}c=XH,d++;break;case jH:if("/"==i){c=KH;break}c=ez;continue;case GH:if(u.scheme=r.scheme,i==IG)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=VG(r.path),u.query=r.query;else if("/"==i||"\\"==i&&u.isSpecial())c=HH;else if("?"==i)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=VG(r.path),u.query="",c=rz;else{if("#"!=i){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=VG(r.path),u.path.length--,c=ez;continue}u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=VG(r.path),u.query=r.query,u.fragment="",c=nz}break;case HH:if(!u.isSpecial()||"/"!=i&&"\\"!=i){if("/"!=i){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,c=ez;continue}c=KH}else c=XH;break;case zH:if(c=XH,"/"!=i||"/"!=tH(l,d+1))continue;d++;break;case XH:if("/"!=i&&"\\"!=i){c=KH;continue}break;case KH:if("@"==i){h&&(l="%40"+l),h=!0,o=UG(l);for(var f=0;f<o.length;f++){var _=o[f];if(":"!=_||p){var m=OH(_,PH);p?u.password+=m:u.username+=m}else p=!0}l=""}else if(i==IG||"/"==i||"?"==i||"#"==i||"\\"==i&&u.isSpecial()){if(h&&""==l)return"Invalid authority";d-=UG(l).length+1,l="",c=qH}else l+=i;break;case qH:case YH:if(t&&"file"==u.scheme){c=ZH;continue}if(":"!=i||v){if(i==IG||"/"==i||"?"==i||"#"==i||"\\"==i&&u.isSpecial()){if(u.isSpecial()&&""==l)return pH;if(t&&""==l&&(u.includesCredentials()||null!==u.port))return;if(a=u.parseHost(l))return a;if(l="",c=$H,t)return;continue}"["==i?v=!0:"]"==i&&(v=!1),l+=i}else{if(""==l)return pH;if(a=u.parseHost(l))return a;if(l="",c=WH,t==YH)return}break;case WH:if(!rH(gH,i)){if(i==IG||"/"==i||"?"==i||"#"==i||"\\"==i&&u.isSpecial()||t){if(""!=l){var g=ZG(l,10);if(g>65535)return fH;u.port=u.isSpecial()&&g===DH[u.scheme]?null:g,l=""}if(t)return;c=$H;continue}return fH}l+=i;break;case QH:if(u.scheme="file","/"==i||"\\"==i)c=JH;else{if(!r||"file"!=r.scheme){c=ez;continue}if(i==IG)u.host=r.host,u.path=VG(r.path),u.query=r.query;else if("?"==i)u.host=r.host,u.path=VG(r.path),u.query="",c=rz;else{if("#"!=i){NH(nH(VG(n,d),""))||(u.host=r.host,u.path=VG(r.path),u.shortenPath()),c=ez;continue}u.host=r.host,u.path=VG(r.path),u.query=r.query,u.fragment="",c=nz}}break;case JH:if("/"==i||"\\"==i){c=ZH;break}r&&"file"==r.scheme&&!NH(nH(VG(n,d),""))&&(MH(r.path[0],!0)?aH(u.path,r.path[0]):u.host=r.host),c=ez;continue;case ZH:if(i==IG||"/"==i||"\\"==i||"?"==i||"#"==i){if(!t&&MH(l))c=ez;else if(""==l){if(u.host="",t)return;c=$H}else{if(a=u.parseHost(l))return a;if("localhost"==u.host&&(u.host=""),t)return;l="",c=$H}continue}l+=i;break;case $H:if(u.isSpecial()){if(c=ez,"/"!=i&&"\\"!=i)continue}else if(t||"?"!=i)if(t||"#"!=i){if(i!=IG&&(c=ez,"/"!=i))continue}else u.fragment="",c=nz;else u.query="",c=rz;break;case ez:if(i==IG||"/"==i||"\\"==i&&u.isSpecial()||!t&&("?"==i||"#"==i)){if(".."===(s=lH(s=l))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(u.shortenPath(),"/"==i||"\\"==i&&u.isSpecial()||aH(u.path,"")):LH(l)?"/"==i||"\\"==i&&u.isSpecial()||aH(u.path,""):("file"==u.scheme&&!u.path.length&&MH(l)&&(u.host&&(u.host=""),l=tH(l,0)+":"),aH(u.path,l)),l="","file"==u.scheme&&(i==IG||"?"==i||"#"==i))for(;u.path.length>1&&""===u.path[0];)uH(u.path);"?"==i?(u.query="",c=rz):"#"==i&&(u.fragment="",c=nz)}else l+=OH(i,xH);break;case tz:"?"==i?(u.query="",c=rz):"#"==i?(u.fragment="",c=nz):i!=IG&&(u.path[0]+=OH(i,wH));break;case rz:t||"#"!=i?i!=IG&&("'"==i&&u.isSpecial()?u.query+="%27":u.query+="#"==i?"%23":OH(i,wH)):(u.fragment="",c=nz);break;case nz:i!=IG&&(u.fragment+=OH(i,CH))}d++}},parseHost:function(e){var t,r,n;if("["==tH(e,0)){if("]"!=tH(e,e.length-1))return pH;if(t=function(e){var t,r,n,i,o,a,s,u=[0,0,0,0,0,0,0,0],c=0,d=null,l=0,h=function(){return tH(e,l)};if(":"==h()){if(":"!=tH(e,1))return;l+=2,d=++c}for(;h();){if(8==c)return;if(":"!=h()){for(t=r=0;r<4&&rH(EH,h());)t=16*t+ZG(h(),16),l++,r++;if("."==h()){if(0==r)return;if(l-=r,c>6)return;for(n=0;h();){if(i=null,n>0){if(!("."==h()&&n<4))return;l++}if(!rH(gH,h()))return;for(;rH(gH,h());){if(o=ZG(h(),10),null===i)i=o;else{if(0==i)return;i=10*i+o}if(i>255)return;l++}u[c]=256*u[c]+i,2!=++n&&4!=n||c++}if(4!=n)return;break}if(":"==h()){if(l++,!h())return}else if(h())return;u[c++]=t}else{if(null!==d)return;l++,d=++c}}if(null!==d)for(a=c-d,c=7;0!=c&&a>0;)s=u[c],u[c--]=u[d+a-1],u[d+--a]=s;else if(8!=c)return;return u}(dH(e,1,-1)),!t)return pH;this.host=t}else if(this.isSpecial()){if(e=BG(e),rH(kH,e))return pH;if(t=function(e){var t,r,n,i,o,a,s,u=cH(e,".");if(u.length&&""==u[u.length-1]&&u.length--,(t=u.length)>4)return e;for(r=[],n=0;n<t;n++){if(""==(i=u[n]))return e;if(o=10,i.length>1&&"0"==tH(i,0)&&(o=rH(yH,i)?16:8,i=dH(i,8==o?1:2)),""===i)a=0;else{if(!rH(10==o?bH:8==o?SH:EH,i))return e;a=ZG(i,o)}aH(r,a)}for(n=0;n<t;n++)if(a=r[n],n==t-1){if(a>=eH(256,5-t))return null}else if(a>255)return null;for(s=oH(r),n=0;n<r.length;n++)s+=r[n]*eH(256,3-n);return s}(e),null===t)return pH;this.host=t}else{if(rH(TH,e))return pH;for(t="",r=UG(e),n=0;n<r.length;n++)t+=OH(r[n],wH);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return NG(DH,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&MH(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,u=e.fragment,c=t+":";return null!==i?(c+="//",e.includesCredentials()&&(c+=r+(n?":"+n:"")+"@"),c+=RH(i),null!==o&&(c+=":"+o)):"file"==t&&(c+="//"),c+=e.cannotBeABaseURL?a[0]:a.length?"/"+nH(a,"/"):"",null!==s&&(c+="?"+s),null!==u&&(c+="#"+u),c},setHref:function(e){var t=this.parse(e);if(t)throw JG(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new oz(e.path[0]).origin}catch(eX){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+RH(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(jG(e)+":",UH)},getUsername:function(){return this.username},setUsername:function(e){var t=UG(jG(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=OH(t[r],PH)}},getPassword:function(){return this.password},setPassword:function(e){var t=UG(jG(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=OH(t[r],PH)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?RH(e):RH(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,qH)},getHostname:function(){var e=this.host;return null===e?"":RH(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,YH)},getPort:function(){var e=this.port;return null===e?"":jG(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=jG(e))?this.port=null:this.parse(e,WH))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+nH(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,$H))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=jG(e))?this.query=null:("?"==tH(e,0)&&(e=dH(e,1)),this.query="",this.parse(e,rz)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=jG(e))?("#"==tH(e,0)&&(e=dH(e,1)),this.fragment="",this.parse(e,nz)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var oz=function(e){var t=MG(this,az),r=HG(arguments.length,1)>1?arguments[1]:void 0,n=KG(t,new iz(e,!1,r));RG||(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())},az=oz.prototype,sz=function(e,t){return{get:function(){return qG(this)[e]()},set:t&&function(e){return qG(this)[t](e)},configurable:!0,enumerable:!0}};if(RG&&(DG(az,"href",sz("serialize","setHref")),DG(az,"origin",sz("getOrigin")),DG(az,"protocol",sz("getProtocol","setProtocol")),DG(az,"username",sz("getUsername","setUsername")),DG(az,"password",sz("getPassword","setPassword")),DG(az,"host",sz("getHost","setHost")),DG(az,"hostname",sz("getHostname","setHostname")),DG(az,"port",sz("getPort","setPort")),DG(az,"pathname",sz("getPathname","setPathname")),DG(az,"search",sz("getSearch","setSearch")),DG(az,"searchParams",sz("getSearchParams")),DG(az,"hash",sz("getHash","setHash"))),OG(az,"toJSON",(function(){return qG(this).serialize()}),{enumerable:!0}),OG(az,"toString",(function(){return qG(this).serialize()}),{enumerable:!0}),QG){var uz=QG.createObjectURL,cz=QG.revokeObjectURL;uz&&OG(oz,"createObjectURL",xG(uz,QG)),cz&&OG(oz,"revokeObjectURL",xG(cz,QG))}GG(oz,"URL"),AG({global:!0,constructor:!0,forced:!wG,sham:!RG},{URL:oz});var dz=ee.URL,lz=function(){var e=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(dz.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)}}(),hz=ad,vz=tu,pz=function(e,t,r,n){for(var i,o=n>1?void 0:n?vz(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&&hz(t,r,o),o},fz=function(){function e(t,r){qd(this,e),sd(this,"_sharedAudioContext",new AudioContext),sd(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),sd(this,"_localGainNode",this._sharedAudioContext.createGain()),sd(this,"_bufferGainNode",this._sharedAudioContext.createGain()),sd(this,"_audioBufferSource",void 0),sd(this,"_localSource",void 0),sd(this,"_context",void 0),sd(this,"_failedAudioList",[]),sd(this,"_startingIds",new FS),sd(this,"_revokeURLs",new gN),sd(this,"mixingMap",new FS),sd(this,"resourcesCache",new FS),sd(this,"volumeConfig",new FS),sd(this,"cachedBuffer",[]),sd(this,"id","AudioMixingManager"),this.engineId=r,this._context=t,this._localGainNode.gain.value=1}var t,r,n;return Kd(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=Em(Sm().mark((function e(t,r,n){var i,o,a,s,u,c,d,l,h,v,p,f,_,m=this;return Sm().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,FO(o=n.type,"mixingType",HB(jd)),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!=(u=this.mixingMap.get(t))&&u.audioNode){u.audioNode.pause(),this._context.emitMessage({mixId:t,state:Gd.AUDIO_MIXING_STATE_STOPPED,error:uR.AUDIO_MIXING_ERROR_OK});try{u.gainNode.disconnect(this._audioDestination),u.audioSource.disconnect(u.gainNode)}catch(g){}}if(!(d=this.resourcesCache.get(t))||d.filePath!==r){e.next=18;break}c=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:Gd.AUDIO_MIXING_STATE_FAILED,error:uR.AUDIO_MIXING_ERROR_START_FAILED}),new cR(sR.LOAD_RESOURCES_FAILED,e.statusText)}));case 20:return l=e.sent,Ub(r).call(r,"mp3")?h={type:"audio/mpeg"}:Ub(r).call(r,"aac")&&(h={type:"audio/aac"}),e.next=24,lz(l,h);case 24:if(e.sent){e.next=28;break}throw this._context.emitMessage({mixId:t,state:Gd.AUDIO_MIXING_STATE_FAILED,error:uR.AUDIO_MIXING_ERROR_START_FAILED}),new cR(sR.LOAD_RESOURCES_FAILED,"invalid audio resource");case 28:(c=new Audio).crossOrigin="anonymous",c.src=dz.createObjectURL(new Blob([l],h));case 31:return i<=0?c.loop=!0:i>0&&(v=i,c.onended=function(){--v>0?c.play():(m.mixingMap.delete(t),m._context.emitMessage({mixId:t,state:Gd.AUDIO_MIXING_STATE_FINISHED,error:uR.AUDIO_MIXING_ERROR_OK}))}),e.prev=32,e.next=35,c.play();case 35:e.next=42;break;case 37:e.prev=37,e.t0=e.catch(32),console.error(e.t0),this._failedAudioList.push(c),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:yd.STREAM_INDEX_MAIN,mediaType:Sd.AUDIO});case 42:if(this._startingIds.delete(t),p=this._sharedAudioContext.createMediaElementSource(c),f=this._sharedAudioContext.createGain(),_=this.volumeConfig.get(t),f.gain.value=_?_/100:1,p.connect(f).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:p,audioNode:c,gainNode:f,type:"file"}),o===jd.PUBLISH)try{f.disconnect(this._sharedAudioContext.destination)}catch(g){}else f.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:Gd.AUDIO_MIXING_STATE_PLAYING,error:uR.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:Gd.AUDIO_MIXING_STATE_STOPPED,error:uR.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Gd.AUDIO_MIXING_STATE_PAUSED,error:uR.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:Gd.AUDIO_MIXING_STATE_PLAYING,error:uR.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=Em(Sm().mark((function e(t,r){var n,i,o=this;return Sm().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 cR(sR.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(o._context.emitMessage({mixId:t,state:Gd.AUDIO_MIXING_STATE_FAILED,error:uR.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof cR)throw e;throw new cR(sR.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,Ub(r).call(r,"mp3")?i={type:"audio/mpeg"}:Ub(r).call(r,"aac")&&(i={type:"audio/aac"}),e.next=7,lz(n,i);case 7:if(e.sent){e.next=11;break}throw this._context.emitMessage({mixId:t,state:Gd.AUDIO_MIXING_STATE_FAILED,error:uR.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new cR(sR.LOAD_RESOURCES_FAILED,"Load resources failed");case 11:return this._context.emitMessage({mixId:t,state:Gd.AUDIO_MIXING_STATE_PRELOADED,error:uR.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){var e=dz.createObjectURL(new Blob([n],i));return o._revokeURLs.add(e),new Audio(e)},filePath:r,duration:0}),e.next=15,new X_((function(e){var r=dz.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)),dz.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){FO(e,"type",HB(jd));var t=this._context.getLocalAudioTrack();if(t){var r=t.getTrack("preprocessing");if(r&&this.mixMediaStream(new MediaStream([r])),e===jd.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:Gd.AUDIO_MIXING_STATE_PCM_ENABLED,error:uR.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:Gd.AUDIO_MIXING_STATE_PCM_DISABLED,error:uR.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=Em(Sm().mark((function e(){var t,r,n,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=YT(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:yd.STREAM_INDEX_MAIN,mediaType:Sd.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 FS,this._revokeURLs.forEach((function(e){dz.revokeObjectURL(e)}))}}]),e}();pz([gP("id","filePath","options")],fz.prototype,"startAudioMixing",1),pz([gP("id")],fz.prototype,"stopAudioMixing",1),pz([gP("id")],fz.prototype,"pauseAudioMixing",1),pz([gP("id")],fz.prototype,"resumeAudioMixing",1),pz([gP("id")],fz.prototype,"preloadAudioMixing",1),pz([gP("id")],fz.prototype,"unloadAudioMixing",1),pz([gP("id")],fz.prototype,"getAudioMixingVolume",1),pz([gP("id","volume")],fz.prototype,"setAudioMixingVolume",1),pz([gP("id")],fz.prototype,"getAudioMixingDuration",1),pz([gP("id")],fz.prototype,"getAudioMixingCurrentPosition",1),pz([gP("id","position")],fz.prototype,"setAudioMixingPosition",1),pz([gP("type")],fz.prototype,"enableAudioMixingBuffer",1),pz([gP()],fz.prototype,"disableAudioMixingBuffer",1),pz([gP("buffer")],fz.prototype,"pushAudioMixingBuffer",1);var _z=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(_z||{}),mz=new nP("RTMClient",1),gz=function(e){wI(c,e);var t,r,n,i,o,a,s,u=XI(c);function c(e,t){var r;return qd(this,c),sd(QT(r=u.call(this)),"_dataChannelSignal",null),sd(QT(r),"_handler",null),sd(QT(r),"_dataChannelSignalState",jV.DISCONNECTED),sd(QT(r),"_loginSessionId",null),sd(QT(r),"_userId",null),sd(QT(r),"_token",null),sd(QT(r),"_isReconnecting",!1),sd(QT(r),"_reconnectTimer",null),sd(QT(r),"_loginResolveCallback",null),sd(QT(r),"_loginRejectCallback",null),sd(QT(r),"_iceConfigNode",null),sd(QT(r),"_wait_login_token",!1),sd(QT(r),"_serverParamsCache",void 0),r.id=e,r._appId=t,r}return Kd(c,[{key:"login",value:function(e,t){var r=this;return new X_((function(n,i){var o;if(mz.print("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new cR(sR.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new cR(sR.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,null===(o=mP(r.id))||void 0===o||o.set({rtm_user_id:t}),r._loginResolveCallback=n,r._loginRejectCallback=i,r._dataChannelSignal?r._login():(mz.print("login","init dataChannelSingling"),r._dataChannelSignalState=jV.CONNECTING,r._createDataChannelSignaling(t).then((function(e){r._dataChannelSignal=e,r._login()})).catch((function(){r._onDisconnect()})))}))}},{key:"logout",value:(s=Em(Sm().mark((function e(){var t;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new cR(sR.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._appId},{functionType:DD.C2RTM}).catch((function(){}));case 4:this._closeDataChannelSignaling(),this._clearState();case 6:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"updateLoginToken",value:(a=Em(Sm().mark((function e(t){var r=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new X_((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 a.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(o=Em(Sm().mark((function e(t){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new cR(sR.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.next=5,this._dataChannelSignal.sendSignaling("getPeerOnlineStatus",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._appId,peerUserId:t},{functionType:DD.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 o.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(i=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new cR(sR.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._appId,to:t,room:"",msg:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"setServerParams",value:(n=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,VO(t,"signature"),VO(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new cR(sR.NOT_LOGIN,"login first");case 5:return this._checkDataChannelSignal(),e.next=8,this._dataChannelSignal.sendSignaling("setServerParams",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._appId,signature:t,url:r},{functionType:DD.C2RTM}).catch((function(e){throw new cR(sR.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 n.apply(this,arguments)})},{key:"sendServerMessage",value:(r=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new cR(sR.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._appId,to:"",room:"",type:RD.BUSINESS_SERVER,msg:t}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){this._clearState(),this._closeDataChannelSignaling(),AI(TI(c.prototype),"removeAllListeners",this).call(this),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=DP();this._checkDataChannelSignal(),this._dataChannelSignal.sendSignaling("login",{Token:UP.token2auth(this._appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:xO.VERSION,deviceId:IO.getDeviceId(),appId:this._appId,userId:this._userId}},{functionType:DD.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,uP.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=sR.INVALID_PARAMS,n="Invalid userId"):(r=sR.INVALID_TOKEN,n="Invalid token",e._wait_login_token=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=sR.LOGIN_FAILED,n="login failed"),"function"==typeof e._loginRejectCallback&&e._loginRejectCallback(new cR(r,a||n))})).finally((function(){e._loginResolveCallback=null,e._loginRejectCallback=null}))}}},{key:"_createDataChannelSignaling",value:(t=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=new UD(this.id),i=this._iceConfigNode){e.next=16;break}return e.prev=3,e.next=6,null==n?void 0:n.getAccessNode(this._appId,"");case 6:if(o=e.sent,i=o[0]){e.next=10;break}throw new Error;case 10:e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(3),SP(this.id,"rtm.login.getNodeFailed",null===e.t0||void 0===e.t0?void 0:e.t0.message),new cR(sR.ICE_SERVER_WRONG,"get ICE config failed");case 16:return SP(this.id,"rtm.login.getNodeSuccess",i),mz.print("_createDataChannelSignaling()","get node success",i),this._handler=RV({id:this.id,avSync:!0}),null===(r=this._handler)||void 0===r||r.once("disconnect",(function(){mz.print("_createDataChannelSignaling()","recv BasicHandler event: disconnect"),c._onDisconnect()})),e.prev=20,e.next=23,null===(s=this._handler)||void 0===s?void 0:s.connect(i);case 23:a=e.sent,mz.print("_createDataChannelSignaling()","establish peerConnection success"),this._dataChannelSignalState=jV.CONNECTED,e.next=33;break;case 28:throw e.prev=28,e.t1=e.catch(20),this._iceConfigNode=null,this._dataChannelSignalState=jV.DISCONNECTED,new cR(sR.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed",e.t1);case 33:return u=new MD(this.id,a),mz.print("_createDataChannelSignaling()","send ping"),u.sendPingSignaling(),u.once("close",(function(){mz.print("_createDataChannelSignaling()","recv DataChannelSignaling event: close"),c._onDisconnect()})),u.on(bD.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){c.emit("onUserMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),u.on(bD.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){c.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),u.on(bD.USER_DISCONNECTION,(function(){c.emit("onUserDisconnection"),c._clearState()})),u.on(bD.NODE_CHANGE,(function(e){SP(c.id,"rtm.nodeChange",ZE(e)),Array.isArray(e.nodes)&&e.nodes.length&&(c._iceConfigNode=e.nodes[0]),c._loginResolveCallback&&c._loginRejectCallback?c._login():c._reconnect()})),e.abrupt("return",u);case 42:case"end":return e.stop()}}),e,this,[[3,12],[20,28]])}))),function(e){return t.apply(this,arguments)})},{key:"_closeDataChannelSignaling",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.destroy(),this._dataChannelSignal=null,null===(t=this._handler)||void 0===t||t.destroy(),this._handler=null}},{key:"_checkDataChannelSignal",value:function(){if(!this._dataChannelSignal||this._dataChannelSignalState!==jV.CONNECTED)throw new cR(sR.NOT_CONNECTED_YET,"datachannel not connect")}},{key:"_onDisconnect",value:function(){this._dataChannelSignalState=jV.DISCONNECTED,this._closeDataChannelSignaling(),navigator.onLine?this._reconnect():this._reconnectTimer=self.setTimeout(this._reconnect.bind(this),3e3)}},{key:"_reconnect",value:function(){var e=this;!this._isReconnecting&&this._userId&&(mz.print("_reconnect()","start reconnect..."),this._isReconnecting=!0,this._createDataChannelSignaling(this._userId).then((function(t){mz.print("_reconnect()","reconnect success!"),e._dataChannelSignal=t,e._login(),e._reconnectTimer=null})).catch((function(t){mz.print("_reconnect()","Reconnecting error, will reconnect after 3s",t),e._reconnectTimer=self.setTimeout(e._reconnect.bind(e),3e3)})).finally((function(){e._isReconnecting=!1})))}},{key:"_clearState",value:function(){this._userId=null,this._token=null,this._loginSessionId=null,uP.setRtsSessionId(this.id,""),null!==this._reconnectTimer&&(self.clearTimeout(this._reconnectTimer),this._reconnectTimer=null)}}]),c}(iD.exports.EventEmitter),yz=function(e){wI(o,e);var t,r,n,i=XI(o);function o(e,t,r){var n,a=r.businessId;return qd(this,o),sd(QT(n=i.call(this)),"_mediaServerClient",void 0),sd(QT(n),"_appId",void 0),sd(QT(n),"_reconnectTimer",void 0),sd(QT(n),"remoteStreams",void 0),sd(QT(n),"_businessId",void 0),n.id=e,n._appId=t,n.remoteStreams=new FS,n._businessId=a,n}return Kd(o,[{key:"connect",value:(n=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._mediaServerClient=new HV({id:this.id,avSync:!0}),this._businessId&&(this._mediaServerClient.businessId=this._businessId),this._bindEvents(),e.next=5,this._mediaServerClient.connect(this._appId);case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startPlayPublicStream",value:(r=Em(Sm().mark((function e(t){var r,n=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.remoteStreams.get(t)){e.next=2;break}throw new cR(sR.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new fV(this.id,t,t,!1,{audiostream:!0,localaudio:!0,videostream:!0,localvideo:!0,extaudio:!1,extvideo:!1,videoDescriptions:[]})).on("onSEIMessage",(function(e){if(e instanceof Uint8Array)for(var t=hO(e),i=0;i<t.seiCount;i++)n.emit(PV.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(){this.remoteStreams=new FS,this._mediaServerClient&&this._mediaServerClient.destroy()}},{key:"_handleReconnected",value:(t=Em(Sm().mark((function e(){var t,r,n,i=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:clearTimeout(this._reconnectTimer),t=YT(this.remoteStreams);try{for(n=function(){var e=WT(r.value,1)[0];i.remoteStreams.delete(e),i.startPlayPublicStream(e).then((function(){var t=i.remoteStreams.get(e);i.safeEmit(PV.RESUBSCRIBE,{stream:t})}))},t.s();!(r=t.n()).done;)n()}catch(o){t.e(o)}finally{t.f()}case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_reconnect",value:function(){var e=this;this._mediaServerClient.removeAllListeners(),this._mediaServerClient.destroy(),navigator.onLine?this.connect().then(this._handleReconnected.bind(this)):this._reconnectTimer=window.setTimeout((function(){return e.connect().then(e._handleReconnected.bind(e))}),3e3)}},{key:"_bindEvents",value:function(){var e,t,r=this;null===(e=this._mediaServerClient)||void 0===e||e.on(kD.ABNORMAL_DISCONNECTION,this._reconnect.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on("onRemoteStreamStats",(function(e){r.emit("onRemoteStreamStats",e)}))}}]),o}(sD),Sz=new nP("AudioDeviceManager",1),bz=function(e){wI(u,e);var t,r,n,i,o,a,s=XI(u);function u(e){var t;return qd(this,u),sd(QT(t=s.call(this)),"_audioLevelFetcher",void 0),sd(QT(t),"_playbackDeviceTestTimer",void 0),sd(QT(t),"_audioElement",void 0),sd(QT(t),"_audioTrack",void 0),sd(QT(t),"_mediaRecorder",void 0),sd(QT(t),"_recoderTimer",void 0),sd(QT(t),"_isAudioPlaybackDeviceTesting",!1),sd(QT(t),"_isAudioDeviceRecordTesting",!1),sd(QT(t),"_audioCaptureAndRecoderResolve",void 0),sd(QT(t),"_onAutoplayFailed",void 0),sd(QT(t),"_audioPlaybackDeviceId",void 0),t._extensionManager=e,t}return Kd(u,[{key:"audioTrack",get:function(){return this._audioTrack}},{key:"startAudioPlaybackDeviceTest",value:(a=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new cR(sR.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,Sz.print("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),Sz.print("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&&(Sz.print("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(o=Em(Sm().mark((function e(t,r,n){var i=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(window.MediaRecorder){e.next=2;break}throw new cR(sR.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 2:if(!this._isAudioDeviceRecordTesting){e.next=4;break}throw new cR(sR.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 4:return this._isAudioDeviceRecordTesting=!0,Sz.print("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){Sz.print("startAudioDeviceRecordTest()","".concat(3e4,'ms automatic call method "stopAudioDeviceRecordAndPlayTest"')),i._stopAudioCaptureAndRecoder()}),3e4),e.prev=7,this._onAutoplayFailed=r,e.next=11,this._startAudioCaptureAndRecoder(t,null!=n?n:100);case 11:e.next=18;break;case 13:throw e.prev=13,e.t0=e.catch(7),this._isAudioDeviceRecordTesting=!1,delete this._onAutoplayFailed,e.t0;case 18:delete this._audioCaptureAndRecoderResolve;case 19:case"end":return e.stop()}}),e,this,[[7,13]])}))),function(e,t,r){return o.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){Sz.print("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(Sz.print("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=Em(Sm().mark((function e(t){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Sz.print("setSinkId()","Invoke"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=3;break}throw new cR(sR.NOT_SUPPORTED,"setSinkId not supported by current browser");case 3:return e.next=5,nU.getDeviceById(t);case 5:if(r=e.sent){e.next=8;break}throw new cR(sR.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(){Sz.print("destroy()","Invoke"),AI(TI(u.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:(n=Em(Sm().mark((function e(t,r){var n,i=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Sz.print("_playAudioFile()",Rm(n="Invoke url=".concat(t,"; loop=")).call(n,r.loop)),e.abrupt("return",new X_((function(e,n){var o=lF("audio",{attributes:{src:t,crossOrigin:"anonymous"}});i._audioElement=o,o.loop=r.loop,i._audioLevelFetcher=new aU(o),o.onplaying=function(){o.onplaying=null,Sz.print("_playAudioFile()","onplaying"),e()},o.onerror=function(){var e=Em(Sm().mark((function e(t){var r,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Sz.print("_playAudioFile()","onerror",t),i=t.message||(null==o||null===(r=o.error)||void 0===r?void 0:r.message),n(new cR(sR.LOAD_RESOURCES_FAILED,"Failed to play recorded audio"+(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;Sz.print("_playAudioFile()","autoplay error",e);var r=Rm(t="Failed to play recorded audio, ".concat(e.name,": ")).call(t,e.message);"NotAllowedError"===e.name&&i._onAutoplayFailed?i._onAutoplayFailed((function(){var e;return X_.all([null===(e=i._audioLevelFetcher)||void 0===e?void 0:e.resume(),o.play()])})):n(new cR(sR.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&&(Sz.print("_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&&(Sz.print("_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&&(Sz.print("_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=Em(Sm().mark((function e(t,r){var n,i=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,MU({},this._extensionManager);case 2:return this._audioTrack=e.sent,this._audioTrack.setVolume(r),n=new MediaStream([this._audioTrack.getTrack("preprocessing")]),Sz.print("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new X_((function(e,r){var o,a;"function"==typeof MediaRecorder.isTypeSupported&&(o=oE(a=["audio/webm","audio/mp4"]).call(a,(function(e){return MediaRecorder.isTypeSupported(e)})),Sz.print("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=Em(Sm().mark((function n(o){var a,u;return Sm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!i._isAudioDeviceRecordTesting){n.next=16;break}return Sz.print("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),u=new Blob([o.data],{type:s}),n.prev=3,n.next=6,i._playAudioFile(dz.createObjectURL(u),{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 cR(sR.AUDIO_DEVICE_TEST_FAILED,e.message||"mediaRecorder error"))},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=Em(Sm().mark((function e(){var t,r,n,i;return Sm().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),Sz.print("setSinkId","ctx.sinkId=".concat(t))}catch(o){Sz.print("setSinkId",Rm(i="failed, ".concat(o.name," - ")).call(i,o.message))}}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),u}(iD.exports.EventEmitter),Ez=function(){function e(t){qd(this,e),sd(this,"_roomId",void 0),sd(this,"_constraints",{}),sd(this,"_profile",void 0),this._appId=t}return Kd(e,[{key:"setRoomId",value:function(e){this._roomId=e}},{key:"setAudioProfile",value:function(e){this._profile=e}},{key:"getOpusConfigStr",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=IO.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,u="number"==typeof a?a:null==a?void 0:a.exact,c={};t.split(";").forEach((function(e){var t=WT(e.split("="),2),r=t[0],n=t[1];r&&n&&(c[r]=n)}));var d=(null==n?void 0:n.bitrate)||this._getConfigByAudioProfile().bitrate;d&&(c.maxaveragebitrate=d);var l=(null==n?void 0:n.enc_sample_rate)||s;l&&(c["sprop-maxcapturerate"]=l);var h=(null==n?void 0:n.playback_rate)||s;return h&&(c.maxplaybackrate=h),(u&&u>1||null!=n&&n.stereo)&&(c["sprop-stereo"]=1,c.stereo=1),null!=n&&n.dtx&&(c.usedtx=1),YE(e=an(c)).call(e,(function(e){var t;return Rm(t="".concat(e,"=")).call(t,c[e])})).join(";")}},{key:"updateConstraints",value:function(e){this._constraints=cd(cd({},this._constraints),e)}},{key:"getConstraints",value:function(){var e=cd({},this._constraints),t=IO.getEngineWebConfig(this._appId,this._roomId||"").audio_capture;pO(null==t?void 0:t.sample_rate)||(e.sampleRate=t.sample_rate),pO(null==t?void 0:t.channel)||(e.channelCount=t.channel),pO(null==t?void 0:t.agc)||(e.autoGainControl=t.agc),pO(null==t?void 0:t.ans)||(e.noiseSuppression=t.ans),pO(null==t?void 0:t.aec)||(e.echoCancellation=t.aec);var r=this._getConfigByAudioProfile(),n=r.sampleRate,i=r.channel;return pO(e.sampleRate)&&!pO(n)&&(e.sampleRate=n),pO(e.channelCount)&&!pO(i)&&(e.channelCount=i),e}},{key:"_getConfigByAudioProfile",value:function(){var e={};switch(this._profile){case Dd.fluent:e.sampleRate=16e3,e.bitrate=24e3;break;case Dd.standard:e.sampleRate=48e3,e.bitrate=48e3;break;case Dd.hd:e.sampleRate=48e3,e.bitrate=128e3,e.channel=2;break;case Dd.standardStereo:e.sampleRate=48e3,e.bitrate=8e4,e.channel=2;break;case Dd.hdMono:e.sampleRate=48e3,e.bitrate=128e3}return e}}]),e}(),kz=new nP("VideoSnapshot",1),Tz=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},Iz=function(){var e=Em(Sm().mark((function e(t,r,n){var i,o,a,s,u,c,d,l;return Sm().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(),!(u=Tz(n))){e.next=16;break}return kz.print("takeSnapshot","VideoPlayer already set."),e.next=11,a(u,u.videoWidth,u.videoHeight);case 11:return c=e.sent,kz.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",c);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 kz.print("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,kz.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",l);case 29:return kz.print("takeSnapshot","use temp video"),e.abrupt("return",new X_((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);kz.print("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)}}(),Az=function(){return{url:"",video:{codec:Ld.H264,width:640,height:360,fps:15,gop:2,kBitRate:Rz(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:Nd.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function Rz(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 wz(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new cR(sR.INVALID_PARAMS,"Invalid rtmp address")}function Cz(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new cR(sR.INVALID_PARAMS,"regions should not be empty.");var t,r=YT(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new cR(sR.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if("boolean"!=typeof n.isScreenStream)throw new cR(sR.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(i){r.e(i)}finally{r.f()}}function xz(e,t){var r,n,i,o=function(e,r){var n=$S(e).call(e,(function(e,t){return null==e?void 0:e[t]}),t),i=$S(e).call(e,(function(e,t){return null==e?void 0:e[t]}),Az());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}))),u=a(o(["video","height"],(function(e){return e>=2&&e<=1920}))),c=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!!oE(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 vk(t=[1,2]).call(t,e)})),profile:o(["audio","AACProfile"],(function(e){var t;return vk(t=[Nd.LC,Nd.HEv1,Nd.HEv2]).call(t,e)}))},video:{codec:o(["video","codec"],(function(e){var t;return vk(t=["H264","H265"]).call(t,e)})),fps:c,gop:o(["video","gop"],(function(e){return e>=1&&e<=5}))*c,bitRate:1e3*(d>=16&&d<=1e4?d:Rz(s,u,c)),width:s,height:u},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:YE(i).call(i,(function(e){var t,r;return{alpha:!e.alpha||+e.alpha>1||+e.alpha<=0?1:+e.alpha,uid:e.userId,zorder:!e.zorder||+e.zorder<0||+e.zorder>100?0:+e.zorder,x:!e.x||+e.x>=1||+e.x<0?0:+e.x,y:!e.y||+e.y>=1||+e.y<0?0:+e.y,w:!e.w||+e.w>1||+e.w<=0?1:+e.w,h:!e.h||+e.h>1||+e.h<=0?1:+e.h,renderMode:e.renderMode&&vk(t=[1,2,3]).call(t,e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&vk(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 Pz,Oz={getDefaultValue:Az,checkStartParams:function(e){var t;wz(e.url),Cz(null===(t=e.layout)||void 0===t?void 0:t.regions)},checckUpdateParams:function(e){var t;e.url&&wz(e.url),Cz(null===(t=e.layout)||void 0===t?void 0:t.regions)},getStartParams:function(e){return xz("started",e)},getUpdateParams:function(e){return xz("layoutChanged",e)}},Dz=ad,Mz=tu,Nz=function(e,t,r,n){for(var i,o=n>1?void 0:n?Mz(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&&Dz(t,r,o),o},Lz=new nP("Engine",0),Uz=function(e){wI(me,e);var t,r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A,R,w,C,x,P,O,D,M,N,L,U,V,F,B,j,G,H,z,X,K,q,Y,W,Q,J,Z,$,ee,te,re,ne,ie,oe,ae,se,ue,ce,de,le,he,ve,pe,fe,_e=XI(me);function me(e,t,r){var n;return qd(this,me),sd(QT(n=_e.call(this)),"monitor",void 0),sd(QT(n),"_room",void 0),sd(QT(n),"_publicStreamManager",void 0),sd(QT(n),"_appId",void 0),sd(QT(n),"_businessId",void 0),sd(QT(n),"_visibility",!0),sd(QT(n),"_localVideoTrack",void 0),sd(QT(n),"_localAudioTrack",void 0),sd(QT(n),"_localImgVideoTrack",void 0),sd(QT(n),"_localImgScreenTrack",void 0),sd(QT(n),"_localScreenVideoTrack",void 0),sd(QT(n),"_localScreenAudioTrack",void 0),sd(QT(n),"_tempMixingAudioTrack",void 0),sd(QT(n),"_localAudioVolume",100),sd(QT(n),"_localScreenAudioVolume",100),sd(QT(n),"_remoteAudioVolume",new FS),sd(QT(n),"_remoteScreenAudioVolume",new FS),sd(QT(n),"_publicAudioVolume",new FS),sd(QT(n),"_videoPlayer",void 0),sd(QT(n),"_screenPlayer",void 0),sd(QT(n),"_remoteVideoPlayer",new FS),sd(QT(n),"_remoteScreenPlayer",new FS),sd(QT(n),"_remoteAudioPlayer",new FS),sd(QT(n),"_remoteScreenAudioPlayer",new FS),sd(QT(n),"_publicStreamAudioPlayer",new FS),sd(QT(n),"_publicStreamVideoPlayer",new FS),sd(QT(n),"_publicStreamIds",new FS),sd(QT(n),"_roomConfig",void 0),sd(QT(n),"_videoStreamConstraints",MO),sd(QT(n),"_audioStreamConstraints",{}),sd(QT(n),"_enableSimulcast",!1),sd(QT(n),"_videoStreamEncodeConfig",[MO]),sd(QT(n),"_screenStreamEncodeConfig",[NO]),sd(QT(n),"_dummyMainImage",void 0),sd(QT(n),"_dummyScreenImage",void 0),sd(QT(n),"_trackSourceType",void 0),sd(QT(n),"_liveTranscodeConfig",void 0),sd(QT(n),"_useCloudProxy",void 0),sd(QT(n),"_startCloudProxyTimestamp",void 0),sd(QT(n),"_localVideoDeviceId",void 0),sd(QT(n),"_localAudioDeviceId",void 0),sd(QT(n),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeStreamIds:{}}),sd(QT(n),"_audioVolumeIndicationTimer",void 0),sd(QT(n),"_dummyMainTimer",void 0),sd(QT(n),"_dummyScreenTimer",void 0),sd(QT(n),"_audioPropertiesReportTimer",null),sd(QT(n),"_mirrorType",kd.MIRROR_TYPE_RENDER),sd(QT(n),"_audioMixingManager",void 0),sd(QT(n),"_pubLock",void 0),sd(QT(n),"_rtmClient",void 0),sd(QT(n),"_messageStatisticsObserver",void 0),sd(QT(n),"_tempRoomInfo",void 0),sd(QT(n),"_originIceConfigRequestUrls",void 0),sd(QT(n),"_originConfigServerUrls",void 0),sd(QT(n),"_originLogServerUrl",void 0),sd(QT(n),"_extensionManager",void 0),sd(QT(n),"_audioDeviceManager",void 0),sd(QT(n),"_audioProfileManager",void 0),sd(QT(n),"_remoteVideoConfig",new FS),sd(QT(n),"_userPriorityMap",new FS),sd(QT(n),"_subscribeFallbackOption",void 0),sd(QT(n),"_cameraCapturing",!1),sd(QT(n),"_interruptCameraCapture",!1),sd(QT(n),"_micCapturing",!1),sd(QT(n),"_interruptMicCapture",!1),sd(QT(n),"_avSync",!0),sd(QT(n),"_config",void 0),sd(QT(n),"_needClosePreTrack",!1),sd(QT(n),"_updateMixAudioTrack",function(){var e=Em(Sm().mark((function e(t){var r,i,o=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.length>1&&void 0!==o[1]?o[1]:jd.PLAYOUT_AND_PUBLISH,Lz.print("_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)}}()),sd(QT(n),"_onAudioMixingMessage",(function(e){n.safeEmit(zd.onAudioMixingStateChanged,e)})),sd(QT(n),"_onAudioMixingAutoplayFailed",(function(e){n.safeEmit(zd.onAutoplayFailed,e)})),n.id=t,n._appId=e,n._pubLock=new xV("pubLock"),n._addDeviceEventHandler(),n._extensionManager=new cU(t),n._audioDeviceManager=new bz(n._extensionManager),n._audioMixingManager=new fz({getLocalAudioTrack:function(){return n._localAudioTrack},updateLocalAudioTrack:n._updateMixAudioTrack,emitMessage:n._onAudioMixingMessage,onAutoPlayFailed:n._onAudioMixingAutoplayFailed},t),n._audioProfileManager=new Ez(e),window.__rtc_engine__=QT(n),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=QT(n),n._trackSourceType={video:dd.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:dd.VIDEO_SOURCE_TYPE_INTERNAL,audio:ld.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:ld.AUDIO_SOURCE_TYPE_INTERNAL},n._config=r,n._rtmClient=new gz(t,e),n._handleRTMClient(n._rtmClient),n._useCloudProxy=!1,n._handleAudioDeviceManager(),n._messageStatisticsObserver=new cP(t),n.monitor=mP(t),uP.createRTSMsgReportor(n.id),n._getServerConfig(),n}return Kd(me,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(fe=Em(Sm().mark((function e(t){var r,n,i,o,a;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("updateToken()","token: %s",t),VO(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 cR(sR.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 fe.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(pe=Em(Sm().mark((function e(t){var r,n,i,o=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("setVideoCaptureDevice()","deviceId: %s",t),VO(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:return r=jB({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete r.deviceId,r.facingMode=t):r.deviceId={exact:t},QP&&eO&&eO>=85&&eO<=91&&(null===(n=this._videoPlayer)||void 0===n||n.removeTrack()),this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),delete this._localVideoTrack),Lz.print("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=12,OU(r,this._extensionManager).catch((function(e){if(o._localVideoTrack&&!o._localVideoTrack.dummy)return Lz.print("setVideoCaptureDevice()","createCameraVideoTrack failed, stop pre VideoTrack."),o._removeLocalTrackEvents(o._localVideoTrack),o._localVideoTrack.close(),delete o._localVideoTrack,OU(r,o._extensionManager).then((function(e){return o._needClosePreTrack=!0,e})).catch(Em(Sm().mark((function t(){var r;return Sm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Lz.print("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,OU(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 12:return i=e.sent,Lz.print("setVideoCaptureDevice()","createCameraVideoTrack success."),this._videoStreamConstraints=r,this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),e.next=18,this._switchTrack(i);case 18:case"end":return e.stop()}}),e,this)}))),function(e){return pe.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(ve=Em(Sm().mark((function e(t){var r,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("setAudioCaptureDevice()","deviceId: %s",t),VO(t,"deviceId"),this._localAudioDeviceId=t,this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return this._audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._localAudioTrack.close(),this._removeLocalTrackEvents(this._localAudioTrack),e.prev=8,this._micCapturing=!0,e.next=12,MU(this._audioProfileManager.getConstraints(),this._extensionManager);case 12:if(n=e.sent,!this._interruptMicCapture){e.next=17;break}return this._interruptMicCapture=!1,n.close(),e.abrupt("return");case 17:if(this._initLocalTrackEvents(n),this._localAudioTrack=n,this._localAudioTrack.setVolume(this._localAudioVolume),this._room){e.next=22;break}return e.abrupt("return");case 22:if(null===(r=this._room)||void 0===r||!r.hasPublished){e.next=25;break}return e.next=25,this._updatePublish();case 25:return e.prev=25,this._micCapturing=!1,e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[8,,25,28]])}))),function(e){return ve.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){nU.on(zd.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),nU.on(zd.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I,A,R,w,C,x,P=this;null===(e=this._room)||void 0===e||e.on(bD.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(bD.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(bD.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(PV.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(PV.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(PV.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(bD.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(bD.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(bD.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(bD.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(d=this._room)||void 0===d||d.on(bD.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(kD.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(h=this._room)||void 0===h||h.on(PV.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(v=this._room)||void 0===v||v.on(PV.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(p=this._room)||void 0===p||p.on(PV.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(f=this._room)||void 0===f||f.on(PV.ON_PUBLISH_RESULT,(function(e){var t;null!==(t=P._room)&&void 0!==t&&t._roomConfig.isAutoPublish&&P.safeEmit(zd.onAutoPublishResult,e)})),null===(_=this._room)||void 0===_||_.on(PV.ON_REMOTE_STREAM_STATS,(function(e){P.safeEmit(zd.onRemoteStreamStats,e)})),null===(m=this._room)||void 0===m||m.on(PV.ON_LOCAL_STREAM_STATS,(function(e){P.safeEmit(zd.onLocalStreamStats,e)})),null===(g=this._room)||void 0===g||g.on(PV.ON_SUBTITLE_STATE_CHANGED,(function(e){P.safeEmit(zd.onSubtitleStateChanged,e)})),null===(y=this._room)||void 0===y||y.on(PV.ON_SUBTITLE_MESSAGE_RECEIVED,(function(e){P.safeEmit(zd.onSubtitleMessageReceived,e)})),null===(S=this._room)||void 0===S||S.on(PV.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(b=this._room)||void 0===b||b.on(PV.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;P._updateAudioPlayerState(t),P.safeEmit(zd.onUserStartAudioCapture,{userId:r})})),null===(E=this._room)||void 0===E||E.on(PV.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(zd.onUserStopAudioCapture,{userId:t})})),null===(k=this._room)||void 0===k||k.on(PV.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(zd.onUserStartVideoCapture,{userId:t})})),null===(T=this._room)||void 0===T||T.on(PV.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(zd.onUserStopVideoCapture,{userId:t})})),null===(I=this._room)||void 0===I||I.on(PV.ON_SEI_MESSAGED_RECEIVED,(function(e){P.safeEmit(zd.onSEIMessageReceived,e)})),null===(A=this._room)||void 0===A||A.on(PV.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){P.safeEmit(zd.onRemoteVideoSizeChanged,e,t)})),null===(R=this._room)||void 0===R||R.on(PV.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return P.safeEmit(zd.onSimulcastSubscribeFallback,e)})),null===(w=this._room)||void 0===w||w.on(PV.RECONNECT_FAILED,(function(){P.safeEmit(zd.onError,{errorCode:sR.RECONNECT_FAILED})})),null===(C=this._room)||void 0===C||C.on(PV.ON_VIDEO_STREAM_BANNED,(function(e){P.safeEmit(zd.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(x=this._room)||void 0===x||x.on(PV.ON_AUDIO_STREAM_BANNED,(function(e){P.safeEmit(zd.onAudioStreamBanned,{uid:e.uid,banned:e.banned})}))}},{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 $O(e)&&yP(this.id,e,i),(t=AI(TI(me.prototype),"safeEmit",this)).call.apply(t,Rm(r=[this,e]).call(r,i))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(he=Em(Sm().mark((function e(){return Sm().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 cF({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:Od.communication},{id:this.id,audioProfileManager:this._audioProfileManager,streamRTT:{},subscribeFallbackOption:this._subscribeFallbackOption,userPriority:this._userPriorityMap,avSync:this._avSync}),this._addHandlerEventHandler(),e.next=6,this._room.connect(this._appId);case 6:case"end":return e.stop()}}),e,this)}))),function(){return he.apply(this,arguments)})},{key:"joinRoom",value:(le=Em(Sm().mark((function e(t,r,n,i){var o,a,s,u,c,d,l;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("joinRoom()","token: %o roomId: %o, userInfo: %o, roomConfig: %o",t,r,n,i),XO(t)||VO(t,"token"),KO(r),WO(n),QO(i=jB({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:Od.communication},i)),(null===(o=this._room)||void 0===o?void 0:o.connectionState)!==jV.CONNECTED){e.next=8;break}throw new cR(sR.REPEAT_JOIN,"Already joined");case 8:return this._room||(this._room=new cF(i,{id:this.id,audioProfileManager:this._audioProfileManager,streamRTT:{},subscribeFallbackOption:this._subscribeFallbackOption,userPriority:this._userPriorityMap,avSync:this._avSync}),this._addHandlerEventHandler()),this._room.roomConfig=i,a=this._liveTranscodeConfig&&Oz.getStartParams(this._liveTranscodeConfig),s=cd(cd({},n),{},{businessId:this._businessId,role:this._visibility?_z.NORMAL_USER:_z.SILENT_USER}),e.prev=12,this._useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),nF(s),e.next=17,this._room.join(this._appId,r,t,s,a,this._useCloudProxy,null===(u=this._config)||void 0===u?void 0:u.expectedIDC);case 17:return d=e.sent,this._roomConfig=i,this._audioProfileManager.setRoomId(r),this._tempRoomInfo&&delete this._tempRoomInfo,null!==(c=i)&&void 0!==c&&c.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:Sd.AUDIO_AND_VIDEO}):this.safeEmit(zd.onAutoPublishResult,{isScreen:!1,state:_d.PUBLISH_FAIL})),uP.setRoomId(this.id,r),uP.setUserId(this.id,n.userId),e.abrupt("return",d);case 27:throw e.prev=27,e.t0=e.catch(12),e.t0.code===sR.INVALID_TOKEN&&(this._tempRoomInfo={config:i,roomId:r,userInfo:s}),null===(l=this._room)||void 0===l||l.destroy(),e.t0;case 32:case"end":return e.stop()}}),e,this,[[12,27]])}))),function(e,t,r,n){return le.apply(this,arguments)})},{key:"leaveRoom",value:(de=Em(Sm().mark((function e(){var t,r,n,i=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],Lz.print("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._audioProfileManager.setRoomId(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new FS,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new FS,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new FS,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new FS,this._roomConfig=void 0,this._publicStreamIds=new FS,uP.setRoomId(this.id,""),uP.setUserId(this.id,"");case 24:case"end":return e.stop()}}),e,this)}))),function(){return de.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;Lz.print("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=[MO],this._screenStreamEncodeConfig=[NO],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeStreamIds:{}},this._messageStatisticsObserver.destroy(),this.monitor.destroy(),uP.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 FS,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new FS,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new FS,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new FS,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new FS,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new FS,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._publicStreamManager)||void 0===r||r.destroy(),this._publicStreamIds=new FS,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new FS,this._userPriorityMap.clear(),this._extensionManager.destroy(),this._cameraCapturing=!1,this._micCapturing=!1,this._interruptCameraCapture=!1,this._interruptMicCapture=!1,this._avSync=!0,this._localAudioVolume=100,this._localScreenAudioVolume=100,this._remoteAudioVolume.clear(),this._remoteScreenAudioVolume.clear(),this._publicAudioVolume.clear()}},{key:"publishStream",value:(ce=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!dO(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,wU(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 ce.apply(this,arguments)})},{key:"unpublishStream",value:(ue=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("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:DV.UNPUB});case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return ue.apply(this,arguments)})},{key:"publishScreen",value:(se=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("publishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.prev=3,!dO(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,xU(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:DV.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof cR)){e.next=18;break}throw e.t0;case 18:throw new cR(sR.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return se.apply(this,arguments)})},{key:"unpublishScreen",value:(ae=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Lz.print("unpublishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.next=5,this._updateScreenPublish({mediaType:t,pubState:DV.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return ae.apply(this,arguments)})},{key:"subscribeStream",value:(oe=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Lz.print("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 oe.apply(this,arguments)})},{key:"_subscribe",value:(ie=Em(Sm().mark((function e(t,r,n){var i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._checkMediaType(n),this._assertNotInRoom(),n!==Sd.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){e.next=5;break}return Lz.print("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 5:if(c=this._room.remoteStreams.get(r),d=null==c?void 0:oE(c).call(c,(function(e){return e.isScreen===t}))){e.next=9;break}throw new cR(sR.STREAM_NOT_EXIST,"stream not exist");case 9:return l=this._pauseAllSubscribeState.audio,h=this._pauseAllSubscribeState.video,this._pauseAllSubscribeState.audio&&(n-=n&Sd.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&Sd.VIDEO),Lz.print("subscribeStream()","due to pauseAll mediaType: %o",n),v=d.hasSubscribed,p=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,p);case 19:cO(n)&&this._updateAudioPlayerState(d),dO(n)&&this._updateVideoPlayerState(d),f=0,_=0,l!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?f|=Sd.AUDIO:_|=Sd.AUDIO),h!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?f|=Sd.VIDEO:_|=Sd.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:fd.SUBSCRIBE_SUCC},this.safeEmit(zd.onAutoSubscribeResult,m)),null!==(u=this._room)&&void 0!==u&&u.multiChatMode||v||!cO(n)||!d.hasAudio||null===(g=d.observer)||void 0===g||g.setSubscribeAudio(!0),!v&&dO(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 ie.apply(this,arguments)})},{key:"unsubscribeStream",value:(ne=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Lz.print("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 ne.apply(this,arguments)})},{key:"subscribeScreen",value:(re=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Lz.print("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 re.apply(this,arguments)})},{key:"unsubscribeScreen",value:(te=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Lz.print("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 te.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(this._checkMediaType(r),this._assertNotInRoom(),r!==Sd.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){var a=this._room.remoteStreams.get(t),s=null==a?void 0:oE(a).call(a,(function(t){return t.isScreen===e}));if(null==s||!s.hasSubscribed)throw new cR(sR.STREAM_NOT_EXIST,"stream not exist");if(QP&&eO&&eO>=85&&eO<=91&&r!==Sd.AUDIO)(e?this._remoteScreenPlayer.get(t):this._remoteVideoPlayer.get(t)).stop();return this._room.unsubscribe(s,r).then((function(){n||delete o._pauseAllSubscribeState.resumeStreamIds[s.streamId]}))}Lz.print("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(ee=Em(Sm().mark((function e(t,r){var n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Lz.print("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),qO(t),eD(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 ee.apply(this,arguments)})},{key:"startVideoCapture",value:($=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("startVideoCapture()","deviceId: %s",t),XO(t)||VO(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,this._trackSourceType.video!==dd.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new cR(sR.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(!(this._cameraCapturing||this._localVideoTrack&&!this._localVideoTrack.dummy)){e.next=8;break}throw new cR(sR.REPEAT_CAPTURE,"Has already capture");case 8:return i=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?i.facingMode=t:i.deviceId={exact:t},this._videoStreamConstraints=i),o={},e.prev=11,this._cameraCapturing=!0,e.next=15,OU(i,this._extensionManager);case 15:if(s=e.sent,!this._interruptCameraCapture){e.next=21;break}throw this._interruptCameraCapture=!1,this._removeLocalTrackEvents(s),s.close(),new cR(sR.INTERRUPT,"interrupt by stopVideoCapture");case 21:if(this._initLocalTrackEvents(s),this._localVideoTrack=s,null===(a=this._videoPlayer)||void 0===a||a.playVideo(s),(u=null==s?void 0:s.getTrack())&&(o=u.getSettings(),c={width:o.width,height:o.height},this._localVideoTrack.resolution=c,setTimeout((function(){return l.safeEmit(zd.onLocalVideoSizeChanged,{streamIndex:yd.STREAM_INDEX_MAIN,info:c})}))),this._room){e.next=28;break}return e.abrupt("return",o);case 28:return e.prev=28,this._cameraCapturing=!1,e.finish(28);case 31:return d=this._room._roomConfig.isAutoPublish,(this._room.hasPublished||d)&&(this._visibility?this._updatePublish():this.safeEmit(zd.onAutoPublishResult,{isScreen:!1,state:_d.PUBLISH_FAIL})),null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableVideo(!0),e.abrupt("return",o);case 35:case"end":return e.stop()}}),e,this,[[11,,28,31]])}))),function(e){return $.apply(this,arguments)})},{key:"stopVideoCapture",value:(Z=Em(Sm().mark((function e(){var t,r,n,i,o,a,s;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("stopVideoCapture()"),!this._cameraCapturing){e.next=5;break}return this._interruptCameraCapture=!0,Lz.print("stopVideoCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.video!==dd.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new cR(sR.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||((a=this._extensionManager.getPluginByName(uU.PRE_PROCESSING,"RTCBeautyExtension"))&&a.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localImgVideoTrack?(null===(s=this._localVideoTrack)||void 0===s||s.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||!r.hasPublished){e.next=14;break}return e.next=14,this._updatePublish();case 14:null===(n=this._room)||void 0===n||null===(i=n.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableVideo(!1);case 15:case"end":return e.stop()}}),e,this)}))),function(){return Z.apply(this,arguments)})},{key:"startAudioCapture",value:(J=Em(Sm().mark((function e(t){var r,n,i,o;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("startAudioCapture()","deviceId: $o",t),XO(t)||VO(t,"deviceId"),t=t||this._localAudioDeviceId,this._localAudioDeviceId=t,this._trackSourceType.audio!==ld.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new cR(sR.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 6:if(!this._micCapturing&&!this._localAudioTrack){e.next=8;break}throw new cR(sR.REPEAT_CAPTURE,"Has already capture");case 8:return t&&this._audioProfileManager.updateConstraints({deviceId:{exact:t}}),e.prev=9,this._micCapturing=!0,e.next=13,MU(this._audioProfileManager.getConstraints(),this._extensionManager);case 13:if(i=e.sent,!this._interruptMicCapture){e.next=19;break}throw this._interruptMicCapture=!1,this._removeLocalTrackEvents(i),i.close(),new cR(sR.INTERRUPT,"interrupt by stopAudioCapture");case 19:if(this._initLocalTrackEvents(i),this._localAudioTrack=i,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),this._room){e.next=25;break}return e.abrupt("return");case 25:return e.prev=25,this._micCapturing=!1,e.finish(25);case 28:o=this._room._roomConfig.isAutoPublish,(this._room.hasPublished||o)&&(this._visibility?this._updatePublish():this.safeEmit(zd.onAutoPublishResult,{isScreen:!1,state:_d.PUBLISH_FAIL})),null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableAudio(!0);case 31:case"end":return e.stop()}}),e,this,[[9,,25,28]])}))),function(e){return J.apply(this,arguments)})},{key:"stopAudioCapture",value:(Q=Em(Sm().mark((function e(){var t,r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("stopAudioCapture()"),!this._micCapturing){e.next=5;break}return this._interruptMicCapture=!0,Lz.print("stopAudioCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.audio!==ld.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new cR(sR.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(!this._room.hasPublished){e.next=15;break}return e.next=15,this._updatePublish();case 15:null===(t=this._room.localStream)||void 0===t||null===(r=t.observer)||void 0===r||r.setEnableAudio(!1);case 16:case"end":return e.stop()}}),e,this)}))),function(){return Q.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return Lz.print("getAudioMixingManager()","invoke"),this._audioMixingManager}},{key:"startScreenCapture",value:(W=Em(Sm().mark((function e(){var t,r,n,i,o,a,s,u,c,d,l,h,v,p=this,f=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=f.length>0&&void 0!==f[0]?f[0]:{},Lz.print("startScreenCapture()","config: %o",o),a=o.enableAudio,s=void 0!==a&&a,this._trackSourceType.screenVideo!==dd.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new cR(sR.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 5:if(this._trackSourceType.screenAudio!==ld.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new cR(sR.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:return e.next=9,LU(s,this._extensionManager,this._screenStreamEncodeConfig[0]);case 9:if(u=e.sent,c=WT(u,2),d=c[0],null==(l=c[1])||l.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=d,null!==(r=this._screenStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&d.setContentHint(null===(h=this._screenStreamEncodeConfig[0])||void 0===h?void 0:h.contentHint),(v=null==d?void 0:d.getTrack())&&setTimeout((function(){var e=v.getSettings(),t={width:e.width,height:e.height};d.resolution=t,p.safeEmit(zd.onLocalVideoSizeChanged,{streamIndex:yd.STREAM_INDEX_SCREEN,info:{width:e.width,height:e.height}})}),500),l&&(this._localScreenAudioTrack=l,this._initLocalTrackEvents(l)),null===(n=this._screenPlayer)||void 0===n||n.playVideo(this._localScreenVideoTrack),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(i=this._room)||void 0===i||!i.hasScreenPublished){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(){return W.apply(this,arguments)})},{key:"stopScreenCapture",value:(Y=Em(Sm().mark((function e(){var t,r,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("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===(n=this._localScreenVideoTrack)||void 0===n||n.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||!r.hasScreenPublished){e.next=8;break}return e.next=8,this._updateScreenPublish();case 8:case"end":return e.stop()}}),e,this)}))),function(){return Y.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){if(Lz.print("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),FO(e,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),t&&t.renderDom){var r,n,i,o,a=cd(cd({userId:this._getUserId()},t),{},{isLocal:!0});if(JO(a),e===yd.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new _F(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)!==Md.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===yd.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new _F(this.id,cd(cd({},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)!==Md.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}else{var s,u;e===yd.STREAM_INDEX_MAIN?(null===(s=this._videoPlayer)||void 0===s||s.destroy(!0),delete this._videoPlayer):(null===(u=this._screenPlayer)||void 0===u||u.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:(q=Em(Sm().mark((function e(t){var r,n,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("startLiveTranscoding()","transcode: %o",t),Oz.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 cR(sR.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(zd.onStreamMixingEvent,{event:OV.START,error:0,message:""}),!this._room||this._room.connectionState!==jV.CONNECTED){e.next=11;break}return e.next=11,null===(i=this._room)||void 0===i?void 0:i.liveControlMessage(Oz.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof cR)){e.next=19;break}throw e.t0;case 19:throw new cR(sR.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return q.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(K=Em(Sm().mark((function e(t){var r,n,i,o;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("updateLiveTranscoding()","transcode: %o",t),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete(i=jB({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,Oz.checckUpdateParams(i),this._liveTranscodeConfig=jB(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(zd.onStreamMixingEvent,{event:OV.UPDATE,error:0,message:""}),e.next=13,null===(o=this._room)||void 0===o?void 0:o.liveControlMessage(Oz.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(e.t0 instanceof cR)){e.next=21;break}throw e.t0;case 21:throw new cR(sR.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return K.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(X=Em(Sm().mark((function e(){var t;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("stopLiveTranscoding()"),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete this._liveTranscodeConfig,e.prev=4,this.safeEmit(zd.onStreamMixingEvent,{event:OV.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 cR)){e.next=16;break}throw e.t0;case 16:throw new cR(sR.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return X.apply(this,arguments)})},{key:"startSubtitle",value:(z=Em(Sm().mark((function e(t){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Lz.print("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 z.apply(this,arguments)})},{key:"stopSubtitle",value:function(){var e;Lz.print("stopSubtitle()","invoke"),null===(e=this._room)||void 0===e||e.stopSubtitle()}},{key:"setBusinessId",value:function(e){return Lz.print("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:(H=Em(Sm().mark((function e(t){var r,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("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?_z.NORMAL_USER:_z.SILENT_USER});case 15:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:Sd.AUDIO_AND_VIDEO});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return H.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]:yd.STREAM_INDEX_MAIN,i=n===yd.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",""),u=null===(o=t._room)||void 0===o||null===(a=o.remoteStreams.get(s))||void 0===a?void 0:oE(a).call(a,(function(e){return e.isScreen===i})),c=function(){r?t.safeEmit(zd.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:s}):(t.safeEmit(zd.onAudioFirstFrameDecoded,{userId:s,isScreen:i}),t.safeEmit(zd.onRemoteAudioFirstFrame,{userId:s,isScreen:i})),t.monitor.report("first_remote_audio_render",{stream_id:"",stream_user_id:s||""},{isScreen:i})};u&&u.observer&&!u.observer.audioFirstFrameReceived?u.observer.once("recvAudioFirstFrame",c):c()}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(zd.onFirstPublicStreamVideoFrameRendered,h),t.safeEmit(zd.onFirstPublicStreamVideoFrameDecoded,h)):e.isLocal||(t.safeEmit(zd.onVideoFirstFrameRendered,h),t.safeEmit(zd.onVideoFirstFrameDecoded,h),t.safeEmit(zd.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),SP(t.id,"autoplay-error",e instanceof _F?"video":"audio",0,n.userId||""),void t.safeEmit(zd.onAutoplayFailed,{userId:n.userId,kind:e instanceof _F?"video":"audio",mediaType:e instanceof _F?Sd.VIDEO:Sd.AUDIO,streamIndex:e.isScreen?yd.STREAM_INDEX_SCREEN:yd.STREAM_INDEX_MAIN})}t.safeEmit(zd.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=Em(Sm().mark((function e(n){var i,o;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.monitor.report("rtc_error",{message:Rm(i="track-".concat(r," mediaType: ")).call(i,n.getTrack().kind),error_code:-1001}),o=!1,n!==t._localScreenAudioTrack&&n!==t._localScreenVideoTrack||(o=!0),t.safeEmit({"track-ended":zd.onTrackEnded,"track-mute":zd.onTrackMute,"track-unmute":zd.onTrackUnmute}[r],{kind:n.getTrack().kind,isScreen:o});case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())})),e.on("resolution-change",(function(e){t._extensionManager.getPluginsByType(uU.PRE_PROCESSING).forEach((function(t){var r;null==t||null===(r=t.applyConstraints)||void 0===r||r.call(t,e)})),t.safeEmit(zd.onLocalVideoSizeChanged,{streamIndex:r?yd.STREAM_INDEX_SCREEN:yd.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){Lz.print("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),FO(e,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),JO(t);var r,n,i,o=t.userId;if(e===yd.STREAM_INDEX_MAIN){var a,s,u;if(null===(a=this._remoteVideoPlayer.get(o))||void 0===a||a.destroy(),!t.renderDom)return;var c=new _F(this.id,t);this._initPlayerEvents(c,!1,e),this._remoteVideoPlayer.set(o,c);var d=null===(s=this._room)||void 0===s||null===(u=s.remoteStreams.get(o))||void 0===u?void 0:oE(u).call(u,(function(e){return!e.isScreen}));return d&&(this._updateVideoPlayerState(d),d.videoDom=c.domElement),c.domElement}if(null===(r=this._remoteScreenPlayer.get(o))||void 0===r||r.destroy(),t.renderDom){var l=new _F(this.id,cd(cd({},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:oE(i).call(i,(function(e){return e.isScreen}));return h&&(this._updateVideoPlayerState(h),h.videoDom=l.domElement),l.domElement}}},{key:"setLocalVideoMirrorType",value:function(e){Lz.print("setLocalVideoMirrorType()","mirrorType: %o",e),FO(e,"mirrorType",[kd.MIRROR_TYPE_NONE,kd.MIRROR_TYPE_RENDER]),this._mirrorType=e,this._videoPlayer&&this._videoPlayer.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(G=Em(Sm().mark((function e(t){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Lz.print("setAudioPlaybackDevice()","deviceId: %s",t),VO(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(zd.onAudioPlaybackDeviceChanged,r),this.monitor.report("rtc_audio_device",{audio_event:"playout_device_switch",message:ZE(r),error_code:0});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return G.apply(this,arguments)})},{key:"play",value:(j=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=g.length>1&&void 0!==g[1]?g[1]:Sd.AUDIO_AND_VIDEO,a=g.length>2?g[2]:void 0,Lz.print("play()","userId: %s, mediaType: %s, streamIndex: %s",t,o,a),s=!t||t===this._getUserId()||"local_user"===t,u=void 0===a||a===yd.STREAM_INDEX_MAIN,c=void 0===a||a===yd.STREAM_INDEX_SCREEN,d=o!==Sd.VIDEO,l=o!==Sd.AUDIO,h=[],s&&l&&(u&&this._localVideoTrack&&(null===(v=this._videoPlayer)||void 0===v||v.mirror(!!this._mirrorType),h.push(null===(p=this._videoPlayer)||void 0===p?void 0:p.playVideo(this._localVideoTrack))),c&&this._localScreenVideoTrack&&h.push(null===(f=this._screenPlayer)||void 0===f?void 0:f.playVideo(this._localScreenVideoTrack))),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&&u&&h.push(gF(this._remoteVideoPlayer,t,!1,_)),l&&c&&h.push(gF(this._remoteScreenPlayer,t,!0,_)),d&&u&&h.push(gF(this._remoteAudioPlayer,t,!1,_)),l&&c&&h.push(gF(this._remoteScreenAudioPlayer,t,!0,_)),m=null===(i=this._publicStreamManager)||void 0===i?void 0:i.remoteStreams,d&&h.push(gF(this._publicStreamVideoPlayer,t,!1,m)),l&&h.push(gF(this._publicStreamAudioPlayer,t,!1,m)),e.abrupt("return",X_.all(h).then((function(){})));case 20:case"end":return e.stop()}}),e,this)}))),function(e){return j.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(B=Em(Sm().mark((function e(t){var r,n,i,o,a,s=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),cO(t)&&(s._pauseAllSubscribeState.audio=!0),dO(t)&&(s._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",X_.resolve());case 6:n=[],i=YT($I(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(u){i.e(u)}finally{i.f()}return e.abrupt("return",X_.all(n).then((function(){})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return B.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(F=Em(Sm().mark((function e(t){var r,n,i,o,a,s=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),cO(t)&&(s._pauseAllSubscribeState.audio=!1),dO(t)&&(s._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",X_.resolve());case 6:n=[],i=YT($I(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(u){i.e(u)}finally{i.f()}return e.abrupt("return",X_.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 F.apply(this,arguments)})},{key:"sendUserMessage",value:(V=Em(Sm().mark((function e(t,r){var n,i,o,a=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qO(t),ZO(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 V.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(U=Em(Sm().mark((function e(t,r){var n,i,o,a=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qO(t),GO(r,"message"),ZO(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 U.apply(this,arguments)})},{key:"sendRoomMessage",value:(L=Em(Sm().mark((function e(t){var r,n,i,o=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ZO(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 L.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(N=Em(Sm().mark((function e(t){var r,n,i,o=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ZO(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 N.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(M=Em(Sm().mark((function e(){var t,r=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.length>0&&void 0!==r[0]?r[0]:{},Lz.print("setAudioCaptureConfig()","config: %o",t),delete t.deviceId,HO(t),this._shouldUpdateAudioConf("setAudioCaptureConfig")&&this._audioProfileManager.updateConstraints(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return M.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(D=Em(Sm().mark((function e(){var t,r=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},Lz.print("setVideoCaptureConfig()","config: %o",t),e.abrupt("return",this._setVideoCaptureConfig(t));case 3:case"end":return e.stop()}}),e,this)}))),function(){return D.apply(this,arguments)})},{key:"_setVideoCaptureConfig",value:(O=Em(Sm().mark((function e(){var t,r,n,i=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(delete(r=i.length>0&&void 0!==i[0]?i[0]:{}).deviceId,HO(r),n=cd(cd({},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 O.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){var t;return Lz.print("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,14!==(null==tO?void 0:tO[0])&&(null!==(t=this._room)&&void 0!==t&&t.hasPublished&&_O("You must call this API before publishing the video streams"),!0)}},{key:"setVideoEncoderConfig",value:(P=Em(Sm().mark((function e(t){var r,n,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(Lz.print("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),rD(t=Gs(t).call(t,(function(e){return!!e}))),t.length>3&&(_O("setVideoEncoderConfig: You can set parameters for up to 3 streams"),t=ym(t).call(t,0,3)),n=1;n<t.length;n++)i=mO(t[0].width)/mO(t[n].width)||1,Math.floor(i)!==i&&_O("setVideoEncoderConfig: The resolution setting needs to be an integer multiple");LA(t).call(t,(function(e,t){return t.maxKbps-e.maxKbps})),this._setVideoCaptureConfig(cd({},t[0])),this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(yd.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 P.apply(this,arguments)})},{key:"setScreenEncoderConfig",value:(x=Em(Sm().mark((function e(t){var r;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Lz.print("setScreenEncoderConfig()","description: %o",t),this._screenStreamEncodeConfig=[t],this._localScreenVideoTrack&&(this._localScreenVideoTrack.updateVideoCaptureConfig(t),t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint)),this._updateDummyCaptureImage(yd.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 x.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(Lz.print("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!FN())throw new cR(sR.NOT_SUPPORTED,"Browser does not support sending SEI");FO(e,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),UO(r,"repeatCount",0,30);var n="string"==typeof t?new Uint8Array(UP.str2ab(t)):t;if(t.length){var i;if(e===yd.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 u,c,d;if(null===(u=this._room)||void 0===u||null===(c=u.localScreenStream)||void 0===c||!c.hasPublished)return;i=null===(d=this._room)||void 0===d?void 0:d.localScreenStream}if(n.byteLength>4096)Lz.print("sei size must not bigger than 4KB");else{var l=DP();i.seiList.push({content:n,uuid:l,repeatCount:r}),setTimeout((function(){var e;if(i){var t,r=XA(e=i.seiList).call(e,(function(e){return e.uuid===l}));if(r)GE(t=i.seiList).call(t,r,1)}}),2e3)}}else Lz.print("sei message must not be empty")}},{key:"setAudioVolumeIndicationInterval",value:function(e){var t=this;Lz.print("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=oE(e).call(e,(function(e){return!1===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(zd.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n=e[0],i=$S(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(zd.onActiveSpeaker,{userId:o.userId,extraInfo:o.extraInfo})}}}},{key:"enableAudioPropertiesReport",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Lz.print("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:yd.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:i,nonlinearVolume:uO(i)}})}if(e._localScreenAudioTrack){var o=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:yd.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:o,nonlinearVolume:uO(o)}})}if(e.safeEmit(zd.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:yd.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:uO(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?yd.STREAM_INDEX_SCREEN:yd.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:uO(o)}})}}))}));e.safeEmit(zd.onRemoteAudioPropertiesReport,s),e._sendActiveSpeaker(t,Gs(s).call(s,(function(e){return e.streamKey.streamIndex!==yd.STREAM_INDEX_SCREEN})))}}}),o))}},{key:"setVideoSourceType",value:(C=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E,k,T,I;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),FO(t,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),FO(r,"VideoSourceType",[dd.VIDEO_SOURCE_TYPE_EXTERNAL,dd.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===yd.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,Lz.print("setVideoSourceType",Rm(i="set ".concat(n," source type to ")).call(i,r)),!this._localVideoTrack||t!==yd.STREAM_INDEX_MAIN){e.next=17;break}if(u=!1,r===dd.VIDEO_SOURCE_TYPE_EXTERNAL&&(u=!0,(c=this._extensionManager.getPluginByName(uU.PRE_PROCESSING,"RTCBeautyExtension"))&&c.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null===(o=this._videoPlayer)||void 0===o||o.stop(),this._localVideoTrack=void 0,d=null===(a=this._room)||void 0===a?void 0:a._roomConfig.isAutoPublish,u?null===(l=this._room)||void 0===l||null===(h=l.localStream)||void 0===h||null===(v=h.observer)||void 0===v||v.setEnableVideo(!1):null===(p=this._room)||void 0===p||null===(f=p.localStream)||void 0===f||null===(_=f.observer)||void 0===_||_.setPushVideo(!1),!(null!==(s=this._room)&&void 0!==s&&s.hasPublished||d)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(!this._localScreenVideoTrack||t!==yd.STREAM_INDEX_SCREEN){e.next=26;break}if(y=!1,r===dd.VIDEO_SOURCE_TYPE_EXTERNAL&&(y=!0,this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(m=this._screenPlayer)||void 0===m||m.stop(),this._localScreenVideoTrack=void 0,y?null===(S=this._room)||void 0===S||null===(b=S.localScreenStream)||void 0===b||null===(E=b.observer)||void 0===E||E.setEnableVideo(!1):null===(k=this._room)||void 0===k||null===(T=k.localScreenStream)||void 0===T||null===(I=T.observer)||void 0===I||I.setPushVideo(!1),null===(g=this._room)||void 0===g||!g.hasScreenPublished){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return C.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(w=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("setExternalVideoTrack()","index: %o, track: %o",t,r),FO(t,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),BO(r),t!==yd.STREAM_INDEX_MAIN){e.next=15;break}if(this._trackSourceType.video===dd.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new cR(sR.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,FU(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),a=null===(i=this._room)||void 0===i?void 0:i._roomConfig.isAutoPublish,!(null!==(o=this._room)&&void 0!==o&&o.hasPublished||a)){e.next=15;break}return e.next=15,this._updatePublish();case 15:if(t!==yd.STREAM_INDEX_SCREEN){e.next=27;break}if(this._trackSourceType.screenVideo===dd.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=18;break}throw new cR(sR.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 18:return e.next=20,HU(r,this._extensionManager);case 20:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(s=this._screenPlayer)||void 0===s||s.playVideo(this._localScreenVideoTrack),null===(u=this._room)||void 0===u||null===(c=u.localScreenStream)||void 0===c||null===(d=c.observer)||void 0===d||d.setPushVideo(!0),null===(l=this._room)||void 0===l||!l.hasScreenPublished){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(e,t){return w.apply(this,arguments)})},{key:"setAudioSourceType",value:(R=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h,v,p,f,_,m,g,y,S,b,E;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),FO(t,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),FO(r,"audioSourceType",[ld.AUDIO_SOURCE_TYPE_EXTERNAL,ld.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===yd.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,Lz.print("setVideoSourceType",Rm(i="set ".concat(n," source type to ")).call(i,r)),!this._localAudioTrack||t!==yd.STREAM_INDEX_MAIN){e.next=16;break}if(s=!1,this._trackSourceType.audio===ld.AUDIO_SOURCE_TYPE_EXTERNAL&&(s=!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,s?null===(c=this._room)||void 0===c||null===(d=c.localStream)||void 0===d||null===(l=d.observer)||void 0===l||l.setEnableAudio(!1):null===(h=this._room)||void 0===h||null===(v=h.localStream)||void 0===v||null===(p=v.observer)||void 0===p||p.setPushAudio(!1),!(null!==(a=this._room)&&void 0!==a&&a.hasPublished||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(!this._localScreenAudioTrack||t!==yd.STREAM_INDEX_SCREEN){e.next=24;break}if(_=!1,this._trackSourceType.audio===ld.AUDIO_SOURCE_TYPE_EXTERNAL&&(_=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,_?null===(m=this._room)||void 0===m||null===(g=m.localScreenStream)||void 0===g||null===(y=g.observer)||void 0===y||y.setEnableAudio(!1):null===(S=this._room)||void 0===S||null===(b=S.localScreenStream)||void 0===b||null===(E=b.observer)||void 0===E||E.setPushAudio(!1),null===(f=this._room)||void 0===f||!f.hasScreenPublished){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(A=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u,c,d,l,h;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("setExternalAudioTrack()","index: %o, track: %o",t,r),FO(t,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),BO(r),t!==yd.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.audio===ld.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new cR(sR.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,jU(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&&s.hasPublished||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(t!==yd.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenAudio===ld.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new cR(sR.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 19:return e.next=21,XU(r,this._extensionManager);case 21:if(this._localScreenAudioTrack=e.sent,this._localScreenAudioTrack.setVolume(this._localScreenAudioVolume),this._initLocalTrackEvents(this._localScreenAudioTrack),null===(c=this._room)||void 0===c||null===(d=c.localScreenStream)||void 0===d||null===(l=d.observer)||void 0===l||l.setPushAudio(!0),null===(h=this._room)||void 0===h||!h.hasScreenPublished){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return A.apply(this,arguments)})},{key:"login",value:(I=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Lz.print("login()","token: %o, userInfo: %o",t,r),XO(t)||VO(t,"token"),qO(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return I.apply(this,arguments)})},{key:"logout",value:(T=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Lz.print("logout()"),e.abrupt("return",this._rtmClient.logout());case 2:case"end":return e.stop()}}),e,this)}))),function(){return T.apply(this,arguments)})},{key:"updateLoginToken",value:(k=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Lz.print("updateLoginToken()","token: %o",t),XO(t)||VO(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(E=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Lz.print("getPeerOnlineStatus()","userId: %o",t),qO(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(b=Em(Sm().mark((function e(t,r){var n,i=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qO(t),ZO(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 b.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(S=Em(Sm().mark((function e(t,r){var n,i=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qO(t),GO(r,"message"),ZO(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 S.apply(this,arguments)})},{key:"setServerParams",value:(y=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Lz.print("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 y.apply(this,arguments)})},{key:"sendServerMessage",value:(g=Em(Sm().mark((function e(t){var r,n=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return VO(t,"message"),ZO(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 g.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(m=Em(Sm().mark((function e(t){var r,n=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return GO(t,"message"),ZO(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 m.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new cR(sR.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");Lz.print("startCloudProxy()",e),VO(e.logProxy,"logProxy"),VO(e.accessProxy,"accessProxy"),VO(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=OO("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=OO("LOG_SERVER_URL"),this._originConfigServerUrls=OO("CONFIG_REQUEST_DOMAINS"),PO("ICE_CONFIG_REQUEST_URLS",e.accessProxy),PO("LOG_SERVER_URL",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://"+e),"".concat(e,"/video/v1/webrtc_log/")}(e.logProxy)),PO("CONFIG_REQUEST_DOMAINS",[e.configProxy]),this._useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){if(this._room)throw new cR(sR.STOP_CLOUD_PROXY_BEFORE_LEAVE,"[stopCloudProxy] should be invoke after leave room ");Lz.print("stopCloudProxy()"),PO("ICE_CONFIG_REQUEST_URLS",[]),PO("LOG_SERVER_URL",this._originLogServerUrl),PO("CONFIG_REQUEST_DOMAINS",this._originConfigServerUrls),this._useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(_=Em(Sm().mark((function e(t,r){var n,i,o,a=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),YO(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new cR(sR.REPEAT_PUSH,"repeat push public media stream");case 5:return o=DO(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 _.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(f=Em(Sm().mark((function e(t,r){var n,i;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Lz.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),YO(t),this._assertNotInRoom(),i=DO(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 f.apply(this,arguments)})},{key:"stopPushPublicStream",value:(p=Em(Sm().mark((function e(t){var r,n=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Lz.print("startPushPublicStream()","publicStreamId: %o",t),YO(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 p.apply(this,arguments)})},{key:"startPlayPublicStream",value:(v=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(YO(t),this._publicStreamManager){e.next=8;break}return this._publicStreamManager=new yz(this.id,this._appId,{businessId:this._businessId}),this._publicStreamManager.on(PV.RESUBSCRIBE,(function(e){var t=e.stream;if(t){var r,n=u._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=u._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,u.safeEmit(zd.onPublicStreamStats,e)})),null===(n=this._publicStreamManager)||void 0===n||n.on(PV.ON_SEI_MESSAGED_RECEIVED,(function(e){u.safeEmit(zd.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 mF(this.id,t,{muted:(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)===Md.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 v.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(h=Em(Sm().mark((function e(t){var r;return Sm().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 h.apply(this,arguments)})},{key:"setAudioProfile",value:(l=Em(Sm().mark((function e(t){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Lz.print("setAudioProfile()","profile: %o",t),this._shouldUpdateAudioConf("setAudioProfile")&&this._audioProfileManager.setAudioProfile(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,i,o;Lz.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 _F(this.id,cd(cd({},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)!==Md.PLAY_MANUALLY&&a.playVideo(s.videoTrack,s)}else this._publicStreamVideoPlayer.delete(e)}},{key:"setDummyCaptureImagePath",value:(d=Em(Sm().mark((function e(t,r){var n=this;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new X_((function(e,i){VO(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){t===yd.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),e()}catch(r){i(new cR(sR.UNEXPECTED_ERROR,r.message))}},o.onerror=function(){i(new cR(sR.UNEXPECTED_ERROR,"Load image error"))}})));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return d.apply(this,arguments)})},{key:"_updateDummyCaptureImage",value:function(e){var t,r;if(e===yd.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=mO(r.width),u=mO(r.height);if(!a)throw new cR(sR.UNEXPECTED_ERROR,"Not support canvas");!s||!u||t.width<=s&&t.height<=u?(n=t.width,i=t.height):(n=Math.min(s,t.width*u/t.height),i=Math.min(u,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 c=window.setInterval((function(){t&&a.drawImage(t,0,0,t.width,t.height,0,0,n,i)}),200);e===yd.STREAM_INDEX_MAIN?(clearInterval(this._dummyMainTimer),this._dummyMainTimer=c):(clearInterval(this._dummyScreenTimer),this._dummyScreenTimer=c);var d,l,h,v,p=o.captureStream(5).getVideoTracks()[0];if(e===yd.STREAM_INDEX_MAIN){if(this._localImgVideoTrack=p,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=p,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",Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t._localVideoTrack||t._localVideoTrack.dummy){e.next=6;break}return t._localVideoTrack&&t._removeLocalTrackEvents(t._localVideoTrack),e.next=4,t._localVideoTrack.generatePreProcessingTrack(t._extensionManager);case 4:return e.next=6,t._switchTrack(t._localVideoTrack);case 6:case"end":return e.stop()}}),e)}))))}},{key:"registerExtension",value:(c=Em(Sm().mark((function e(t){return Sm().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 c.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(ZE(Oz.getDefaultValue()))}},{key:"_updatePublish",value:(u=Em(Sm().mark((function e(){var t,r,n,i=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},Lz.print("_updatePublish()","config: %o",t),r={mediaType:void 0,invokeByJoinRoom:!1,pubState:DV.PUB},t=cd(cd({},r),t),this._visibility){e.next=6;break}throw new cR(sR.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===jV.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 cR)){e.next=24;break}throw e.t0;case 24:throw new cR(sR.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 u.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(s=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Lz.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),VO(t,"filePath"),UO(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 s.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){Lz.print("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(a=Em(Sm().mark((function e(t,r){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Lz.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),UO(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 a.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){Lz.print("stopAudioDeviceRecordAndPlayTest()"),this._audioDeviceManager.stopAudioDeviceRecordAndPlayTest()}},{key:"stopAudioDevicePlayTest",value:function(){Lz.print("stopAudioDevicePlayTest()"),this._audioDeviceManager.stopAudioDevicePlayTest()}},{key:"setRemoteUserPriority",value:function(e,t){var r;Lz.print("setRemoteUserPriority()","userId: %o, priority: %o",e,t);try{qO(e),FO(t,"priority",[Cd.HIGH,Cd.MEDIUM,Cd.LOW])}catch(n){return console.warn(n),!1}return this._userPriorityMap.set(e,t),null===(r=this._room)||void 0===r||r.updateRemoteUserPriority(e),!0}},{key:"takeLocalSnapshot",value:(o=Em(Sm().mark((function e(t){var r,n;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("takeLocalSnapshot()","streamIndex: %o",t),FO(t,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),r=t===yd.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new cR(sR.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return n=t===yd.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer,e.abrupt("return",Iz(r.getTrack("preprocessing"),(null==n?void 0:n.mirrorType)===kd.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(i=Em(Sm().mark((function e(t,r){var n,i,o,a,s,u;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Lz.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),VO(t,"id"),FO(r,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),u=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=oE(i).call(i,(function(e){return e.isScreen===(r===yd.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 cR(sR.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",Iz(u.getTrack(),!1,r===yd.STREAM_INDEX_MAIN?this._remoteVideoPlayer.get(t):this._remoteScreenPlayer.get(t)));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){Lz.print("setSubscribeFallbackOption()","option: %o",e);try{FO(e,"option",[wd.DISABLE,wd.VIDEO_STREAM_LOW,wd.AUDIO_ONLY])}catch(t){return console.warn(t),!1}return!this._room&&(this._subscribeFallbackOption=e,!0)}},{key:"getLocalStreamTrack",value:function(e,t){var r,n,i,o=this;if(e===yd.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 qU&&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,u,c,d;if(t===yd.STREAM_INDEX_MAIN)a=oE(o).call(o,(function(e){return!e.isScreen})),i="video"===r?null===(s=a)||void 0===s?void 0:s.videoTrack:null===(u=a)||void 0===u?void 0:u.audioTrack;else a=oE(o).call(o,(function(e){return e.isScreen})),i="video"===r?null===(c=a)||void 0===c?void 0:c.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._avSync=!!e,!0)}},{key:"setCaptureVolume",value:function(e,t){var r,n,i;(FO(e,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),t=nD(t,"volume",0,400),e===yd.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(qO(e),FO(t,"streamIndex",[yd.STREAM_INDEX_MAIN,yd.STREAM_INDEX_SCREEN]),r=nD(r,"volume",0,400),null!==(n=this._room)&&void 0!==n&&n.multiChatMode)_O("setPlaybackVolume is not supported in Conference mode");else{var a=t===yd.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;VO(e,"publicStreamId"),t=nD(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:"_reportMsTrackEvent",value:function(e,t){var r=this;if(!e.hookStop){e.hookStop=!0;var n=e.stop;e.stop=function(){SP(r.id,"stop",t,0,t),n.call(e)}}}},{key:"_updateScreenPublish",value:(n=Em(Sm().mark((function e(){var t,r,n,i=arguments;return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:{},Lz.print("_updateScreenPublish()"),r={mediaType:void 0,pubState:DV.PUB},t=cd(cd({},r),t),e.next=6,this._pubLock.lock();case 6:if(n=e.sent,this._room&&this._room.connectionState===jV.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 cR)){e.next=22;break}throw e.t0;case 22:throw new cR(sR.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){Lz.print("_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||this.multiChatMode)){var a,s,u,c=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(c),!o){var d;o=new mF(this.id,r,{muted:(null===(d=this._config)||void 0===d?void 0:d.autoPlayPolicy)===Md.VIDEO_ONLY,isScreen:n}),this._initPlayerEvents(o,!1,n?yd.STREAM_INDEX_SCREEN:yd.STREAM_INDEX_MAIN),i.set(r,o);var l=this._audioDeviceManager.getSinkId();l&&o.setPlaybackDevice(l)}(null===(u=this._config)||void 0===u?void 0:u.autoPlayPolicy)!==Md.PLAY_MANUALLY&&o.playAudio(e.audioTrack),jP&&YP&&(t=this._remoteAudioPlayer,Pz&&clearTimeout(Pz),Pz=setTimeout((function(){var e,r=YT(t);try{for(r.s();!(e=r.n()).done;){var n=WT(e.value,2),i=n[0],o=n[1];null!=i&&aR(i).call(i,"mux")&&o.pause()}}catch(l){r.e(l)}finally{r.f()}var a,s=YT(t);try{for(s.s();!(a=s.n()).done;){var u=WT(a.value,2),c=u[0],d=u[1];null!=c&&aR(c).call(c,"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;Lz.print("_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)!==Md.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=Em(Sm().mark((function e(t){var r,n,i,o,a,s,u,c,d;return Sm().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,u=i.videostream,c=WU.NONE,a&&(c|=Sd.AUDIO),u&&(c|=Sd.VIDEO),!c){e.next=12;break}return e.next=9,new X_((function(e){return setTimeout(e)}));case 9:null!=n&&n.isScreen?this.safeEmit(zd.onUserPublishScreen,{userId:n.userId,mediaType:c}):(this.safeEmit(zd.onUserPublishStream,{userId:n.userId,mediaType:c,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:c,isScreen:!(null==n||!n.isScreen)}),null!=n&&n.isScreen||(o&&this.safeEmit(zd.onUserStartAudioCapture,{userId:n.userId}),s&&this.safeEmit(zd.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=WU.NONE;if(null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoSubscribeAudio&&(i|=Sd.AUDIO),null!==(n=this._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo&&(i|=Sd.VIDEO),i){var o,a;if(t&&cO(i))null===(o=e.observer)||void 0===o||o.setAutoSubscribeAudio(!0);if(t&&dO(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=Fz[e.reason])&&void 0!==t?t:bd.STREAM_REMOVE_REASON_OTHER,o=n.isScreen?zd.onUserUnpublishScreen:zd.onUserUnpublishStream,a=WU.NONE;n.attributes.audiostream&&(a|=Sd.AUDIO),n.attributes.videostream&&(a|=Sd.VIDEO),a!==WU.NONE&&(this.safeEmit(o,{userId:n.userId,mediaType:a,reason:i}),this.safeEmit("onRemoveStream",{userId:n.userId,isScreen:n.isScreen})),this._getRemotePlayer(n.userId,n.isScreen).forEach((function(e){var t=n.isScreen?"".concat(n.userId,"_screen"):n.userId;r._remoteAudioPlayer.delete(t),n.isScreen?r._remoteScreenPlayer.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(zd.onUserJoined,e)}))}},{key:"_onUserLeave",value:function(e){this.safeEmit(zd.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(zd.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,Rm(e=[zd.onNetworkQuality]).call(e,r))}},{key:"_onConnectionStateChange",value:function(e){if(void 0!==this._startCloudProxyTimestamp&&this._useCloudProxy&&e.state===Ed.CONNECTION_STATE_CONNECTED&&this.safeEmit(zd.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),this.safeEmit(zd.onConnectionStateChanged,e),e.state===Ed.CONNECTION_STATE_RECONNECTING){var t,r=YT(this._remoteAudioPlayer);try{for(r.s();!(t=r.n()).done;){var n=WT(t.value,2),i=n[0],o=n[1];null!=i&&aR(i).call(i,"mux")&&o.stop()}}catch(a){r.e(a)}finally{r.f()}}}},{key:"_getRemotePlayer",value:function(e,t){return[(t?this._remoteScreenAudioPlayer:this._remoteAudioPlayer).get(e),(t?this._remoteScreenPlayer:this._remoteVideoPlayer).get(e)]}},{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){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(zd.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(zd.onAudioDeviceStateChanged,e)}},{key:"_onUserPublishStateChange",value:function(e){var t,r=e.userId,n=e.isScreen,i=e.mediaType,o=e.pubState,a=e.remoteStream,s={userId:r,mediaType:i};n?o===DV.PUB?this.safeEmit(zd.onUserPublishScreen,s):this.safeEmit(zd.onUserUnpublishScreen,cd(cd({},s),{},{reason:bd.STREAM_REMOVE_REASON_UNPUBLISH})):o===DV.PUB?(s.videoStreamDescriptions=null==a||null===(t=a.attributes)||void 0===t?void 0:t.videoDescriptions,this.safeEmit(zd.onUserPublishStream,s),this._handleAutoSubscribe(a,!0)):this.safeEmit(zd.onUserUnpublishStream,cd(cd({},s),{},{reason:bd.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(zd.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(zd.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(zd.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(zd.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(zd.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(zd.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(zd.onTokenWillExpire)}},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(zd.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(zd.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(zd.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(zd.onError,{errorCode:sR.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(zd.onError,{errorCode:sR.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(zd.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(zd.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||this._room.connectionState!==jV.CONNECTED)throw new cR(sR.NOT_CONNECTED_YET,"server not connected")}},{key:"_checkMediaType",value:function(e){FO(e,"mediaType",[Sd.AUDIO,Sd.VIDEO,Sd.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=Em(Sm().mark((function e(t){var r,n;return Sm().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||!n.hasPublished){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=(null===(t=this._room)||void 0===t?void 0:t.hasPublished)||this._localAudioTrack&&this._localAudioTrack.sourceType===dU.INTERNAL;if(r){var n="engine.".concat(e," should be called before publishing or capturing.");console.warn("[RTC WebSDK]: "+n),SP(this.id,e,n)}return!r}},{key:"_getServerConfig",value:function(){xP({engineId:this.id,appId:this.appId,sdkVersion:OO("VERSION"),requestDomains:OO("CONFIG_REQUEST_DOMAINS"),keys:["rts_report"]}).then((function(e){e.rts_report&&uP.setConfig(e.rts_report)}))}}]),me}(sD);Nz([gP()],Uz.prototype,"updateToken",1),Nz([gP()],Uz.prototype,"setVideoCaptureDevice",1),Nz([gP()],Uz.prototype,"setAudioCaptureDevice",1),Nz([function(e,t,r){if("function"==typeof r.value){var n=r.value;r.value=function(){for(var e,t=mP(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)}}},gP()],Uz.prototype,"connect",1),Nz([gP()],Uz.prototype,"joinRoom",1),Nz([gP()],Uz.prototype,"leaveRoom",1),Nz([gP()],Uz.prototype,"destroy",1),Nz([gP()],Uz.prototype,"publishStream",1),Nz([gP()],Uz.prototype,"unpublishStream",1),Nz([gP()],Uz.prototype,"publishScreen",1),Nz([gP()],Uz.prototype,"unpublishScreen",1),Nz([gP()],Uz.prototype,"subscribeStream",1),Nz([gP()],Uz.prototype,"unsubscribeStream",1),Nz([gP()],Uz.prototype,"subscribeScreen",1),Nz([gP()],Uz.prototype,"unsubscribeScreen",1),Nz([gP()],Uz.prototype,"setRemoteVideoConfig",1),Nz([gP()],Uz.prototype,"startVideoCapture",1),Nz([gP()],Uz.prototype,"stopVideoCapture",1),Nz([gP()],Uz.prototype,"startAudioCapture",1),Nz([gP()],Uz.prototype,"stopAudioCapture",1),Nz([gP()],Uz.prototype,"getAudioMixingManager",1),Nz([gP()],Uz.prototype,"startScreenCapture",1),Nz([gP()],Uz.prototype,"stopScreenCapture",1),Nz([gP()],Uz.prototype,"setLocalVideoPlayer",1),Nz([gP()],Uz.prototype,"startLiveTranscoding",1),Nz([gP()],Uz.prototype,"updateLiveTranscoding",1),Nz([gP()],Uz.prototype,"stopLiveTranscoding",1),Nz([gP()],Uz.prototype,"startSubtitle",1),Nz([gP()],Uz.prototype,"stopSubtitle",1),Nz([gP()],Uz.prototype,"setBusinessId",1),Nz([gP()],Uz.prototype,"setUserVisibility",1),Nz([gP()],Uz.prototype,"setRemoteVideoPlayer",1),Nz([gP()],Uz.prototype,"setLocalVideoMirrorType",1),Nz([gP()],Uz.prototype,"setAudioPlaybackDevice",1),Nz([gP()],Uz.prototype,"play",1),Nz([gP()],Uz.prototype,"pauseAllSubscribedStream",1),Nz([gP()],Uz.prototype,"resumeAllSubscribedStream",1),Nz([gP()],Uz.prototype,"sendUserMessage",1),Nz([gP()],Uz.prototype,"sendUserBinaryMessage",1),Nz([gP()],Uz.prototype,"sendRoomMessage",1),Nz([gP()],Uz.prototype,"sendRoomBinaryMessage",1),Nz([gP()],Uz.prototype,"setAudioCaptureConfig",1),Nz([fO("4.51"),gP()],Uz.prototype,"setVideoCaptureConfig",1),Nz([gP()],Uz.prototype,"enableSimulcastMode",1),Nz([gP()],Uz.prototype,"setVideoEncoderConfig",1),Nz([gP()],Uz.prototype,"setScreenEncoderConfig",1),Nz([gP()],Uz.prototype,"sendSEIMessage",1),Nz([fO("4.42"),gP()],Uz.prototype,"setAudioVolumeIndicationInterval",1),Nz([gP()],Uz.prototype,"enableAudioPropertiesReport",1),Nz([gP()],Uz.prototype,"setVideoSourceType",1),Nz([gP()],Uz.prototype,"setExternalVideoTrack",1),Nz([gP()],Uz.prototype,"setAudioSourceType",1),Nz([gP()],Uz.prototype,"setExternalAudioTrack",1),Nz([gP()],Uz.prototype,"login",1),Nz([gP()],Uz.prototype,"logout",1),Nz([gP()],Uz.prototype,"updateLoginToken",1),Nz([gP()],Uz.prototype,"getPeerOnlineStatus",1),Nz([gP()],Uz.prototype,"sendUserMessageOutsideRoom",1),Nz([gP()],Uz.prototype,"sendUserBinaryMessageOutsideRoom",1),Nz([gP()],Uz.prototype,"setServerParams",1),Nz([gP()],Uz.prototype,"sendServerMessage",1),Nz([gP()],Uz.prototype,"sendServerBinaryMessage",1),Nz([gP()],Uz.prototype,"startCloudProxy",1),Nz([gP()],Uz.prototype,"stopCloudProxy",1),Nz([gP()],Uz.prototype,"startPushPublicStream",1),Nz([gP()],Uz.prototype,"updatePublicStreamParam",1),Nz([gP()],Uz.prototype,"stopPushPublicStream",1),Nz([gP("streamId")],Uz.prototype,"startPlayPublicStream",1),Nz([gP("streamId")],Uz.prototype,"stopPlayPublicStream",1),Nz([gP()],Uz.prototype,"setAudioProfile",1),Nz([gP()],Uz.prototype,"setPublicStreamVideoPlayer",1),Nz([gP()],Uz.prototype,"setDummyCaptureImagePath",1),Nz([gP()],Uz.prototype,"registerExtension",1),Nz([gP()],Uz.prototype,"startAudioPlaybackDeviceTest",1),Nz([gP()],Uz.prototype,"stopAudioPlaybackDeviceTest",1),Nz([gP()],Uz.prototype,"startAudioDeviceRecordTest",1),Nz([gP()],Uz.prototype,"stopAudioDeviceRecordAndPlayTest",1),Nz([gP()],Uz.prototype,"stopAudioDevicePlayTest",1),Nz([gP()],Uz.prototype,"setRemoteUserPriority",1),Nz([gP()],Uz.prototype,"takeLocalSnapshot",1),Nz([gP()],Uz.prototype,"takeRemoteSnapshot",1),Nz([gP()],Uz.prototype,"setSubscribeFallbackOption",1),Nz([gP()],Uz.prototype,"getLocalStreamTrack",1),Nz([gP()],Uz.prototype,"getRemoteStreamTrack",1),Nz([gP()],Uz.prototype,"getPublicStreamTrack",1),Nz([gP()],Uz.prototype,"setRemoteStreamRenderSync",1);var Vz,Fz={"client unpublished":bd.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":bd.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":bd.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":bd.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":bd.STREAM_REMOVE_REASON_REPUBLISH},Bz=new nP("VERTC",0);$x.storeKey=Rm(Vz="".concat(Date.now(),"-")).call(Vz,IO.getDeviceId()),dP({rtc_sdk_version:xO.VERSION,device_id:IO.getDeviceId(),log_cache_key:$x.storeKey}),lP(xO.LOG_SERVER_URL);var jz=1,Gz=function(e,t){Bz.print("createEngine","Invoke VERTC.createEngine"),VO(e,"appId");var r=(jz++).toString();return function(e,t){var r=new jx(e);r.set(cd(cd({},t),{},{engine_session_id:ZR()})),r.report("sdk_init_engine",{start:Date.now(),type:"begin"}),_P.set(e,r)}(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new Uz(e,r,t)},Hz=function(e){if(Bz.print("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof Uz))throw new cR(sR.INVALID_ENGINE,"Invalid engine object");var t;e.destroy(),(t=e.monitor).report("sdk_init_engine",{start:Date.now(),type:"end"}),_P.delete(t.id)},zz=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",nU.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Xz=function(){var e=Em(Sm().mark((function e(){var t,r,n,i,o,a,s=arguments;return Sm().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=13;break}return e.prev=4,e.next=7,nU.getPermissions({video:!0,force:!0});case 7:o=e.sent,i.video=o.video,e.next=13;break;case 11:e.prev=11,e.t0=e.catch(4);case 13:if(!n){e.next=23;break}return e.prev=14,e.next=17,nU.getPermissions({audio:!0,force:!0});case 17:a=e.sent,i.audio=a.audio,e.next=23;break;case 21:e.prev=21,e.t1=e.catch(14);case 23:return e.abrupt("return",i);case 24:case"end":return e.stop()}}),e,null,[[4,11],[14,21]])})));return function(){return e.apply(this,arguments)}}(),Kz=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",nU.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),qz=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",nU.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Yz=function(){var e=Em(Sm().mark((function e(){return Sm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",nU.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Wz=function(){return xO.VERSION},Qz=function(){return vP("isSupported",0,""),IN()},Jz=function(){return vP("getSupportedCodecs",0,""),wN()},Zz=function(e){var t=e.logLevel,r=e.LogfileSize;t&&($x.logLevel=t),r&&($x.LogfileSize=r)},$z=function(e){$x.download(e)};return cd(cd(cd(cd({},new(Kd((function e(){qd(this,e),sd(this,"getSdkVersion",Wz),sd(this,"createEngine",Gz),sd(this,"destroyEngine",Hz),sd(this,"enumerateDevices",zz),sd(this,"enableDevices",Xz),sd(this,"enumerateAudioCaptureDevices",Kz),sd(this,"enumerateVideoCaptureDevices",qz),sd(this,"enumerateAudioPlaybackDevices",Yz),sd(this,"getParameter",OO),sd(this,"setParameter",PO),sd(this,"isSupported",Qz),sd(this,"getSupportedCodecs",Jz),sd(this,"events",zd),sd(this,"ErrorCode",sR),sd(this,"platform","BytePlus"),sd(this,"downloadLog",$z),sd(this,"setLogConfig",Zz)})))),Fd),Hd),{},{events:zd})}));